Skip to content

UI: handle clock rollover in display and shutdown timers - #3722

Open
Amoulier wants to merge 1 commit into
meshcore-dev:devfrom
Amoulier:fix/ui-new-wrap-safe-timers
Open

Amoulier wants to merge 1 commit into
meshcore-dev:devfrom
Amoulier:fix/ui-new-wrap-safe-timers

Conversation

@Amoulier

@Amoulier Amoulier commented Oct 28, 2026 •

Copy link
Copy Markdown

ui-new compares render, alert and auto-off deadlines directly against millis(). A deadline just after the 32-bit wrap can therefore be treated as already expired before the wrap, or postponed afterwards. Its shutdown sound timeout also subtracts 2500 from the current time before comparing, which underflows during the first 2.5 seconds of uptime.

Use signed deadline differences for the short UI deadlines and unsigned elapsed time for the shutdown wait. Use the existing zero refresh marker consistently instead of the stale absolute value 100. Reserve zero for forced refresh/no active alert, including the exact-zero wrap case when scheduling a new deadline. This does not change display navigation or the configured timeout durations.

Validation:

  • python test/ui_new_timing/run.py passed on Windows.
  • python3 test/ui_new_timing/run.py --sanitize passed under Linux ASan/UBSan.
  • python test/ui_new_timing/run.py --source-ref 42ded8da646c7fbe9ccb8c522441f7aa87767344 fails against the original timing code, as expected.
  • pio run -e muzi_base_uno_superIO_companion_radio_ble passed against dev with RadioLib 7.8.1.
  • git diff --check passed.

The standalone harness compiles the actual UITask timing expressions and alert method with a 32-bit clock. Cases cover before/at/after deadlines, 0xFFFFFFFF wrap, disabled alerts, forced refresh at high uptime, exact-zero scheduling, and early-boot shutdown waiting. Other UI timers outside these paths are not changed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant