From 2f3b95adb477f84f90ff5fe67b26d20919ce2040 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Wed, 30 Sep 2026 23:23:04 +0200 Subject: [PATCH] fix(l2): the GPS switch no longer jumps UiCore::setGpsEnabled() wrote the prefs to flash at once, which stalled the loop mid-animation. It takes save = false now (default true, the L1 unchanged); the L2 marks the prefs changed and writes them on leaving the screen, as its other switches. Co-Authored-By: Claude Opus 5.5 --- examples/companion_radio/ui-core/UiCore.h | 6 ++++-- examples/companion_radio/ui-lvgl/UITask.cpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/companion_radio/ui-core/UiCore.h b/examples/companion_radio/ui-core/UiCore.h index 44ea9c68..1d079af0 100644 --- a/examples/companion_radio/ui-core/UiCore.h +++ b/examples/companion_radio/ui-core/UiCore.h @@ -133,11 +133,13 @@ public: return i >= 0 && strcmp(_sensors->getSettingValue(i), "1") == 0; } // False when the board has no GPS. - bool setGpsEnabled(bool on) { + // save = false: the caller has the prefs written later (the L2 on leaving + // the screen -- a flash write mid-tap stalls the switch's animation). + bool setGpsEnabled(bool on, bool save = true) { if (gpsSettingIndex() < 0) return false; _sensors->setSettingValue("gps", on ? "1" : "0"); if (_prefs) _prefs->gps_enabled = on ? 1 : 0; - the_mesh.savePrefs(); + if (save) the_mesh.savePrefs(); return true; } diff --git a/examples/companion_radio/ui-lvgl/UITask.cpp b/examples/companion_radio/ui-lvgl/UITask.cpp index 895c69ff..a04e882c 100644 --- a/examples/companion_radio/ui-lvgl/UITask.cpp +++ b/examples/companion_radio/ui-lvgl/UITask.cpp @@ -1965,7 +1965,8 @@ void UITask::refreshStatusBar() { } void UITask::setGps(bool on) { - if (!_core->setGpsEnabled(on)) { showToast("No GPS on this device"); return; } + if (!_core->setGpsEnabled(on, false)) { showToast("No GPS on this device"); return; } + prefsSave(); // written on leaving the screen, as the other switches refreshStatusBar(); }