@@ -470,6 +470,10 @@ void wakeUp() //place to send the interrupts
470470{
471471 pinIntTrigger = 1 ;
472472}
473+ void wakeUp2 () // place to send the second interrupts
474+ {
475+ pinIntTrigger = 2 ;
476+ }
473477
474478void MySensor::internalSleep (unsigned long ms) {
475479 while (!pinIntTrigger && ms >= 8000 ) { LowPower.powerDown (SLEEP_8S, ADC_OFF, BOD_OFF); ms -= 8000 ; }
@@ -512,7 +516,32 @@ bool MySensor::sleep(uint8_t interrupt, uint8_t mode, unsigned long ms) {
512516 return pinTriggeredWakeup;
513517}
514518
519+ int8_t MySensor::sleep (uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms) {
520+ int8_t retVal = 1 ;
521+ Serial.flush (); // Let serial prints finish (debug, log etc)
522+ RF24::powerDown ();
523+ attachInterrupt (interrupt1, wakeUp, mode1);
524+ attachInterrupt (interrupt2, wakeUp2, mode2);
525+ if (ms>0 ) {
526+ pinIntTrigger = 0 ;
527+ sleep (ms);
528+ if (0 == pinIntTrigger) {
529+ retVal = -1 ;
530+ }
531+ } else {
532+ Serial.flush ();
533+ LowPower.powerDown (SLEEP_FOREVER, ADC_OFF, BOD_OFF);
534+ }
535+ detachInterrupt (interrupt1);
536+ detachInterrupt (interrupt2);
515537
538+ if (1 == pinIntTrigger) {
539+ retVal = (int8_t )interrupt1;
540+ } else if (2 == pinIntTrigger) {
541+ retVal = (int8_t )interrupt2;
542+ }
543+ return retVal;
544+ }
516545
517546#ifdef DEBUG
518547void MySensor::debugPrint (const char *fmt, ... ) {
0 commit comments