button procedure library

Dependents:   MIDI_CW Gemphet8

Files at this revision

API Documentation at this revision

Comitter:
ChuckTimber
Date:
Sun Jul 13 05:12:21 2014 +0000
Child:
1:20c8438edaee
Commit message:
button lib version

Changed in this revision

button.cpp Show annotated file Show diff for this revision Revisions of this file
button.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/button.cpp	Sun Jul 13 05:12:21 2014 +0000
@@ -0,0 +1,37 @@
+#include "button.h"
+#include "mbed.h"
+
+/** class to make sound with a buzzer, based on a PwmOut
+ *   The class use a timeout to switch off the sound  - it is not blocking while making noise
+ *
+ * Example:
+ * @code
+ * @endcode
+ */
+
+using namespace mbed;
+ // constructor
+ /** Create a Beep object connected to the specified PwmOut pin
+  *
+  * @param pin PwmOut pin to connect to 
+  */
+
+void BTN::sample_btn()
+{
+    unsigned char a, b;
+
+    a = _Pin;
+    
+    if (a == FIL) {
+        b = STAT;
+        STAT = a;
+        b = (b ^ a) & a;
+        if (b) CMD = b;
+    }
+    FIL = a;
+}
+
+BTN::BTN(PinName pin) : _Pin(pin) {
+    CMD = STAT = FIL = 0;
+    _Tick.attach(this, &BTN::sample_btn, 0.01);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/button.h	Sun Jul 13 05:12:21 2014 +0000
@@ -0,0 +1,36 @@
+#ifndef MBED_BUTTON_H
+#define MBED_BUTTON_H
+
+#include "mbed.h"
+
+/** class to make 
+ *   The class use 
+ *
+ * Example:
+ * @code
+ * @endcode
+ */
+
+
+namespace mbed {
+
+/* Class: BTN
+ *  A class witch uses 
+ */
+class BTN {
+
+public:
+    BTN(PinName pin);
+    unsigned char CMD;
+    unsigned char STAT;
+
+private:
+    void sample_btn(void);
+    unsigned char FIL;
+    DigitalIn _Pin;
+    Ticker _Tick;
+
+};
+
+}
+#endif