Skip to content

Commit 1c79e68

Browse files
3rdIterationclaude
andcommitted
fix: tdeck backlight turned off for all valid brightness levels
power_backlight_on() scaled brightness as a 0-255 value, but Jade passes levels BACKLIGHT_MIN..BACKLIGHT_MAX (1..5), so the result was always 0 and the backlight switched off as soon as the stored brightness was applied after boot. Clamp and map levels 1..5 linearly onto dimmer steps 1..16. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent bb716c7 commit 1c79e68

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

main/power/tdeck.inc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,17 @@ esp_err_t power_shutdown(void)
8484
esp_err_t power_screen_on(void) { return ESP_OK; }
8585
esp_err_t power_screen_off(void) { return ESP_OK; }
8686

87-
esp_err_t power_backlight_on(const uint8_t brightness)
87+
esp_err_t power_backlight_on(uint8_t brightness)
8888
{
89-
const uint8_t scaled = (brightness * BACKLIGHT_STEPS) / 255;
89+
// Brightness is a level BACKLIGHT_MIN (1) to BACKLIGHT_MAX (5),
90+
// mapped linearly onto dimmer steps 1 to BACKLIGHT_STEPS.
91+
if (brightness < BACKLIGHT_MIN) {
92+
brightness = BACKLIGHT_MIN;
93+
} else if (brightness > BACKLIGHT_MAX) {
94+
brightness = BACKLIGHT_MAX;
95+
}
96+
const uint8_t scaled
97+
= 1 + ((BACKLIGHT_STEPS - 1) * (brightness - BACKLIGHT_MIN)) / (BACKLIGHT_MAX - BACKLIGHT_MIN);
9098
set_backlight(scaled);
9199
return ESP_OK;
92100
}

0 commit comments

Comments
 (0)