fix(sos): e-ink status view refreshes every 15 s and shows minutes, not a second-by-second count

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-11-02 09:23:17 +01:00
co-authored by Claude Opus 5.5
parent 745e554e72
commit 81b74e41ce
3 changed files with 14 additions and 6 deletions
+3 -2
View File
@@ -78,10 +78,11 @@ public:
if (_sent) snprintf(out, n, "Sent %u x", (unsigned)_sent); if (_sent) snprintf(out, n, "Sent %u x", (unsigned)_sent);
else snprintf(out, n, "Not sent"); else snprintf(out, n, "Not sent");
} }
void nextLine(char* out, int n, uint32_t now) const { // `minutes` for a slow panel, where a line ticking every second is a refresh a second.
void nextLine(char* out, int n, uint32_t now, bool minutes = false) const {
const int next = nextSecs(now); const int next = nextSecs(now);
if (next < 0) snprintf(out, n, "No more repeats"); if (next < 0) snprintf(out, n, "No more repeats");
else if (next < 60) snprintf(out, n, "Next in %d s", next); else if (next < 60) snprintf(out, n, minutes ? "Next in <1 min" : "Next in %d s", next);
else snprintf(out, n, "Next in %d min", (next + 59) / 60); else snprintf(out, n, "Next in %d min", (next + 59) / 60);
} }
+7 -4
View File
@@ -207,10 +207,13 @@ public:
} }
// The countdown, then what has been sent and who answered. Returns the delay // The countdown, then what has been sent and who answered. Returns the delay
// to the next frame. // to the next frame. On e-ink only the countdown ticks: a send or an answer
// redraws the view anyway (UITask::openSosView).
int renderStatus(DisplayDriver& d) { int renderStatus(DisplayDriver& d) {
SosEngine& s = _task->core().sos; SosEngine& s = _task->core().sos;
const uint32_t now = millis(); const uint32_t now = millis();
const bool eink = d.isEink();
const int status_ms = eink ? 15000 : 1000;
const int cx = d.width() / 2; const int cx = d.width() / 2;
const int foot = d.height() - d.getLineHeight() - 1; const int foot = d.height() - d.getLineHeight() - 1;
char buf[40]; char buf[40];
@@ -244,16 +247,16 @@ public:
} }
if (mins) { snprintf(buf, sizeof(buf), "%u min ago", (unsigned)mins); d.drawTextCentered(cx, y, buf); } if (mins) { snprintf(buf, sizeof(buf), "%u min ago", (unsigned)mins); d.drawTextCentered(cx, y, buf); }
d.drawTextCentered(cx, foot, "Hold Enter: end"); d.drawTextCentered(cx, foot, "Hold Enter: end");
return 1000; return status_ms;
} }
s.sentLine(buf, sizeof(buf)); s.sentLine(buf, sizeof(buf));
d.drawTextCentered(cx, y, buf); d.drawTextCentered(cx, y, buf);
y += d.lineStep(); y += d.lineStep();
s.nextLine(buf, sizeof(buf), now); s.nextLine(buf, sizeof(buf), now, eink);
d.drawTextCentered(cx, y, buf); d.drawTextCentered(cx, y, buf);
int32_t lat, lon; int32_t lat, lon;
if (!_task->currentLocation(lat, lon)) d.drawTextCentered(cx, y + d.lineStep(), "No GPS fix"); if (!_task->currentLocation(lat, lon)) d.drawTextCentered(cx, y + d.lineStep(), "No GPS fix");
d.drawTextCentered(cx, foot, "Hold Enter: stop"); d.drawTextCentered(cx, foot, "Hold Enter: stop");
return 1000; return status_ms;
} }
}; };
+4
View File
@@ -367,6 +367,10 @@ TEST_F(Sos, TheStatusLines) {
EXPECT_STREQ(b, "Next in 5 min"); EXPECT_STREQ(b, "Next in 5 min");
sos.nextLine(b, sizeof(b), now + 5UL * 60000UL - 30000UL); sos.nextLine(b, sizeof(b), now + 5UL * 60000UL - 30000UL);
EXPECT_STREQ(b, "Next in 30 s"); EXPECT_STREQ(b, "Next in 30 s");
sos.nextLine(b, sizeof(b), now + 5UL * 60000UL - 30000UL, true);
EXPECT_STREQ(b, "Next in <1 min");
sos.nextLine(b, sizeof(b), now, true);
EXPECT_STREQ(b, "Next in 5 min");
prefs.sos_repeat_idx = 0; prefs.sos_repeat_idx = 0;
sos.markSent(now, true, true); sos.markSent(now, true, true);
sos.nextLine(b, sizeof(b), now); sos.nextLine(b, sizeof(b), now);