Skip to content

Commit

Permalink
Possibility to setup the interrupt_mode in sleepnode
Browse files Browse the repository at this point in the history
Now it is possible to setup the interrupt mode in sleepnode (default 0=LOW)

if(INTERRUPT_MODE==0) attachInterrupt(interruptPin,wakeUp, LOW)
if(INTERRUPT_MODE==1) attachInterrupt(interruptPin,wakeUp, RISING)
if(INTERRUPT_MODE==2) attachInterrupt(interruptPin,wakeUp, FALLING)
if(INTERRUPT_MODE==3) attachInterrupt(interruptPin,wakeUp, CHANGE)
  • Loading branch information
ricgyver authored Oct 1, 2016
1 parent 01cdecb commit 7169f23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions RF24Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,15 +1294,18 @@ ISR(WDT_vect){
}


bool RF24Network::sleepNode( unsigned int cycles, int interruptPin ){
bool RF24Network::sleepNode( unsigned int cycles, int interruptPin, int INTERRUPT_MODE){


sleep_cycles_remaining = cycles;
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
sleep_enable();
if(interruptPin != 255){
wasInterrupted = false; //Reset Flag
attachInterrupt(interruptPin,wakeUp, LOW);
if(INTERRUPT_MODE==0) attachInterrupt(interruptPin,wakeUp, LOW);
if(INTERRUPT_MODE==1) attachInterrupt(interruptPin,wakeUp, RISING);
if(INTERRUPT_MODE==2) attachInterrupt(interruptPin,wakeUp, FALLING);
if(INTERRUPT_MODE==3) attachInterrupt(interruptPin,wakeUp, CHANGE);
}

#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
Expand Down
2 changes: 1 addition & 1 deletion RF24Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ class RF24Network
* @param interruptPin: The interrupt number to use (0,1) for pins two and three on Uno,Nano. More available on Mega etc.
* @return True if sleepNode completed normally, after the specified number of cycles. False if sleep was interrupted
*/
bool sleepNode( unsigned int cycles, int interruptPin );
bool sleepNode( unsigned int cycles, int interruptPin, int INTERRUPT_MODE=0); //added interrupt mode support (default 0=LOW)


/**
Expand Down

0 comments on commit 7169f23

Please sign in to comment.