sforkowany z mirror/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
|
// 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)
|
// #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)
|
// 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 bool wasPressed = false;
|
||||||
static uint32_t minPressMs; // what tick should we call this press long enough
|
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 (!digitalRead(BUTTON_PIN))
|
||||||
{
|
{
|
||||||
if (!wasPressed)
|
if (!wasPressed)
|
||||||
|
@ -444,6 +444,7 @@ void loop()
|
||||||
wasPressed = true;
|
wasPressed = true;
|
||||||
|
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
|
lastPressMs = now;
|
||||||
minPressMs = now + 3000;
|
minPressMs = now + 3000;
|
||||||
|
|
||||||
if (now - lastPingMs > 60 * 1000)
|
if (now - lastPingMs > 60 * 1000)
|
||||||
|
@ -470,8 +471,8 @@ void loop()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MINWAKE_MSECS
|
#ifdef MINWAKE_MSECS
|
||||||
// Don't deepsleep if we have USB power
|
// Don't deepsleep if we have USB power or if the user as pressed a button recently
|
||||||
if (millis() > MINWAKE_MSECS && !isCharging)
|
if (millis() - lastPressMs > MINWAKE_MSECS && !isCharging)
|
||||||
{
|
{
|
||||||
sleep();
|
sleep();
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue