kopia lustrzana https://github.com/meshtastic/firmware
don't sleep if user pressed button recently
rodzic
cbe2b8cafa
commit
56f884cd10
|
@ -62,7 +62,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
// If not defined, we will wait for lock forever
|
||||
|
||||
#define MINWAKE_MSECS (60 * 1000) // stay awake a long time (30 mins) for debugging
|
||||
#define MINWAKE_MSECS (5 * 60 * 1000) // stay awake a long time (30 mins) for debugging
|
||||
// #define MINWAKE_MSECS (30 * 1000) // Wait after every boot for GPS lock (may need longer than 5s because we turned the gps off during deep sleep)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -434,7 +434,7 @@ void loop()
|
|||
// if user presses button for more than 3 secs, discard our network prefs and reboot (FIXME, use a debounce lib instead of this boilerplate)
|
||||
static bool wasPressed = false;
|
||||
static uint32_t minPressMs; // what tick should we call this press long enough
|
||||
static uint32_t lastPingMs;
|
||||
static uint32_t lastPingMs, lastPressMs;
|
||||
if (!digitalRead(BUTTON_PIN))
|
||||
{
|
||||
if (!wasPressed)
|
||||
|
@ -444,6 +444,7 @@ void loop()
|
|||
wasPressed = true;
|
||||
|
||||
uint32_t now = millis();
|
||||
lastPressMs = now;
|
||||
minPressMs = now + 3000;
|
||||
|
||||
if (now - lastPingMs > 60 * 1000)
|
||||
|
@ -470,8 +471,8 @@ void loop()
|
|||
#endif
|
||||
|
||||
#ifdef MINWAKE_MSECS
|
||||
// Don't deepsleep if we have USB power
|
||||
if (millis() > MINWAKE_MSECS && !isCharging)
|
||||
// Don't deepsleep if we have USB power or if the user as pressed a button recently
|
||||
if (millis() - lastPressMs > MINWAKE_MSECS && !isCharging)
|
||||
{
|
||||
sleep();
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue