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 @@ -490,6 +490,23 @@ void MySensor::sleep(unsigned long ms) {
490
490
internalSleep (ms);
491
491
}
492
492
493
+ void MySensor::wait (unsigned long ms) {
494
+ bool slept_enough = false ;
495
+ unsigned long start = millis ();
496
+ unsigned long now;
497
+
498
+ // Let serial prints finish (debug, log etc)
499
+ Serial.flush ();
500
+
501
+ while (!slept_enough) {
502
+ MySensor::process ();
503
+ now = millis ();
504
+ if (now - start > ms) {
505
+ slept_enough = true ;
506
+ }
507
+ }
508
+ }
509
+
493
510
bool MySensor::sleep (uint8_t interrupt, uint8_t mode, unsigned long ms) {
494
511
// Let serial prints finish (debug, log etc)
495
512
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