arduino-libraries / ArduinoLowPower

Powersave features for SAMD boards
GNU Lesser General Public License v2.1
80 stars 57 forks source link

Allow sleep durations of 1 day or longer #24

Closed per1234 closed 4 years ago

per1234 commented 4 years ago

Previously, sleep durations "overflowed" at one day, resulting in a maximum sleep duration of 1 millisecond less than a day.

Demonstration sketch:

#include <ArduinoLowPower.h>

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  LowPower.sleep(24 * 60 * 60 * 1000);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(100);
  digitalWrite(LED_BUILTIN, LOW);
  delay(100);
}

The expected behavior of the above code is the LED should start blinking after the sleep of 24 hours ends. With the current library code, the sleep ends, and LED starts blinking, immediately.

Fixes https://github.com/arduino-libraries/ArduinoLowPower/issues/22

facchinm commented 4 years ago

Merging, thank you so much!