|
C++ DevKit
C++ set of OOP library
|
SwitchButton status is sampled periodically by software. More...
#include <switch_button.h>


Public Member Functions | |
| 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. | |
Protected Member Functions | |
| bool | is_switch_pushed () |
| return the 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_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. | |
SwitchButton status is sampled periodically by software.
During each period, the status of the button is compared to the previous status and the function member process_sample_event() return an event accordingly.
SwitchButton can be associated with UIController if button belongs to a GUI. In such case a new class must be created that inherits from SwitchButton and UIController.
| SwitchButton::SwitchButton | ( | uint | gpio, |
| struct_ConfigSwitchButton | conf = {} ) |
Construct a new SwitchButton object.
| gpio | the microcontroller GPIO that read the switch status |
| conf | the configuration data according struct_ConfigSwitchButton |


| ButtonState SwitchButton::get_button_status | ( | ) |
Get the button status object.
|
protected |
return the status of the switch.

| UIControlEvent SwitchButton::process_sample_event | ( | ) |
the periodic routine that process deboucing, push and release of the switch.
