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

rtosSwitchButton is processed by an Interrupt Service Routine (ISR) under control of FreeRTOS routines. More...

#include <rtos_switch_button.h>

Inheritance diagram for rtosSwitchButton:
Inheritance graph
Collaboration diagram for rtosSwitchButton:
Collaboration graph

Public Member Functions

 rtosSwitchButton (uint gpio, gpio_irq_callback_t call_back, QueueHandle_t in_switch_button_queue, QueueHandle_t out_control_event_queue, struct_rtosConfigSwitchButton conf={}, uint32_t event_mask_config=GPIO_IRQ_EDGE_FALL|GPIO_IRQ_EDGE_RISE)
 Construct a new rtos Switch Button object.
 
 ~rtosSwitchButton ()
 Destroy the SwitchButton object.
 
virtual void rtos_process_IRQ_event ()
 Process IRQ event and sent the resulting event to the event queue.
 

Protected Member Functions

bool is_switch_pushed (uint32_t current_event_mask)
 return the logical status of the switch. It process rising and falling edges of the interrupt, according to the active_lo status of the switch.
 

Protected Attributes

uint debounce_delay_us
 The time during which all changes in the switch state is ignored.
 
uint long_push_delay_ms
 when a button is pushed more than long_push_delay_ms (in milliseconds) 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_ms
 if the button is released after time_out_delay_ms (in milliseconds) 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.
 
QueueHandle_t switch_button_queue
 the queue from which IRQ data are received
 
QueueHandle_t control_event_queue
 the queue to which the resulting control event is sent
 

Detailed Description

rtosSwitchButton is processed by an Interrupt Service Routine (ISR) under control of FreeRTOS routines.

  • Switch status is the status of the physical (i.e. mechanical) switch device.
  • Button status is the logical status of the button (regardless if the switch is wired active Lo or HI).

During each ISR, the status of the button is compared to the previous status and the function member rtos_process_IRQ_event() sends an event accordingly toward the control_event output queue.

SwitchButton can be associated with UIController if button belongs to a GUI. In such case a new class must be created that inherits from rtosSwitchButton and UIController.

SwitchButton times references for long release

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

Constructor & Destructor Documentation

◆ rtosSwitchButton()

rtosSwitchButton::rtosSwitchButton ( uint gpio,
gpio_irq_callback_t call_back,
QueueHandle_t in_switch_button_queue,
QueueHandle_t out_control_event_queue,
struct_rtosConfigSwitchButton conf = {},
uint32_t event_mask_config = GPIO_IRQ_EDGE_FALL | GPIO_IRQ_EDGE_RISE )

Construct a new rtos Switch Button object.

Parameters
gpioThe microcontroller GPIO connected to the switch
call_backThe ISR (interrupt Service Routine) that process IRQ event
in_switch_button_queuethe input queue that receives data from IRQ
out_control_event_queuethe output queue that receives computed control event
confthe configuration value of the switch
event_mask_configthe rising/falling edge configuratio of the irq
Here is the caller graph for this function:

Member Function Documentation

◆ is_switch_pushed()

bool rtosSwitchButton::is_switch_pushed ( uint32_t current_event_mask)
protected

return the logical status of the switch. It process rising and falling edges of the interrupt, according to the active_lo status of the switch.

Parameters
current_event_mask
Returns
true if switch status is read LO (resp. HI) if active_lo is true (resp. false)
false if switch status is read HI (resp. LO) if active_lo is true (resp. false)
Here is the caller graph for this function:

◆ rtos_process_IRQ_event()

void rtosSwitchButton::rtos_process_IRQ_event ( )
virtual

Process IRQ event and sent the resulting event to the event queue.

Reimplemented in rtosRotaryEncoder.

Here is the call graph for this function:

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