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--;