rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
SignalDebounce Class Reference

#include <signaldebounce.h>

Collaboration diagram for SignalDebounce:
Collaboration graph
[legend]

Public Member Functions

 SignalDebounce (float debounceSeconds, bool initialState)
 
 SignalDebounce (float debounceSeconds)
 
void set (bool newState)
 
bool get () const
 

Private Attributes

Timer timer
 
const float period
 
bool state
 

Detailed Description

Definition at line 8 of file signaldebounce.h.

Constructor & Destructor Documentation

◆ SignalDebounce() [1/2]

SignalDebounce::SignalDebounce ( float  debounceSeconds,
bool  initialState 
)
inline

Definition at line 10 of file signaldebounce.h.

10 :
11 period(debounceSeconds),
12 state(initialState)
13 { }
const float period

◆ SignalDebounce() [2/2]

SignalDebounce::SignalDebounce ( float  debounceSeconds)
inline

Definition at line 14 of file signaldebounce.h.

14 :
15 period(debounceSeconds),
16 state(false)
17 { }

Member Function Documentation

◆ get()

bool SignalDebounce::get ( ) const
inline

Definition at line 32 of file signaldebounce.h.

32 {
33 return state;
34 }

Referenced by configureRusefiLuaHooks().

Here is the caller graph for this function:

◆ set()

void SignalDebounce::set ( bool  newState)
inline

Definition at line 20 of file signaldebounce.h.

21 {
22 if (state == newState) {
23 timer.reset();
24 }
25 else if (timer.hasElapsedSec(period)) {
26 state = newState;
27 timer.reset();
28 }
29 }

Referenced by configureRusefiLuaHooks().

Here is the caller graph for this function:

Field Documentation

◆ period

const float SignalDebounce::period
private

Definition at line 38 of file signaldebounce.h.

Referenced by set().

◆ state

bool SignalDebounce::state
private

Definition at line 39 of file signaldebounce.h.

Referenced by get(), and set().

◆ timer

Timer SignalDebounce::timer
private

Definition at line 37 of file signaldebounce.h.

Referenced by set().


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