Skip to content

Commit

Permalink
Fix: The argument to LowPower.idle(millis) has absolutely no effect. a…
Browse files Browse the repository at this point in the history
  • Loading branch information
be-philippe committed Feb 22, 2021
1 parent d701922 commit 0531915
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/samd/ArduinoLowPower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,20 @@ void ArduinoLowPowerClass::idle() {
__WFI();
}

void ArduinoLowPowerClass::idle(uint32_t millis) {
setAlarmIn(millis);
idle();
void ArduinoLowPowerClass::idle(uint32_t delay)
{
uint32_t ticks = delay;
while (ticks > 0)
{
uint32_t lastMillis = millis();
idle();
uint32_t delta = millis() - lastMillis;
if (delta > ticks) {
ticks = 0;
} else {
ticks -= delta;
}
}
}

void ArduinoLowPowerClass::sleep() {
Expand Down

0 comments on commit 0531915

Please sign in to comment.