Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
ToggleDebouncer< Debouncer > Class Template Reference

This class acts as a debouncer that uses one momentary input button, and switches the event state at every rising edge of that input button. More...

#include <Debouncer.hxx>

Public Types

typedef Debouncer::Options Options
 Options type.
 

Public Member Functions

 ToggleDebouncer (const Options &options)
 Constructor.
 
void initialize (bool state)
 Sets the initial state.
 
void override (bool state)
 Forces the state to a given value.
 
bool current_state ()
 
bool update_state (bool state)
 Inserts a single poll measurement.
 

Private Attributes

Debouncer impl_
 Implementation of the debounce logic.
 
unsigned eventState_: 1
 what the world thinks about the event
 

Detailed Description

template<class Debouncer>
class ToggleDebouncer< Debouncer >

This class acts as a debouncer that uses one momentary input button, and switches the event state at every rising edge of that input button.

Internally it uses another debouncer to smooth the input button.

Definition at line 263 of file Debouncer.hxx.

Member Typedef Documentation

◆ Options

template<class Debouncer >
typedef Debouncer::Options ToggleDebouncer< Debouncer >::Options

Options type.

Definition at line 267 of file Debouncer.hxx.

Constructor & Destructor Documentation

◆ ToggleDebouncer()

template<class Debouncer >
ToggleDebouncer< Debouncer >::ToggleDebouncer ( const Options options)
inline

Constructor.

Parameters
optionsspecified options for the debouncer strategy.

Definition at line 271 of file Debouncer.hxx.

Member Function Documentation

◆ current_state()

template<class Debouncer >
bool ToggleDebouncer< Debouncer >::current_state ( )
inline
Returns
the current (last advertised / accepted) state.

Definition at line 292 of file Debouncer.hxx.

◆ initialize()

template<class Debouncer >
void ToggleDebouncer< Debouncer >::initialize ( bool  state)
inline

Sets the initial state.

Parameters
stateis the initial (or default) state.

Definition at line 278 of file Debouncer.hxx.

◆ override()

template<class Debouncer >
void ToggleDebouncer< Debouncer >::override ( bool  state)
inline

Forces the state to a given value.

Parameters
stateis the forced state value.

Definition at line 286 of file Debouncer.hxx.

◆ update_state()

template<class Debouncer >
bool ToggleDebouncer< Debouncer >::update_state ( bool  state)
inline

Inserts a single poll measurement.

Parameters
stateis the measured state.
Returns
true if the state just changed right now.

Definition at line 300 of file Debouncer.hxx.

Member Data Documentation

◆ eventState_

template<class Debouncer >
unsigned ToggleDebouncer< Debouncer >::eventState_
private

what the world thinks about the event

Definition at line 317 of file Debouncer.hxx.

◆ impl_

template<class Debouncer >
Debouncer ToggleDebouncer< Debouncer >::impl_
private

Implementation of the debounce logic.

Definition at line 315 of file Debouncer.hxx.


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