Demo of how to wakeup from sleep mode on timers.
Dependencies: WakeUp mBuino_Sleep mbed
Revision 0:a9faf46beadf, committed 2014-09-28
- Comitter:
- AndyA
- Date:
- Sun Sep 28 09:25:24 2014 +0000
- Commit message:
- First commit
Changed in this revision
diff -r 000000000000 -r a9faf46beadf WakeUp.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WakeUp.lib Sun Sep 28 09:25:24 2014 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/Sissors/code/WakeUp/#f3adba7cf7c4
diff -r 000000000000 -r a9faf46beadf mBuino_Sleep.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mBuino_Sleep.lib Sun Sep 28 09:25:24 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/AndyA/code/mBuino_Sleep/#bcb4ed255791
diff -r 000000000000 -r a9faf46beadf main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Sep 28 09:25:24 2014 +0000 @@ -0,0 +1,63 @@ +// example code on how to wake from sleep mode after a fixed period of time. + +// Normal sleep we can use a timer but there isn't a huge power saving. + +// DeepSleep or PowerDown we need to use the watchdog (via the WakeUp library) + +// pick which version to compile, 1 for sleep, 0 for power down +#define normalSleep 0 + +#if normalSleep + +// code for normal sleep mode: +#include "mbed.h" +#include "mBuinoSleep.h" + +Ticker OneSecClock; + +void onClock() +{ + NULL; // empty function, just need a place holder here +} + +int main () +{ + LEDs = 1; + + OneSecClock.attach(onClock,1); + + while (1) { + wait(0.1); + mBuinoSleep(Sleep); + if (LEDs == 127) + LEDs = 1; + else + LEDs = LEDs + 1; + } +} + + +#else + +// code for power down mode +#include "mbed.h" +#include "mBuinoSleep.h" +#include "WakeUp.h" + +int main () +{ + WakeUp::calibrate(); + LEDs = 1; + + while (1) { + wait(0.1); + WakeUp::set_ms(900); + mBuinoSleep(PowerDownWD); + if (LEDs == 127) + LEDs = 1; + else + LEDs = LEDs + 1; + } +} + +#endif \ No newline at end of file
diff -r 000000000000 -r a9faf46beadf mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Sep 28 09:25:24 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file