2026年2月16日 星期一

[OTTO GO]動畫測試-穩定循環播放 + 不會顏色亂 + 不會卡在 setup return

 

arduino:
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
// ESP32 + TFT_eSPI + microSD (SdFat)
// ST7789 320x240 : RAW565 player (FAST SD read)
// Profile: SD read vs TFT push

#include <TFT_eSPI.h>
#include <SPI.h>
#include <SdFat.h>

TFT_eSPI tft;

// ===== SD pins =====
#define SD_CS   33
#define SD_MOSI 26
#define SD_MISO 36
#define SD_SCLK 25
SPIClass sdSPI(HSPI);

// SdFat objects
SdFat sd;
FsFile f;

// ===== Display size =====
static const int W = 320;
static const int H = 240;

// ===== Playback =====
int totalFrames = 0;           // 由掃描自動取得
int frameDelayMs = 10;         // 你可調整
const char *framePrefix = "tile";
const int digits = 3;

// ===== Block push settings =====
static const int BLOCK_H = 24; // 建議 16~24 更穩
static uint16_t blockBuf[W * BLOCK_H];

static bool drawRaw565_Profile_SdFat(const char *filename) {
  if (!f.open(filename, O_RDONLY)) {
    Serial.println("  開檔失敗");
    return false;
  }

  const uint32_t expected = (uint32_t)W * (uint32_t)H * 2u;
  if (f.fileSize() != expected) {
    Serial.printf("  檔案大小不符:%lu (應為 %lu)\n",
                  (unsigned long)f.fileSize(), (unsigned long)expected);
    f.close();
    return false;
  }

  uint32_t tReadUs = 0, tPushUs = 0;

  tft.startWrite();

  for (int y = 0; y < H; y += BLOCK_H) {
    int thisH = (y + BLOCK_H <= H) ? BLOCK_H : (H - y);
    int pxCount = W * thisH;
    int byteCount = pxCount * 2;

    uint32_t a = micros();
    int got = f.read((uint8_t*)blockBuf, byteCount);
    uint32_t b = micros();
    tReadUs += (b - a);

    if (got != byteCount) {
      Serial.println("  讀取不足");
      tft.endWrite();
      f.close();
      return false;
    }

    a = micros();
    tft.setAddrWindow(0, y, W, thisH);
    tft.pushPixels(blockBuf, pxCount);
    b = micros();
    tPushUs += (b - a);
  }

  tft.endWrite();
  f.close();

//  Serial.printf("  SD讀取: %lu ms, TFT推畫: %lu ms\n",
//                (unsigned long)(tReadUs / 1000),
//                (unsigned long)(tPushUs / 1000));
  return true;
}

// 連續測試 /tile000.raw, /tile001.raw ... 直到缺檔
static int countFrames() {
  int n = 0;
  while (true) {
    char filename[32];
    snprintf(filename, sizeof(filename), "/%s%0*d.raw", framePrefix, digits, n);

    FsFile tf = sd.open(filename, O_RDONLY);
    if (!tf) break;
    tf.close();

    n++;
    if (n > 999) break; // digits=3 的保護
  }
  return n;
}

void setup() {
  Serial.begin(115200);
  delay(300);
  Serial.println("\nSdFat RAW565 開始(修正版)");

  tft.init();
  tft.setRotation(3);

  // ★ 若你的 raw 是 big-endian(用 Python struct.pack('>H') 產生),要開 true
  tft.setSwapBytes(true);

  sdSPI.begin(SD_SCLK, SD_MISO, SD_MOSI, SD_CS);

  bool ok = false;

  // 先試 40MHz
  {
    SdSpiConfig cfg40(SD_CS, DEDICATED_SPI, SD_SCK_MHZ(40), &sdSPI);
    if (sd.begin(cfg40)) {
      Serial.println("SdFat 初始化成功!(40MHz)");
      ok = true;
    }
  }

  // 失敗再試 20MHz
  if (!ok) {
    Serial.println("SdFat 40MHz 失敗,改用 20MHz...");
    SdSpiConfig cfg20(SD_CS, DEDICATED_SPI, SD_SCK_MHZ(20), &sdSPI);
    if (sd.begin(cfg20)) {
      Serial.println("SdFat 初始化成功!(20MHz)");
      ok = true;
    }
  }

  if (!ok) {
    Serial.println("SdFat 初始化失敗!");
    tft.fillScreen(TFT_BLACK);
    tft.setTextColor(TFT_RED, TFT_BLACK);
    tft.setTextDatum(MC_DATUM);
    tft.drawString("SD INIT FAIL", tft.width() / 2, tft.height() / 2);
    while (1) delay(1000);
  }

  Serial.printf("TFT: %dx%d\n", tft.width(), tft.height());

  totalFrames = countFrames();
  Serial.printf("掃描到 %d 幀\n", totalFrames);

  if (totalFrames <= 0) {
    tft.fillScreen(TFT_BLACK);
    tft.setTextColor(TFT_YELLOW, TFT_BLACK);
    tft.setTextDatum(MC_DATUM);
    tft.drawString("NO FRAMES", tft.width() / 2, tft.height() / 2);
  } else {
    tft.fillScreen(TFT_BLACK);
    tft.setTextColor(TFT_GREEN, TFT_BLACK);
    tft.setTextDatum(MC_DATUM);
    tft.drawString("PLAYING...", tft.width() / 2, tft.height() / 2);
    delay(200);
  }
}

void loop() {
  if (totalFrames <= 0) {
    delay(1000);
    return;
  }

  for (int i = 0; i < totalFrames; i++) {
    char filename[32];
    snprintf(filename, sizeof(filename), "/%s%0*d.raw", framePrefix, digits, i);

//    Serial.printf("\n幀 %d/%d → %s\n", i + 1, totalFrames, filename);
    unsigned long start = millis();

    bool ok = drawRaw565_Profile_SdFat(filename);
    if (!ok) {
      tft.fillScreen(TFT_BLACK);
      tft.setTextColor(TFT_RED, TFT_BLACK);
      tft.setTextDatum(MC_DATUM);
      tft.drawString("RAW LOAD FAIL", W / 2, H / 2);
      delay(800);
      break;
    }

    unsigned long end = millis();
//    Serial.printf("  完成,花費 %lu ms\n", end - start);

    delay(frameDelayMs);
  }

  Serial.println("一輪結束...");
  delay(3000);
}

2026年2月15日 星期日

[OTTO GO] 動畫測試,使用RAW和SdFat 版



Python:BMP轉檔成RAW

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from PIL import Image, ImageOps
import struct
import glob
import os

W, H = 320, 240

def rgb_to_565(r, g, b):
    return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)

def convert_one(bmp_path):
    img = Image.open(bmp_path).convert("RGB")

    # 轉成剛好 320x240:置中裁切/縮放(避免尺寸不符)
    img = ImageOps.fit(img, (W, H), method=Image.Resampling.LANCZOS, centering=(0.5, 0.5))

    raw_path = os.path.splitext(bmp_path)[0] + ".raw"
    pix = img.load()

    with open(raw_path, "wb") as f:
        # 逐像素寫入 RGB565(Little-endian:低位元組在前)
        for y in range(H):
            for x in range(W):
                r, g, b = pix[x, y]
                v = rgb_to_565(r, g, b)
                f.write(struct.pack("<H", v))

    print(f"OK: {bmp_path} -> {raw_path}")

def main():
    # 轉換 tile*.bmp(例如 tile000.bmp)
    bmps = sorted(glob.glob("tile*.bmp"))
    if not bmps:
        print("找不到 tile*.bmp,請確認檔名例如 tile000.bmp")
        return
    for p in bmps:
        convert_one(p)

if __name__ == "__main__":
    main()

Arduino:


  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// ESP32 + TFT_eSPI + microSD (SdFat)
// ST7789 320x240 : RAW565 player (FAST SD read)
// Profile: SD read vs TFT push
#include <TFT_eSPI.h>
#include <SPI.h>
#include <SdFat.h>

TFT_eSPI tft = TFT_eSPI();

// ===== SD pins =====
#define SD_CS   33
#define SD_MOSI 26
#define SD_MISO 36
#define SD_SCLK 25
SPIClass sdSPI(HSPI);

// SdFat objects
SdFat sd;
FsFile f;

// ===== Display size =====
static const int W = 320;
static const int H = 240;

// ===== Playback =====
const int totalFrames = 4;
int frameDelay = 10;
const char *framePrefix = "tile";
const int digits = 3;

// ===== Block push settings =====
static const int BLOCK_H = 40;
static uint16_t blockBuf[W * BLOCK_H];

