Debounce a mechanical switch by periodic sampling.

Dependents:   RedButton WS_7_Seg_mit_LM1635 WS_7_Seg_mit_LM1635 Lichtschalter_M0 ... more

Revision:
1:e59480cf6c72
Parent:
0:2359961af424
Child:
2:7f2f00805d41
--- a/Debouncer.cpp	Mon May 18 12:57:27 2015 +0000
+++ b/Debouncer.cpp	Mon May 18 13:08:33 2015 +0000
@@ -26,14 +26,24 @@
 /*! \class Debouncer
  * \brief Debounce a mechanical switch by periodic sampling.
  * \code
-FIXME: EXAMPLE HERE
+#include <mbed.h>
+#include <Pulsator.h>
+
+Debouncer butt(PI_BUTTON);
+void fall(void) { puts("Pushed!"); }
+void rise(void) { puts("Released!"); }
+
+int main(void) {
+    butt.attach_fall(&fall).attach_rise(&rise);
+    while(true) wait(1.0f);
+}
  * \endcode
  * \note This implements \a DebounceSwitch2() as described by
  *  http://www.ganssle.com/debouncing-pt2.htm
  * \note In particular, directly hooking up a mechanical switch as an
  *  interrupt will not suffice: in general, the signal will not always
  *  satisfy any arbitrary processor's interrupt pin's min clock width,
- *  data setup nor hold times & c., and will not trigger reliably.
+ *  data setup nor hold times & c., and so will not trigger reliably.
  */
 
 void Debouncer::tick(void)