diff --git a/examples/companion_radio/DataStore.cpp b/examples/companion_radio/DataStore.cpp index 813476cc..961f1748 100644 --- a/examples/companion_radio/DataStore.cpp +++ b/examples/companion_radio/DataStore.cpp @@ -314,6 +314,12 @@ void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& no if (sentinel != NodePrefs::SCHEMA_SENTINEL) { MESH_DEBUG_PRINTLN("prefs schema sentinel mismatch: got 0x%08X, expected 0x%08X — re-saving on next change", (unsigned)sentinel, (unsigned)NodePrefs::SCHEMA_SENTINEL); + // 0xC0DE0001 → 0xC0DE0002: FAVOURITES home page added. Older saves have it + // implicitly off (their mask doesn't include HP_FAVOURITES); turn it on so + // upgraded users see the new page by default and can toggle it later. + if (_prefs.home_pages_mask != 0) { + _prefs.home_pages_mask |= NodePrefs::HP_FAVOURITES; + } } file.close(); diff --git a/examples/companion_radio/ui-new/SettingsScreen.h b/examples/companion_radio/ui-new/SettingsScreen.h index 802cb656..b4d2d40d 100644 --- a/examples/companion_radio/ui-new/SettingsScreen.h +++ b/examples/companion_radio/ui-new/SettingsScreen.h @@ -238,18 +238,34 @@ class SettingsScreen : public UIScreen { } // Initialises page_order to the default display sequence if not already set. - // Also repairs a partially-initialised order where CLOCK (bit 0, stored as 1) is absent. + // Also repairs a partially-initialised order where CLOCK is absent, and migrates + // older orders by inserting FAVOURITES after CLOCK so the page is reorderable. void ensurePageOrderInit(NodePrefs* p) const { if (!p) return; if (p->page_order_set == NodePrefs::PAGE_ORDER_MAGIC) { - // Order was previously set — verify CLOCK is present to guard against partial/corrupted data. - for (int i = 0; i < NodePrefs::HPB_COUNT; i++) { + bool has_clock = false; + bool has_fav = false; + int len = 0; + int clock_at = -1; + for (int i = 0; i < NodePrefs::PAGE_ORDER_LEN; i++) { uint8_t v = p->page_order[i]; if (v < 1 || v > NodePrefs::HPB_COUNT) break; - if (v == 0 + 1) return; // CLOCK found, order is intact + if ((int)(v - 1) == NodePrefs::HPB_CLOCK) { has_clock = true; clock_at = i; } + if ((int)(v - 1) == NodePrefs::HPB_FAVOURITES) { has_fav = true; } + len = i + 1; + } + if (!has_clock) { + // Corrupted/partial — full re-init below. + memset(p->page_order, 0, sizeof(p->page_order)); + } else { + if (!has_fav && len < NodePrefs::PAGE_ORDER_LEN) { + // Insert FAVOURITES right after CLOCK; shift the tail down by one. + int insert_at = clock_at + 1; + for (int i = len; i > insert_at; i--) p->page_order[i] = p->page_order[i - 1]; + p->page_order[insert_at] = NodePrefs::HPB_FAVOURITES + 1; + } + return; } - // CLOCK missing — reset and fall through to full re-init. - memset(p->page_order, 0, sizeof(p->page_order)); } // Default: CLOCK FAVOURITES RECENT RADIO BT ADVERT [GPS] [SENSORS] SETTINGS TOOLS MESSAGES // SHUTDOWN is omitted from the explicit list (PAGE_ORDER_LEN = 11 leaves room for the diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index adc948d4..10483e8f 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -747,18 +747,19 @@ public: } else if (_page == HomePage::FAVOURITES) { // Grid of pinned contacts. Layout transposes to current orientation: // landscape → 3×2, portrait → 2×3. Selected tile inverts via drawSelectionRow. + // No title — node name + battery (top bar) and the page-dots indicator above + // serve as the page identity. display.setColor(DisplayDriver::LIGHT); display.setTextSize(1); - display.drawTextCentered(display.width() / 2, 0, "FAVOURITES"); - display.fillRect(0, display.headerH() - 1, display.width(), display.sepH()); const int cols = display.isLandscape() ? 3 : 2; const int rows = NodePrefs::FAVOURITES_COUNT / cols; - const int grid_y = display.headerH() + display.sepH(); - const int grid_h = display.height() - grid_y; + const int margin = 2; + const int grid_y = content_y + margin; + const int grid_h = display.height() - grid_y - margin; const int cell_w = display.width() / cols; const int cell_h = grid_h / rows; - const int lh = display.getLineHeight(); + const int line_h = display.getLineHeight(); if (_fav_sel >= NodePrefs::FAVOURITES_COUNT) _fav_sel = 0; @@ -791,7 +792,7 @@ public: char name[24]; if (found) display.translateUTF8ToBlocks(name, ci.name, sizeof(name)); else strncpy(name, "(gone)", sizeof(name) - 1), name[sizeof(name) - 1] = '\0'; - int name_y = cy + (cell_h - lh) / 2; + int name_y = cy + (cell_h - line_h) / 2; display.drawTextEllipsized(cx + 2, name_y, cell_w - 4, name); if (found) { @@ -805,7 +806,7 @@ public: } } } else { - int plus_y = cy + (cell_h - lh) / 2; + int plus_y = cy + (cell_h - line_h) / 2; display.drawTextCentered(cx + cell_w / 2, plus_y, "+"); } if (sel) display.setColor(DisplayDriver::LIGHT);