fix(ui): trail elapsed/avg-speed driven by millis(), not RTC

The previous implementation derived "Time" and "Avg speed" from the
RTC: first().ts and rtc_clock.getCurrentTime(). When the RTC isn't
synced yet (no GPS time fix, no host sync), every point ts is 0, the
current time is 0 too, and elapsed stays at 0 — Time never moves and
Avg speed reads 0 even with the map filling in. Real-world breakage.

Switch the elapsed/avg-speed timebase to millis():
- TrailStore gains _session_start_ms (millis() when the current
  start→stop window opened) and _accumulated_ms (banked time across
  previous windows).
- setActive(true) records the start; setActive(false) banks the
  delta into the accumulator.
- elapsedSeconds = (_accumulated_ms + active session delta) / 1000.
- clear() zeroes both.

Per-point ts stays RTC-derived (used for the HH:MM labels in List view
where a wallclock is what the user actually wants).

TrailScreen drops the now_ts argument it was passing in, and bumps the
refresh interval to 1 s while active so the m:ss counter actually
ticks every second.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-25 12:51:37 +02:00
co-authored by Claude Sonnet 4.6
parent 237dcbf524
commit 178a34d1ec
2 changed files with 37 additions and 24 deletions
@@ -47,7 +47,7 @@ public:
display.setCursor(2, hint_y);
display.print(hint);
return _store->isActive() ? 2000 : 5000;
return _store->isActive() ? 1000 : 5000;
}
bool handleInput(char c) override {
@@ -107,7 +107,7 @@ private:
break;
}
case 3: {
uint32_t es = _store->elapsedSeconds((uint32_t)rtc_clock.getCurrentTime());
uint32_t es = _store->elapsedSeconds();
// Below 1 h show m:ss so the seconds counter updates visibly each refresh.
if (es < 3600) snprintf(buf, n, "Time: %lu:%02lu",
(unsigned long)(es / 60), (unsigned long)(es % 60));
@@ -116,8 +116,7 @@ private:
break;
}
case 4:
snprintf(buf, n, "Avg speed: %u km/h",
(unsigned)_store->avgSpeedKmh((uint32_t)rtc_clock.getCurrentTime()));
snprintf(buf, n, "Avg speed: %u km/h", (unsigned)_store->avgSpeedKmh());
break;
default:
buf[0] = '\0';