Skip to content

Nightstand Clock: fix unreachable nightlight, 12h midnight, and notification-record lifetime (closes #243) - #244

Merged
xMasterX merged 2 commits into
devfrom
nightstand-clock-fixes
Jul 24, 2026
Merged

Nightstand Clock: fix unreachable nightlight, 12h midnight, and notification-record lifetime (closes #243)#244
xMasterX merged 2 commits into
devfrom
nightstand-clock-fixes

Conversation

@mishamyte

Copy link
Copy Markdown
Collaborator

Fixes #243.

Three user-facing bugs in the Nightstand Clock app (non_catalog_apps/FlipperNightStand_clock), plus a startup resource leak found during review.

1. LED nightlight unreachable at some brightness levels

The internal brightness counter was seeded with a truncating SavedBrightness * 100, and handle_up/handle_down stepped by +/-5 with no clamp. The system LCD brightness uses 0.05 steps, six of which truncate off the multiple-of-5 grid (35/45/65/70/90/95% -> 34/44/64/69/89/94), so Down walked ...,9,4,-1 and never hit 0 - the nightlight (brightness == 0) could never be switched on, and brightness left the 0-100 range.

Fix: roundf on init + clamp to [0,100] in both handlers. This also removes a latent progress-bar assert-crash in debug builds.

2. 12-hour clock shows midnight as 00

Hour 0 printed as 00:xx AM instead of 12:xx AM. Fixed with hour12 = hour % 12; if(hour12 == 0) hour12 = 12; (noon/PM unchanged).

3. notif used after furi_record_close

On exit the settings-restore ran after the notification record had already been closed. Moved the close to after the restore block.

4. Startup timer-alloc failure leaked the notification record + view_port

The timer == NULL early-return freed only the mutex/queue/state, leaking the open RECORD_NOTIFICATION handle and the allocated view_port and leaving the backlight forced on. It now restores the notification settings and releases both, mirroring the normal teardown.


fap_version 1.0 -> 1.1, added CHANGELOG.md. This app is third-party (@nymda & @Willy-JL); the fixes may want mirroring upstream.

Reviewed with the pr-review-toolkit code-reviewer and code-simplifier agents and clang-formatted with the project style.

🤖 Generated with Claude Code

mishamyte and others added 2 commits July 24, 2026 17:30
… use-after-close (closes #243)

- Round the inherited system brightness and clamp it to 0-100 so the -5/+5
  stepping always lands exactly on 0 (the LED nightlight) and 100. Several
  system brightness levels (e.g. 70%, 90%) truncated off the multiple-of-5
  grid, so Down skipped 0 and the nightlight could never be switched on, and
  brightness could leave the valid range.
- Show midnight as 12:xx AM instead of 00:xx AM in 12-hour locales.
- Close RECORD_NOTIFICATION after the exit-time settings restore instead of
  before it, so notif is no longer dereferenced after its record is closed.

Bump fap_version 1.0 -> 1.1 and add CHANGELOG.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…oc fails

The timer == NULL startup path returned 255 after freeing only the mutex,
event queue and plugin_state, leaking the already-opened RECORD_NOTIFICATION
handle and the allocated view_port, and leaving the backlight forced on with
display_off_delay_ms = 0. Restore the notification settings and release both
resources on that path, mirroring the normal teardown.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mishamyte mishamyte added type/bug Something isn't working category/tools App category: tools pack/non-catalog App in non_catalog_apps status/third-party App is authored/maintained outside our team; coordinate fixes with upstream labels Jul 24, 2026
@xMasterX
xMasterX merged commit 03f0a70 into dev Jul 24, 2026
2 checks passed
@xMasterX
xMasterX deleted the nightstand-clock-fixes branch July 24, 2026 20:10
Repository owner locked as resolved and limited conversation to collaborators Jul 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

category/tools App category: tools pack/non-catalog App in non_catalog_apps status/third-party App is authored/maintained outside our team; coordinate fixes with upstream type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nightstand Clock: nightlight unreachable at some brightness levels, 12h midnight shows 00, and notif used after record close

2 participants