ENSMM / Mbed 2 deprecated Timeout

Dependencies:   mbed

Fork of Timeout by Joël Imbaud

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