diff --git a/components/touch_element/include/touch_element/touch_button.h b/components/touch_element/include/touch_element/touch_button.h index c1543a7bfb..76bc971a72 100644 --- a/components/touch_element/include/touch_element/touch_button.h +++ b/components/touch_element/include/touch_element/touch_button.h @@ -61,7 +61,7 @@ typedef struct { } touch_button_message_t; typedef touch_elem_handle_t touch_button_handle_t; //!< Button handle -typedef void(*touch_button_callback_t)(touch_button_handle_t, touch_button_message_t, void *); //!< Button callback type +typedef void(*touch_button_callback_t)(touch_button_handle_t, touch_button_message_t *, void *); //!< Button callback type /** * @brief Touch Button initialize @@ -160,6 +160,8 @@ esp_err_t touch_button_set_dispatch_method(touch_button_handle_t button_handle, * @param[in] button_handle Button handle * @param[in] button_callback User input callback * + * @note Button 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(). * diff --git a/components/touch_element/include/touch_element/touch_matrix.h b/components/touch_element/include/touch_element/touch_matrix.h index 70173a0236..9c4359a8da 100644 --- a/components/touch_element/include/touch_element/touch_matrix.h +++ b/components/touch_element/include/touch_element/touch_matrix.h @@ -75,7 +75,7 @@ typedef struct { } touch_matrix_message_t; typedef touch_elem_handle_t touch_matrix_handle_t; //!< Matrix button instance handle -typedef void(*touch_matrix_callback_t)(touch_matrix_handle_t, touch_matrix_message_t, void *); //!< Matrix button callback type +typedef void(*touch_matrix_callback_t)(touch_matrix_handle_t, touch_matrix_message_t *, void *); //!< Matrix button callback type /** * @brief Touch matrix button initialize @@ -178,6 +178,8 @@ esp_err_t touch_matrix_set_dispatch_method(touch_matrix_handle_t matrix_handle, * @param[in] matrix_handle Matrix button handle * @param[in] matrix_callback User input callback * + * @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(). * diff --git a/components/touch_element/include/touch_element/touch_slider.h b/components/touch_element/include/touch_element/touch_slider.h index a10589c77f..8cf6f79daa 100644 --- a/components/touch_element/include/touch_element/touch_slider.h +++ b/components/touch_element/include/touch_element/touch_slider.h @@ -77,7 +77,7 @@ typedef struct { } touch_slider_message_t; typedef touch_elem_handle_t touch_slider_handle_t; //!< Slider instance handle -typedef void(*touch_slider_callback_t)(touch_slider_handle_t, touch_slider_message_t, void *); //!< Slider callback type +typedef void(*touch_slider_callback_t)(touch_slider_handle_t, touch_slider_message_t *, void *); //!< Slider callback type /** * @brief Touch slider initialize @@ -178,6 +178,8 @@ esp_err_t touch_slider_set_dispatch_method(touch_slider_handle_t slider_handle, * @param[in] slider_handle Slider handle * @param[in] slider_callback User input callback * + * @note Slider 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(). * diff --git a/components/touch_element/touch_button.c b/components/touch_element/touch_button.c index 9f89f6ad41..2ecceed198 100644 --- a/components/touch_element/touch_button.c +++ b/components/touch_element/touch_button.c @@ -347,7 +347,7 @@ static inline void button_dispatch(te_button_handle_t button_handle, touch_elem_ } else if (dispatch_method == TOUCH_ELEM_DISP_CALLBACK) { touch_button_message_t button_info; button_info.event = button_handle->event; - button_handle->config->callback(button_handle, button_info, button_handle->config->arg); //Event callback + button_handle->config->callback(button_handle, &button_info, button_handle->config->arg); //Event callback } } diff --git a/components/touch_element/touch_matrix.c b/components/touch_element/touch_matrix.c index cd8c8e3f10..89e24d126d 100644 --- a/components/touch_element/touch_matrix.c +++ b/components/touch_element/touch_matrix.c @@ -404,7 +404,7 @@ static inline void matrix_dispatch(te_matrix_handle_t matrix_handle, touch_elem_ matrix_info.event = matrix_handle->event; matrix_info.position = matrix_handle->position; void *arg = matrix_handle->config->arg; - matrix_handle->config->callback(matrix_handle, matrix_info, arg); //Event callback + matrix_handle->config->callback(matrix_handle, &matrix_info, arg); //Event callback } } diff --git a/components/touch_element/touch_slider.c b/components/touch_element/touch_slider.c index ff10b6da6f..3fba3a87af 100644 --- a/components/touch_element/touch_slider.c +++ b/components/touch_element/touch_slider.c @@ -406,7 +406,7 @@ static inline void slider_dispatch(te_slider_handle_t slider_handle, touch_elem_ slider_info.event = slider_handle->event; slider_info.position = slider_handle->position; void *arg = slider_handle->config->arg; - slider_handle->config->callback(slider_handle, slider_info, arg); //Event callback + slider_handle->config->callback(slider_handle, &slider_info, arg); //Event callback } } diff --git a/examples/peripherals/touch_element/touch_button/main/touch_button_example_main.c b/examples/peripherals/touch_element/touch_button/main/touch_button_example_main.c index 183ce9f78f..76285e7846 100644 --- a/examples/peripherals/touch_element/touch_button/main/touch_button_example_main.c +++ b/examples/peripherals/touch_element/touch_button/main/touch_button_example_main.c @@ -84,14 +84,14 @@ static void button_handler_task(void *arg) } #elif CONFIG_TOUCH_ELEM_CALLBACK /* Button callback routine */ -static void button_handler(touch_button_handle_t out_handle, touch_button_message_t out_message, void *arg) +static void button_handler(touch_button_handle_t out_handle, touch_button_message_t *out_message, void *arg) { (void) out_handle; //Unused - if (out_message.event == TOUCH_BUTTON_EVT_ON_PRESS) { + if (out_message->event == TOUCH_BUTTON_EVT_ON_PRESS) { ESP_LOGI(TAG, "Button[%d] Press", (uint32_t)arg); - } else if (out_message.event == TOUCH_BUTTON_EVT_ON_RELEASE) { + } else if (out_message->event == TOUCH_BUTTON_EVT_ON_RELEASE) { ESP_LOGI(TAG, "Button[%d] Release", (uint32_t)arg); - } else if (out_message.event == TOUCH_BUTTON_EVT_ON_LONGPRESS) { + } else if (out_message->event == TOUCH_BUTTON_EVT_ON_LONGPRESS) { ESP_LOGI(TAG, "Button[%d] LongPress", (uint32_t)arg); } } diff --git a/examples/peripherals/touch_element/touch_matrix/main/touch_matrix_example_main.c b/examples/peripherals/touch_element/touch_matrix/main/touch_matrix_example_main.c index 81d7c7730d..ec2dacc172 100644 --- a/examples/peripherals/touch_element/touch_matrix/main/touch_matrix_example_main.c +++ b/examples/peripherals/touch_element/touch_matrix/main/touch_matrix_example_main.c @@ -76,18 +76,18 @@ static void matrix_handler_task(void *arg) } #elif CONFIG_TOUCH_ELEM_CALLBACK /* Matrix callback routine */ -void matrix_handler(touch_matrix_handle_t out_handle, touch_matrix_message_t out_message, void *arg) +void matrix_handler(touch_matrix_handle_t out_handle, touch_matrix_message_t *out_message, void *arg) { (void) arg; //Unused if (out_handle != matrix_handle) { return; } - if (out_message.event == TOUCH_MATRIX_EVT_ON_PRESS) { - ESP_LOGI(TAG, "Matrix Press, axis: (%d, %d) index: %d", out_message.position.x_axis, out_message.position.y_axis, out_message.position.index); - } else if (out_message.event == TOUCH_MATRIX_EVT_ON_RELEASE) { - ESP_LOGI(TAG, "Matrix Release, axis: (%d, %d) index: %d", out_message.position.x_axis, out_message.position.y_axis, out_message.position.index); - } else if (out_message.event == TOUCH_MATRIX_EVT_ON_LONGPRESS) { - ESP_LOGI(TAG, "Matrix LongPress, axis: (%d, %d) index: %d", out_message.position.x_axis, out_message.position.y_axis, out_message.position.index); + if (out_message->event == TOUCH_MATRIX_EVT_ON_PRESS) { + ESP_LOGI(TAG, "Matrix Press, axis: (%d, %d) index: %d", out_message->position.x_axis, out_message->position.y_axis, out_message->position.index); + } else if (out_message->event == TOUCH_MATRIX_EVT_ON_RELEASE) { + ESP_LOGI(TAG, "Matrix Release, axis: (%d, %d) index: %d", out_message->position.x_axis, out_message->position.y_axis, out_message->position.index); + } else if (out_message->event == TOUCH_MATRIX_EVT_ON_LONGPRESS) { + ESP_LOGI(TAG, "Matrix LongPress, axis: (%d, %d) index: %d", out_message->position.x_axis, out_message->position.y_axis, out_message->position.index); } } #endif diff --git a/examples/peripherals/touch_element/touch_slider/main/touch_slider_example_main.c b/examples/peripherals/touch_element/touch_slider/main/touch_slider_example_main.c index 329543325a..fefe6e0832 100644 --- a/examples/peripherals/touch_element/touch_slider/main/touch_slider_example_main.c +++ b/examples/peripherals/touch_element/touch_slider/main/touch_slider_example_main.c @@ -70,18 +70,18 @@ static void slider_handler_task(void *arg) } #elif CONFIG_TOUCH_ELEM_CALLBACK /* Slider callback routine */ -void slider_handler(touch_slider_handle_t out_handle, touch_slider_message_t out_message, void *arg) +void slider_handler(touch_slider_handle_t out_handle, touch_slider_message_t *out_message, void *arg) { (void) arg; //Unused if (out_handle != slider_handle) { return; } - if (out_message.event == TOUCH_SLIDER_EVT_ON_PRESS) { - ESP_LOGI(TAG, "Slider Press, position: %d", out_message.position); - } else if (out_message.event == TOUCH_SLIDER_EVT_ON_RELEASE) { - ESP_LOGI(TAG, "Slider Release, position: %d", out_message.position); - } else if (out_message.event == TOUCH_SLIDER_EVT_ON_CALCULATION) { - ESP_LOGI(TAG, "Slider Calculate, position: %d", out_message.position); + if (out_message->event == TOUCH_SLIDER_EVT_ON_PRESS) { + ESP_LOGI(TAG, "Slider Press, position: %d", out_message->position); + } else if (out_message->event == TOUCH_SLIDER_EVT_ON_RELEASE) { + ESP_LOGI(TAG, "Slider Release, position: %d", out_message->position); + } else if (out_message->event == TOUCH_SLIDER_EVT_ON_CALCULATION) { + ESP_LOGI(TAG, "Slider Calculate, position: %d", out_message->position); } } #endif