mbed events example

Files at this revision

API Documentation at this revision

Comitter:
sarahmarshy
Date:
Thu Sep 07 16:03:58 2017 +0000
Commit message:
Initial commit

Changed in this revision

.gitignore 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-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 488fe91e2e80 .gitignore
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Thu Sep 07 16:03:58 2017 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
diff -r 000000000000 -r 488fe91e2e80 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Sep 07 16:03:58 2017 +0000
@@ -0,0 +1,15 @@
+#include "mbed_events.h"
+#include <stdio.h>
+
+int main() {
+    // creates a queue with the default size
+    EventQueue queue;
+
+    // events are simple callbacks
+    queue.call(printf, "called immediately\n");
+    queue.call_in(2000, printf, "called in 2 seconds\n");
+    queue.call_every(1000, printf, "called every 1 seconds\n");
+
+    // events are executed by the dispatch method
+    queue.dispatch();
+}
\ No newline at end of file
diff -r 000000000000 -r 488fe91e2e80 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Thu Sep 07 16:03:58 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#98ba8acb83cfc65f30a8a0771a27c71443ab093a