From 54ab351b2f74246bbc139fd5f1c8d963d14a6721 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:15:07 +0200 Subject: [PATCH] fix(NearbyScreen): TIME filter stale sort + right-align distance/age column - TIME mode: call refresh() every 3 s so newly-heard contacts bubble up to the correct position; previously the list froze at the order captured when the filter was selected. - All filters: right-align the distance/age value within the right column (width - textWidth - 2 px) instead of pinning it to a fixed left edge, so short strings like "5s" or "3m" sit flush with the longer ones. Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/ui-new/NearbyScreen.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/companion_radio/ui-new/NearbyScreen.h b/examples/companion_radio/ui-new/NearbyScreen.h index cdf92c7a..7c9e2f49 100644 --- a/examples/companion_radio/ui-new/NearbyScreen.h +++ b/examples/companion_radio/ui-new/NearbyScreen.h @@ -38,7 +38,9 @@ class NearbyScreen : public UIScreen { uint8_t _filter; unsigned long _detail_refresh_ms; + unsigned long _list_refresh_ms = 0; static const unsigned long DETAIL_REFRESH_MS = 10000UL; + static const unsigned long TIME_LIST_REFRESH_MS = 3000UL; PopupMenu _ctx_menu; PopupMenu _opts; // detail-view Options: Navigate / Ping @@ -605,6 +607,13 @@ public: } // ── list view ──────────────────────────────────────────────────────────── + // In TIME mode re-sort periodically so newly-heard contacts bubble up. + if (_filter == FILTER_COUNT - 1 && + millis() - _list_refresh_ms >= TIME_LIST_REFRESH_MS) { + refresh(); + _list_refresh_ms = millis(); + } + int item_h = display.lineStep(); int start_y = display.listStart(); int dist_col = display.width() - display.getCharWidth() * 7; @@ -644,7 +653,8 @@ public: if (e.dist_km >= 0.0f) geo::fmtDist(right, sizeof(right), e.dist_km, useImperial()); else strncpy(right, "?GPS", sizeof(right)); } - display.setCursor(dist_col, y); + // Right-align within the right column (2 px margin from edge). + display.setCursor(display.width() - display.getTextWidth(right) - 2, y); display.print(right); }