Fix GlobalTime tick drift and blocking NTP/timezone retries #334

Open
Bullpuph123 wants to merge 1 commit from Bullpuph123/fix/globaltime-tick-drift into dev
Bullpuph123 commented 2026-07-15 00:46:44 +00:00 (Migrated from github.com)

Split from #330 (part 1 of 3), rebased onto dev as requested.

Summary

  • Drift-free 1s scheduler: updateTime() used m_updateTimer = millis() after a > comparison, which accumulates drift and eventually skips seconds (visible as irregular colon blink / tick jumps). The timer now advances by whole 1000ms periods, staying phase-locked to the second grid. All comparisons use rollover-safe unsigned arithmetic (millis() wraps at ~49.7 days).
  • Gated NTP attempts: NTPClient's forceUpdate() blocks ~1010ms on timeout without advancing _lastUpdate, so once an update is due, a dead/unreachable NTP server stalls every loop iteration by ~1s (the whole UI degrades to ~1Hz). NTP attempts are now rate-limited (61s once synced, 5s until first sync) so a failing server costs at most one blocked call per interval.
  • Gated timezone API attempts: same class of bug — a failing timezone API call could be retried every second, each one a blocking HTTP request. Now retried at 30s until first success, then 5min after a failure.

Test plan

  • Builds with pio run -e infoorbs-v0_3
  • Host-side simulation (firmware/test/host_sim_long_uptime.py) covering scheduler drift, uint32 rollover, and NTP-failure stall behavior — all checks pass
  • Equivalent change soak-tested on hardware for several days on the main-based branch from #330

🤖 Generated with Claude Code

Split from #330 (part 1 of 3), rebased onto dev as requested. ## Summary - **Drift-free 1s scheduler**: `updateTime()` used `m_updateTimer = millis()` after a `>` comparison, which accumulates drift and eventually skips seconds (visible as irregular colon blink / tick jumps). The timer now advances by whole 1000ms periods, staying phase-locked to the second grid. All comparisons use rollover-safe unsigned arithmetic (millis() wraps at ~49.7 days). - **Gated NTP attempts**: NTPClient's `forceUpdate()` blocks ~1010ms on timeout *without* advancing `_lastUpdate`, so once an update is due, a dead/unreachable NTP server stalls every loop iteration by ~1s (the whole UI degrades to ~1Hz). NTP attempts are now rate-limited (61s once synced, 5s until first sync) so a failing server costs at most one blocked call per interval. - **Gated timezone API attempts**: same class of bug — a failing timezone API call could be retried every second, each one a blocking HTTP request. Now retried at 30s until first success, then 5min after a failure. ## Test plan - [x] Builds with `pio run -e infoorbs-v0_3` - [x] Host-side simulation (`firmware/test/host_sim_long_uptime.py`) covering scheduler drift, uint32 rollover, and NTP-failure stall behavior — all checks pass - [x] Equivalent change soak-tested on hardware for several days on the main-based branch from #330 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ericthelin (Migrated from github.com) approved these changes 2026-07-15 23:31:36 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin Bullpuph123/fix/globaltime-tick-drift:Bullpuph123/fix/globaltime-tick-drift
git switch Bullpuph123/fix/globaltime-tick-drift

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch dev
git merge --no-ff Bullpuph123/fix/globaltime-tick-drift
git switch Bullpuph123/fix/globaltime-tick-drift
git rebase dev
git switch dev
git merge --ff-only Bullpuph123/fix/globaltime-tick-drift
git switch Bullpuph123/fix/globaltime-tick-drift
git rebase dev
git switch dev
git merge --no-ff Bullpuph123/fix/globaltime-tick-drift
git switch dev
git merge --squash Bullpuph123/fix/globaltime-tick-drift
git switch dev
git merge --ff-only Bullpuph123/fix/globaltime-tick-drift
git switch dev
git merge Bullpuph123/fix/globaltime-tick-drift
git push origin dev
Sign in to join this conversation.
No description provided.