Add wait() helper that doesn't sleep. Useful for repeaters and sensors that read from the network.

This commit is contained in:
Roy Hooper
2015-02-01 15:00:45 -05:00
parent dfd38ff3bc
commit d45a48d8b7
2 changed files with 26 additions and 0 deletions
+17
View File
@@ -486,6 +486,23 @@ void MySensor::sleep(unsigned long ms) {
internalSleep(ms);
}
void MySensor::wait(unsigned long ms) {
bool slept_enough = false;
unsigned long start = millis();
unsigned long now;
// Let serial prints finish (debug, log etc)
Serial.flush();
while (!slept_enough) {
MySensor::process();
now = millis();
if (now - start > ms) {
slept_enough = true;
}
}
}
bool MySensor::sleep(uint8_t interrupt, uint8_t mode, unsigned long ms) {
// Let serial prints finish (debug, log etc)
bool pinTriggeredWakeup = true;