The Debouce class. Just the deboucing code separated from all harware.
More...
#include <Bounce2.h>
|
| Debouncer () |
| Create an instance of the Debounce class. More...
|
|
void | interval (uint16_t interval_millis) |
| Sets the debounce interval in milliseconds. More...
|
|
bool | update () |
| Updates the pin's state. More...
|
|
bool | read () |
| Returns the pin's state (HIGH or LOW). More...
|
|
bool | fell () |
| Returns true if pin signal transitions from high to low.
|
|
bool | rose () |
| Returns true if pin signal transitions from low to high.
|
|
bool | changed () |
| Returns true if the state changed on last update. More...
|
|
unsigned long | duration () |
| Returns the duration in milliseconds of the current state. More...
|
|
unsigned long | previousDuration () |
| Returns the duration in milliseconds of the previous state. More...
|
|
|
void | begin () |
|
virtual bool | readCurrentState ()=0 |
|
|
unsigned long | previous_millis |
|
uint16_t | interval_millis |
|
uint8_t | state |
|
unsigned long | stateChangeLastTime |
|
unsigned long | durationOfPreviousState |
|
The Debouce class. Just the deboucing code separated from all harware.
◆ Debouncer()
Create an instance of the Debounce class.
◆ changed()
bool Debouncer::changed |
( |
| ) |
|
|
inline |
Returns true if the state changed on last update.
- Returns
- True if the state changed on last update. Otherwise, returns false.
◆ duration()
unsigned long Debouncer::duration |
( |
| ) |
|
Returns the duration in milliseconds of the current state.
Is reset to 0 once the pin rises ( rose() ) or falls ( fell() ).
- Returns
- The duration in milliseconds (unsigned long) of the current state.
◆ interval()
void Debouncer::interval |
( |
uint16_t |
interval_millis | ) |
|
Sets the debounce interval in milliseconds.
- Parameters
-
interval_millis | The interval time in milliseconds. |
◆ previousDuration()
unsigned long Debouncer::previousDuration |
( |
| ) |
|
Returns the duration in milliseconds of the previous state.
Takes the values of duration() once the pin changes state.
- Returns
- The duration in milliseconds (unsigned long) of the previous state.
◆ read()
Returns the pin's state (HIGH or LOW).
- Returns
- HIGH or LOW.
◆ update()
bool Debouncer::update |
( |
| ) |
|
Updates the pin's state.
Because Bounce does not use interrupts, you have to "update" the object before reading its value and it has to be done as often as possible (that means to include it in your loop()). Only call update() once per loop().
- Returns
- True if the pin changed state.
The documentation for this class was generated from the following files: