Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
QuiesceDebouncer Class Reference

This debouncer will update state if for N consecutive attempts the input value is the same. More...

#include <Debouncer.hxx>

Public Types

typedef uint8_t Options
 Type declaring what opeions we can supply to this class.
 

Public Member Functions

 QuiesceDebouncer (const Options &wait_count)
 Constructor.
 
void reset_options (const Options &opts)
 Re-creates the debouncer with new options.
 
void initialize (bool state)
 Initializes the debouncer.
 
void override (bool new_state)
 
bool current_state ()
 
bool update_state (bool state)
 Iteration function of the debouncer.
 

Private Attributes

unsigned count_: 8
 How many times we've seen the proposed new state.
 
unsigned waitCount_: 8
 Configuration: what is the quiesce count we have to reach.
 
unsigned currentState_: 1
 Current visible state.
 

Detailed Description

This debouncer will update state if for N consecutive attempts the input value is the same.

Definition at line 66 of file Debouncer.hxx.

Member Typedef Documentation

◆ Options

typedef uint8_t QuiesceDebouncer::Options

Type declaring what opeions we can supply to this class.

Definition at line 70 of file Debouncer.hxx.

Constructor & Destructor Documentation

◆ QuiesceDebouncer()

QuiesceDebouncer::QuiesceDebouncer ( const Options wait_count)
inline

Constructor.

Parameters
wait_countdefines how many poll cycles the input has to quiesce (not change) before we accept that input and forward to the caller.

Definition at line 75 of file Debouncer.hxx.

Member Function Documentation

◆ current_state()

bool QuiesceDebouncer::current_state ( )
inline
Returns
the currently visible (accepted) state.

Definition at line 104 of file Debouncer.hxx.

◆ initialize()

void QuiesceDebouncer::initialize ( bool  state)
inline

Initializes the debouncer.

Parameters
stateis the externally forced state.

Definition at line 91 of file Debouncer.hxx.

◆ override()

void QuiesceDebouncer::override ( bool  new_state)
inline
Parameters
stateis the externally forced state.

Definition at line 98 of file Debouncer.hxx.

◆ reset_options()

void QuiesceDebouncer::reset_options ( const Options opts)
inline

Re-creates the debouncer with new options.

Parameters
optsnew options.

Definition at line 84 of file Debouncer.hxx.

◆ update_state()

bool QuiesceDebouncer::update_state ( bool  state)
inline

Iteration function of the debouncer.

Parameters
stateis the new state read.
Returns
true if the state has just changed (the visible state just flipped from being != state to being == state). False if the visible state was not changed by this poll cycle.

Definition at line 113 of file Debouncer.hxx.

Member Data Documentation

◆ count_

unsigned QuiesceDebouncer::count_
private

How many times we've seen the proposed new state.

Definition at line 132 of file Debouncer.hxx.

◆ currentState_

unsigned QuiesceDebouncer::currentState_
private

Current visible state.

Definition at line 136 of file Debouncer.hxx.

◆ waitCount_

unsigned QuiesceDebouncer::waitCount_
private

Configuration: what is the quiesce count we have to reach.

Definition at line 134 of file Debouncer.hxx.


The documentation for this class was generated from the following file: