fix(locator): hide homing beeper in leave-only mode

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 <noreply@anthropic.com>
This commit is contained in:
MarekZegare4
2026-06-24 23:50:16 +02:00
parent 94a97967ae
commit 49f790bf76
2 changed files with 14 additions and 3 deletions

View File

@@ -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;

View File

@@ -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;