Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions non_catalog_apps/FlipperNightStand_clock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
2 changes: 1 addition & 1 deletion non_catalog_apps/FlipperNightStand_clock/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
25 changes: 19 additions & 6 deletions non_catalog_apps/FlipperNightStand_clock/clock_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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) {
Expand Down Expand Up @@ -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--;
Expand Down
Loading