From 55cb5d25d3ea944855fc1ab2d4125ef9c70512f3 Mon Sep 17 00:00:00 2001 From: MarekZegare4 Date: Fri, 14 Aug 2026 00:40:50 +0200 Subject: [PATCH] fix(gps): hold GPS awake during waypoint nav/avg/track-back and message-location navigate These views run the same live bearing/distance readout as Compass/Nearby's navigate mode, which already held GPS awake -- these three didn't, so duty-cycling could leave them stuck on a stale fix until the next scheduled wake (up to the configured sleep interval). --- examples/companion_radio/ui-new/MessagesScreen.h | 4 ++++ examples/companion_radio/ui-new/TrailScreen.h | 3 +++ examples/companion_radio/ui-new/UITask.cpp | 2 ++ examples/companion_radio/ui-new/WaypointsView.h | 6 ++++++ release-notes.md | 2 +- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/examples/companion_radio/ui-new/MessagesScreen.h b/examples/companion_radio/ui-new/MessagesScreen.h index 16903aa5..90794762 100644 --- a/examples/companion_radio/ui-new/MessagesScreen.h +++ b/examples/companion_radio/ui-new/MessagesScreen.h @@ -627,6 +627,10 @@ public: // The history rings + per-channel unread counters init in MessageHistory. } + // Forwarded to UITask's GPS duty-cycle hold — true while showing the + // bearing/distance view to a location shared in a message. + bool navActive() const { return _nav_active; } + // First free channel slot (existing config or blank name), or -1 if full. int findFreeChannelSlot() const { for (int i = 0; i < MAX_GROUP_CHANNELS; i++) { diff --git a/examples/companion_radio/ui-new/TrailScreen.h b/examples/companion_radio/ui-new/TrailScreen.h index 2a06eff6..44029ebc 100644 --- a/examples/companion_radio/ui-new/TrailScreen.h +++ b/examples/companion_radio/ui-new/TrailScreen.h @@ -114,6 +114,9 @@ public: // KEY_CANCEL returns there, not to Tools. void showMapView() { _view = V_MAP; _return_home = true; } + // Forwarded to UITask's GPS duty-cycle hold — see WaypointsView::needsLiveGps(). + bool wpNeedsLiveGps() const { return _wp.needsLiveGps(); } + int render(DisplayDriver& display) override { display.setTextSize(1); display.setColor(DisplayDriver::LIGHT); diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index ca05d734..e4fb877b 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -2590,6 +2590,8 @@ void UITask::loop() { || (_node_prefs && _node_prefs->locator_enabled && _node_prefs->locator_has_target) || curr == compass_screen || (curr == nearby_screen && ((NearbyScreen*)nearby_screen)->isNavigating()) + || (curr == trail_screen && ((TrailScreen*)trail_screen)->wpNeedsLiveGps()) + || (curr == messages_screen && ((MessagesScreen*)messages_screen)->navActive()) || the_mesh.isGpsFixPending(); _sensors->setGpsKeepAwake(gps_needed_live); // A fresh wake (either a duty-cycle wake, or GPS forced continuously back diff --git a/examples/companion_radio/ui-new/WaypointsView.h b/examples/companion_radio/ui-new/WaypointsView.h index 9c10f976..4408a006 100644 --- a/examples/companion_radio/ui-new/WaypointsView.h +++ b/examples/companion_radio/ui-new/WaypointsView.h @@ -274,6 +274,12 @@ public: // True while the component owns the screen (a sub-mode or the keyboard is up). bool active() const { return _mode != OFF || _kb_active; } + // True in the sub-modes that read a live, continuous GPS position (bearing + // to target, running average, walking a track back) -- as opposed to LIST + // (just browsing) or ADD (typed coordinates, no fix involved). Used by + // UITask's GPS duty-cycle hold so these don't stall waiting on a nap. + bool needsLiveGps() const { return _mode == NAV || _mode == AVG || _mode == TRACKBACK; } + // Entry points called from TrailScreen's action menu. void openList() { _mode = LIST; _sel = 0; _scroll = 0; } void markHere() { diff --git a/release-notes.md b/release-notes.md index 91b5b823..f453559b 100644 --- a/release-notes.md +++ b/release-notes.md @@ -5,7 +5,7 @@ - **Experimental: M5Stack Cardputer ADV and LilyGO T-Echo Lite + KeyShield board support** — built-in keyboard, no CardKB or joystick needed. Full companion/solo/repeater/room-server env range. - **Experimental: solo builds for Heltec V3 and V4** — full on-device UI, driven by CardKB or a wired joystick. - **Screenshot support added to the Heltec V3/V4 solo builds.** -- **GPS duty-cycling** (Settings › System › "GPS pwr") — sleeps GPS between fixes to save power. Stays on automatically when Trail, Live share, Locator, Compass/Nearby, or `!gps fix` need it. +- **GPS duty-cycling** (Settings › System › "GPS pwr") — sleeps GPS between fixes to save power. Stays on automatically when Trail (including waypoint navigate/average/track-back), Live share, Locator, Compass/Nearby, navigating a shared location, or `!gps fix` need it. - **RX power-save (Settings › Radio › Pwr save) now recovers on its own** if the hardware duty-cycle sequencer gets stuck. - **Updated upstream base to companion-v1.17.0** — hardware Channel Activity Detection, MCU temperature telemetry, LR2021 standby fix, and misc upstream fixes.