fix: review pass - Discover's late replies dropped and its way back usable, the Gallery's newest first and faster, the network clock's toast

- Discover: a reply after its try timed out, was stopped or was overtaken
  went on to the normal handling and became the contact's route (and sent
  a path back); the last tags sent are kept and a late reply is dropped.
  Leaving Route on the L2 stops a discovery as it stops a trace.
- Discover: a route whose reply came back another way offers that way too
  (L2 There / Back, L1 a Back row), turned round into a route there, so a
  trace checks it; the Discover button no longer sits on its group.
- Screenshots: numbered one past the highest (one pass over the folder,
  not a stat per number), so one taken after a delete is still the newest.
- Gallery: the newest 300 kept whatever order the folder lists them in;
  BMP rows read in the file's order and several at a time; the thumbnail
  buffer sized to the page; the folder read once per visit; a failed
  open frees or restores the picture.
- NTP: the slot the router's server goes in emptied before joining, so a
  cached address isn't taken for it; "Clock set from the network" judged
  against the clock a tick before (SNTP has set the system time already).
- Sim: sim_scroll up stops at the top.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-29 16:30:19 +01:00
co-authored by Claude Opus 5.5
parent e154a4e721
commit 3a26a8bee7
11 changed files with 171 additions and 65 deletions
@@ -323,9 +323,11 @@ void UITask::wifiSave() {
// From loop(), any screen, once a second: SNTP runs while WiFi is connected
// (Settings > WiFi, a map download, an update, the app over WiFi), and each
// time it answers the clock takes the time -- ahead or behind, as from GPS.
// The first answer of a connection says so when it moved the clock.
// The first answer of a connection says so when it moved the clock --
// judged against the clock a tick before: without a clock chip rtc_clock is
// the system time, which SNTP has set already by the time we hear of it.
void UITask::wifiClockTick() {
static uint32_t next_ms = 0;
static uint32_t next_ms = 0, ref_wall = 0, ref_ms = 0;
static bool first = false;
if ((int32_t)(millis() - next_ms) < 0) return;
next_ms = millis() + 1000;
@@ -338,9 +340,11 @@ void UITask::wifiClockTick() {
const uint32_t t = lvport::ntpTake();
if (t > 1700000000UL) {
const uint32_t now = rtc_clock.getCurrentTime();
const bool moved = t > now + 1 || now > t + 1;
if (moved) rtc_clock.setCurrentTime(t);
if (first && moved && !_asleep) showToast("Clock set from the network");
if (t > now + 1 || now > t + 1) rtc_clock.setCurrentTime(t); // a clock chip: SNTP set only the system time
const uint32_t was = ref_wall + (millis() - ref_ms) / 1000;
if (first && (t > was + 2 || was > t + 2) && !_asleep) showToast("Clock set from the network");
first = false;
}
ref_wall = rtc_clock.getCurrentTime();
ref_ms = millis();
}