mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-02 10:51:57 +00:00
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:
@@ -78,10 +78,11 @@ public:
|
||||
if (_sent) snprintf(out, n, "Sent %u x", (unsigned)_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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -207,10 +207,13 @@ public:
|
||||
}
|
||||
|
||||
// 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) {
|
||||
SosEngine& s = _task->core().sos;
|
||||
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 foot = d.height() - d.getLineHeight() - 1;
|
||||
char buf[40];
|
||||
@@ -244,16 +247,16 @@ public:
|
||||
}
|
||||
if (mins) { snprintf(buf, sizeof(buf), "%u min ago", (unsigned)mins); d.drawTextCentered(cx, y, buf); }
|
||||
d.drawTextCentered(cx, foot, "Hold Enter: end");
|
||||
return 1000;
|
||||
return status_ms;
|
||||
}
|
||||
s.sentLine(buf, sizeof(buf));
|
||||
d.drawTextCentered(cx, y, buf);
|
||||
y += d.lineStep();
|
||||
s.nextLine(buf, sizeof(buf), now);
|
||||
s.nextLine(buf, sizeof(buf), now, eink);
|
||||
d.drawTextCentered(cx, y, buf);
|
||||
int32_t lat, lon;
|
||||
if (!_task->currentLocation(lat, lon)) d.drawTextCentered(cx, y + d.lineStep(), "No GPS fix");
|
||||
d.drawTextCentered(cx, foot, "Hold Enter: stop");
|
||||
return 1000;
|
||||
return status_ms;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -367,6 +367,10 @@ TEST_F(Sos, TheStatusLines) {
|
||||
EXPECT_STREQ(b, "Next in 5 min");
|
||||
sos.nextLine(b, sizeof(b), now + 5UL * 60000UL - 30000UL);
|
||||
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;
|
||||
sos.markSent(now, true, true);
|
||||
sos.nextLine(b, sizeof(b), now);
|
||||
|
||||
Reference in New Issue
Block a user