#author("2020-04-16T12:45:42+09:00","default:kuran","kuran")
[[戻る>PyBadge]]

*画面表示 [#m4619a69]
Adafruit_Arcadaクラスがあるのでそれを使って画面を制御する。~
10x10のキャラクタを画面の真ん中に表示するサンプルプログラムです。~

*サンプルプログラム [#m03bed63]
 #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);
 }
*実行結果 [#y4b038f8]
#ref(ScreenSamplePyBadge.jpg)
*サンプルプログラムのダウンロード [#cd51a498]
#ref(ScreenSamplePyBadge.zip)~

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS