From 49f790bf76fd32ec2f4dc41959c5a29b38a0d9f9 Mon Sep 17 00:00:00 2001 From: MarekZegare4 Date: Wed, 24 Jun 2026 23:50:16 +0200 Subject: [PATCH] fix(locator): hide homing beeper in leave-only mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The proximity beeper only fires inside the radius and ticks faster toward the centre — a homing aid that only makes sense when "arrive" is part of the alert mode. In pure "leave" mode it's contradictory (silent outside, slows as you near the exit), so hide the Beeper row there and gate the beeper engine on the mode, so a stale beeper=ON pref carried over from arrive mode can't keep chirping after switching to leave. Co-Authored-By: Claude Opus 4.8 --- examples/companion_radio/ui-new/LocatorScreen.h | 15 +++++++++++++-- examples/companion_radio/ui-new/UITask.cpp | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/examples/companion_radio/ui-new/LocatorScreen.h b/examples/companion_radio/ui-new/LocatorScreen.h index 349b900b..b6dd5112 100644 --- a/examples/companion_radio/ui-new/LocatorScreen.h +++ b/examples/companion_radio/ui-new/LocatorScreen.h @@ -60,6 +60,15 @@ class LocatorScreen : public UIScreen { return R[i]; } + // The homing Beeper only makes sense when "arrive" is part of the alert mode — + // it guides you toward the target while inside the radius. In pure "leave" + // mode (1) it's contradictory (silent outside, slows as you near the exit), so + // hide its row. Beeper is the last row, so this is just a shorter visible count; + // the beeper engine (UITask::locatorProximityBeeper) is gated on the mode too. + int visibleRows() const { + return (_prefs && _prefs->locator_mode == 1) ? ROW_COUNT - 1 : ROW_COUNT; + } + public: LocatorScreen(UITask* task, NodePrefs* prefs) : _task(task), _prefs(prefs) {} @@ -102,8 +111,10 @@ public: if (_picking) { renderPicker(display); return 400; } display.drawCenteredHeader("LOCATOR"); + const int rc = visibleRows(); + if (_sel >= rc) _sel = rc - 1; // beeper row may have just been hidden const int valx = display.width() / 2 + 6; - drawList(display, ROW_COUNT, _sel, _scroll, [&](int i, int y, bool sel, int reserve) { + drawList(display, rc, _sel, _scroll, [&](int i, int y, bool sel, int reserve) { Row r = rows(i); display.drawSelectionRow(0, y - 1, display.width() - reserve, display.lineStep() - 1, sel); display.setCursor(4, y); @@ -115,7 +126,7 @@ public: return 500; } - void moveSel(int dir) { _sel = (_sel + dir + ROW_COUNT) % ROW_COUNT; } + void moveSel(int dir) { int rc = visibleRows(); _sel = (_sel + dir + rc) % rc; } void activate(int dir) { if (!_prefs) return; diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index ee0efece..ce1cf6fd 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -2391,7 +2391,7 @@ void UITask::locatorProximityBeeper() { static const uint32_t BEEP_MIN_MS = 150; // fastest cadence (at the target) static const uint32_t BEEP_MAX_MS = 2000; // slowest cadence (at the edge) if (!_node_prefs || !_node_prefs->locator_enabled || !_node_prefs->locator_beeper - || !_node_prefs->locator_has_target) { + || !_node_prefs->locator_has_target || _node_prefs->locator_mode == 1) { // leave-only mode: no homing return; } if ((int32_t)(millis() - _locator_beep_check_ms) < 0) return;