Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (38 sloc) 962 Bytes
#include "Arduino.h"
#define timetosleep 5000
#define timetowake 5000
static TimerEvent_t sleep;
static TimerEvent_t wakeUp;
uint8_t lowpower=1;
void onSleep()
{
Serial.printf("into lowpower mode, %d ms later wake up.\r\n",timetowake);
lowpower=1;
//timetosleep ms later wake up;
TimerSetValue( &wakeUp, timetowake );
TimerStart( &wakeUp );
}
void onWakeUp()
{
Serial.printf("wake up, %d ms later into lowpower mode.\r\n",timetosleep);
lowpower=0;
//timetosleep ms later into lowpower mode;
TimerSetValue( &sleep, timetosleep );
TimerStart( &sleep );
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
boardInitMcu();
Radio.Sleep( );
TimerInit( &sleep, OnSleep );
TimerInit( &wakeUp, onWakeUp );
OnSleep();
}
void loop() {
if(lowpower){
//note that lowPowerHandler() run six times the mcu into lowpower mode;
lowPowerHandler();
}
// put your main code here, to run repeatedly:
}
You can’t perform that action at this time.