Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Timeout by
Diff: Main.cpp
- Revision:
- 1:50617d33bd51
- Parent:
- 0:7a0f7fbc736b
--- a/Main.cpp Tue Jan 08 10:23:12 2019 +0000
+++ b/Main.cpp Tue Jan 08 10:29:04 2019 +0000
@@ -10,6 +10,7 @@
#include "mbed.h"
+/* Example 1:
Timeout flipper;
DigitalOut led1(LED1);
@@ -24,4 +25,37 @@
while(1) {
}
- }
\ No newline at end of file
+ }
+
+*/
+
+/*Example 2:
+
+// A class for flip()-ing a DigitalOut
+
+class Flipper {
+ public:
+ Flipper(PinName pin) : _pin(pin) {
+ _pin = 0;
+ }
+void flip() {
+ _pin = !_pin;
+ }
+
+ private:
+ DigitalOut _pin;
+ };
+
+Flipper LED(LED1);
+Timeout t;
+
+int main() {
+ // the address of the object, member function, and interval
+ t.attach(callback(&LED, &Flipper::flip), 2.0);
+ // spin in a main loop. flipper will interrupt it to call flip
+
+while(1) {
+ }
+ }
+
+*/
\ No newline at end of file
