File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -486,6 +486,23 @@ void MySensor::sleep(unsigned long ms) {
486
486
internalSleep (ms);
487
487
}
488
488
489
+ void MySensor::wait (unsigned long ms) {
490
+ bool slept_enough = false ;
491
+ unsigned long start = millis ();
492
+ unsigned long now;
493
+
494
+ // Let serial prints finish (debug, log etc)
495
+ Serial.flush ();
496
+
497
+ while (!slept_enough) {
498
+ MySensor::process ();
499
+ now = millis ();
500
+ if (now - start > ms) {
501
+ slept_enough = true ;
502
+ }
503
+ }
504
+ }
505
+
489
506
bool MySensor::sleep (uint8_t interrupt, uint8_t mode, unsigned long ms) {
490
507
// Let serial prints finish (debug, log etc)
491
508
bool pinTriggeredWakeup = true ;
Original file line number Diff line number Diff line change @@ -210,6 +210,15 @@ class MySensor : public RF24
210
210
*/
211
211
void sleep (unsigned long ms);
212
212
213
+ /* *
214
+ * Wait for a specified amount of time to pass. Keeps process()ing.
215
+ * This does not power-down the radio nor the Arduino.
216
+ * Because this calls process() in a loop, it is a good way to wait
217
+ * in your loop() on a repeater node or sensor that listens to messages.
218
+ * @param ms Number of milliseconds to sleep.
219
+ */
220
+ void wait (unsigned long ms);
221
+
213
222
/* *
214
223
* Sleep (PowerDownMode) the Arduino and radio. Wake up on timer or pin change.
215
224
* See: http://arduino.cc/en/Reference/attachInterrupt for details on modes and which pin
You can’t perform that action at this time.
0 commit comments