Chapter 2. API Reference
TOUCH_ELEM_DISP_CALLBACK
Callback dispatch.
TOUCH_ELEM_DISP_MAX
API Reference - Touch Button
Header File
•
components/touch_element/include/touch_element/touch_button.h
Functions
esp_err_t
touch_button_install(const
Touch Button initialize.
This function initializes touch button global and acts on all touch button instances.
Return
• ESP_OK: Successfully initialized touch button
• ESP_ERR_INVALID_STATE: Touch element library was not initialized
• ESP_ERR_INVALID_ARG: button_init is NULL
• ESP_ERR_NO_MEM: Insufficient memory
Parameters
• [in] global_config: Button object initialization configuration
void touch_button_uninstall(void)
Release resources allocated using touch_button_install()
esp_err_t
touch_button_create(const
Create a new touch button instance.
Note The sensitivity has to be explored in experiments, Sensitivity = (Raw(touch) - Raw(release)) /
Raw(release) * 100%
Return
• ESP_OK: Successfully create touch button
• ESP_ERR_INVALID_STATE: Touch button driver was not initialized
• ESP_ERR_NO_MEM: Insufficient memory
• ESP_ERR_INVALID_ARG: Invalid configuration struct or arguments is NULL
Parameters
• [in] button_config: Button configuration
• [out] button_handle: Button handle
esp_err_t touch_button_delete(touch_button_handle_t
Release resources allocated using touch_button_create()
Return
• ESP_OK: Successfully released resources
• ESP_ERR_INVALID_STATE: Touch button driver was not initialized
• ESP_ERR_INVALID_ARG: button_handle is null
• ESP_ERR_NOT_FOUND: Input handle is not a button handle
Parameters
• [in] button_handle: Button handle
esp_err_t touch_button_subscribe_event(touch_button_handle_t
Touch button subscribes event.
This function uses event mask to subscribe to touch button events, once one of the subscribed events occurs,
the event message could be retrieved by calling touch_element_message_receive() or input callback routine.
Note Touch button only support three kind of event masks, they are TOUCH_ELEM_EVENT_ON_PRESS,
TOUCH_ELEM_EVENT_ON_RELEASE, TOUCH_ELEM_EVENT_ON_LONGPRESS. You can
use those event masks in any combination to achieve the desired effect.
Espressif Systems
touch_button_global_config_t
touch_button_config_t
touch_button_handle_t
*button_handle)
button_handle)
event_mask, void *arg)
433
Submit Document Feedback
*global_config)
*button_config,
button_handle,
uint32_t
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?