From f0f142890f1e76d726ceb09c497e744b47d3895a Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Tue, 12 May 2026 09:57:21 +0200 Subject: [PATCH] Fix home_pages_mask=0 inconsistency and navPage fallback - Remove mask==0 guard from isPageVisible/homePageVisible/toggle: mask=0 now correctly means "all optional pages hidden" instead of silently reverting to all-visible. Initialization always sets 0x01FF before loadPrefs so 0 only occurs if user explicitly hides everything. - Simplify toggle handler: direct XOR on home_pages_mask. - HomeScreen: use navPage(+1) as fallback when current page becomes hidden, instead of always jumping to i=0. Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/ui-new/UITask.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index dd0a27c8..3aa097bb 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -295,7 +295,6 @@ class SettingsScreen : public UIScreen { uint16_t bit = homePageBit(item); if (!bit) return false; uint16_t mask = p ? p->home_pages_mask : HP_ALL; - if (mask == 0) mask = HP_ALL; return (mask & bit) != 0; } @@ -679,9 +678,7 @@ public: return right || left; } if (isHomePage(_selected) && p && (left || right || enter)) { - uint16_t bit = homePageBit(_selected); - uint16_t mask = p->home_pages_mask ? p->home_pages_mask : HP_ALL; - p->home_pages_mask = mask ^ bit; + p->home_pages_mask ^= homePageBit(_selected); _dirty = true; return true; } @@ -2169,7 +2166,6 @@ class HomeScreen : public UIScreen { int bit = pageBit(page); if (bit < 0) return true; uint16_t mask = _node_prefs ? _node_prefs->home_pages_mask : HP_ALL; - if (mask == 0) mask = HP_ALL; return (mask >> bit) & 1; } @@ -2325,9 +2321,7 @@ public: renderBatteryIndicator(display, _task->getBattMilliVolts()); // ensure current page is visible (e.g. after settings change) - if (!isPageVisible(_page)) { - for (int i = 0; i < (int)Count; i++) { if (isPageVisible(i)) { _page = i; break; } } - } + if (!isPageVisible(_page)) _page = navPage(_page, +1); // curr page indicator — only visible pages get a dot {