Library for debouncing inputs, originally by Andres Mora Bedoya. Updated to include PinMode capability and class documentation.
Fork of DebouncedIn by
Diff: DebouncedIn.cpp
- Revision:
- 1:7b8a80c09b8c
- Parent:
- 0:dc1131de43e8
- Child:
- 2:261228f701a1
--- a/DebouncedIn.cpp Tue Nov 05 19:29:03 2013 +0000 +++ b/DebouncedIn.cpp Wed Oct 08 14:44:47 2014 +0000 @@ -1,7 +1,7 @@ #include "DebouncedIn.h" #include "mbed.h" -/* +/** * Constructor */ DebouncedIn::DebouncedIn(PinName in) @@ -18,6 +18,21 @@ // Attach ticker _ticker.attach(this, &DebouncedIn::_sample, 0.005); } + +DebouncedIn::DebouncedIn(PinName in, PinMode mode) + : _in(in, mode) { + + // reset all the flags and counters + _samples = 0; + _output = 0; + _output_last = 0; + _rising_flag = 0; + _falling_flag = 0; + _state_counter = 0; + + // Attach ticker + _ticker.attach(this, &DebouncedIn::_sample, 0.005); +} void DebouncedIn::_sample() {