Skip to content
C

Finalize 1.3.0 device settings

YU CHIH CHANG93fcd3b929e8
diff --git a/README.md b/README.md
index 698948d..27d305f 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
# ESP32 GT7 Dashboard ([Installer](https://caa1211.github.io/esp32-gt7-dashboard/))
+[English](README.md) | [繁體中文](README.zh-TW.md)
+
> **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.
@@ -77,7 +79,7 @@ One firmware includes three dashboard themes with the same live GT7 telemetry fe
- **Classic** — the original engineering-style five-column dashboard.
- **Retro** — a warm paper-colored instrument panel with dark text and restrained accents.
-While the display is active, tap it once, 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.
+While the display is active, tap it once, 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 or brightness.
<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">
@@ -153,7 +155,10 @@ No IP address configuration is required.
- Open Settings while the display is active.
- Wake the display when it is asleep; the first tap does not also open Settings.
- Select and save the Classic, GT3, or Retro dashboard theme.
-- Reset saved Wi-Fi through a separate confirmation screen.
+- Open **DEVICE SETTINGS** to adjust brightness from 20% to 100% in 10% steps.
+- Reset saved Wi-Fi from Device Settings through a separate confirmation screen.
+
+Brightness defaults to 80%, is saved after adjustment, and is restored after reboot or wake. Automatic sleep still turns the backlight fully off.
GT3 is used when no theme has been saved. Classic, GT3 and Retro expose the same supported telemetry; only their presentation differs.
diff --git a/README.zh-TW.md b/README.zh-TW.md
index 026fc49..ded7ac4 100644
--- a/README.zh-TW.md
+++ b/README.zh-TW.md
@@ -1,5 +1,7 @@
# ESP32 GT7 Dashboard ([線上安裝](https://caa1211.github.io/esp32-gt7-dashboard/))
+[English](README.md) | [繁體中文](README.zh-TW.md)
+
> **主題開發:** 架構、開發流程與實機驗收項目請參考[主題開發指南](docs/THEME_DEVELOPMENT.md)及[實作規畫](docs/THEME_SWITCH_PLAN.md)。
一個專為 **Gran Turismo 7** 打造、完全運行於 **ESP32** 的獨立儀表板。
@@ -78,7 +80,7 @@
- **Classic** — 原本偏工程風格的五欄儀表板。
- **Retro** — 暖色紙張底、深色文字與低調提示色的復古儀表板。
-螢幕亮起時點一下,選擇 **SELECT THEME**,再選取需要的主題。主題會以固定 enum 值儲存並在重新開機後恢復;重設 Wi-Fi 不會清除主題設定。
+螢幕亮起時點一下,選擇 **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 外觀比較">
@@ -149,7 +151,10 @@ http://192.168.4.1
- 螢幕亮起時開啟設定選單。
- 螢幕休眠時只喚醒顯示,第一次點擊不會同時進入設定。
- 選擇並儲存 Classic、GT3 或 Retro 儀表主題。
-- 透過獨立確認畫面重設已儲存的 Wi-Fi。
+- 進入 **DEVICE SETTINGS**,以 10% 級距調整 20%~100% 的亮度。
+- 從 Device Settings 透過獨立確認畫面重設已儲存的 Wi-Fi。
+
+亮度預設為 80%,調整後會儲存,重新開機或喚醒時會恢復;自動休眠仍會完全關閉背光。
沒有儲存過主題時會使用 GT3。Classic、GT3 與 Retro 顯示相同的支援遙測資料,只有呈現方式不同。
diff --git a/docs/THEME_DEVELOPMENT.md b/docs/THEME_DEVELOPMENT.md
index 2827ecb..d8181e1 100644
--- a/docs/THEME_DEVELOPMENT.md
+++ b/docs/THEME_DEVELOPMENT.md
@@ -22,6 +22,8 @@ The included themes are:
Persisted values are part of the device settings format. Never reorder or reuse an existing enum value.
+Display brightness is stored separately in the same `gt7dash` Preferences namespace. It uses a validated percentage (`20`–`100`) rather than a menu index. Changes are applied immediately and written after a short idle delay to avoid unnecessary flash writes. Wi-Fi reset must not clear theme or brightness preferences.
+
## Data available to renderers
`DashboardState` is the renderer contract. It includes:
@@ -101,7 +103,7 @@ For each display controller, verify:
- low, mid and alert-range RPM behavior
- repeated switching among all themes
- saved theme restoration after power cycling
-- Settings Back and timeout behavior
+- Settings Back, Device Settings brightness and timeout behavior
- Wi-Fi reset Cancel and confirmation
- automatic sleep, tap-to-wake and active-screen tap-to-Settings behavior
- no visible flicker in high-frequency fields
diff --git a/installer/firmware/firmware-ili9341.bin b/installer/firmware/firmware-ili9341.bin
index f11f37f..3bb5e86 100644
Binary files a/installer/firmware/firmware-ili9341.bin and b/installer/firmware/firmware-ili9341.bin differ
diff --git a/installer/firmware/firmware-st7789.bin b/installer/firmware/firmware-st7789.bin
index 4d1cd26..f11f5b8 100644
Binary files a/installer/firmware/firmware-st7789.bin and b/installer/firmware/firmware-st7789.bin differ
diff --git a/installer/release-notes.json b/installer/release-notes.json
index 2dbddb2..72229f8 100644
--- a/installer/release-notes.json
+++ b/installer/release-notes.json
@@ -2,6 +2,7 @@
"1.3.0": [
"Added switchable GT3, Classic, and Retro dashboard themes with persistent on-device selection; GT3 remains the default.",
"Added the touch Settings menu: tap an active display to open Settings, or tap a sleeping display to wake it.",
+ "Added Device Settings with persistent 20–100% brightness control and protected Wi-Fi reset access.",
"Refined the Classic min-alert RPM marker and increased Retro gear readability."
],
"1.2.7": [
diff --git a/installer/releases.json b/installer/releases.json
index 2b42761..f53220d 100644
--- a/installer/releases.json
+++ b/installer/releases.json
@@ -5,6 +5,7 @@
"notes": [
"Added switchable GT3, Classic, and Retro dashboard themes with persistent on-device selection; GT3 remains the default.",
"Added the touch Settings menu: tap an active display to open Settings, or tap a sleeping display to wake it.",
+ "Added Device Settings with persistent 20–100% brightness control and protected Wi-Fi reset access.",
"Refined the Classic min-alert RPM marker and increased Retro gear readability."
],
"manifests": {
diff --git a/installer/versions/1.3.0/firmware-ili9341.bin b/installer/versions/1.3.0/firmware-ili9341.bin
index f11f37f..3bb5e86 100644
Binary files a/installer/versions/1.3.0/firmware-ili9341.bin and b/installer/versions/1.3.0/firmware-ili9341.bin differ
diff --git a/installer/versions/1.3.0/firmware-st7789.bin b/installer/versions/1.3.0/firmware-st7789.bin
index 4d1cd26..f11f5b8 100644
Binary files a/installer/versions/1.3.0/firmware-st7789.bin and b/installer/versions/1.3.0/firmware-st7789.bin differ
diff --git a/src/SHCustomProtocol.h b/src/SHCustomProtocol.h
index 07f0e3b..2d7b3b1 100644
--- a/src/SHCustomProtocol.h
+++ b/src/SHCustomProtocol.h
@@ -258,14 +258,20 @@ private:
static constexpr uint8_t FADE_DELAY_MS = 4;
static constexpr unsigned long SCREEN_SLEEP_TIMEOUT = 5UL * 60UL * 1000UL;
// static constexpr unsigned long SCREEN_SLEEP_TIMEOUT = 10000;
- static constexpr uint8_t SCREEN_NORMAL_BRIGHTNESS = 255;
+ static constexpr uint8_t DEFAULT_BRIGHTNESS_PERCENT = 80;
+ static constexpr uint8_t MIN_BRIGHTNESS_PERCENT = 20;
+ static constexpr uint8_t BRIGHTNESS_STEP_PERCENT = 10;
+ static constexpr unsigned long BRIGHTNESS_SAVE_DELAY_MS = 750UL;
static constexpr bool TOUCH_SCREEN_CONTROL_ENABLED = true;
// Connecting 畫面動畫設定
static constexpr unsigned long CONNECT_ANIMATION_INTERVAL = 1000;
static constexpr int CONNECT_DOT_COUNT = 5;
- uint8_t currentBrightness = SCREEN_NORMAL_BRIGHTNESS;
+ uint8_t userBrightnessPercent = DEFAULT_BRIGHTNESS_PERCENT;
+ uint8_t currentBrightness = 255;
+ bool brightnessSavePending = false;
+ unsigned long brightnessChangedTime = 0;
unsigned long gameStoppedTime = 0;
bool gameStoppedTimerStarted = false;
@@ -274,12 +280,13 @@ private:
// 是否由使用者手動關閉
bool screenOffByUser = false;
- // Long-press the dashboard to open the touch-driven Settings menu.
+ // Tap the active dashboard to open the touch-driven Settings menu.
enum class SettingsScreen : uint8_t
{
Closed,
Main,
ThemeSelection,
+ DeviceSettings,
WifiResetConfirmation,
};
@@ -315,6 +322,28 @@ private:
}
}
+ uint8_t normalBrightness() const
+ {
+ return static_cast<uint8_t>(
+ (userBrightnessPercent * 255U + 50U) / 100U);
+ }
+
+ void scheduleBrightnessSave()
+ {
+ brightnessSavePending = true;
+ brightnessChangedTime = millis();
+ }
+
+ void saveBrightnessIfDue()
+ {
+ if (!brightnessSavePending ||
+ millis() - brightnessChangedTime < BRIGHTNESS_SAVE_DELAY_MS)
+ return;
+ if (dashboardPreferencesReady)
+ dashboardPreferences.putUChar("brightness", userBrightnessPercent);
+ brightnessSavePending = false;
+ }
+
void invalidateDashboardRenderer()
{
tft.fillScreen(TFT_BLACK);
@@ -341,6 +370,12 @@ private:
{
storedTheme = dashboardPreferences.getUChar(
"theme", static_cast<uint8_t>(DashboardTheme::GT3));
+ const uint8_t storedBrightness = dashboardPreferences.getUChar(
+ "brightness", DEFAULT_BRIGHTNESS_PERCENT);
+ userBrightnessPercent =
+ storedBrightness >= MIN_BRIGHTNESS_PERCENT && storedBrightness <= 100
+ ? storedBrightness
+ : DEFAULT_BRIGHTNESS_PERCENT;
}
activeDashboardTheme = isValidDashboardTheme(storedTheme)
@@ -493,8 +528,8 @@ public:
tft.init();
loadDashboardTheme();
tft.setRotation(DASHBOARD_DISPLAY_ROTATION);
- tft.setBrightness(SCREEN_NORMAL_BRIGHTNESS);
- currentBrightness = SCREEN_NORMAL_BRIGHTNESS;
+ tft.setBrightness(normalBrightness());
+ currentBrightness = normalBrightness();
tft.fillScreen(TFT_BLACK);
screenSleeping = false;
// Serial.begin(115200); //x debug
@@ -3329,7 +3364,7 @@ public:
void fadeScreenOn()
{
- fadeToBrightness(SCREEN_NORMAL_BRIGHTNESS);
+ fadeToBrightness(normalBrightness());
}
void fadeScreenOff()
@@ -3381,6 +3416,33 @@ public:
tft.drawString(label, x + width / 2, y + height / 2, 2);
}
+ void drawDeviceBrightnessValue()
+ {
+ static LGFX_Sprite brightnessSprite(&tft);
+ static bool spriteCreated = false;
+ if (!spriteCreated)
+ {
+ brightnessSprite.setColorDepth(16);
+ spriteCreated = brightnessSprite.createSprite(116, 48) != nullptr;
+ }
+ if (spriteCreated)
+ {
+ brightnessSprite.fillSprite(TFT_BLACK);
+ brightnessSprite.setTextColor(TFT_WHITE, TFT_BLACK);
+ brightnessSprite.setTextDatum(MC_DATUM);
+ brightnessSprite.drawString(
+ String(userBrightnessPercent) + "%", 58, 24, 4);
+ brightnessSprite.pushSprite(102, 72);
+ }
+ else
+ {
+ tft.fillRect(102, 72, 116, 48, TFT_BLACK);
+ tft.setTextColor(TFT_WHITE, TFT_BLACK);
+ tft.setTextDatum(MC_DATUM);
+ tft.drawString(String(userBrightnessPercent) + "%", X_CENTER, 96, 4);
+ }
+ }
+
void drawSettingsScreen(int pressedButton = -1)
{
tft.fillScreen(TFT_BLACK);
@@ -3392,8 +3454,7 @@ public:
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.drawString("SETTINGS", X_CENTER, 25, 4);
drawSettingsButton(30, 55, 260, 48, "SELECT THEME", pressedButton == 0);
- drawSettingsButton(30, 113, 260, 48, "RESET WIFI", pressedButton == 1,
- false, true);
+ drawSettingsButton(30, 113, 260, 48, "DEVICE SETTINGS", pressedButton == 1);
drawSettingsButton(30, 171, 260, 48, "BACK", pressedButton == 2);
}
else if (settingsScreen == SettingsScreen::ThemeSelection)
@@ -3414,6 +3475,19 @@ public:
}
drawSettingsButton(30, 180, 260, 38, "BACK", pressedButton == 3);
}
+ else if (settingsScreen == SettingsScreen::DeviceSettings)
+ {
+ tft.setTextColor(TFT_WHITE, TFT_BLACK);
+ tft.drawString("DEVICE SETTINGS", X_CENTER, 20, 4);
+ tft.setTextColor(TFT_LIGHTGREY, TFT_BLACK);
+ tft.drawString("BRIGHTNESS", X_CENTER, 53, 2);
+ drawSettingsButton(30, 72, 70, 48, "-", pressedButton == 0);
+ drawSettingsButton(220, 72, 70, 48, "+", pressedButton == 1);
+ drawDeviceBrightnessValue();
+ drawSettingsButton(30, 132, 260, 38, "RESET WIFI", pressedButton == 2,
+ false, true);
+ drawSettingsButton(30, 182, 260, 38, "BACK", pressedButton == 3);
+ }
else if (settingsScreen == SettingsScreen::WifiResetConfirmation)
{
tft.setTextColor(TFT_WHITE, TFT_BLACK);
@@ -3435,8 +3509,7 @@ public:
if (button == 0)
drawSettingsButton(30, 55, 260, 48, "SELECT THEME", pressed);
else if (button == 1)
- drawSettingsButton(30, 113, 260, 48, "RESET WIFI", pressed,
- false, true);
+ drawSettingsButton(30, 113, 260, 48, "DEVICE SETTINGS", pressed);
else if (button == 2)
drawSettingsButton(30, 171, 260, 48, "BACK", pressed);
}
@@ -3459,6 +3532,18 @@ public:
drawSettingsButton(30, 180, 260, 38, "BACK", pressed);
}
}
+ else if (settingsScreen == SettingsScreen::DeviceSettings)
+ {
+ if (button == 0)
+ drawSettingsButton(30, 72, 70, 48, "-", pressed);
+ else if (button == 1)
+ drawSettingsButton(220, 72, 70, 48, "+", pressed);
+ else if (button == 2)
+ drawSettingsButton(30, 132, 260, 38, "RESET WIFI", pressed,
+ false, true);
+ else if (button == 3)
+ drawSettingsButton(30, 182, 260, 38, "BACK", pressed);
+ }
else if (settingsScreen == SettingsScreen::WifiResetConfirmation)
{
if (button == 0)
@@ -3474,8 +3559,8 @@ public:
{
screenSleeping = false;
screenOffByUser = false;
- tft.setBrightness(SCREEN_NORMAL_BRIGHTNESS);
- currentBrightness = SCREEN_NORMAL_BRIGHTNESS;
+ tft.setBrightness(normalBrightness());
+ currentBrightness = normalBrightness();
settingsScreen = screen;
wifiResetConfirmOpen = screen == SettingsScreen::WifiResetConfirmation;
settingsPressedButton = -1;
@@ -3502,8 +3587,8 @@ public:
// 即使原本處於暗屏,也要先亮起確認畫面。
screenSleeping = false;
screenOffByUser = false;
- tft.setBrightness(SCREEN_NORMAL_BRIGHTNESS);
- currentBrightness = SCREEN_NORMAL_BRIGHTNESS;
+ tft.setBrightness(normalBrightness());
+ currentBrightness = normalBrightness();
tft.fillScreen(TFT_BLACK);
tft.setTextPadding(0);
@@ -3578,6 +3663,13 @@ public:
}
if (touchInside(30, 180, 260, 38)) return 3;
}
+ else if (settingsScreen == SettingsScreen::DeviceSettings)
+ {
+ if (touchInside(30, 72, 70, 48)) return 0;
+ if (touchInside(220, 72, 70, 48)) return 1;
+ if (touchInside(30, 132, 260, 38)) return 2;
+ if (touchInside(30, 182, 260, 38)) return 3;
+ }
else if (settingsScreen == SettingsScreen::WifiResetConfirmation)
{
if (touchInside(25, 135, 120, 62)) return 0;
@@ -3593,7 +3685,7 @@ public:
if (button == 0)
showSettingsScreen(SettingsScreen::ThemeSelection);
else if (button == 1)
- showWifiResetConfirm();
+ showSettingsScreen(SettingsScreen::DeviceSettings);
else if (button == 2)
closeSettings();
}
@@ -3618,11 +3710,36 @@ public:
showSettingsScreen(SettingsScreen::Main);
}
}
+ else if (settingsScreen == SettingsScreen::DeviceSettings)
+ {
+ if (button == 0 || button == 1)
+ {
+ const int adjustment = button == 0
+ ? -BRIGHTNESS_STEP_PERCENT
+ : BRIGHTNESS_STEP_PERCENT;
+ userBrightnessPercent = constrain(
+ static_cast<int>(userBrightnessPercent) + adjustment,
+ static_cast<int>(MIN_BRIGHTNESS_PERCENT), 100);
+ tft.setBrightness(normalBrightness());
+ currentBrightness = normalBrightness();
+ scheduleBrightnessSave();
+ settingsLastInteractionTime = millis();
+ drawDeviceBrightnessValue();
+ }
+ else if (button == 2)
+ {
+ showWifiResetConfirm();
+ }
+ else if (button == 3)
+ {
+ showSettingsScreen(SettingsScreen::Main);
+ }
+ }
else if (settingsScreen == SettingsScreen::WifiResetConfirmation)
{
if (button == 0)
{
- showSettingsScreen(SettingsScreen::Main);
+ showSettingsScreen(SettingsScreen::DeviceSettings);
}
else if (button == 1)
{
@@ -3634,6 +3751,7 @@ public:
void readTouch()
{
+ saveBrightnessIfDue();
if (!TOUCH_SCREEN_CONTROL_ENABLED)
{
return;
@@ -3667,8 +3785,6 @@ public:
{
settingsLastInteractionTime = millis();
settingsPressedButton = settingsButtonAtTouch();
- if (settingsPressedButton >= 0)
- redrawSettingsButton(settingsPressedButton, true);
}
else if (!isTouched && wasTouched)
{
@@ -3681,10 +3797,6 @@ public:
activateSettingsButton(pressedButton);
waitForReleaseAfterScreenChange = true;
}
- else if (pressedButton >= 0)
- {
- redrawSettingsButton(pressedButton, false);
- }
}
wasTouched = isTouched;