#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
#define TFT_CS 10
#define TFT_DC 9
#define TFT_RST 8
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
const uint8_t ymhs1Bitmap[] PROGMEM = { //楊
0x19,0xf8,0x11,0x08,0x11,0xf8,0xfd,0x08,
0x11,0xf8,0x31,0x08,0x30,0x00,0x5b,0xfe,
0x54,0x80,0x95,0xfe,0x12,0x4a,0x10,0x92,
0x13,0x22,0x10,0xdc,0x10,0x08,0x00,0x00,
0x31,0x80,0x21,0x04,0x21,0xfe,0xfa,0x00,
0x25,0xfc,0x61,0x44,0x61,0x24,0xb7,0xfe,
0xa9,0x44,0xa9,0x24,0x22,0x24,0x23,0xfe,
0x22,0x08,0x20,0x78,0x20,0x10,0x00,0x00,
0x02,0x00,0x01,0x04,0xff,0xfe,0x00,0x00,
0x1f,0xe0,0x10,0x20,0x1f,0xe0,0x40,0x04,
0x7f,0xfe,0x40,0x04,0x4f,0xc4,0x48,0x44,
0x4f,0xc4,0x40,0x1c,0x40,0x08,0x00,0x00,
0x01,0x80,0x01,0x00,0x01,0x00,0x41,0x04,
0x7f,0xfe,0x41,0x04,0x41,0x04,0x41,0x04,
0x41,0x04,0x7f,0xfc,0x41,0x04,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
0x44,0x44,0x7e,0x7e,0x48,0x90,0xfe,0xfc,
0x42,0x84,0x7e,0xfc,0x42,0x84,0x7e,0xfc,
0x40,0x04,0x47,0xc4,0x44,0x44,0x47,0xc4,
0x44,0x44,0x47,0xdc,0x40,0x08,0x00,0x00,
0x31,0x86,0x21,0x04,0x27,0xc4,0xf9,0x04,
0x27,0xde,0x20,0x04,0x67,0xc4,0x74,0x64,
0xac,0x54,0xa7,0xd4,0x24,0x84,0x22,0xc4,
0x2f,0x04,0x24,0x1c,0x20,0x08,0x00,0x00,
0x18,0x00,0x11,0xfe,0x11,0x02,0xfd,0x7a,
0x11,0x02,0x31,0x02,0x39,0x7a,0x55,0x4a,
0x55,0x4a,0x91,0x7a,0x11,0x4a,0x11,0x02,
0x11,0x02,0x11,0x0e,0x11,0x04,0x00,0x00
};
void setup() {
tft.initR(INITR_BLACKTAB);
tft.setRotation(2);
tft.fillScreen(ST77XX_BLACK);
// 顏色陣列(7 種不同顏色)
uint16_t colors[7] = {
ST77XX_WHITE,
ST77XX_RED,
ST77XX_GREEN,
ST77XX_BLUE,
ST77XX_YELLOW,
ST77XX_CYAN,
ST77XX_MAGENTA
};
// 顯示 7 次,每次往右移 16 像素,起始 X 為 5
for (int i = 0; i < 7; i++) {
int x = 5 + i * 16;
int y = 10;
// 繪製圖像
tft.drawBitmap(x, y, ymhs1Bitmap, 16, 112, colors[i]);
// 如果是奇數位置(第 1, 3, 5, 7 個),畫框
if (i % 2 == 0) {
tft.drawRect(x - 1, y - 1, 18, 114, ST77XX_WHITE); // 白色框,略大於圖像
}
delay(500);
}
}
void loop() {
// 不需重複繪製
}