mbed events example

Committer:
sarahmarshy
Date:
Thu Sep 07 16:03:58 2017 +0000
Revision:
0:488fe91e2e80
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sarahmarshy 0:488fe91e2e80 1 #include "mbed_events.h"
sarahmarshy 0:488fe91e2e80 2 #include <stdio.h>
sarahmarshy 0:488fe91e2e80 3
sarahmarshy 0:488fe91e2e80 4 int main() {
sarahmarshy 0:488fe91e2e80 5 // creates a queue with the default size
sarahmarshy 0:488fe91e2e80 6 EventQueue queue;
sarahmarshy 0:488fe91e2e80 7
sarahmarshy 0:488fe91e2e80 8 // events are simple callbacks
sarahmarshy 0:488fe91e2e80 9 queue.call(printf, "called immediately\n");
sarahmarshy 0:488fe91e2e80 10 queue.call_in(2000, printf, "called in 2 seconds\n");
sarahmarshy 0:488fe91e2e80 11 queue.call_every(1000, printf, "called every 1 seconds\n");
sarahmarshy 0:488fe91e2e80 12
sarahmarshy 0:488fe91e2e80 13 // events are executed by the dispatch method
sarahmarshy 0:488fe91e2e80 14 queue.dispatch();
sarahmarshy 0:488fe91e2e80 15 }