|
Firmware SDK
|
Driver for generic button. More...
Data Structures | |
| struct | twr_button_driver_t |
| Button driver interface. More... | |
Typedefs | |
| typedef struct twr_button_t | twr_button_t |
| Button instance. | |
Enumerations | |
| enum | twr_button_event_t { TWR_BUTTON_EVENT_PRESS = 0 , TWR_BUTTON_EVENT_RELEASE = 1 , TWR_BUTTON_EVENT_CLICK = 2 , TWR_BUTTON_EVENT_HOLD = 3 } |
| Callback events. More... | |
Functions | |
| void | twr_button_init (twr_button_t *self, twr_gpio_channel_t gpio_channel, twr_gpio_pull_t gpio_pull, int idle_state) |
| Initialize button. More... | |
| void | twr_button_init_virtual (twr_button_t *self, int channel, const twr_button_driver_t *driver, int idle_state) |
| Initialize virtual button. More... | |
| void | twr_button_set_event_handler (twr_button_t *self, void(*event_handler)(twr_button_t *, twr_button_event_t, void *), void *event_param) |
| Set callback function. More... | |
| void | twr_button_set_scan_interval (twr_button_t *self, twr_tick_t scan_interval) |
| Set scan interval (period of button input sampling) More... | |
| void | twr_button_set_debounce_time (twr_button_t *self, twr_tick_t debounce_time) |
| Set debounce time (minimum sampling interval during which input cannot change to toggle its state) More... | |
| void | twr_button_set_click_timeout (twr_button_t *self, twr_tick_t click_timeout) |
| Set click timeout (maximum interval within which button has to be released to recognize click event) More... | |
| void | twr_button_set_hold_time (twr_button_t *self, twr_tick_t hold_time) |
| Set hold time (interval after which hold event is recognized when button is steadily pressed) More... | |
Driver for generic button.
| enum twr_button_event_t |
Callback events.
Definition at line 14 of file twr_button.h.
| void twr_button_init | ( | twr_button_t * | self, |
| twr_gpio_channel_t | gpio_channel, | ||
| twr_gpio_pull_t | gpio_pull, | ||
| int | idle_state | ||
| ) |
Initialize button.
| [in] | self | Instance |
| [in] | gpio_channel | GPIO channel button is connected to |
| [in] | gpio_pull | GPIO pull-up/pull-down setting |
| [in] | idle_state | GPIO pin idle state (when button is not pressed) |
Definition at line 20 of file twr_button.c.
Referenced by twr_module_encoder_init().


| void twr_button_init_virtual | ( | twr_button_t * | self, |
| int | channel, | ||
| const twr_button_driver_t * | driver, | ||
| int | idle_state | ||
| ) |
Initialize virtual button.
| [in] | self | Instance |
| [in] | channel | Virtual channel button is connected to |
| [in] | driver | Virtual channel button driver |
| [in] | idle_state | Virtual pin idle state (when button is not pressed) |
Definition at line 43 of file twr_button.c.
Referenced by twr_module_lcd_set_event_handler().


| void twr_button_set_click_timeout | ( | twr_button_t * | self, |
| twr_tick_t | click_timeout | ||
| ) |
Set click timeout (maximum interval within which button has to be released to recognize click event)
| [in] | self | Instance |
| [in] | click_timeout | Desired click timeout in ticks |
Definition at line 93 of file twr_button.c.
Referenced by twr_module_lcd_set_button_click_timeout().

| void twr_button_set_debounce_time | ( | twr_button_t * | self, |
| twr_tick_t | debounce_time | ||
| ) |
Set debounce time (minimum sampling interval during which input cannot change to toggle its state)
| [in] | self | Instance |
| [in] | debounce_time | Desired debounce time in ticks |
Definition at line 88 of file twr_button.c.
Referenced by twr_module_lcd_set_button_debounce_time().

| void twr_button_set_event_handler | ( | twr_button_t * | self, |
| void(*)(twr_button_t *, twr_button_event_t, void *) | event_handler, | ||
| void * | event_param | ||
| ) |
Set callback function.
| [in] | self | Instance |
| [in] | event_handler | Function address |
| [in] | event_param | Optional event parameter (can be NULL) |
Definition at line 66 of file twr_button.c.
Referenced by twr_module_encoder_init(), and twr_module_lcd_set_event_handler().


| void twr_button_set_hold_time | ( | twr_button_t * | self, |
| twr_tick_t | hold_time | ||
| ) |
Set hold time (interval after which hold event is recognized when button is steadily pressed)
| [in] | self | Instance |
| [in] | hold_time | Desired hold time in ticks |
Definition at line 98 of file twr_button.c.
Referenced by twr_module_lcd_set_button_hold_time().

| void twr_button_set_scan_interval | ( | twr_button_t * | self, |
| twr_tick_t | scan_interval | ||
| ) |
Set scan interval (period of button input sampling)
| [in] | self | Instance |
| [in] | scan_interval | Desired scan interval in ticks |
Definition at line 83 of file twr_button.c.
Referenced by twr_module_lcd_set_button_scan_interval().
