Adafruit_Arcadaクラスがあるのでそれを使って画面を制御する。
10x10のキャラクタを画面の真ん中に表示するサンプルプログラムです。
#include <Adafruit_Arcada.h> #include <Adafruit_SPIFlash.h> Adafruit_Arcada arcada; unsigned short* frameBuffer; int screenWidth; int screenHeight; // PyBadge 65536 Color(RGB565) picture data // HIYOKO_10x10_1 // 10 x 10 dot const unsigned short HIYOKO_10x10_1[10 * 10] = { 0x0000, 0x0000, 0x0000, 0x80DE, 0x80DE, 0x80DE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x80DE, 0x80DE, 0x80DE, 0x80DE, 0x80DE, 0x0000, 0x0000, 0x0000, 0x0000, 0x80DE, 0x0B18, 0x0B18, 0x80DE, 0x80DE, 0x80DE, 0x80DE, 0x0000, 0x0000, 0x0000, 0x80DE, 0xFFFF, 0x0B18, 0x80DE, 0x80DE, 0x80DE, 0x80DE, 0x0000, 0x0000, 0x0000, 0x80DE, 0x0B18, 0x0B18, 0x80DE, 0x88FE, 0x88FE, 0x88FE, 0x88FE, 0x88FE, 0x80DB, 0x80DB, 0x80DB, 0x80DE, 0x80DE, 0x80DE, 0x80DE, 0x80DE, 0x80DE, 0x88FE, 0x0000, 0x0000, 0x0000, 0x80DE, 0x80DE, 0x80DE, 0x80DE, 0x80DE, 0x88FE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x80DE, 0x80DE, 0x80DE, 0x88FE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x80DB, 0x0000, 0x80DB, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x80DB, 0x0000, 0x80DB, 0x0000, 0x0000, 0x0000 }; void setup() { Serial.begin(9600); if(arcada.arcadaBegin() == false) { Serial.print("Failed to begin"); while(1); } arcada.displayBegin(); arcada.setBacklight(255); screenWidth = arcada.display->width(); screenHeight = arcada.display->height(); if(arcada.createFrameBuffer(screenWidth, screenHeight) == false) { arcada.haltBox("Could not allocate framebuffer"); } frameBuffer = arcada.getFrameBuffer(); } // Draw sprite no clip void DrawSprite(const unsigned short* buffer, int x, int y, int width, int height, int color_key) { int scanX; int scanY; int sourceAddress = 0; int destinationAddress = screenWidth * y + x; for(scanY = 0; scanY < height; ++ scanY) { for(scanX = 0; scanX < width; ++ scanX) { unsigned short color = buffer[sourceAddress + scanX]; if(static_cast<int>(color) != color_key) { frameBuffer[destinationAddress + scanX] = color; } } sourceAddress += width; destinationAddress += screenWidth; } } void loop() { arcada.display->dmaWait(); DrawSprite(HIYOKO_10x10_1, 75, 59, 10, 10, 0x0000); arcada.blitFrameBuffer(0, 0, false, true); }
#ref(): File not found: "ScreenSamplePyBadge.zip" at page "pyBadge/画面表示"