Update MotionMote.ino
This commit is contained in:
parent
750796debd
commit
afc6e71968
|
|
@ -225,7 +225,7 @@ void checkBattery()
|
||||||
void sleep(uint32_t sleepTime) {
|
void sleep(uint32_t sleepTime) {
|
||||||
DEBUGFlush();
|
DEBUGFlush();
|
||||||
if (sleepTime < 262) { //sleeps just the MCU, using WDT (radio is not touched)
|
if (sleepTime < 262) { //sleeps just the MCU, using WDT (radio is not touched)
|
||||||
LowPower.longPowerDown(sleepTime);
|
longPowerDown(sleepTime);
|
||||||
} else { //sleeps MCU using the radio timer - should not be used if radio needs to be in RX mode!
|
} else { //sleeps MCU using the radio timer - should not be used if radio needs to be in RX mode!
|
||||||
uint32_t freq = radio.getFrequency();
|
uint32_t freq = radio.getFrequency();
|
||||||
if (sleepTime%262 && sleepTime > 262*2) {
|
if (sleepTime%262 && sleepTime > 262*2) {
|
||||||
|
|
@ -254,3 +254,62 @@ void listenModeSleep(uint16_t millisInterval) {
|
||||||
LowPower.powerDown( SLEEP_FOREVER, ADC_OFF, BOD_OFF );
|
LowPower.powerDown( SLEEP_FOREVER, ADC_OFF, BOD_OFF );
|
||||||
radio.endListenModeSleep();
|
radio.endListenModeSleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void longPowerDown(uint32_t sleepTime) {
|
||||||
|
do {
|
||||||
|
if (sleepTime > 8000)
|
||||||
|
{
|
||||||
|
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
|
||||||
|
sleepTime-=8000;
|
||||||
|
}
|
||||||
|
else if (sleepTime > 4000)
|
||||||
|
{
|
||||||
|
LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);
|
||||||
|
sleepTime-=4000;
|
||||||
|
}
|
||||||
|
else if (sleepTime > 2000)
|
||||||
|
{
|
||||||
|
LowPower.powerDown(SLEEP_2S, ADC_OFF, BOD_OFF);
|
||||||
|
sleepTime-=2000;
|
||||||
|
}
|
||||||
|
else if (sleepTime > 1000)
|
||||||
|
{
|
||||||
|
LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
|
||||||
|
sleepTime-=1000;
|
||||||
|
}
|
||||||
|
else if (sleepTime > 512)
|
||||||
|
{
|
||||||
|
LowPower.powerDown(SLEEP_500MS, ADC_OFF, BOD_OFF);
|
||||||
|
sleepTime-=512;
|
||||||
|
}
|
||||||
|
else if (sleepTime > 256)
|
||||||
|
{
|
||||||
|
LowPower.powerDown(SLEEP_250MS, ADC_OFF, BOD_OFF);
|
||||||
|
sleepTime-=256;
|
||||||
|
}
|
||||||
|
else if (sleepTime > 128)
|
||||||
|
{
|
||||||
|
LowPower.powerDown(SLEEP_120MS, ADC_OFF, BOD_OFF);
|
||||||
|
sleepTime-=128;
|
||||||
|
}
|
||||||
|
else if (sleepTime > 64)
|
||||||
|
{
|
||||||
|
LowPower.powerDown(SLEEP_60MS, ADC_OFF, BOD_OFF);
|
||||||
|
sleepTime-=64;
|
||||||
|
}
|
||||||
|
else if (sleepTime > 32)
|
||||||
|
{
|
||||||
|
LowPower.powerDown(SLEEP_30MS, ADC_OFF, BOD_OFF);
|
||||||
|
sleepTime-=32;
|
||||||
|
}
|
||||||
|
else if (sleepTime > 16)
|
||||||
|
{
|
||||||
|
LowPower.powerDown(SLEEP_15MS, ADC_OFF, BOD_OFF);
|
||||||
|
sleepTime-=16;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sleepTime=0;
|
||||||
|
}
|
||||||
|
} while(sleepTime);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue