ENSMM / Mbed 2 deprecated Timeout

Dependencies:   mbed

Fork of Timeout by Joël Imbaud

Files at this revision

API Documentation at this revision

Comitter:
jimbaud
Date:
Tue Jan 08 10:29:04 2019 +0000
Parent:
0:7a0f7fbc736b
Commit message:
Use the Timeout interface to set up an interrupt to call a function after a specified delay.; You can create any number of Timeout objects, allowing multiple outstanding interrupts at the same time.

Changed in this revision

Main.cpp Show annotated file Show diff for this revision Revisions of this file
--- 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