static bool drawRaw565_Profile_SdFat(const char *filename) {
  if (!f.open(filename, O_RDONLY)) {
    Serial.println("  開檔失敗");
    return false;
  }

  const uint32_t expected = (uint32_t)W * (uint32_t)H * 2u;
  if (f.fileSize() != expected) {
    Serial.printf("  檔案大小不符:%lu (應為 %lu)\n",
                  (unsigned long)f.fileSize(), (unsigned long)expected);
    f.close();
    return false;
  }

  uint32_t tReadUs = 0, tPushUs = 0;

  tft.startWrite();

  for (int y = 0; y < H; y += BLOCK_H) {
    int thisH = (y + BLOCK_H <= H) ? BLOCK_H : (H - y);
    int pxCount = W * thisH;
    int byteCount = pxCount * 2;

    uint32_t a = micros();
    int got = f.read((uint8_t*)blockBuf, byteCount);
    uint32_t b = micros();
    tReadUs += (b - a);

    if (got != byteCount) {
      Serial.println("  讀取不足");
      tft.endWrite();
      f.close();
      return false;
    }

    a = micros();
    tft.setAddrWindow(0, y, W, thisH);
    tft.pushPixels(blockBuf, pxCount);
    b = micros();
    tPushUs += (b - a);
  }

  tft.endWrite();
  f.close();

  Serial.printf("  SD讀取: %lu ms, TFT推畫: %lu ms\n",
                (unsigned long)(tReadUs / 1000),
                (unsigned long)(tPushUs / 1000));
  return true;
}

void setup() {
  Serial.begin(115200);
  delay(300);
  Serial.println("\nSdFat RAW565 開始(cfg 修正版)");

  tft.init();
  tft.setRotation(3);
  tft.setSwapBytes(false);

  sdSPI.begin(SD_SCLK, SD_MISO, SD_MOSI, SD_CS);

  // 先試 40MHz
  {
    SdSpiConfig cfg40(SD_CS, DEDICATED_SPI, SD_SCK_MHZ(40), &sdSPI);
    if (sd.begin(cfg40)) {
      Serial.println("SdFat 初始化成功!(40MHz)");
      Serial.printf("TFT: %dx%d\n", tft.width(), tft.height());
      return;
    }
  }

  // 失敗再試 20MHz
  Serial.println("SdFat 40MHz 失敗,改用 20MHz...");
  {
    SdSpiConfig cfg20(SD_CS, DEDICATED_SPI, SD_SCK_MHZ(20), &sdSPI);
    if (sd.begin(cfg20)) {
      Serial.println("SdFat 初始化成功!(20MHz)");
      Serial.printf("TFT: %dx%d\n", tft.width(), tft.height());
      return;
    }
  }

  Serial.println("SdFat 初始化失敗!");
  while (1) delay(1000);
}

void loop() {
  for (int i = 0; i < totalFrames; i++) {
    char filename[32];
    snprintf(filename, sizeof(filename), "/%s%0*d.raw", framePrefix, digits, i);

    Serial.printf("\n幀 %d/%d → %s\n", i + 1, totalFrames, filename);
    unsigned long start = millis();

    bool ok = drawRaw565_Profile_SdFat(filename);
    if (!ok) {
      tft.fillScreen(TFT_BLACK);
      tft.setTextColor(TFT_RED, TFT_BLACK);
      tft.setTextDatum(MC_DATUM);
      tft.drawString("RAW LOAD FAIL", W / 2, H / 2);
    }

    unsigned long end = millis();
    Serial.printf("  完成,花費 %lu ms\n", end - start);

    delay(frameDelay);
  }

  Serial.println("一輪結束...");
  delay(300);
}


[OTTO GO] 動畫測試,用4張bmp圖檔



1.取得gif檔,然後用工具轉成不同的bmp圖檔,記得大小要跟TFT一樣。

2. 使用小畫家轉成深度24bit。

arduino:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
// ESP32 + TFT_eSPI + microSD
// ST7789 320x240 : FAST BMP player (no sprite, sequential SD read, per-line push)
// Supports: 24-bit uncompressed BMP
// Files: /tile000.bmp ... /tile003.bmp

#include <TFT_eSPI.h>
#include <SD.h>
#include <SPI.h>

TFT_eSPI tft = TFT_eSPI();

// ===== SD pins =====
#define SD_CS   33
#define SD_MOSI 26
#define SD_MISO 36
#define SD_SCLK 25
SPIClass sdSPI(HSPI);

// ===== Playback =====
const int totalFrames = 4;
int frameDelay = 1;               // 你可再降
const char *framePrefix = "tile";
const int digits = 3;

