Demo of how to wakeup from sleep mode on timers.

Dependencies:   WakeUp mBuino_Sleep mbed

Files at this revision

API Documentation at this revision

Comitter:
AndyA
Date:
Sun Sep 28 09:25:24 2014 +0000
Commit message:
First commit

Changed in this revision

WakeUp.lib Show annotated file Show diff for this revision Revisions of this file
mBuino_Sleep.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /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
--- /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
--- /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