Skip to content

Commit 22fc9f3

Browse files
jplexerclaude
andcommitted
fw/light: give each dynamic backlight mode its own intensity floor
In a dark room the dynamic backlight ramp bottomed out at a fixed 10% regardless of mode, so switching between the Standard and Battery Saver presets produced no visible brightness change unless Max Brightness was selected. Give each dynamic mode a distinct 0-lux floor (Bright 30%, Standard 20%, Dim 10%) so the presets are distinguishable in the dark. Fixes FIRM-3993 Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Joshua Jun <lets@throw.rocks>
1 parent 5055310 commit 22fc9f3

1 file changed

Lines changed: 26 additions & 10 deletions

File tree

src/fw/services/light/service.c

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,21 @@ static uint32_t prv_dynamic_mode_full_lux(BacklightDynamicMode mode) {
160160
return 250;
161161
}
162162
}
163+
164+
//! Intensity floor at 0 lux, per mode. Distinct floors keep the modes
165+
//! visually distinguishable in a dark room, where the ramp contributes
166+
//! nothing.
167+
static uint8_t prv_dynamic_mode_floor_intensity(BacklightDynamicMode mode) {
168+
switch (mode) {
169+
case BacklightDynamicMode_Bright:
170+
return 30;
171+
case BacklightDynamicMode_Dim:
172+
return 10;
173+
case BacklightDynamicMode_Standard:
174+
default:
175+
return 20;
176+
}
177+
}
163178
#endif
164179

165180
static void prv_change_state(BacklightState new_state);
@@ -234,27 +249,28 @@ static uint8_t prv_backlight_get_intensity(void) {
234249
}
235250

236251
#if defined(CONFIG_DYNAMIC_BACKLIGHT) && !defined(CONFIG_RECOVERY_FW)
237-
// Dynamic backlight: linear ramp from dim_intensity at 0 lux up to 100% at
238-
// the mode's full-brightness lux level, then clamped to user_max. This keeps
239-
// the slope independent of the user's brightness preference, so a user who
240-
// caps their max at e.g. 60% still hits that cap partway up the ALS range
241-
// rather than only at the brightest end. prv_light_allowed() independently
242-
// rejects wakes above the dark threshold; paths that bypass it (app-driven
243-
// force-on, ambient-sensor pref off) sensibly land at user_max here.
252+
// Dynamic backlight: linear ramp from the mode's floor intensity at 0 lux up
253+
// to 100% at the mode's full-brightness lux level, then clamped to user_max.
254+
// This keeps the slope independent of the user's brightness preference, so a
255+
// user who caps their max at e.g. 60% still hits that cap partway up the ALS
256+
// range rather than only at the brightest end. prv_light_allowed()
257+
// independently rejects wakes above the dark threshold; paths that bypass it
258+
// (app-driven force-on, ambient-sensor pref off) sensibly land at user_max
259+
// here.
244260
const BacklightDynamicMode mode = backlight_get_dynamic_mode();
245261
if (mode != BacklightDynamicMode_Off) {
246-
const uint8_t dim_intensity = 10;
262+
const uint8_t floor_intensity = prv_dynamic_mode_floor_intensity(mode);
247263
const uint8_t user_max = backlight_get_intensity();
248264
const uint32_t als = prv_get_als_level();
249265
const uint32_t full_lux = prv_dynamic_mode_full_lux(mode);
250266

251-
if (user_max <= dim_intensity) {
267+
if (user_max <= floor_intensity) {
252268
return user_max;
253269
}
254270
if (als >= full_lux) {
255271
return user_max;
256272
}
257-
const uint32_t ramped = dim_intensity + ((100 - dim_intensity) * als) / full_lux;
273+
const uint32_t ramped = floor_intensity + ((100 - floor_intensity) * als) / full_lux;
258274
return (ramped > user_max) ? user_max : (uint8_t)ramped;
259275
}
260276
#endif

0 commit comments

Comments
 (0)