Debounce an input pin.
Debounce.h@0:d73a3ab5ce11, 2015-03-28 (annotated)
- Committer:
- michaelruck
- Date:
- Sat Mar 28 18:36:46 2015 +0000
- Revision:
- 0:d73a3ab5ce11
Debounce an input pin.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
michaelruck | 0:d73a3ab5ce11 | 1 | /* michael@ruck.com märz 2015 v0.1*/ |
michaelruck | 0:d73a3ab5ce11 | 2 | #ifndef MBED_DEBOUNCE_H |
michaelruck | 0:d73a3ab5ce11 | 3 | #define MBED_DEBOUNCE_H |
michaelruck | 0:d73a3ab5ce11 | 4 | |
michaelruck | 0:d73a3ab5ce11 | 5 | #include "mbed.h" |
michaelruck | 0:d73a3ab5ce11 | 6 | |
michaelruck | 0:d73a3ab5ce11 | 7 | class Debounce { |
michaelruck | 0:d73a3ab5ce11 | 8 | public: |
michaelruck | 0:d73a3ab5ce11 | 9 | Debounce(PinName pin, uint16_t delay, PinMode pull=PullNone); |
michaelruck | 0:d73a3ab5ce11 | 10 | uint8_t read(); |
michaelruck | 0:d73a3ab5ce11 | 11 | |
michaelruck | 0:d73a3ab5ce11 | 12 | private: |
michaelruck | 0:d73a3ab5ce11 | 13 | uint16_t _delay; |
michaelruck | 0:d73a3ab5ce11 | 14 | DigitalIn _pin; |
michaelruck | 0:d73a3ab5ce11 | 15 | Timer _timer; |
michaelruck | 0:d73a3ab5ce11 | 16 | }; |
michaelruck | 0:d73a3ab5ce11 | 17 | #endif |