Created
June 10, 2016 12:32
-
-
Save matthijskooijman/010515bf06e552c41472be0656bac62b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This sleeps in powerdown mode for about the specified number of ms. | |
// If an interrupt occurs during sleep, it will be handled and sleep | |
// will continue (but up to 8 seconds of sleep might be "lost"). | |
// START-DOSLEEP | |
void doSleep(uint32_t time) { | |
#if defined(DhtSend_ino) | |
DebugSerial.flush(); | |
#endif | |
while (time > 0) { | |
// END-DOSLEEP | |
// This sleeps for at most time ms, or the minimum sleep time if | |
// that's more than time ms. Only some sleep times are available, so | |
// multiple sleeps might be needed. | |
// START-DOSLEEP | |
int slept; | |
if (time < 8000) | |
slept = Watchdog.sleep(time); | |
else | |
slept = Watchdog.sleep(8000); | |
if (slept >= time) | |
return; | |
time -= slept; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment