Show the live time on the set-clock page instead of a stale cached value#615
Open
bob9 wants to merge 4 commits into
Open
Show the live time on the set-clock page instead of a stale cached value#615bob9 wants to merge 4 commits into
bob9 wants to merge 4 commits into
Conversation
The rollers were populated from a date cached at boot (or last manual set), so a clock updated via the ELRS backpack or NTP still showed the old time on the set-clock screen. Reload from the RTC each time the page is entered.
Refresh the rollers from the RTC once a second while the clock page is open, so a time set remotely (ELRS backpack / NTP) is visible without re-entering the page. Paused while a roller is focused or an edit is pending so it never fights manual input; last_option is kept in step so a programmatic refresh doesn't arm the dirty state.
The once-a-second refresh rebuilt every roller's option list even while the user was scrolling between items, which could trap the cursor on the year roller. Only rebuild the lists when their contents actually change (year/month rollover changes the day count); otherwise just move the selected indices, and hold off entirely for 3s after any user input.
…he menu The refresh ran on an lvgl timer created on page enter and deleted on exit, so scrolling onto the Clock menu item showed stale (or cleared) time until the user actually entered the page. Drive the refresh from the page's on_update hook instead, which the main menu loop calls continuously, and pace it with the lvgl tick (the loop's delta_ms resets its reference every call, alternating between tiny and huge).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The set-clock page's rollers are populated from a value cached in memory, not from the RTC. If the clock changes behind the scenes — the goggles already accept
MSP_SET_RTCfrom the ELRS backpack today — the page keeps showing the stale time, and a pilot who opens it and hits save writes that stale time back over the correct one.Why it helps pilots: the clock page becomes trustworthy. What it shows is the actual current time, so pilots can confirm at a glance that their clock (and therefore their DVR timestamps) is right, and can't accidentally undo an automatic time sync by saving old roller values.
Implementation
Changes confined to
src/ui/page_clock.c:on_updatehook (rather than an lvgl timer scoped to enter/exit), so the page is already showing the live time when the user merely scrolls onto the Clock menu item — no need to enter the page. Paced with the lvgl tick, since the menu loop'sdelta_msresets its reference on every call.No change to how the clock is set or saved.
Related PRs
Standalone — useful with the existing backpack
MSP_SET_RTCpath alone — but it pairs naturally with the automatic time-sync set, which makes background clock updates much more common: