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) {
490490 internalSleep (ms);
491491}
492492
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+
493510bool MySensor::sleep (uint8_t interrupt, uint8_t mode, unsigned long ms) {
494511 // Let serial prints finish (debug, log etc)
495512 bool pinTriggeredWakeup = true ;
Original file line number Diff line number Diff line change @@ -210,6 +210,15 @@ class MySensor : public RF24
210210 */
211211 void sleep (unsigned long ms);
212212
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+
213222 /* *
214223 * Sleep (PowerDownMode) the Arduino and radio. Wake up on timer or pin change.
215224 * 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