This debouncer will count the ON values and if the number of ON values in a given window exceeds a threshold, then triggers.
More...
#include <Debouncer.hxx>
This debouncer will count the ON values and if the number of ON values in a given window exceeds a threshold, then triggers.
- Todo:
- : there should really be a hysteresis.
Definition at line 142 of file Debouncer.hxx.
◆ CountingDebouncer()
| CountingDebouncer::CountingDebouncer |
( |
const Options & |
opts | ) |
|
|
inline |
Constructor.
- Parameters
-
| opts | specified the debouncing options. |
Definition at line 157 of file Debouncer.hxx.
◆ current_state()
| bool CountingDebouncer::current_state |
( |
| ) |
|
|
inline |
- Returns
- the current debounced state.
Definition at line 204 of file Debouncer.hxx.
◆ initialize()
| void CountingDebouncer::initialize |
( |
bool |
state | ) |
|
|
inline |
Initilalize the debouncer.
- Parameters
-
| state | is the current input state at initialization time, which will be taken over as is (without debouncing because we don't have any information based on which to debounce). |
Definition at line 183 of file Debouncer.hxx.
◆ options()
| const Options & CountingDebouncer::options |
( |
| ) |
|
|
inline |
Retrieves the currently set options.
Definition at line 175 of file Debouncer.hxx.
◆ override()
| void CountingDebouncer::override |
( |
bool |
new_state | ) |
|
|
inline |
Overrides the debounced state to a given value, irrespective of what is on the input pin.
- Parameters
-
| new_state | is the desired state. |
Definition at line 198 of file Debouncer.hxx.
◆ reset_options()
| void CountingDebouncer::reset_options |
( |
const Options & |
opts | ) |
|
|
inline |
Re-creates the debouncer with new options.
- Parameters
-
Definition at line 167 of file Debouncer.hxx.
◆ trim_options()
| void CountingDebouncer::trim_options |
( |
| ) |
|
|
inlineprivate |
◆ update_state()
| bool CountingDebouncer::update_state |
( |
bool |
state | ) |
|
|
inline |
Callback from the polling loop checking the input state.
- Parameters
-
| state | is the currently observed input state. |
- Returns
- true if the debounced state has just transitioned to matching the inbound parameter, false if the debounced state has not changed (i.e. not yet matching the current observed state or already previously matching the observed state).
Definition at line 214 of file Debouncer.hxx.
◆ currentState_
| unsigned CountingDebouncer::currentState_ |
|
private |
◆ lastCount_
| unsigned CountingDebouncer::lastCount_ |
|
private |
how many 1 bits we have in the window
Definition at line 256 of file Debouncer.hxx.
◆ opts_
◆ window_
| uint32_t CountingDebouncer::window_ {0} |
|
private |
bit-map of last observations. bit 0 is latest.
Definition at line 254 of file Debouncer.hxx.
The documentation for this class was generated from the following file: