From 1799f6cb0fc437ab7b36ae96e5cf770737a393bb Mon Sep 17 00:00:00 2001 From: Todd Herbert Date: Wed, 12 Jun 2024 15:36:42 +1200 Subject: [PATCH] Clear old lock-time prediction on triple press --- src/gps/GPS.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index c9558dc71..6cd00575e 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -783,7 +783,9 @@ void GPS::setGPSPower(bool on, bool standbyOnly, uint32_t sleepTime) // Record the current powerState if (on) powerState = GPS_ACTIVE; - else if (sleepTime <= GPS_IDLE_THRESHOLD_SECONDS * 1000UL && sleepTime > 0) // Note: sleepTime==0 if from GPS::disable() + else if (!enabled) // User has disabled with triple press + powerState = GPS_OFF; + else if (sleepTime <= GPS_IDLE_THRESHOLD_SECONDS * 1000UL) powerState = GPS_IDLE; else if (standbyOnly) powerState = GPS_STANDBY; @@ -1664,6 +1666,10 @@ bool GPS::whileIdle() } void GPS::enable() { + // Clear the old lock-time prediction + GPSCycles = 0; + averageLockTime = 0; + enabled = true; setInterval(GPS_THREAD_INTERVAL); setAwake(true);