// ===== Line buffer =====
#define LINE_W 320
static uint8_t  sdbuf[LINE_W * 3];     // BGR888 bytes
static uint16_t lcdbuf[LINE_W];        // RGB565 pixels

// ---------- BMP helpers ----------
static uint16_t read16(File &f) {
  uint16_t r;
  ((uint8_t*)&r)[0] = f.read();
  ((uint8_t*)&r)[1] = f.read();
  return r;
}

static uint32_t read32(File &f) {
  uint32_t r;
  ((uint8_t*)&r)[0] = f.read();
  ((uint8_t*)&r)[1] = f.read();
  ((uint8_t*)&r)[2] = f.read();
  ((uint8_t*)&r)[3] = f.read();
  return r;
}

// Fast draw: sequential read rows, push each row to TFT
static bool drawBmpFast(const char *filename) {
  File bmp = SD.open(filename);
  if (!bmp) {
    Serial.println("  開檔失敗");
    return false;
  }

  if (read16(bmp) != 0x4D42) {
    Serial.println("  不是 BMP");
    bmp.close();
    return false;
  }

  (void)read32(bmp); // fileSize
  (void)read32(bmp); // reserved
  uint32_t dataOffset = read32(bmp);

  uint32_t headerSize = read32(bmp);
  if (headerSize < 40) {
    Serial.println("  headerSize 不支援");
    bmp.close();
    return false;
  }

  int32_t w  = (int32_t)read32(bmp);
  int32_t h0 = (int32_t)read32(bmp);
  (void)read16(bmp); // planes
  uint16_t depth = read16(bmp);
  uint32_t compression = read32(bmp);

  if (depth != 24 || compression != 0) {
    Serial.println("  只支援 24-bit 無壓縮 BMP");
    bmp.close();
    return false;
  }

  bool topDown = false;
  int32_t h = h0;
  if (h0 < 0) { topDown = true; h = -h0; }

  // 這版針對 320x240 全螢幕最快:若不是滿版也能置中,但會裁切
  const int screenW = tft.width();   // 320
  const int screenH = tft.height();  // 240

  int drawW = w;
  int drawH = h;

  int offsetX = (screenW - drawW) / 2;
  int offsetY = (screenH - drawH) / 2;

  int srcX0 = 0, srcY0 = 0;
  if (offsetX < 0) { srcX0 = -offsetX; offsetX = 0; drawW = screenW; }
  if (offsetY < 0) { srcY0 = -offsetY; offsetY = 0; drawH = screenH; }
  if (offsetX + drawW > screenW) drawW = screenW - offsetX;
  if (offsetY + drawH > screenH) drawH = screenH - offsetY;

  // 為了速度與簡化:要求 drawW <= LINE_W
  if (drawW > LINE_W) {
    Serial.println("  圖太寬,請把 LINE_W 調大或改用分段");
    bmp.close();
    return false;
  }

  // BMP rows padded to 4-byte boundary
  uint32_t rowSize = (uint32_t)((w * 3 + 3) & ~3);
  uint32_t padBytes = rowSize - (uint32_t)w * 3;

  // 重要:避免每行 seek,改成「一次 seek 到資料起點後連續讀」
  // 但若要裁切 X(srcX0),就必須每行跳過 srcX0*3 bytes
  // 我們仍維持連續讀:每行讀完整一行(w*3),再取中間需要的區段
  if (!bmp.seek(dataOffset)) {
    Serial.println("  seek(dataOffset) 失敗");
    bmp.close();
    return false;
  }

  tft.startWrite();

  // 若你是滿版 320x240,整張都覆蓋,就不需要清屏
  // 若非滿版想避免殘影,可自行在外面清一次背景

  for (int fileRow = 0; fileRow < h; fileRow++) {
    // 讀一整行原始像素(w * 3)
    int want = (int)w * 3;
    int got = bmp.read(sdbuf, want);
    if (got != want) {
      Serial.println("  讀取不足");
      tft.endWrite();
      bmp.close();
      return false;
    }

    // 跳過 padding
    if (padBytes) bmp.seek(bmp.position() + padBytes);

    // 這行在螢幕上的 Y(BMP 若 bottom-up,需要倒過來畫)
    int srcY = fileRow;                         // 0..h-1 in file order
    int dstY_in_img = topDown ? srcY : (h - 1 - srcY);  // 轉成由上到下的影像座標

    // 若有 Y 裁切(srcY0..srcY0+drawH-1),不在範圍就略過(但仍已讀掉)
    if (dstY_in_img < srcY0 || dstY_in_img >= (srcY0 + drawH)) continue;

    int yOnScreen = offsetY + (dstY_in_img - srcY0);

    // 從 sdbuf 中取出需要的 X 範圍(srcX0..srcX0+drawW-1)
    // sdbuf 是 B,G,R
    uint8_t *p = sdbuf + (srcX0 * 3);
    for (int x = 0; x < drawW; x++) {
      uint8_t b = p[x * 3 + 0];
      uint8_t g = p[x * 3 + 1];
      uint8_t r = p[x * 3 + 2];
      lcdbuf[x] = tft.color565(r, g, b);
    }

    // 推到 TFT:一次設定視窗 + 推一行
    tft.setAddrWindow(offsetX, yOnScreen, drawW, 1);

    // 依 TFT_eSPI 版本不同,pushPixels / pushColors 可能都可用
    // pushPixels 在 ESP32/ST7789 常見可用
    tft.pushPixels(lcdbuf, drawW);
  }

  tft.endWrite();
  bmp.close();
  return true;
}

void setup() {
  Serial.begin(115200);
  delay(300);
  Serial.println("\nBMP FAST(逐行直推 TFT)開始");

  tft.init();
  tft.setRotation(3);

  // 建議:顏色更穩(不同版本行為略有差)
  tft.setSwapBytes(true);

  // SD init
  sdSPI.begin(SD_SCLK, SD_MISO, SD_MOSI, SD_CS);
  if (!SD.begin(SD_CS, sdSPI)) {
    Serial.println("SD 初始化失敗!");
    while (1) delay(1000);
  }
  Serial.println("SD 初始化成功!");
}

void loop() {
  for (int i = 0; i < totalFrames; i++) {
    char filename[32];
    snprintf(filename, sizeof(filename), "/%s%0*d.bmp", framePrefix, digits, i);

    Serial.printf("\n幀 %d/%d → %s\n", i + 1, totalFrames, filename);
    unsigned long start = millis();

    // 如果你的 BMP 是滿版 320x240,完全覆蓋,就不要清屏(省非常多時間)
    // tft.fillScreen(TFT_BLACK);

    bool ok = drawBmpFast(filename);
    if (!ok) {
      tft.fillScreen(TFT_BLACK);
      tft.setTextColor(TFT_RED, TFT_BLACK);
      tft.setTextDatum(MC_DATUM);
      tft.drawString("BMP LOAD FAIL", tft.width() / 2, tft.height() / 2);
    }

    unsigned long end = millis();
    Serial.printf("  完成,花費 %lu ms\n", end - start);

    delay(frameDelay);
  }

  Serial.println("一輪結束,稍等後重播...");
  delay(500);
}

User_Setup.h

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#define USER_SETUP_INFO "My_ST7789_240x320"

// 驅動器:ST7789
#define ST7789_DRIVER

// 螢幕尺寸(你的實際尺寸)
#define TFT_WIDTH  240
#define TFT_HEIGHT 320

// 腳位(你的板子)
#define TFT_MOSI 19
#define TFT_SCLK 18
#define TFT_CS   5
#define TFT_DC   16
#define TFT_RST  23   // 如果 RST 接 3.3V 或不穩,改成 -1 試試

// 顏色順序(這是關鍵!先試 TFT_BGR_ORDER)
#define TFT_RGB_ORDER TFT_BGR   // 先試這個(BGR 順序常解決彩虹噪點)
 //#define TFT_RGB_ORDER TFT_RGB   // 如果 BGR 不行,再換這個

// SPI 頻率(先降速避免噪點)
//#define SPI_FREQUENCY  27000000   // 27MHz 先試;若還噪點改成 20000000
#define SPI_FREQUENCY  40000000   // 等穩定後再試 40MHz

#define SPI_READ_FREQUENCY 20000000
#define SPI_TOUCH_FREQUENCY  2500000

// 字型載入(保持你原來的)
#define LOAD_GLCD
#define LOAD_FONT2
#define LOAD_FONT4
#define LOAD_FONT6
#define LOAD_FONT7
#define LOAD_FONT8
#define LOAD_GFXFF
#define SMOOTH_FONT

// 可選:反轉顏色(如果黑白顛倒再開)
 //#define TFT_INVERSION_ON
 //#define TFT_INVERSION_OFF

#define USE_DMA