Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: RedButton WS_7_Seg_mit_LM1635 WS_7_Seg_mit_LM1635 Lichtschalter_M0 ... more
Revision 1:e59480cf6c72, committed 2015-05-18
- Comitter:
- huliyang
- Date:
- Mon May 18 13:08:33 2015 +0000
- Parent:
- 0:2359961af424
- Child:
- 2:7f2f00805d41
- Commit message:
- Debouncer: example
Changed in this revision
| Debouncer.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- 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)