C
Restore Classic dashboard renderer
YU CHIH CHANG37772fa0e745
diff --git a/THEME_SWITCH_PLAN.md b/THEME_SWITCH_PLAN.mdindex e7d04d6..283b915 100644--- a/THEME_SWITCH_PLAN.md+++ b/THEME_SWITCH_PLAN.md@@ -8,7 +8,7 @@ Overall progress:- [x] **Phase 1 — Theme infrastructure** — accepted on ST7789 hardware (2026-08-17)- [x] **Phase 2 — Touch Settings and theme selection** — accepted on ST7789 and ILI9341 hardware (2026-08-17)-- [ ] **Phase 3 — Classic 1.2.5 renderer**+- [x] **Phase 3 — Classic 1.2.5 renderer** — accepted on ST7789 hardware (2026-08-17)- [ ] **Phase 4 — Retro renderer**- [ ] **Phase 5 — Integration, regression testing and release**@@ -313,16 +313,18 @@ Compare Classic on the physical display against the version 1.2.5 UI reference wPass conditions:-- [ ] The major layout, typography, colors and visual hierarchy match version 1.2.5.-- [ ] Every current dashboard function has a defined place; no current function disappears.-- [ ] No obsolete 1.2.5 parser, Wi-Fi or button behavior has been restored.-- [ ] Speed, gear, RPM, timing, fuel, tyre, pedal and driver-aid fields update correctly.-- [ ] RPM scaling and shift-warning behavior use the current telemetry logic.-- [ ] Returning from Classic to GT3 leaves neither stale pixels nor stale cached values.-- [ ] Classic remains stable for at least one normal driving session.+- [x] The major layout, typography, colors and visual hierarchy match version 1.2.5.+- [x] Every current dashboard function has a defined place; no current function disappears.+- [x] No obsolete 1.2.5 parser, Wi-Fi or button behavior has been restored.+- [x] Speed, gear, RPM, timing, fuel, tyre, pedal and driver-aid fields update correctly.+- [x] RPM scaling and shift-warning behavior use the current telemetry logic.+- [x] Returning from Classic to GT3 leaves neither stale pixels nor stale cached values.+- [x] Classic remains stable for at least one normal driving session.Minor pixel-level visual tuning may remain, but data correctness and clean switching are required before Phase 4.+**Acceptance record:** Phase 3 was accepted after physical ST7789 testing of the restored Classic layout, current telemetry fields, theme switching and the two-layer throttle/brake presentation. Pedal cells are composed off-screen to prevent flicker; driver input uses a white base layer and the filtered actual output uses the existing yellow/blue foreground. The final white-base adjustment was explicitly accepted without another visual verification cycle.+### Phase 4 — Retro Renderer- Create a 320 × 240 layout sketch using the existing data fields.diff --git a/src/SHCustomProtocol.h b/src/SHCustomProtocol.hindex da26f0c..8e3a6c5 100644--- a/src/SHCustomProtocol.h+++ b/src/SHCustomProtocol.h@@ -1022,7 +1022,7 @@ public:switch (activeDashboardTheme){case DashboardTheme::Classic:- drawThemePlaceholder(state, DashboardTheme::Classic, forceUpdate);+ drawPage1Legacy(forceUpdate);break;case DashboardTheme::Retro:drawThemePlaceholder(state, DashboardTheme::Retro, forceUpdate);@@ -2028,7 +2028,9 @@ public:CELL_WIDTH * 2 - 2,CELL_HEIGHT - 1,constrain(tcLevel.toInt(), 0, 100),+ constrain(tcFilteredLevel.toInt(), 0, 100),constrain(absLevel.toInt(), 0, 100),+ constrain(absFilteredLevel.toInt(), 0, 100),forceUpdate);// ABS、TCS 狀態與油量@@ -2680,11 +2682,15 @@ public:int32_t totalWidth,int32_t totalHeight,int throttlePercent,+ int throttleAppliedPercent,int brakePercent,+ int brakeAppliedPercent,bool forceUpdate = false){throttlePercent = constrain(throttlePercent, 0, 100);+ throttleAppliedPercent = constrain(throttleAppliedPercent, 0, 100);brakePercent = constrain(brakePercent, 0, 100);+ brakeAppliedPercent = constrain(brakeAppliedPercent, 0, 100);// 上下兩格,而不是左右兩格。const int32_t gap = 2;@@ -2695,16 +2701,51 @@ public:auto updateOneCell = [&](int32_t cellY,int percent,+ int appliedPercent,const char *id,uint16_t color){- const bool firstDraw = prevData.count(id) == 0;- const int oldPercent = firstDraw- ? 0- : constrain(prevData[id].toInt(), 0, 100);+ const String state = String(percent) + ":" + String(appliedPercent);+ const bool firstDraw = true;+ const int oldPercent = 0;++ if (!forceUpdate && prevData[id] == state)+ {+ return;+ }++ const int32_t spriteInset = 2;+ const int32_t spriteFillWidth = totalWidth - spriteInset * 2;+ const int32_t spriteFillHeight = cellHeight - spriteInset * 2;+ const int32_t spriteInputFill = spriteFillWidth * percent / 100;+ const int32_t spriteAppliedFill = spriteFillWidth * appliedPercent / 100;+ static LGFX_Sprite classicPedalSprite(&tft);+ static int32_t spriteWidth = 0;+ static int32_t spriteHeight = 0;+ if (spriteWidth != totalWidth || spriteHeight != cellHeight)+ {+ classicPedalSprite.deleteSprite();+ classicPedalSprite.setColorDepth(16);+ if (classicPedalSprite.createSprite(totalWidth, cellHeight) != nullptr)+ {+ spriteWidth = totalWidth;+ spriteHeight = cellHeight;+ }+ }- if (!forceUpdate && !firstDraw && oldPercent == percent)+ if (spriteWidth == totalWidth && spriteHeight == cellHeight){+ classicPedalSprite.fillSprite(TFT_BLACK);+ if (spriteInputFill > 0)+ classicPedalSprite.fillRect(spriteInset, spriteInset,+ spriteInputFill, spriteFillHeight, TFT_WHITE);+ if (spriteAppliedFill > 0)+ classicPedalSprite.fillRect(spriteInset, spriteInset,+ spriteAppliedFill, spriteFillHeight, color);+ classicPedalSprite.drawRoundRect(0, 0, totalWidth, cellHeight, 5,+ TFT_DARKGREY);+ classicPedalSprite.pushSprite(x, cellY);+ prevData[id] = state;return;}@@ -2725,7 +2766,8 @@ public:if (newFill > 0){- tft.fillRect(fillX, fillY, newFill, fillHeight, color);+ tft.fillRect(fillX, fillY, newFill, fillHeight,+ TFT_WHITE);}}else if (newFill > oldFill)@@ -2750,12 +2792,19 @@ public:}// 保險重畫邊框,避免填色蓋到外框。+ const int32_t appliedFill = fillWidthMax * appliedPercent / 100;+ if (appliedFill > 0)+ {+ tft.fillRect(fillX, fillY, appliedFill, fillHeight, color);+ }tft.drawRoundRect(x, cellY, totalWidth, cellHeight, 5, TFT_DARKGREY);- prevData[id] = String(percent);+ prevData[id] = state;};- updateOneCell(throttleY, throttlePercent, "pedalThrottle", TFT_YELLOW);- updateOneCell(brakeY, brakePercent, "pedalBrake", TFT_BLUE);+ updateOneCell(throttleY, throttlePercent, throttleAppliedPercent,+ "pedalThrottle", TFT_YELLOW);+ updateOneCell(brakeY, brakePercent, brakeAppliedPercent,+ "pedalBrake", TFT_BLUE);}void drawCell(