61#ifndef _UTILS_DEBOUNCER_HXX_
62#define _UTILS_DEBOUNCER_HXX_
98 void override(
bool new_state)
115 unsigned new_state = state ? 1 : 0;
198 void override(
bool new_state)
281 impl_.initialize(state);
286 void override(
bool state)
302 bool press_changed =
impl_.update_state(state);
304 if (press_changed &&
impl_.current_state())
This debouncer will count the ON values and if the number of ON values in a given window exceeds a th...
void reset_options(const Options &opts)
Re-creates the debouncer with new options.
uint32_t window_
bit-map of last observations. bit 0 is latest.
const Options & options()
Retrieves the currently set options.
unsigned currentState_
last known state
bool update_state(bool state)
Callback from the polling loop checking the input state.
void initialize(bool state)
Initilalize the debouncer.
CountingDebouncer(const Options &opts)
Constructor.
unsigned lastCount_
how many 1 bits we have in the window
This debouncer will update state if for N consecutive attempts the input value is the same.
unsigned count_
How many times we've seen the proposed new state.
bool update_state(bool state)
Iteration function of the debouncer.
unsigned currentState_
Current visible state.
unsigned waitCount_
Configuration: what is the quiesce count we have to reach.
uint8_t Options
Type declaring what opeions we can supply to this class.
void initialize(bool state)
Initializes the debouncer.
void reset_options(const Options &opts)
Re-creates the debouncer with new options.
QuiesceDebouncer(const Options &wait_count)
Constructor.
This class acts as a debouncer that uses one momentary input button, and switches the event state at ...
Debouncer impl_
Implementation of the debounce logic.
unsigned eventState_
what the world thinks about the event
bool update_state(bool state)
Inserts a single poll measurement.
ToggleDebouncer(const Options &options)
Constructor.
void initialize(bool state)
Sets the initial state.
Debouncer::Options Options
Options type.
Static parameters for the CountingDebouncer.
uint8_t min_count
Number of samples that have to be 1 within the window to consider the debounce value 1.
uint8_t window_size
Number of samples to keep. Must be between 1 and 32.