C
Integrate dashboard themes and touch controls
YU CHIH CHANGb6c16ac3efba
diff --git a/README.md b/README.mdindex 561efce..570e30f 100644--- a/README.md+++ b/README.md@@ -1,7 +1,7 @@# ESP32 GT7 Dashboard ([Installer](https://caa1211.github.io/esp32-gt7-dashboard/))-> **Development roadmap:** The multi-theme UI renovation (Classic, GT3 and Retro) is tracked in [THEME_SWITCH_PLAN.md](THEME_SWITCH_PLAN.md), including phase-by-phase progress and hardware acceptance checks.+> **Theme development:** See the [theme guide](docs/THEME_DEVELOPMENT.md) and [implementation plan](docs/THEME_SWITCH_PLAN.md) for architecture, workflow and hardware acceptance checks.A standalone **Gran Turismo 7 dashboard** running entirely on an ESP32.No SimHub • No PC • Auto PS5 Discovery@@ -69,14 +69,15 @@ Currently supported:----## Firmware Versions+## Dashboard Themes-The dashboard appearance differs between firmware versions:+One firmware includes three dashboard themes with the same live GT7 telemetry features:-- **1.2.5** uses the original engineering-style dashboard layout.-- **1.2.6** introduces the refined GT3-style dashboard with a centered gear display, curved segmented RPM bar, larger telemetry values, tyre-temperature blocks, and brake/throttle bars.+- **GT3** (default) — centered gear, curved shift-light bar and a dark motorsport layout.+- **Classic** — the original engineering-style five-column dashboard.+- **Retro** — a warm paper-colored instrument panel with dark text and restrained accents.-Both versions are available for the supported ILI9341 and ST7789 display variants. Choose the version whose dashboard layout you prefer in the Web Installer.+Press and hold the display for 2 seconds, choose **SELECT THEME**, then select a theme. The selection is saved by enum value and restored after reboot. Resetting Wi-Fi does not reset the selected theme.<p align="center"><img src="photos/1.25and1.26_en.png" width="900" alt="Comparison of GT7 Dashboard firmware versions 1.2.5 and 1.2.6">@@ -149,7 +150,7 @@ No IP address configuration is required.**Tap**-- Turn the display on or off.+- Wake the display when it is asleep. Tapping an active display does nothing.**Press and Hold (2 sec)**@@ -157,6 +158,8 @@ No IP address configuration is required.- Select and save the Classic, GT3, or Retro dashboard theme.- Reset saved Wi-Fi through a separate confirmation screen.+GT3 is used when no theme has been saved. Classic, GT3 and Retro expose the same supported telemetry; only their presentation differs.+<p align="center"><img src="photos/003.jpg" width="900" alt="ESP32 GT7 Dashboard"></p>@@ -169,7 +172,7 @@ To reduce power consumption and extend display life:- The display automatically enters sleep mode after several minutes without GT7 telemetry.- It automatically wakes when GT7 telemetry is detected again.-- The display can also be turned off manually by tapping the screen.+- Tap the screen to wake it after automatic sleep.---diff --git a/README.zh-TW.md b/README.zh-TW.mdindex deb4b30..2d5ade3 100644--- a/README.zh-TW.md+++ b/README.zh-TW.md@@ -1,6 +1,6 @@# ESP32 GT7 Dashboard ([線上安裝](https://caa1211.github.io/esp32-gt7-dashboard/))-> **開發規畫:** Classic、GT3 與 Retro 多主題 UI 翻新進度、分階段流程及實機驗收項目記錄於 [THEME_SWITCH_PLAN.md](THEME_SWITCH_PLAN.md)。+> **主題開發:** 架構、開發流程與實機驗收項目請參考[主題開發指南](docs/THEME_DEVELOPMENT.md)及[實作規畫](docs/THEME_SWITCH_PLAN.md)。一個專為 **Gran Turismo 7** 打造、完全運行於 **ESP32** 的獨立儀表板。@@ -70,14 +70,15 @@----## 韌體版本+## 儀表主題-不同韌體版本使用不同的儀表板外觀:+同一份韌體內建三種儀表主題,並提供相同的即時 GT7 遙測功能:-- **1.2.5** 使用原本偏工程風格的儀表板版面。-- **1.2.6** 使用重新設計的 GT3 風格儀表板,包含置中的檔位、弧形分段 RPM、放大的遙測數值、胎溫色塊,以及煞車/油門指示條。+- **GT3**(預設)— 置中檔位、弧形換檔燈與深色賽車風格版面。+- **Classic** — 原本偏工程風格的五欄儀表板。+- **Retro** — 暖色紙張底、深色文字與低調提示色的復古儀表板。-兩個版本都提供 ILI9341 與 ST7789 顯示器對應的韌體。請在 Web Installer 中選擇自己偏好的儀表板版本。+長按螢幕 2 秒,選擇 **SELECT THEME**,再選取需要的主題。主題會以固定 enum 值儲存並在重新開機後恢復;重設 Wi-Fi 不會清除主題設定。<p align="center"><img src="photos/1.25and1.26_cht.png" width="900" alt="GT7 Dashboard 韌體 1.2.5 與 1.2.6 外觀比較">@@ -145,7 +146,7 @@ http://192.168.4.1**點一下**-- 手動熄屏/開屏。+- 螢幕休眠時喚醒顯示;亮屏時點一下不會執行動作。**長按(2 秒)**@@ -153,6 +154,8 @@ http://192.168.4.1- 選擇並儲存 Classic、GT3 或 Retro 儀表主題。- 透過獨立確認畫面重設已儲存的 Wi-Fi。+沒有儲存過主題時會使用 GT3。Classic、GT3 與 Retro 顯示相同的支援遙測資料,只有呈現方式不同。+<p align="center"><img src="photos/003.jpg" width="900" alt="ESP32 GT7 Dashboard"></p>@@ -165,7 +168,7 @@ http://192.168.4.1- 長時間未收到 GT7 遙測資料時,螢幕會自動進入休眠。- 收到 GT7 遙測資料後,會自動恢復顯示。-- 也可以透過點擊螢幕手動熄屏。+- 自動休眠後可點擊螢幕恢復顯示。---diff --git a/docs/THEME_DEVELOPMENT.md b/docs/THEME_DEVELOPMENT.mdnew file mode 100644index 0000000..9d954e0--- /dev/null+++ b/docs/THEME_DEVELOPMENT.md@@ -0,0 +1,123 @@+# Dashboard Theme Development Guide++This guide explains how to add or maintain a dashboard theme without duplicating telemetry, connection, touch, or settings logic.++## Architecture++The dashboard has three layers:++1. GT7 parsing and derived metrics update the canonical `DashboardState`.+2. `renderDashboard()` selects a renderer from the persisted `DashboardTheme` enum.+3. Each renderer reads the same state and controls presentation only.++Theme code lives primarily in `src/SHCustomProtocol.h`. A renderer must not parse packets, own a second telemetry model, reset Wi-Fi, or change the touch workflow.++The included themes are:++| Enum | Stored value | Renderer | Purpose |+| --- | ---: | --- | --- |+| `Classic` | 0 | `drawPage1Legacy()` | Original five-column engineering UI |+| `GT3` | 1 | `drawPage1()` | Default dark motorsport UI |+| `Retro` | 2 | `drawRetroDashboard()` | Warm paper-and-ink instrument UI |++Persisted values are part of the device settings format. Never reorder or reuse an existing enum value.++## Data available to renderers++`DashboardState` is the renderer contract. It includes:++- RPM percentage, engine RPM, alert range validity, min-alert position and rev-limit state+- gear and speed+- current, last and best lap times and live delta+- tyre temperatures and the existing REM/LAP/POS display fields+- fuel display data+- throttle/brake input and filtered applied values+- ABS and TCS state+- game-running state++If a new telemetry field is genuinely required by every theme, add it to the shared state and populate it in the parser/derived-data layer. Do not obtain it inside one renderer. A theme should not invent unsupported values merely to match a reference image.++## Adding a theme++1. Append a new explicit value to `DashboardTheme`; do not change existing values.+2. Extend `isValidDashboardTheme()` and `dashboardThemeName()`.+3. Add a renderer branch in `renderDashboard()`.+4. Implement a renderer that accepts `const DashboardState &` and `forceUpdate`.+5. Add the theme to both theme arrays used by the Settings drawing and activation code.+6. Redesign Theme Selection if the buttons no longer fit comfortably.+7. Document the theme in both root README files.+8. Build and test both `esp32` (ILI9341) and `esp32-st7789` targets.++The current 320 x 240 Settings screen intentionally fits three large theme buttons plus Back. Three is not a firmware limit, but it is the recommended usability limit for the current menu. A fourth theme should introduce pagination or Previous/Next controls instead of smaller touch targets.++## Renderer rules++- Treat `forceUpdate` as a complete redraw request.+- Use theme-specific cache keys in `prevData` and `prevColor`, such as `retroSpeed`.+- Never depend on another theme having drawn first.+- Switching themes must leave no stale pixels; `invalidateDashboardRenderer()` clears shared caches and requests a full redraw.+- Keep geometry, colors and fonts local to the renderer or a theme-specific layout namespace.+- Avoid blocking animation. Use `millis()` and frame intervals.+- Only animate the region that needs animation.+- Keep RPM fill clamped to the available segment count and preserve a safe fallback when GT7 alert values are invalid.++## Preventing flicker++SPI displays expose a visible flash when code clears a frequently updated area and draws the replacement in separate transfers.++Use one of these approaches:++- Redraw only changed segments or pixels.+- Compose a small dynamic region in an `LGFX_Sprite`, then call `pushSprite()` once.+- Cache the rendered value and skip unchanged frames.++Do not allocate a full-screen 16-bit sprite on these boards. Prefer small persistent sprites for high-frequency fields such as speed, current time, pedals and tyre temperatures. If sprite allocation can fail, retain a direct-draw fallback where practical.++Fractionally scaling small bitmap fonts can create malformed or illegible glyphs on the 2.8-inch display. Prefer a native font size for small labels and timing values, then adjust the containing rectangle rather than squeezing the font.++## Shift-light behavior++All themes receive the same dynamic RPM state:++- RPM fill maps to the vehicle-specific alert range when valid.+- `rpmRedLineSetting` represents the min-alert position as a percentage of the active bar range.+- warning animation starts in the alert range and strengthens toward the upper range.+- `revLimitAlertActive` requests the strongest warning.++A theme may express this in its own visual language, but inactive elements and unrelated UI must not pulse. Animation must remain non-blocking.++## Build and hardware verification++Run both targets:++```powershell+platformio run -e esp32 -e esp32-st7789+```++For each display controller, verify:++- fresh boot and telemetry connection+- every telemetry field updates without stale pixels+- low, mid and alert-range RPM behavior+- repeated switching among all themes+- saved theme restoration after power cycling+- Settings Back and timeout behavior+- Wi-Fi reset Cancel and confirmation+- automatic sleep and tap-to-wake+- no visible flicker in high-frequency fields+- no watchdog reset or obvious heap degradation during a driving session++Use photographs of the physical 2.8-inch display for typography and contrast approval. Desktop mockups do not reproduce RGB565 color, viewing angle, SPI update behavior or actual text legibility.++## Release checklist++After hardware acceptance:++1. Mark the phase complete in [THEME_SWITCH_PLAN.md](THEME_SWITCH_PLAN.md).+2. Choose the release version and update `VERSION` and `include/version.h`.+3. Add release notes.+4. Build and archive both controller binaries.+5. Update installer manifests and verify the selectable version list.+6. Commit the accepted checkpoint before publishing.++See [RELEASING.md](RELEASING.md) for binary staging and installer publishing details.diff --git a/THEME_SWITCH_PLAN.md b/docs/THEME_SWITCH_PLAN.mdsimilarity index 98%rename from THEME_SWITCH_PLAN.mdrename to docs/THEME_SWITCH_PLAN.mdindex c364940..cabceca 100644--- a/THEME_SWITCH_PLAN.md+++ b/docs/THEME_SWITCH_PLAN.md@@ -1,5 +1,7 @@# Dashboard Theme Switching Plan+See also: [Theme Development Guide](THEME_DEVELOPMENT.md).+## Project StatusThis is a major UI architecture renovation. Work proceeds one phase at a time, and every phase must pass its physical-device acceptance gate before the next phase begins.@@ -369,15 +371,15 @@ Run a final regression pass without temporary theme overrides or test-only screePass conditions:-- [ ] A clean build succeeds for `esp32` and `esp32-st7789`.+- [x] A clean build succeeds for `esp32` and `esp32-st7789`.- [ ] Both binaries are flashed or otherwise validated on their intended display target where hardware is available.-- [ ] Fresh installation defaults to GT3.-- [ ] Upgrade from version 1.2.7 preserves a usable default and does not require manual storage clearing.-- [ ] Classic, GT3 and Retro all receive identical live telemetry inputs and expose the same supported functions.+- [x] Fresh installation defaults to GT3.+- [x] Upgrade from version 1.2.7 preserves a usable default and does not require manual storage clearing.+- [x] Classic, GT3 and Retro all receive identical live telemetry inputs and expose the same supported functions.- [ ] Theme selection survives reboot and ordinary Wi-Fi reconnection.- [ ] Screen on/off, Settings entry, Settings timeout and Wi-Fi reset all pass regression testing.- [ ] No theme-specific crash, watchdog reset or obvious memory degradation appears during an extended session.-- [ ] README documents Settings entry, theme switching, the three included themes and Wi-Fi reset.+- [x] README documents Settings entry, theme switching, the three included themes and Wi-Fi reset.- [ ] Release notes describe the theme system and identify GT3 as the default.- [ ] Installer manifests and archived firmware packages contain the correct version and both display builds.diff --git a/src/SHCustomProtocol.h b/src/SHCustomProtocol.hindex d107fe7..9aba9c5 100644--- a/src/SHCustomProtocol.h+++ b/src/SHCustomProtocol.h@@ -3715,13 +3715,9 @@ public:gameStoppedTimerStarted = false;}}- else- {- screenOffByUser = true;- screenSleeping = true;- fadeScreenOff();- gameStoppedTimerStarted = false;- }+ // While the display is active, a short tap intentionally does nothing.+ // This prevents an attempted Settings long-press from turning the screen+ // off when the user releases slightly before the hold threshold.}wasTouched = isTouched;