From 9edbba774e210029e78775adedf62574acd7a078 Mon Sep 17 00:00:00 2001 From: Mykhailo Shevchuk Date: Sat, 25 Jul 2026 02:13:07 +0300 Subject: [PATCH] Nightstand Clock: make Up/Down actually change the screen brightness (closes #245) The app pins the backlight with enforce_on and forces display_off_delay_ms=0, so on unleashed the notification service early-returns from a plain sequence_display_backlight_on while the backlight is already on (lcd_backlight_is_on stays true and, with no auto-off delay, never clears) - the on-screen bar moved but the panel never changed. Use sequence_display_backlight_force_on, which clears lcd_backlight_is_on before applying so the new level reaches the panel. Up/Down go through a new set_enforced_brightness (force_on + enforce_auto + enforce_on) that also refreshes the locked internal layer; the exit restore uses force_on too so the saved brightness is reapplied immediately. Removes the author's obsolete commented-out per-frame workaround. Bump fap_version 1.1 -> 1.2 and add the CHANGELOG entry. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../FlipperNightStand_clock/CHANGELOG.md | 4 +++ .../FlipperNightStand_clock/application.fam | 2 +- .../FlipperNightStand_clock/clock_app.c | 25 ++++++++++++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/non_catalog_apps/FlipperNightStand_clock/CHANGELOG.md b/non_catalog_apps/FlipperNightStand_clock/CHANGELOG.md index bb21d198..f9bdc45b 100644 --- a/non_catalog_apps/FlipperNightStand_clock/CHANGELOG.md +++ b/non_catalog_apps/FlipperNightStand_clock/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.2 + +- Fix Up/Down not actually changing the screen brightness: the new level is now pushed to the panel even while the backlight is held always-on (previously the on-screen bar moved but the backlight stayed at the startup brightness) + ## 1.1 - Fix the 12-hour clock showing midnight as `00:xx AM` instead of `12:xx AM` diff --git a/non_catalog_apps/FlipperNightStand_clock/application.fam b/non_catalog_apps/FlipperNightStand_clock/application.fam index bc1b860f..98444660 100644 --- a/non_catalog_apps/FlipperNightStand_clock/application.fam +++ b/non_catalog_apps/FlipperNightStand_clock/application.fam @@ -9,6 +9,6 @@ App( fap_category="Tools", fap_author="@nymda & @Willy-JL", fap_weburl="https://github.com/nymda/FlipperNightStand", - fap_version="1.1", + fap_version="1.2", fap_description="Clock with screen brightness controls", ) diff --git a/non_catalog_apps/FlipperNightStand_clock/clock_app.c b/non_catalog_apps/FlipperNightStand_clock/clock_app.c index 0431fcff..2afb561f 100644 --- a/non_catalog_apps/FlipperNightStand_clock/clock_app.c +++ b/non_catalog_apps/FlipperNightStand_clock/clock_app.c @@ -49,9 +49,25 @@ static const NotificationSequence led_reset = { NULL, }; +// Use force_on (not backlight_on) so the level is pushed to the panel even when +// the backlight is already on - a plain backlight_on early-returns in that case. +// Used on exit to restore the saved brightness after the enforce lock is freed. void set_backlight_brightness(float brightness) { notif->settings.display_brightness = brightness; - notification_message(notif, &sequence_display_backlight_on); + notification_message(notif, &sequence_display_backlight_force_on); +} + +// While the app holds the backlight on with enforce_on, a plain backlight_on +// does not change the screen: the notification service early-returns when the +// backlight is already on, and the enforced "internal" layer that is actually +// shown is only set once at startup. force_on bypasses that early-return to +// update the panel now; the enforce pair then refreshes the locked internal +// layer so the new level cannot be reverted. +void set_enforced_brightness(float brightness) { + notif->settings.display_brightness = brightness; + notification_message(notif, &sequence_display_backlight_force_on); + notification_message(notif, &sequence_display_backlight_enforce_auto); + notification_message(notif, &sequence_display_backlight_enforce_on); } void handle_up() { @@ -62,7 +78,7 @@ void handle_up() { brightness += 5; if(brightness > 100) brightness = 100; } - set_backlight_brightness((float)(brightness / 100.f)); + set_enforced_brightness((float)(brightness / 100.f)); } void handle_down() { @@ -82,7 +98,7 @@ void handle_down() { notification_message(notif, &led_off); } } - set_backlight_brightness((float)(brightness / 100.f)); + set_enforced_brightness((float)(brightness / 100.f)); } static void clock_input_callback(InputEvent* input_event, void* ctx) { @@ -122,9 +138,6 @@ static void clock_render_callback(Canvas* const canvas, void* ctx) { //canvas_clear(canvas); //canvas_set_color(canvas, ColorBlack); - //avoids a bug with the brightness being reverted after the backlight-off period - //set_backlight_brightness((float)(brightness / 100.f)); - if(dspBrightnessBarFrames > 0) { elements_progress_bar_vertical(canvas, 119, 1, 62, (float)(brightness / 100.f)); dspBrightnessBarFrames--;