C++ DevKit
C++ set of OOP library
Loading...
Searching...
No Matches
SwitchButtonWithIRQ Class Reference

SwitchButtonWithIRQ status is processed by an Interrupt Service Routine. It is derived from SwithButton, but debouncing, press and release are processed differently. More...

#include <switch_button.h>

Inheritance diagram for SwitchButtonWithIRQ:
Inheritance graph
Collaboration diagram for SwitchButtonWithIRQ:
Collaboration graph

Public Member Functions

void irq_enabled (bool enabled)
 "AND" function used to enable/disable interrupt during Interrupt Service Routine (ISR)
 
 SwitchButtonWithIRQ (uint gpio, gpio_irq_callback_t call_back, struct_ConfigSwitchButton conf={}, uint32_t event_mask_config=GPIO_IRQ_EDGE_FALL|GPIO_IRQ_EDGE_RISE)
 Construct a new SwitchButtonWithIRQ object.
 
 ~SwitchButtonWithIRQ ()
 Destroy the SwitchButtonWithIRQ object.
 
UIControlEvent process_IRQ_event (uint32_t current_event_mask)
 Process IRQ event and return the resulting event.
 
- Public Member Functions inherited from SwitchButton
 SwitchButton (uint gpio, struct_ConfigSwitchButton conf={})
 Construct a new SwitchButton object.
 
 ~SwitchButton ()
 Destroy the SwitchButton object.
 
UIControlEvent process_sample_event ()
 the periodic routine that process deboucing, push and release of the switch.
 
ButtonState get_button_status ()
 Get the button status object.
 

Additional Inherited Members

- Protected Member Functions inherited from SwitchButton
bool is_switch_pushed ()
 return the status of the switch.
 
- Protected Attributes inherited from SwitchButton
uint debounce_delay_us
 The time during which all changes in the switch state is ignored.
 
uint long_push_delay_us
 when a button is pushed more than long_push_delay_us (in microseconds) a UIControlEvent::LONG_PUSH is returned.
 
uint long_release_delay_us
 if the button is released after long_release_delay_us (in microseconds) a UIControlEvent::RELEASED_AFTER_LONG_TIME is returned, else a UIControlEvent::RELEASED_AFTER_SHORT_TIME is released.
 
uint time_out_delay_us
 if the button is released after time_out_delay_us (in microseconds) a UIControlEvent::TIME_OUT is returned,
 
uint gpio
 the GPIO that reads the logical state of the switch (pushed or released)
 
bool active_lo
 his indicates that when the switch is pushed, a logical LO (0) signal is read.
 
uint previous_change_time_us
 the system time stored on the previous switch state change.
 
bool previous_switch_pushed_state
 The previous state read during the previous period.
 
ButtonState button_status {ButtonState::IDLE}
 the logical button status, required to manage the event returned when the switch is pushed or released.
 

Detailed Description

SwitchButtonWithIRQ status is processed by an Interrupt Service Routine. It is derived from SwithButton, but debouncing, press and release are processed differently.

Note
WARNING: LONG_PUSH and TIME_OUT cannot be implemented by processing IRQ. NOTICE: SwitchButtonWithIRQ can be associated with UIController only if button belongs to a UI.

NOTICE: the test program for switch button with IRQ is implemented with the rotary encoder device, which is a good example of what can be done with and without IRQ

Constructor & Destructor Documentation

◆ SwitchButtonWithIRQ()

SwitchButtonWithIRQ::SwitchButtonWithIRQ ( uint gpio,
gpio_irq_callback_t call_back,
struct_ConfigSwitchButton conf = {},
uint32_t event_mask_config = GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE )

Construct a new SwitchButtonWithIRQ object.

Parameters
gpioThe microcontroller GPIO connected to the switch
call_backThe ISR (interrupt Service Routine) that process IRQ event
confthe configuration value of the switch
event_mask_configthe rising/falling edge configuratio of the irq
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ irq_enabled()

void SwitchButtonWithIRQ::irq_enabled ( bool enabled)

"AND" function used to enable/disable interrupt during Interrupt Service Routine (ISR)

Parameters
enabled
Here is the caller graph for this function:

◆ process_IRQ_event()

UIControlEvent SwitchButtonWithIRQ::process_IRQ_event ( uint32_t current_event_mask)

Process IRQ event and return the resulting event.

Parameters
current_event_mask
Returns
UIControlEvent
Here is the call graph for this function:
Here is the caller graph for this function:

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