From 82bf0782f67b7114db4801658b15174335a95627 Mon Sep 17 00:00:00 2001 From: razze Date: Mon, 23 Nov 2026 03:07:47 +0100 Subject: [PATCH] Show when the companion has no adverts or sensor readings Skip empty slots when drawing recent adverts so the list starts at the top. --- src/helpers/ui/companion-new/UITask.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/helpers/ui/companion-new/UITask.cpp b/src/helpers/ui/companion-new/UITask.cpp index 652fef94..a3e667f3 100644 --- a/src/helpers/ui/companion-new/UITask.cpp +++ b/src/helpers/ui/companion-new/UITask.cpp @@ -378,7 +378,7 @@ public: } else if (_page == HomePage::RECENT) { display.setColor(UIColor::primary_txt); int y = 20; - for (int i = 0, k = recent_next_idx; i < UI_RECENT_LIST_SIZE; i++, y += 11, k = (k + 1) % UI_RECENT_LIST_SIZE) { + for (int i = 0, k = recent_next_idx; i < UI_RECENT_LIST_SIZE; i++, k = (k + 1) % UI_RECENT_LIST_SIZE) { auto a = &recent[k]; if (a->name[0] == 0) continue; // empty slot int secs = _rtc->getCurrentTime() - a->recv_timestamp; @@ -398,6 +398,10 @@ public: display.drawTextEllipsized(0, y, max_name_width, filtered_recent_name); display.setCursor(display.width() - timestamp_width - 1, y); display.print(tmp); + y += 11; + } + if (y == 20) { + display.drawTextCentered(display.width() / 2, 32, "No recent adverts"); } } else if (_page == HomePage::RADIO) { display.setColor(UIColor::primary_txt); @@ -496,6 +500,11 @@ public: } else if (_page == HomePage::SENSORS) { int y = 18; refresh_sensors(); + if (sensors_nb == 0) { + display.setColor(UIColor::primary_txt); + display.drawTextCentered(display.width() / 2, 32, "No sensor readings"); + return 5000; + } char buf[30]; char name[30]; LPPReader r(sensors_lpp.getBuffer(), sensors_lpp.getSize());