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

#include <debounce.h>

Collaboration diagram for ButtonDebounce:
Collaboration graph
[legend]

Public Member Functions

 ButtonDebounce (const char *name)
 
void init (efitimems_t threshold, brain_pin_e &pin, pin_input_mode_e &mode, bool inverted=false)
 
void stopConfiguration ()
 
void startConfiguration ()
 
bool readPinEvent ()
 
bool readPinState ()
 
bool readPinState2 (bool valueWithinThreshold)
 
bool getPhysicalState ()
 

Static Public Member Functions

static void stopConfigurationList ()
 
static void startConfigurationList ()
 
static void debug ()
 
static void resetForUnitTests ()
 

Private Attributes

const char *const m_name
 
efidur_t m_threshold
 
Timer timeLast
 
brain_pin_em_pin
 
brain_pin_e active_pin = Gpio::Unassigned
 
pin_input_mode_em_mode
 
pin_input_mode_e active_mode = PI_DEFAULT
 
bool storedValue = false
 
bool m_inverted = false
 
bool isInstanceRegisteredInGlobalList = false
 
bool needsPinInitialization = true
 
ButtonDebouncenextDebounce = nullptr
 

Static Private Attributes

static ButtonDebounces_firstDebounce = nullptr
 

Detailed Description

Definition at line 16 of file debounce.h.

Constructor & Destructor Documentation

◆ ButtonDebounce()

ButtonDebounce::ButtonDebounce ( const char name)
explicit

Definition at line 15 of file debounce.cpp.

16 : m_name(name)
17{
18}
const char *const m_name
Definition debounce.h:35

Member Function Documentation

◆ debug()

static void ButtonDebounce::debug ( )
static

Referenced by stopConfiguration().

Here is the caller graph for this function:

◆ getPhysicalState()

bool ButtonDebounce::getPhysicalState ( )

Referenced by slowStartStopButtonCallback(), and stopConfiguration().

Here is the caller graph for this function:

◆ init()

void ButtonDebounce::init ( efitimems_t  threshold,
brain_pin_e pin,
pin_input_mode_e mode,
bool  inverted = false 
)

We need to have a separate init function because we do not have the pin or mode in the context in which the class is originally created

Definition at line 23 of file debounce.cpp.

23 {
24 // we need to keep track of whether we have already been initialized due to the way unit tests run.
26 // Link us to the list that is used to track ButtonDebounce instances, so that when the configuration changes,
27 // they can be looped through and updated.
29 s_firstDebounce = this;
30 }
31 m_threshold = MS2NT(threshold);
32 m_pin = &pin;
33 m_mode = &mode;
34 m_inverted = inverted;
37}
bool isInstanceRegisteredInGlobalList
Definition debounce.h:44
pin_input_mode_e * m_mode
Definition debounce.h:40
void startConfiguration()
static ButtonDebounce * s_firstDebounce
Definition debounce.h:47
ButtonDebounce * nextDebounce
Definition debounce.h:46
efidur_t m_threshold
Definition debounce.h:36
brain_pin_e * m_pin
Definition debounce.h:38
bool m_inverted
Definition debounce.h:43
brain_pin_e pin
Definition stm32_adc.cpp:15

Referenced by ButtonShiftController::init(), initSensors(), and initStartStopButton().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readPinEvent()

bool ButtonDebounce::readPinEvent ( )

Referenced by slowStartStopButtonCallback(), stopConfiguration(), and ButtonShiftController::update().

Here is the caller graph for this function:

◆ readPinState()

bool ButtonDebounce::readPinState ( )

Referenced by getAcToggle(), and stopConfiguration().

Here is the caller graph for this function:

◆ readPinState2()

bool ButtonDebounce::readPinState2 ( bool  valueWithinThreshold)

Referenced by stopConfiguration().

Here is the caller graph for this function:

◆ resetForUnitTests()

static void ButtonDebounce::resetForUnitTests ( )
inlinestatic

Definition at line 30 of file debounce.h.

30 {
31 s_firstDebounce = nullptr;
32 }

◆ startConfiguration()

void ButtonDebounce::startConfiguration ( )

Referenced by init(), startConfigurationList(), and stopConfiguration().

Here is the caller graph for this function:

◆ startConfigurationList()

void ButtonDebounce::startConfigurationList ( )
static

Definition at line 49 of file debounce.cpp.

49 {
51 int loopLimitCounter = 0;
52 while (listItem != nullptr) {
53 criticalAssertVoid(loopLimitCounter++ < 10000, "dead startConfigurationList?");
54 listItem->startConfiguration();
55 listItem = listItem->nextDebounce;
56 }
57}

Referenced by applyNewHardwareSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stopConfiguration()

void ButtonDebounce::stopConfiguration ( )
Returns
true if the button is pressed, and will not return true again within the set timeout

Definition at line 59 of file debounce.cpp.

Referenced by stopConfigurationList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stopConfigurationList()

void ButtonDebounce::stopConfigurationList ( )
static

Definition at line 39 of file debounce.cpp.

39 {
41 int loopLimitCounter = 0;
42 while (listItem != nullptr) {
43 criticalAssertVoid(loopLimitCounter++ < 10000, "dead stopConfigurationList?");
44 listItem->stopConfiguration();
45 listItem = listItem->nextDebounce;
46 }
47}
void stopConfiguration()
Definition debounce.cpp:59

Referenced by applyNewHardwareSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ active_mode

pin_input_mode_e ButtonDebounce::active_mode = PI_DEFAULT
private

Definition at line 41 of file debounce.h.

Referenced by stopConfiguration().

◆ active_pin

brain_pin_e ButtonDebounce::active_pin = Gpio::Unassigned
private

Definition at line 39 of file debounce.h.

Referenced by stopConfiguration().

◆ isInstanceRegisteredInGlobalList

bool ButtonDebounce::isInstanceRegisteredInGlobalList = false
private

Definition at line 44 of file debounce.h.

Referenced by init().

◆ m_inverted

bool ButtonDebounce::m_inverted = false
private

Definition at line 43 of file debounce.h.

Referenced by init(), and stopConfiguration().

◆ m_mode

pin_input_mode_e* ButtonDebounce::m_mode
private

Definition at line 40 of file debounce.h.

Referenced by init(), and stopConfiguration().

◆ m_name

const char* const ButtonDebounce::m_name
private

Definition at line 35 of file debounce.h.

Referenced by stopConfiguration().

◆ m_pin

brain_pin_e* ButtonDebounce::m_pin
private

Definition at line 38 of file debounce.h.

Referenced by init(), and stopConfiguration().

◆ m_threshold

efidur_t ButtonDebounce::m_threshold
private

Definition at line 36 of file debounce.h.

Referenced by init(), and stopConfiguration().

◆ needsPinInitialization

bool ButtonDebounce::needsPinInitialization = true
private

Definition at line 45 of file debounce.h.

Referenced by stopConfiguration().

◆ nextDebounce

ButtonDebounce* ButtonDebounce::nextDebounce = nullptr
private

Definition at line 46 of file debounce.h.

Referenced by init(), startConfigurationList(), stopConfiguration(), and stopConfigurationList().

◆ s_firstDebounce

ButtonDebounce * ButtonDebounce::s_firstDebounce = nullptr
staticprivate

◆ storedValue

bool ButtonDebounce::storedValue = false
private

Definition at line 42 of file debounce.h.

Referenced by stopConfiguration().

◆ timeLast

Timer ButtonDebounce::timeLast
private

Definition at line 37 of file debounce.h.

Referenced by stopConfiguration().


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