|
|
ChaosDMX
Open-Source DMX-Interface
|
Dynamic hardware button execution mapped directly to app configuration. More...
#include "button_actions.h"#include "button_gpio.h"#include "config.h"#include "driver/gpio.h"#include "esp_system.h"#include "iot_button.h"#include "led.h"#include "logger.h"Go to the source code of this file.
Macros | |
| #define | LOG_TAG "BUTTON" |
| Logging tag for the button actions component. | |
| #define | BUTTON_GPIO_NUM GPIO_NUM_5 |
| GPIO number assigned to the hardware button. | |
| #define | RESET_HOLD_TIME_MS 3000 |
| Duration (ms) the button must be held for a reset trigger. | |
Functions | |
| static void | execute_button_action (config_button_action_t assigned_action) |
| Executes the action compiled into the configuration for the triggered event. | |
| static void | iot_button_single_click_cb (void *arg, void *usr_data) |
| Callback for single click events. | |
| static void | iot_button_double_click_cb (void *arg, void *usr_data) |
| Callback for double click events. | |
| static void | iot_button_multiple_click_cb (void *arg, void *usr_data) |
| Callback for multiple click events. | |
| esp_err_t | button_init (void) |
| Initializes the hardware button configuration and event callbacks. | |
| bool | button_is_pressed (void) |
| Checks if the button is currently physically pressed. | |
Variables | |
| static button_handle_t | s_btn_handle = NULL |
| Internal handle for the IoT button instance. | |
Dynamic hardware button execution mapped directly to app configuration.
Definition in file button_actions.c.
| #define BUTTON_GPIO_NUM GPIO_NUM_5 |
GPIO number assigned to the hardware button.
Definition at line 24 of file button_actions.c.
Referenced by button_init().
| #define LOG_TAG "BUTTON" |
Logging tag for the button actions component.
Definition at line 10 of file button_actions.c.
| #define RESET_HOLD_TIME_MS 3000 |
Duration (ms) the button must be held for a reset trigger.
Definition at line 29 of file button_actions.c.
Referenced by button_init().
| esp_err_t button_init | ( | void | ) |
Initializes the hardware button configuration and event callbacks.
Configures the designated GPIO pin, sets up the debounce thresholds, and registers callbacks for both a single/double/triple short click
Definition at line 120 of file button_actions.c.
References BUTTON_GPIO_NUM, iot_button_double_click_cb(), iot_button_multiple_click_cb(), iot_button_single_click_cb(), LOGE, LOGI, RESET_HOLD_TIME_MS, and s_btn_handle.
Referenced by app_main().
| bool button_is_pressed | ( | void | ) |
Checks if the button is currently physically pressed.
Definition at line 163 of file button_actions.c.
References s_btn_handle.
Referenced by app_main().
|
static |
Executes the action compiled into the configuration for the triggered event.
This evaluates the current NVS/RAM configuration dynamically on every click, making it fully hot-swappable from the Web UI without registering callbacks.
| assigned_action | The configured action to execute. |
Definition at line 45 of file button_actions.c.
References APP_BUTTON_ACTION_NONE, APP_BUTTON_ACTION_REBOOT, APP_BUTTON_ACTION_TOGGLE_LED, config_get_led_brightness(), config_save(), config_set_led_brightness(), and LOGI.
Referenced by iot_button_double_click_cb(), iot_button_multiple_click_cb(), and iot_button_single_click_cb().
|
static |
Callback for double click events.
| arg | Pointer to the button handle (unused). |
| usr_data | User data passed during registration (unused). |
Definition at line 101 of file button_actions.c.
References APP_BUTTON_EVENT_DOUBLE_CLICK, config_get_button_action(), execute_button_action(), and LOGI.
Referenced by button_init().
|
static |
Callback for multiple click events.
| arg | Pointer to the button handle (unused). |
| usr_data | User data passed during registration (unused). |
Definition at line 112 of file button_actions.c.
References APP_BUTTON_EVENT_MULTIPLE_CLICK, config_get_button_action(), execute_button_action(), and LOGI.
Referenced by button_init().
|
static |
Callback for single click events.
| arg | Pointer to the button handle (unused). |
| usr_data | User data passed during registration (unused). |
Definition at line 90 of file button_actions.c.
References APP_BUTTON_EVENT_SINGLE_CLICK, config_get_button_action(), execute_button_action(), and LOGI.
Referenced by button_init().
|
static |
Internal handle for the IoT button instance.
Definition at line 34 of file button_actions.c.
Referenced by button_init(), and button_is_pressed().