Chapter 2. API Reference
• ESP_ERR_INVALID_ARG: matrix_handle is null
• ESP_ERR_NOT_FOUND: Input handle is not a matrix handle
Parameters
• [in] matrix_handle: Matrix handle
esp_err_t touch_matrix_subscribe_event(touch_matrix_handle_t matrix_handle, uint32_t
event_mask, void *arg)
Touch matrix button subscribes event.
This function uses event mask to subscribe to touch matrix 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 matrix 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 combina-
tion to achieve the desired effect.
Return
• ESP_OK: Successfully subscribed touch matrix event
• ESP_ERR_INVALID_STATE: Touch matrix driver was not initialized
• ESP_ERR_INVALID_ARG: matrix_handle is null or event is not supported
Parameters
• [in] matrix_handle: Matrix handle
• [in] event_mask: Matrix subscription event mask
• [in] arg: User input argument
esp_err_t touch_matrix_set_dispatch_method(touch_matrix_handle_t matrix_handle,
touch_elem_dispatch_t dispatch_method)
Touch matrix button set dispatch method.
This function sets a dispatch method that the driver core will use this method as the event notification method.
Return
• ESP_OK: Successfully set dispatch method
• ESP_ERR_INVALID_STATE: Touch matrix driver was not initialized
• ESP_ERR_INVALID_ARG: matrix_handle is null or dispatch_method is invalid
Parameters
• [in] matrix_handle: Matrix button handle
• [in] dispatch_method: Dispatch method (By callback/event)
esp_err_t touch_matrix_set_callback(touch_matrix_handle_t matrix_handle,
touch_matrix_callback_t matrix_callback)
Touch matrix button set callback.
This function sets a callback routine into touch element driver core, when the subscribed events occur, the
callback routine will be called.
Note Matrix message will be passed from the callback function and it will be destroyed when the callback
function return.
Warning Since this input callback routine runs on driver core (esp-timer callback routine), it should not do
something that attempts to Block, such as calling vTaskDelay().
Return
• ESP_OK: Successfully set callback
• ESP_ERR_INVALID_STATE: Touch matrix driver was not initialized
• ESP_ERR_INVALID_ARG: matrix_handle or matrix_callback is null
Parameters
• [in] matrix_handle: Matrix button handle
• [in] matrix_callback: User input callback
esp_err_t touch_matrix_set_longpress(touch_matrix_handle_t matrix_handle, uint32_t thresh-
old_time)
Touch matrix button set long press trigger time.
This function sets the threshold time (ms) for a long press event. If a matrix button is pressed and held for a
period of time that exceeds the threshold time, a long press event is triggered.
Espressif Systems 440
Submit Document Feedback
Release v4.4