diff --git a/examples/companion_radio/ui-core/SosEngine.h b/examples/companion_radio/ui-core/SosEngine.h index b7b2eb1c..88ef06af 100644 --- a/examples/companion_radio/ui-core/SosEngine.h +++ b/examples/companion_radio/ui-core/SosEngine.h @@ -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); } diff --git a/examples/companion_radio/ui-new/SosScreen.h b/examples/companion_radio/ui-new/SosScreen.h index 703be480..4d22c51e 100644 --- a/examples/companion_radio/ui-new/SosScreen.h +++ b/examples/companion_radio/ui-new/SosScreen.h @@ -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; } }; diff --git a/test/test_sos_engine/test_sos_engine.cpp b/test/test_sos_engine/test_sos_engine.cpp index 0f6ea7ca..cda8b7d7 100644 --- a/test/test_sos_engine/test_sos_engine.cpp +++ b/test/test_sos_engine/test_sos_engine.cpp @@ -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);