semf
semf::DebouncedDigitalInPolling Class Reference

Class for reading and debouncing a digital input (e.g. used for buttons or relays inputs). The two signals changedToHigh and changedToLow will be emitted after the pin level changed and the debounce time is passed. More...

#include <debounceddigitalinpolling.h>

Inheritance diagram for semf::DebouncedDigitalInPolling:
Inheritance graph
Collaboration diagram for semf::DebouncedDigitalInPolling:
Collaboration graph

Public Member Functions

 DebouncedDigitalInPolling (Gpio &gpio, uint32_t debounceLowTime, uint32_t debounceHighTime, bool inverted=false)
 Constructor. More...
 
 DebouncedDigitalInPolling (Gpio &gpio, app::TimeBase &timeBase, uint32_t debounceLowTime, uint32_t debounceHighTime, bool inverted=false)
 Constructor. More...
 
 DebouncedDigitalInPolling (const DebouncedDigitalInPolling &other)=delete
 
virtual ~DebouncedDigitalInPolling ()=default
 
void setDebounceHighTime (uint32_t time)
 Sets the debounce time for switching from low to high. More...
 
void setDebounceLowTime (uint32_t time)
 Sets the debounce time for switching from high to low. More...
 
void tick () override
 Checks the present pin state and counts the debounce time. More...
 
- Public Member Functions inherited from semf::DigitalInPolling
 DigitalInPolling (Gpio &gpio, bool inverted=false)
 Constructor. More...
 
 DigitalInPolling (Gpio &gpio, app::TimeBase &timeBase, bool inverted=false)
 Constructor. More...
 
 DigitalInPolling (const DigitalInPolling &other)=delete
 
virtual ~DigitalInPolling ()=default
 
void tick () override
 
State state () const override
 Returns the level status of the hardware pin. More...
 
- Public Member Functions inherited from semf::DigitalIn
 DigitalIn (Gpio &gpio, bool inverted=false)
 Constructor. More...
 
 DigitalIn (const DigitalIn &other)=delete
 
bool isInverted () const override
 Returns of the pin level logic is inverted. More...
 
void setInverted (bool inverted) override
 Configures the inversion of the input reading. More...
 
State state () const override
 Returns the level status of the hardware pin. More...
 
- Public Member Functions inherited from semf::app::DigitalIn
virtual ~DigitalIn ()=default
 
virtual bool isInverted () const =0
 Returns of the pin level logic is inverted. More...
 
virtual void setInverted (bool inverted)=0
 Configures the inversion of the input reading. More...
 
virtual State state () const =0
 Returns the level status of the hardware pin. More...
 
- Public Member Functions inherited from semf::TickReceiver
virtual ~TickReceiver ()=default
 
virtual void tick ()=0
 Is called by every tick. Is called periodically e.g. by a Timer object. More...
 
- Public Member Functions inherited from semf::LinkedList< T >::Node
virtual ~Node ()=default
 
T * next () const
 Returns a pointer to the next element in a list. More...
 
void setNext (T *next)
 Sets a pointer to the next element in a list. More...
 
T * previous () const
 Returns a pointer to the previous element in a list. More...
 
void setPrevious (T *previous)
 Sets a pointer to the previous element in a list. More...
 
bool isInAList ()
 Returns if a node is part of a LinkedList. More...
 

Additional Inherited Members

- Public Types inherited from semf::app::DigitalIn
enum  State : bool { Low = false , High = true }
 
- Public Attributes inherited from semf::app::DigitalIn
Signal changedToHigh
 
Signal changedToLow
 
- Protected Member Functions inherited from semf::DigitalInPolling
void setState (State state)
 Sets the hardware pin status internally. More...
 
- Protected Member Functions inherited from semf::DigitalIn
Gpiogpio () const
 Returns the pointer to the GPIO to check the status from. More...
 

Detailed Description

Class for reading and debouncing a digital input (e.g. used for buttons or relays inputs). The two signals changedToHigh and changedToLow will be emitted after the pin level changed and the debounce time is passed.

For reading the actual hardware pin level, call the function DigitalIn::state().

See also
app::DigitalIn
DigitalInPolling

Definition at line 27 of file debounceddigitalinpolling.h.

Constructor & Destructor Documentation

◆ DebouncedDigitalInPolling() [1/3]

semf::DebouncedDigitalInPolling::DebouncedDigitalInPolling ( Gpio gpio,
uint32_t  debounceLowTime,
uint32_t  debounceHighTime,
bool  inverted = false 
)

Constructor.

Parameters
gpioGPIO interface object for hardware access.
debounceLowTimeDebounce time taken to change from high to low.
debounceHighTimeDebounce time taken to change from low to high.
invertedtrue sets high level of a pin as low and low level of a pin as high.

Definition at line 15 of file debounceddigitalinpolling.cpp.

◆ DebouncedDigitalInPolling() [2/3]

semf::DebouncedDigitalInPolling::DebouncedDigitalInPolling ( Gpio gpio,
app::TimeBase timeBase,
uint32_t  debounceLowTime,
uint32_t  debounceHighTime,
bool  inverted = false 
)

Constructor.

Parameters
gpioGPIO interface object for hardware access.
timeBaseThe timebase for the internal timer.
debounceLowTimeDebounce time taken to change from high to low.
debounceHighTimeDebounce time taken to change from low to high.
invertedtrue sets high level of a pin as low and low level of a pin as high.

Definition at line 22 of file debounceddigitalinpolling.cpp.

◆ DebouncedDigitalInPolling() [3/3]

semf::DebouncedDigitalInPolling::DebouncedDigitalInPolling ( const DebouncedDigitalInPolling other)
explicitdelete

◆ ~DebouncedDigitalInPolling()

virtual semf::DebouncedDigitalInPolling::~DebouncedDigitalInPolling ( )
virtualdefault

Member Function Documentation

◆ setDebounceHighTime()

void semf::DebouncedDigitalInPolling::setDebounceHighTime ( uint32_t  time)

Sets the debounce time for switching from low to high.

Parameters
timeThe debounce high time.

Definition at line 29 of file debounceddigitalinpolling.cpp.

◆ setDebounceLowTime()

void semf::DebouncedDigitalInPolling::setDebounceLowTime ( uint32_t  time)

Sets the debounce time for switching from high to low.

Parameters
timeThe debounce low time.

Definition at line 35 of file debounceddigitalinpolling.cpp.

◆ tick()

void semf::DebouncedDigitalInPolling::tick ( )
overridevirtual

Checks the present pin state and counts the debounce time.

Note
This method must be called periodically using a timer (e.g. SysTick).

Implements semf::TickReceiver.

Definition at line 41 of file debounceddigitalinpolling.cpp.

Here is the call graph for this function: