Rob Keij / TOGGLE

Files at this revision

API Documentation at this revision

Comitter:
qynx
Date:
Sat Jun 11 12:19:44 2016 +0000
Child:
1:27360e9dc2c5
Commit message:
Toggle library easy for debugging based on :; https://developer.mbed.org/cookbook/Writing-a-Library

Changed in this revision

toggle.cpp Show annotated file Show diff for this revision Revisions of this file
toggle.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toggle.cpp	Sat Jun 11 12:19:44 2016 +0000
@@ -0,0 +1,16 @@
+#include "toggle.h"
+#include "mbed.h"
+
+
+Togglen::Togglen(PinName pin) : _p(pin)
+{
+    _p = 0;
+}
+
+void Togglen::Toggle(int n)
+{
+    for(int i=0; i<n*2; i++) {
+        _p = !_p;
+        wait(0.2);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toggle.h	Sat Jun 11 12:19:44 2016 +0000
@@ -0,0 +1,59 @@
+#ifndef TOGGLE_H
+#define TOGGLE_H
+ 
+#include "mbed.h"
+
+
+ 
+/** Toggle pin for debugging purposes
+ *
+ * @code
+ * #include "mbed.h"
+ * #include "toggle.h"
+ *
+ * Toggle pin(P1_24); 
+ * Toggle led(P1.25);
+ *  
+ * int main() {
+ *     
+ *   pin.toggle(3);   // toggle pin P1_24 3 times
+ *   led.toggle(5);   // toggle led P1_25 5 times
+ *
+ * }
+ * @endcode
+ */ 
+ 
+ 
+class Togglen {
+public:
+
+    /**
+      * toggle constructor
+      *
+      * @param pin  "pin" to toggle
+      */
+    Togglen(PinName pin);
+
+
+    /**
+      * toggle destructor
+      */
+
+    ~Togglen();
+
+    /**
+    * Command to n times toggle the pin
+    */
+    
+    void Toggle(int n);
+  
+private:  
+
+    /**
+     * Set the Digital out pin
+     */
+     
+    DigitalOut _p;
+};
+ 
+#endif
\ No newline at end of file