From b5f2df0f4bfffc3cd5bb3d96afba13861558395c Mon Sep 17 00:00:00 2001 From: Petr Opravil Date: Fri, 21 Nov 2025 09:42:00 +0100 Subject: [PATCH 1/6] feat(multi-touch): Multi-touch gestures in display example --- examples/display/main/lvgl_demo_ui.c | 82 +++++++++++++++++++++++- examples/display/main/main.c | 6 +- examples/display/sdkconfig.bsp.esp-box-3 | 3 + 3 files changed, 89 insertions(+), 2 deletions(-) diff --git a/examples/display/main/lvgl_demo_ui.c b/examples/display/main/lvgl_demo_ui.c index 9eb6da102..8081dd619 100644 --- a/examples/display/main/lvgl_demo_ui.c +++ b/examples/display/main/lvgl_demo_ui.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: CC0-1.0 */ @@ -29,6 +29,82 @@ static lv_color_t arc_color[] = { LV_COLOR_MAKE(90, 202, 228), }; +#if (CONFIG_ESP_LCD_TOUCH_MAX_POINTS > 1 && CONFIG_LV_USE_GESTURE_RECOGNITION) +void gesture_cb(lv_event_t *e) +{ + static uint32_t logo_scale = LV_SCALE_NONE; + static int32_t logo_rotation = 0; + static int32_t logo_offset_x = 0; + static int32_t logo_offset_y = 0; + + lv_indev_gesture_type_t type = lv_event_get_gesture_type(e); + lv_indev_gesture_state_t state = lv_event_get_gesture_state(e, type); + + if (state == LV_INDEV_GESTURE_STATE_RECOGNIZED || state == LV_INDEV_GESTURE_STATE_ENDED) { + switch (type) { + case LV_INDEV_GESTURE_PINCH: + // Read current pinch scale and convert it from float to image scale + uint32_t pinch_scale_rel = lv_event_get_pinch_scale(e) * LV_SCALE_NONE; + // Cutoff negative results at 0 + uint32_t pinch_scale_abs = logo_scale + pinch_scale_rel < LV_SCALE_NONE ? 0 : logo_scale + ((int32_t)pinch_scale_rel - LV_SCALE_NONE); + lv_img_set_zoom(img_logo, pinch_scale_abs); + // Save the resulting image scale after the gesture ends + if (state == LV_INDEV_GESTURE_STATE_ENDED) { + logo_scale = pinch_scale_abs; + } + break; + case LV_INDEV_GESTURE_ROTATE: + // Get gesture rotation in degrees + int32_t rotation_rel = lv_event_get_rotation(e) * (180.0f / M_PI) * 10.0f; + // Calculate resulting angle and limit it to 360 degrees + int32_t rotation_abs = (logo_rotation + rotation_rel) % 3600; + lv_img_set_angle(img_logo, rotation_abs); + // Save the resulting image rotation angle after the gesture ends + if (state == LV_INDEV_GESTURE_STATE_ENDED) { + logo_rotation = rotation_abs; + } + break; + case LV_INDEV_GESTURE_TWO_FINGERS_SWIPE: + // Get two finger swipe values + lv_dir_t swipe_dir = lv_event_get_two_fingers_swipe_dir(e); + float swipe_dist = lv_event_get_two_fingers_swipe_distance(e); + int32_t swipe_dist_abs; + switch (swipe_dir) { + case LV_DIR_BOTTOM: + case LV_DIR_TOP: + // Vertical offset sign depends on the swipe direction + swipe_dist_abs = swipe_dir == LV_DIR_TOP ? + logo_offset_y - swipe_dist : + logo_offset_y + swipe_dist; + lv_obj_set_pos(img_logo, logo_offset_x, swipe_dist_abs); + // Save the resulting vertical image offset after the gesture ends + if (state == LV_INDEV_GESTURE_STATE_ENDED) { + logo_offset_y = swipe_dist_abs; + } + break; + case LV_DIR_RIGHT: + case LV_DIR_LEFT: + // Horizontal offset sign depends on the swipe direction + swipe_dist_abs = swipe_dir == LV_DIR_LEFT ? + logo_offset_x - swipe_dist : + logo_offset_x + swipe_dist; + lv_obj_set_pos(img_logo, swipe_dist_abs, logo_offset_y); + // Save the resulting horizontal image offset after the gesture ends + if (state == LV_INDEV_GESTURE_STATE_ENDED) { + logo_offset_x = swipe_dist_abs; + } + break; + default: + break; + } + break; + default: + break; + } + } +} +#endif + static void anim_timer_cb(lv_timer_t *timer) { my_timer_context_t *timer_ctx = (my_timer_context_t *) lv_timer_get_user_data(timer); @@ -81,6 +157,10 @@ void example_lvgl_demo_ui(lv_obj_t *scr) lv_img_set_src(img_logo, &esp_logo); lv_obj_center(img_logo); +#if (CONFIG_ESP_LCD_TOUCH_MAX_POINTS > 1 && CONFIG_LV_USE_GESTURE_RECOGNITION) + lv_obj_add_event_cb(scr, gesture_cb, LV_EVENT_GESTURE, NULL); +#endif + // Create arcs for (size_t i = 0; i < sizeof(arc) / sizeof(arc[0]); i++) { arc[i] = lv_arc_create(scr); diff --git a/examples/display/main/main.c b/examples/display/main/main.c index b627b4467..988be55cb 100644 --- a/examples/display/main/main.c +++ b/examples/display/main/main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: CC0-1.0 */ @@ -25,6 +25,10 @@ void app_main(void) ESP_LOGI("example", "Display LVGL animation"); bsp_display_lock(0); lv_obj_t *scr = lv_disp_get_scr_act(NULL); +#if (CONFIG_ESP_LCD_TOUCH_MAX_POINTS > 1 && CONFIG_LV_USE_GESTURE_RECOGNITION) + lv_indev_t *indev = bsp_display_get_input_dev(); + lv_indev_set_rotation_rad_threshold(indev, 0.15f); +#endif example_lvgl_demo_ui(scr); bsp_display_unlock(); diff --git a/examples/display/sdkconfig.bsp.esp-box-3 b/examples/display/sdkconfig.bsp.esp-box-3 index db225300a..ca2aa2439 100644 --- a/examples/display/sdkconfig.bsp.esp-box-3 +++ b/examples/display/sdkconfig.bsp.esp-box-3 @@ -25,3 +25,6 @@ CONFIG_LV_USE_PERF_MONITOR=y # CONFIG_LV_MEM_CUSTOM=y # CONFIG_LV_MEMCPY_MEMSET_STD=y # CONFIG_LV_SPRINTF_CUSTOM=y + +CONFIG_LV_USE_FLOAT=y +CONFIG_LV_USE_GESTURE_RECOGNITION=y From a5634c6b163f3b5151b2395ed4e57b23d46ec4c4 Mon Sep 17 00:00:00 2001 From: Petr Opravil Date: Fri, 28 Nov 2025 08:48:50 +0100 Subject: [PATCH 2/6] feat(multi-touch): Add multi-touch gestures to LVGL port --- components/esp_lvgl_port/CHANGELOG.md | 6 +++ components/esp_lvgl_port/README.md | 16 ++++++++ components/esp_lvgl_port/idf_component.yml | 2 +- .../src/lvgl9/esp_lvgl_port_touch.c | 38 +++++++++++++++---- 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/components/esp_lvgl_port/CHANGELOG.md b/components/esp_lvgl_port/CHANGELOG.md index 2a3972477..e1da573e4 100644 --- a/components/esp_lvgl_port/CHANGELOG.md +++ b/components/esp_lvgl_port/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 2.7.0 + +### Features + +- Added support for multi-touch gestures. + ## 2.6.3 ### Fixes diff --git a/components/esp_lvgl_port/README.md b/components/esp_lvgl_port/README.md index cbdff862e..2dc05739a 100644 --- a/components/esp_lvgl_port/README.md +++ b/components/esp_lvgl_port/README.md @@ -275,6 +275,22 @@ Display rotation can be changed at runtime. > [!NOTE] > During the hardware rotating, the component call [`esp_lcd`](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/lcd.html) API. When using software rotation, you cannot use neither `direct_mode` nor `full_refresh` in the driver. See [LVGL documentation](https://docs.lvgl.io/8.3/porting/display.html?highlight=sw_rotate) for more info. +### Detecting gestures + +LVGL (version 9.4 and higher) includes support for software detection of multi-touch gestures. +This detection can be enabled by setting the `LVGL_PORT_ENABLE_GESTURES` config and having `ESP_LCD_TOUCH_MAX_POINTS` > 1. +Example usage of the gesture callback can be found in LVGL [documentation](https://docs.lvgl.io/master/details/main-modules/indev/gestures.html). + +The LVGL port task is responsible for passing the touch coordinates to the gesture recognizers and calling the registered callback when a gesture is detected. + +To correctly distinguish two finger swipe from rotation, we recommend changing the default value (which is 0) for the rotation threshold. +From our testing we recommend starting with 0.15 radians. + +``` + lv_indev_t indev = bsp_display_get_input_dev(); + lv_indev_set_rotation_rad_threshold(indev, 0.15f); +``` + ### Using PSRAM canvas If the SRAM is insufficient, you can use the PSRAM as a canvas and use a small trans_buffer to carry it, this makes drawing more efficient. diff --git a/components/esp_lvgl_port/idf_component.yml b/components/esp_lvgl_port/idf_component.yml index 931fab405..8f6461df5 100644 --- a/components/esp_lvgl_port/idf_component.yml +++ b/components/esp_lvgl_port/idf_component.yml @@ -1,4 +1,4 @@ -version: "2.6.3" +version: "2.7.0" description: ESP LVGL port url: https://github.com/espressif/esp-bsp/tree/master/components/esp_lvgl_port dependencies: diff --git a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_touch.c b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_touch.c index 58e985edf..5b0893c29 100644 --- a/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_touch.c +++ b/components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_touch.c @@ -9,6 +9,8 @@ #include "esp_check.h" #include "esp_lcd_touch.h" #include "esp_lvgl_port.h" +#include "esp_timer.h" +#include "sdkconfig.h" static const char *TAG = "LVGL"; @@ -117,19 +119,39 @@ static void lvgl_port_touchpad_read(lv_indev_t *indev_drv, lv_indev_data_t *data assert(touch_ctx); assert(touch_ctx->handle); - uint16_t touchpad_x[1] = {0}; - uint16_t touchpad_y[1] = {0}; - uint8_t touchpad_cnt = 0; + uint8_t touch_cnt = 0; + esp_lcd_touch_point_data_t touch_data[CONFIG_ESP_LCD_TOUCH_MAX_POINTS] = {0}; /* Read data from touch controller into memory */ - esp_lcd_touch_read_data(touch_ctx->handle); + ESP_ERROR_CHECK(esp_lcd_touch_read_data(touch_ctx->handle)); /* Read data from touch controller */ - bool touchpad_pressed = esp_lcd_touch_get_coordinates(touch_ctx->handle, touchpad_x, touchpad_y, NULL, &touchpad_cnt, 1); + ESP_ERROR_CHECK(esp_lcd_touch_get_data(touch_ctx->handle, touch_data, &touch_cnt, CONFIG_ESP_LCD_TOUCH_MAX_POINTS)); - if (touchpad_pressed && touchpad_cnt > 0) { - data->point.x = touch_ctx->scale.x * touchpad_x[0]; - data->point.y = touch_ctx->scale.y * touchpad_y[0]; +#if (CONFIG_ESP_LCD_TOUCH_MAX_POINTS > 1 && CONFIG_LV_USE_GESTURE_RECOGNITION) + // Number of touch points which need to be constantly updated inside gesture recognizers +#define GESTURE_TOUCH_POINTS 2 + + /* Initialize LVGL touch data for each activated touch point */ + lv_indev_touch_data_t touches[GESTURE_TOUCH_POINTS] = {0}; + + for (int i = 0; i < touch_cnt && i < GESTURE_TOUCH_POINTS; i++) { + touches[i].state = LV_INDEV_STATE_PRESSED; + touches[i].point.x = touch_ctx->scale.x * touch_data[i].x; + touches[i].point.y = touch_ctx->scale.y * touch_data[i].y; + touches[i].id = touch_data[i].track_id; + touches[i].timestamp = esp_timer_get_time() / 1000; + } + + /* Pass touch data to LVGL gesture recognizers */ + lv_indev_gesture_recognizers_update(indev_drv, touches, GESTURE_TOUCH_POINTS); + lv_indev_gesture_recognizers_set_data(indev_drv, data); + +#endif + + if (touch_cnt > 0) { + data->point.x = touch_ctx->scale.x * touch_data[0].x; + data->point.y = touch_ctx->scale.y * touch_data[0].y; data->state = LV_INDEV_STATE_PRESSED; } else { data->state = LV_INDEV_STATE_RELEASED; From e3ed08eab3ce475c45a9bf6d2cf1e4055b844341 Mon Sep 17 00:00:00 2001 From: Petr Opravil Date: Fri, 28 Nov 2025 11:04:27 +0100 Subject: [PATCH 3/6] feat(multi-touch): Add track id reading to GT911 driver --- .../lcd_touch/esp_lcd_touch_gt911/README.md | 8 +-- .../esp_lcd_touch_gt911/esp_lcd_touch_gt911.c | 68 ++++++++++++------- .../esp_lcd_touch_gt911/idf_component.yml | 4 +- 3 files changed, 49 insertions(+), 31 deletions(-) diff --git a/components/lcd_touch/esp_lcd_touch_gt911/README.md b/components/lcd_touch/esp_lcd_touch_gt911/README.md index 820cb47a9..6d5373ba9 100644 --- a/components/lcd_touch/esp_lcd_touch_gt911/README.md +++ b/components/lcd_touch/esp_lcd_touch_gt911/README.md @@ -56,13 +56,11 @@ Read data from the touch controller and store it in RAM memory. It should be cal esp_lcd_touch_read_data(tp); ``` -Get one X and Y coordinates with strength of touch. +Get attributes of a single touch point. ``` - uint16_t touch_x[1]; - uint16_t touch_y[1]; - uint16_t touch_strength[1]; + esp_lcd_touch_point_data_t touch_point_data[1]; uint8_t touch_cnt = 0; - bool touchpad_pressed = esp_lcd_touch_get_coordinates(tp, touch_x, touch_y, touch_strength, &touch_cnt, 1); + ESP_ERROR_CHECK(esp_lcd_touch_get_data(tp, touch_point_data, &touch_cnt, 1)); ``` diff --git a/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c b/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c index cb1a44149..00dc5a59b 100644 --- a/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c +++ b/components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -34,6 +34,7 @@ static const char *TAG = "GT911"; *******************************************************************************/ static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp); static bool esp_lcd_touch_gt911_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num); +static esp_err_t esp_lcd_touch_gt911_get_track_id(esp_lcd_touch_handle_t tp, uint8_t *track_id, uint8_t point_num); #if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) static esp_err_t esp_lcd_touch_gt911_get_button_state(esp_lcd_touch_handle_t tp, uint8_t n, uint8_t *state); #endif @@ -60,9 +61,9 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const { esp_err_t ret = ESP_OK; - assert(io != NULL); - assert(config != NULL); - assert(out_touch != NULL); + ESP_RETURN_ON_FALSE(io != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch panel handler pointer can't be NULL"); + ESP_RETURN_ON_FALSE(config != NULL, ESP_ERR_INVALID_ARG, TAG, "Config pointer can't be NULL"); + ESP_RETURN_ON_FALSE(out_touch != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch handler pointer can't be NULL"); /* Prepare main structure */ esp_lcd_touch_handle_t esp_lcd_touch_gt911 = heap_caps_calloc(1, sizeof(esp_lcd_touch_t), MALLOC_CAP_DEFAULT); @@ -74,6 +75,7 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const /* Only supported callbacks are set */ esp_lcd_touch_gt911->read_data = esp_lcd_touch_gt911_read_data; esp_lcd_touch_gt911->get_xy = esp_lcd_touch_gt911_get_xy; + esp_lcd_touch_gt911->get_track_id = esp_lcd_touch_gt911_get_track_id; #if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) esp_lcd_touch_gt911->get_button_state = esp_lcd_touch_gt911_get_button_state; #endif @@ -214,7 +216,7 @@ static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp) uint8_t clear = 0; size_t i = 0; - assert(tp != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler pointer can't be NULL"); err = touch_gt911_i2c_read(tp, ESP_LCD_TOUCH_GT911_READ_XY_REG, buf, 1); ESP_RETURN_ON_ERROR(err, TAG, "I2C read error!"); @@ -277,9 +279,10 @@ static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp) /* Fill all coordinates */ for (i = 0; i < touch_cnt; i++) { - tp->data.coords[i].x = ((uint16_t)buf[(i * 8) + 3] << 8) + buf[(i * 8) + 2]; - tp->data.coords[i].y = (((uint16_t)buf[(i * 8) + 5] << 8) + buf[(i * 8) + 4]); - tp->data.coords[i].strength = (((uint16_t)buf[(i * 8) + 7] << 8) + buf[(i * 8) + 6]); + tp->data.points_data[i].track_id = buf[(i * 8) + 1]; + tp->data.points_data[i].x = ((uint16_t)buf[(i * 8) + 3] << 8) + buf[(i * 8) + 2]; + tp->data.points_data[i].y = (((uint16_t)buf[(i * 8) + 5] << 8) + buf[(i * 8) + 4]); + tp->data.points_data[i].strength = (((uint16_t)buf[(i * 8) + 7] << 8) + buf[(i * 8) + 6]); } portEXIT_CRITICAL(&tp->data.lock); @@ -290,11 +293,11 @@ static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp) static bool esp_lcd_touch_gt911_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num) { - assert(tp != NULL); - assert(x != NULL); - assert(y != NULL); - assert(point_num != NULL); - assert(max_point_num > 0); + ESP_RETURN_ON_FALSE(tp != NULL, false, TAG, "Touch point handler pointer can't be NULL"); + ESP_RETURN_ON_FALSE(x != NULL, false, TAG, "Data array pointer can't be NULL"); + ESP_RETURN_ON_FALSE(y != NULL, false, TAG, "Data array pointer can't be NULL"); + ESP_RETURN_ON_FALSE(point_num != NULL, false, TAG, "Pointer to number of touch points can't be NULL"); + ESP_RETURN_ON_FALSE(max_point_num > 0, false, TAG, "Array size must be at least 1"); portENTER_CRITICAL(&tp->data.lock); @@ -302,11 +305,11 @@ static bool esp_lcd_touch_gt911_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, u *point_num = (tp->data.points > max_point_num ? max_point_num : tp->data.points); for (size_t i = 0; i < *point_num; i++) { - x[i] = tp->data.coords[i].x; - y[i] = tp->data.coords[i].y; + x[i] = tp->data.points_data[i].x; + y[i] = tp->data.points_data[i].y; if (strength) { - strength[i] = tp->data.coords[i].strength; + strength[i] = tp->data.points_data[i].strength; } } @@ -315,12 +318,29 @@ static bool esp_lcd_touch_gt911_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, u return (*point_num > 0); } +static esp_err_t esp_lcd_touch_gt911_get_track_id(esp_lcd_touch_handle_t tp, uint8_t *track_id, uint8_t max_point_num) +{ + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler pointer can't be NULL"); + ESP_RETURN_ON_FALSE(track_id != NULL, ESP_ERR_INVALID_ARG, TAG, "Track ID array pointer can't be NULL"); + ESP_RETURN_ON_FALSE(max_point_num > 0, ESP_ERR_INVALID_ARG, TAG, "Array size must be at least 1"); + + portENTER_CRITICAL(&tp->data.lock); + + for (int i = 0; i < max_point_num; i++) { + track_id[i] = tp->data.points_data[i].track_id; + } + + portEXIT_CRITICAL(&tp->data.lock); + + return ESP_OK; +} + #if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) static esp_err_t esp_lcd_touch_gt911_get_button_state(esp_lcd_touch_handle_t tp, uint8_t n, uint8_t *state) { esp_err_t err = ESP_OK; - assert(tp != NULL); - assert(state != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler pointer can't be NULL"); + ESP_RETURN_ON_FALSE(state != NULL, ESP_ERR_INVALID_ARG, TAG, "State array pointer can't be NULL"); *state = 0; @@ -340,7 +360,7 @@ static esp_err_t esp_lcd_touch_gt911_get_button_state(esp_lcd_touch_handle_t tp, static esp_err_t esp_lcd_touch_gt911_del(esp_lcd_touch_handle_t tp) { - assert(tp != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler pointer can't be NULL"); /* Reset GPIO pin settings */ if (tp->config.int_gpio_num != GPIO_NUM_NC) { @@ -367,7 +387,7 @@ static esp_err_t esp_lcd_touch_gt911_del(esp_lcd_touch_handle_t tp) /* Reset controller */ static esp_err_t touch_gt911_reset(esp_lcd_touch_handle_t tp) { - assert(tp != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler pointer can't be NULL"); if (tp->config.rst_gpio_num != GPIO_NUM_NC) { ESP_RETURN_ON_ERROR(gpio_set_level(tp->config.rst_gpio_num, tp->config.levels.reset), TAG, "GPIO set level error!"); @@ -383,7 +403,7 @@ static esp_err_t touch_gt911_read_cfg(esp_lcd_touch_handle_t tp) { uint8_t buf[4]; - assert(tp != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler pointer can't be NULL"); ESP_RETURN_ON_ERROR(touch_gt911_i2c_read(tp, ESP_LCD_TOUCH_GT911_PRODUCT_ID_REG, (uint8_t *)&buf[0], 3), TAG, "GT911 read error!"); ESP_RETURN_ON_ERROR(touch_gt911_i2c_read(tp, ESP_LCD_TOUCH_GT911_CONFIG_REG, (uint8_t *)&buf[3], 1), TAG, "GT911 read error!"); @@ -396,8 +416,8 @@ static esp_err_t touch_gt911_read_cfg(esp_lcd_touch_handle_t tp) static esp_err_t touch_gt911_i2c_read(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t *data, uint8_t len) { - assert(tp != NULL); - assert(data != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler pointer can't be NULL"); + ESP_RETURN_ON_FALSE(data != NULL, ESP_ERR_INVALID_ARG, TAG, "Data array pointer can't be NULL"); /* Read data */ return esp_lcd_panel_io_rx_param(tp->io, reg, data, len); @@ -405,7 +425,7 @@ static esp_err_t touch_gt911_i2c_read(esp_lcd_touch_handle_t tp, uint16_t reg, u static esp_err_t touch_gt911_i2c_write(esp_lcd_touch_handle_t tp, uint16_t reg, uint8_t data) { - assert(tp != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler pointer can't be NULL"); // *INDENT-OFF* /* Write data */ diff --git a/components/lcd_touch/esp_lcd_touch_gt911/idf_component.yml b/components/lcd_touch/esp_lcd_touch_gt911/idf_component.yml index 6895ccd47..0454f994f 100644 --- a/components/lcd_touch/esp_lcd_touch_gt911/idf_component.yml +++ b/components/lcd_touch/esp_lcd_touch_gt911/idf_component.yml @@ -1,9 +1,9 @@ -version: "1.1.3" +version: "1.2.0" description: ESP LCD Touch GT911 - touch controller GT911 url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch_gt911 dependencies: idf: ">=4.4.2" esp_lcd_touch: - version: "^1.1.0" + version: "^1.2.0" public: true override_path: ../esp_lcd_touch From ab346fcb29ee24c42deaf65a6802073ffdb76e0d Mon Sep 17 00:00:00 2001 From: Petr Opravil Date: Fri, 28 Nov 2025 11:15:56 +0100 Subject: [PATCH 4/6] feat(multi-touch): Add get_data API to esp_lcd_touch --- .../lcd_touch/esp_lcd_touch/esp_lcd_touch.c | 113 ++++++++++++++---- .../lcd_touch/esp_lcd_touch/idf_component.yml | 2 +- .../esp_lcd_touch/include/esp_lcd_touch.h | 45 +++++-- 3 files changed, 130 insertions(+), 30 deletions(-) diff --git a/components/lcd_touch/esp_lcd_touch/esp_lcd_touch.c b/components/lcd_touch/esp_lcd_touch/esp_lcd_touch.c index 2e6034f7c..83462df2b 100644 --- a/components/lcd_touch/esp_lcd_touch/esp_lcd_touch.c +++ b/components/lcd_touch/esp_lcd_touch/esp_lcd_touch.c @@ -1,10 +1,11 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/gpio.h" @@ -30,7 +31,8 @@ static const char *TAG = "TP"; esp_err_t esp_lcd_touch_enter_sleep(esp_lcd_touch_handle_t tp) { - assert(tp != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL"); + if (tp->enter_sleep == NULL) { ESP_LOGE(TAG, "Sleep mode not supported!"); return ESP_FAIL; @@ -41,7 +43,8 @@ esp_err_t esp_lcd_touch_enter_sleep(esp_lcd_touch_handle_t tp) esp_err_t esp_lcd_touch_exit_sleep(esp_lcd_touch_handle_t tp) { - assert(tp != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL"); + if (tp->exit_sleep == NULL) { ESP_LOGE(TAG, "Sleep mode not supported!"); return ESP_FAIL; @@ -52,7 +55,7 @@ esp_err_t esp_lcd_touch_exit_sleep(esp_lcd_touch_handle_t tp) esp_err_t esp_lcd_touch_read_data(esp_lcd_touch_handle_t tp) { - assert(tp != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL"); assert(tp->read_data != NULL); return tp->read_data(tp); @@ -62,10 +65,10 @@ bool esp_lcd_touch_get_coordinates(esp_lcd_touch_handle_t tp, uint16_t *x, uint1 { bool touched = false; - assert(tp != NULL); - assert(x != NULL); - assert(y != NULL); - assert(tp->get_xy != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, false, TAG, "Touch point handler can't be NULL"); + ESP_RETURN_ON_FALSE(x != NULL, false, TAG, "X coordinates data array can't be NULL"); + ESP_RETURN_ON_FALSE(y != NULL, false, TAG, "Y coordinates data array can't be NULL"); + ESP_RETURN_ON_FALSE(tp->get_xy != NULL, false, TAG, "Touch driver must be initialized"); touched = tp->get_xy(tp, x, y, strength, point_num, max_point_num); if (!touched) { @@ -106,11 +109,79 @@ bool esp_lcd_touch_get_coordinates(esp_lcd_touch_handle_t tp, uint16_t *x, uint1 return touched; } +esp_err_t esp_lcd_touch_get_data(esp_lcd_touch_handle_t tp, esp_lcd_touch_point_data_t *data, uint8_t *point_cnt, uint8_t max_point_cnt) +{ + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL"); + ESP_RETURN_ON_FALSE(data != NULL, ESP_ERR_INVALID_ARG, TAG, "Data array can't be NULL"); + ESP_RETURN_ON_FALSE(tp->get_xy != NULL, ESP_ERR_INVALID_STATE, TAG, "Touch driver must be initialized"); + + uint16_t x[max_point_cnt]; + uint16_t y[max_point_cnt]; + uint16_t strength[max_point_cnt]; + uint8_t track_id[max_point_cnt]; + + bool touched = tp->get_xy(tp, x, y, strength, point_cnt, max_point_cnt); + + if (!touched) { + return ESP_OK; + } + + /* Process coordinates by user */ + if (tp->config.process_coordinates != NULL) { + tp->config.process_coordinates(tp, x, y, strength, point_cnt, max_point_cnt); + } + + /* Software coordinates adjustment needed */ + bool sw_adj_needed = ((tp->config.flags.mirror_x && (tp->set_mirror_x == NULL)) || + (tp->config.flags.mirror_y && (tp->set_mirror_y == NULL)) || + (tp->config.flags.swap_xy && (tp->set_swap_xy == NULL))); + + /* Adjust all coordinates */ + for (int i = 0; (sw_adj_needed && i < *point_cnt); i++) { + + /* Mirror X coordinates (if not supported by HW) */ + if (tp->config.flags.mirror_x && tp->set_mirror_x == NULL) { + x[i] = tp->config.x_max - x[i]; + } + + /* Mirror Y coordinates (if not supported by HW) */ + if (tp->config.flags.mirror_y && tp->set_mirror_y == NULL) { + y[i] = tp->config.y_max - y[i]; + } + + /* Swap X and Y coordinates (if not supported by HW) */ + if (tp->config.flags.swap_xy && tp->set_swap_xy == NULL) { + uint16_t tmp = x[i]; + x[i] = y[i]; + y[i] = tmp; + } + } + + /* Process read track IDs */ + if (tp->get_track_id != NULL && touched) { + tp->get_track_id(tp, track_id, *point_cnt); + } + + /* Initialize the struct array since some features might not be available */ + memset(data, 0, sizeof(esp_lcd_touch_point_data_t) * max_point_cnt); + + for (int i = 0; i < *point_cnt; i++) { + data[i].x = x[i]; + data[i].y = y[i]; + data[i].strength = strength[i]; + if (tp->get_track_id != NULL) { + data[i].track_id = track_id[i]; + } + } + + return ESP_OK; +} + #if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) esp_err_t esp_lcd_touch_get_button_state(esp_lcd_touch_handle_t tp, uint8_t n, uint8_t *state) { - assert(tp != NULL); - assert(state != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL"); + ESP_RETURN_ON_FALSE(state != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to an argument can't be NULL"); *state = 0; @@ -140,8 +211,8 @@ esp_err_t esp_lcd_touch_set_swap_xy(esp_lcd_touch_handle_t tp, bool swap) esp_err_t esp_lcd_touch_get_swap_xy(esp_lcd_touch_handle_t tp, bool *swap) { - assert(tp != NULL); - assert(swap != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL"); + ESP_RETURN_ON_FALSE(swap != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to an argument can't be NULL"); /* Is swap supported by HW? */ if (tp->get_swap_xy) { @@ -155,7 +226,7 @@ esp_err_t esp_lcd_touch_get_swap_xy(esp_lcd_touch_handle_t tp, bool *swap) esp_err_t esp_lcd_touch_set_mirror_x(esp_lcd_touch_handle_t tp, bool mirror) { - assert(tp != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL"); tp->config.flags.mirror_x = mirror; @@ -169,8 +240,8 @@ esp_err_t esp_lcd_touch_set_mirror_x(esp_lcd_touch_handle_t tp, bool mirror) esp_err_t esp_lcd_touch_get_mirror_x(esp_lcd_touch_handle_t tp, bool *mirror) { - assert(tp != NULL); - assert(mirror != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL"); + ESP_RETURN_ON_FALSE(mirror != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to an argument can't be NULL"); /* Is swap supported by HW? */ if (tp->get_mirror_x) { @@ -184,7 +255,7 @@ esp_err_t esp_lcd_touch_get_mirror_x(esp_lcd_touch_handle_t tp, bool *mirror) esp_err_t esp_lcd_touch_set_mirror_y(esp_lcd_touch_handle_t tp, bool mirror) { - assert(tp != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL"); tp->config.flags.mirror_y = mirror; @@ -198,8 +269,8 @@ esp_err_t esp_lcd_touch_set_mirror_y(esp_lcd_touch_handle_t tp, bool mirror) esp_err_t esp_lcd_touch_get_mirror_y(esp_lcd_touch_handle_t tp, bool *mirror) { - assert(tp != NULL); - assert(mirror != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL"); + ESP_RETURN_ON_FALSE(mirror != NULL, ESP_ERR_INVALID_ARG, TAG, "Pointer to an argument can't be NULL"); /* Is swap supported by HW? */ if (tp->get_mirror_y) { @@ -213,7 +284,7 @@ esp_err_t esp_lcd_touch_get_mirror_y(esp_lcd_touch_handle_t tp, bool *mirror) esp_err_t esp_lcd_touch_del(esp_lcd_touch_handle_t tp) { - assert(tp != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL"); if (tp->del != NULL) { return tp->del(tp); @@ -225,7 +296,7 @@ esp_err_t esp_lcd_touch_del(esp_lcd_touch_handle_t tp) esp_err_t esp_lcd_touch_register_interrupt_callback(esp_lcd_touch_handle_t tp, esp_lcd_touch_interrupt_callback_t callback) { esp_err_t ret = ESP_OK; - assert(tp != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL"); /* Interrupt pin is not selected */ if (tp->config.int_gpio_num == GPIO_NUM_NC) { @@ -259,7 +330,7 @@ esp_err_t esp_lcd_touch_register_interrupt_callback(esp_lcd_touch_handle_t tp, e esp_err_t esp_lcd_touch_register_interrupt_callback_with_data(esp_lcd_touch_handle_t tp, esp_lcd_touch_interrupt_callback_t callback, void *user_data) { - assert(tp != NULL); + ESP_RETURN_ON_FALSE(tp != NULL, ESP_ERR_INVALID_ARG, TAG, "Touch point handler can't be NULL"); tp->config.user_data = user_data; return esp_lcd_touch_register_interrupt_callback(tp, callback); diff --git a/components/lcd_touch/esp_lcd_touch/idf_component.yml b/components/lcd_touch/esp_lcd_touch/idf_component.yml index 2441f18f1..a0f2be72c 100644 --- a/components/lcd_touch/esp_lcd_touch/idf_component.yml +++ b/components/lcd_touch/esp_lcd_touch/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.1.2" +version: "1.2.0" description: ESP LCD Touch - main component for using touch screen controllers url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch dependencies: diff --git a/components/lcd_touch/esp_lcd_touch/include/esp_lcd_touch.h b/components/lcd_touch/esp_lcd_touch/include/esp_lcd_touch.h index d0b267632..13560c1d2 100644 --- a/components/lcd_touch/esp_lcd_touch/include/esp_lcd_touch.h +++ b/components/lcd_touch/esp_lcd_touch/include/esp_lcd_touch.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -69,13 +69,15 @@ typedef struct { } esp_lcd_touch_config_t; typedef struct { - uint8_t points; /*!< Count of touch points saved */ + uint8_t track_id; + uint16_t x; /*!< X coordinate */ + uint16_t y; /*!< Y coordinate */ + uint16_t strength; /*!< Strength */ +} esp_lcd_touch_point_data_t; - struct { - uint16_t x; /*!< X coordinate */ - uint16_t y; /*!< Y coordinate */ - uint16_t strength; /*!< Strength */ - } coords[CONFIG_ESP_LCD_TOUCH_MAX_POINTS]; +typedef struct { + uint8_t points; /*!< Count of touch points saved */ + esp_lcd_touch_point_data_t points_data[CONFIG_ESP_LCD_TOUCH_MAX_POINTS]; #if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) uint8_t buttons; /*!< Count of buttons states saved */ @@ -145,6 +147,18 @@ struct esp_lcd_touch_s { */ bool (*get_xy)(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num); + /** + * @brief Get track ids of touch points + * + * @param tp: Touch handler + * @param track_id: Array of track ids + * @param point_num: Count of touched points to return + * + * @return + * - ESP_OK on success, otherwise returns ESP_ERR_xxx + */ + esp_err_t (*get_track_id)(esp_lcd_touch_handle_t tp, uint8_t *track_id, uint8_t point_num); + #if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) /** @@ -271,6 +285,21 @@ struct esp_lcd_touch_s { */ esp_err_t esp_lcd_touch_read_data(esp_lcd_touch_handle_t tp); +/** + * @brief Get each touch point data from touch controller + * + * @param tp: Touch handler + * @param data: Array of data structures to be filled out + * @param point_cnt: Count of points touched (equals with count of items in x and y array) + * @param max_point_cnt: Maximum count of touched points to return (equals with max size of x and y array) + * + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_ERR_INVALID_STATE if parameter is uninitialized + */ +esp_err_t esp_lcd_touch_get_data(esp_lcd_touch_handle_t tp, esp_lcd_touch_point_data_t *data, uint8_t *point_cnt, uint8_t max_point_cnt); + /** * @brief Read coordinates from touch controller * @@ -284,9 +313,9 @@ esp_err_t esp_lcd_touch_read_data(esp_lcd_touch_handle_t tp); * @return * - Returns true, when touched and coordinates readed. Otherwise returns false. */ +[[deprecated("This API will be removed in version 2.0.0. Use esp_lcd_touch_get_data instead!")]] bool esp_lcd_touch_get_coordinates(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num); - #if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) /** * @brief Get button state From 545dd1bf33382942a2deb41e8c6a8d49c6ce4ead Mon Sep 17 00:00:00 2001 From: Petr Opravil Date: Fri, 28 Nov 2025 14:09:13 +0100 Subject: [PATCH 5/6] feat(multi-touch): Fix overriding path of touch controller for m5dial --- bsp/m5dial/README.md | 46 ++++++++++++++++++------------------ bsp/m5dial/idf_component.yml | 4 +++- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/bsp/m5dial/README.md b/bsp/m5dial/README.md index da90e20b1..0e7170c98 100644 --- a/bsp/m5dial/README.md +++ b/bsp/m5dial/README.md @@ -69,30 +69,30 @@ M5Dial provides versatile power supply options to cater to various needs. It acc ## LVGL Benchmark -**DATE:** 01.10.2025 13:12 +**DATE:** 07.11.2025 09:03 -**LVGL version:** 9.3.0 +**LVGL version:** 9.4.0 | Name | Avg. CPU | Avg. FPS | Avg. time | render time | flush time | | ---- | :------: | :------: | :-------: | :---------: | :--------: | -| Empty screen | 96% | 37 | 23 | 6 | 17 | -| Moving wallpaper | 98% | 38 | 23 | 11 | 12 | -| Single rectangle | 32% | 97 | 1 | 0 | 1 | -| Multiple rectangles | 90% | 59 | 13 | 10 | 3 | -| Multiple RGB images | 40% | 94 | 1 | 1 | 0 | -| Multiple ARGB images | 35% | 90 | 4 | 4 | 0 | -| Rotated ARGB images | 81% | 57 | 16 | 16 | 0 | -| Multiple labels | 70% | 94 | 4 | 2 | 2 | -| Screen sized text | 98% | 23 | 40 | 39 | 1 | -| Multiple arcs | 23% | 90 | 0 | 0 | 0 | -| Containers | 42% | 83 | 13 | 9 | 4 | -| Containers with overlay | 97% | 32 | 27 | 21 | 6 | -| Containers with opa | 51% | 78 | 16 | 12 | 4 | -| Containers with opa_layer | 55% | 73 | 20 | 17 | 3 | -| Containers with scrolling | 98% | 32 | 28 | 22 | 6 | -| Widgets demo | 99% | 26 | 20 | 18 | 2 | -| All scenes avg. | 69% | 62 | 14 | 11 | 3 | - - - - +| Empty screen | 96% | 38 | 22 | 6 | 16 | +| Moving wallpaper | 97% | 38 | 23 | 11 | 12 | +| Single rectangle | 37% | 97 | 1 | 0 | 1 | +| Multiple rectangles | 92% | 59 | 12 | 9 | 3 | +| Multiple RGB images | 33% | 89 | 1 | 1 | 0 | +| Multiple ARGB images | 34% | 93 | 4 | 4 | 0 | +| Rotated ARGB images | 81% | 56 | 17 | 16 | 1 | +| Multiple labels | 57% | 90 | 6 | 5 | 1 | +| Screen sized text | 97% | 23 | 41 | 39 | 2 | +| Multiple arcs | 32% | 89 | 1 | 1 | 0 | +| Containers | 37% | 80 | 14 | 9 | 5 | +| Containers with overlay | 90% | 32 | 28 | 22 | 6 | +| Containers with opa | 51% | 76 | 17 | 13 | 4 | +| Containers with opa_layer | 50% | 70 | 20 | 18 | 2 | +| Containers with scrolling | 97% | 31 | 30 | 25 | 5 | +| Widgets demo | 99% | 26 | 21 | 20 | 1 | +| All scenes avg. | 67% | 61 | 15 | 12 | 3 | + + + + \ No newline at end of file diff --git a/bsp/m5dial/idf_component.yml b/bsp/m5dial/idf_component.yml index 6b63fbeec..6640a5b07 100644 --- a/bsp/m5dial/idf_component.yml +++ b/bsp/m5dial/idf_component.yml @@ -11,7 +11,9 @@ tags: dependencies: idf: ">=5.3" # We use I2C Driver-NG from IDF v5.2 but esp-codec-dev supports from v5.3 - esp_lcd_touch_ft5x06: "^1" + esp_lcd_touch_ft5x06: + version: "^1" + override_path: "../../components/lcd_touch/esp_lcd_touch_ft5x06" espressif/esp_lcd_gc9a01: version: "^2" From 6b0dd5978e1e39f4bf8b1d745af46d79c9252f1f Mon Sep 17 00:00:00 2001 From: Petr Opravil Date: Fri, 28 Nov 2025 14:14:36 +0100 Subject: [PATCH 6/6] feat(multi-touch): Update touch drivers to the latest lcd_touch --- .../esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c | 10 +++++----- .../esp_lcd_touch_cst816s/idf_component.yml | 2 +- .../esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c | 12 ++++++------ .../esp_lcd_touch_ft5x06/idf_component.yml | 2 +- .../esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c | 14 +++++++------- .../esp_lcd_touch_gt1151/idf_component.yml | 2 +- .../esp_lcd_touch_stmpe610.c | 14 +++++++------- .../esp_lcd_touch_stmpe610/idf_component.yml | 2 +- .../esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c | 12 ++++++------ .../esp_lcd_touch_tt21100/idf_component.yml | 2 +- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/components/lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c b/components/lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c index d363529f4..aac4b0ef7 100644 --- a/components/lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c +++ b/components/lcd_touch/esp_lcd_touch_cst816s/esp_lcd_touch_cst816s.c @@ -116,8 +116,8 @@ static esp_err_t read_data(esp_lcd_touch_handle_t tp) tp->data.points = point.num; /* Fill all coordinates */ for (int i = 0; i < point.num; i++) { - tp->data.coords[i].x = point.x_h << 8 | point.x_l; - tp->data.coords[i].y = point.y_h << 8 | point.y_l; + tp->data.points_data[i].x = point.x_h << 8 | point.x_l; + tp->data.points_data[i].y = point.y_h << 8 | point.y_l; } portEXIT_CRITICAL(&tp->data.lock); @@ -130,11 +130,11 @@ static bool get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t /* Count of points */ *point_num = (tp->data.points > max_point_num ? max_point_num : tp->data.points); for (size_t i = 0; i < *point_num; i++) { - x[i] = tp->data.coords[i].x; - y[i] = tp->data.coords[i].y; + x[i] = tp->data.points_data[i].x; + y[i] = tp->data.points_data[i].y; if (strength) { - strength[i] = tp->data.coords[i].strength; + strength[i] = tp->data.points_data[i].strength; } } /* Invalidate */ diff --git a/components/lcd_touch/esp_lcd_touch_cst816s/idf_component.yml b/components/lcd_touch/esp_lcd_touch_cst816s/idf_component.yml index 9b2be0317..73c206c42 100644 --- a/components/lcd_touch/esp_lcd_touch_cst816s/idf_component.yml +++ b/components/lcd_touch/esp_lcd_touch_cst816s/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.1.0" +version: "1.1.1" description: ESP LCD Touch CST816S - touch controller CST816S url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch_cst816s dependencies: diff --git a/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c b/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c index ff10a5df0..8ab5fc049 100644 --- a/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c +++ b/components/lcd_touch/esp_lcd_touch_ft5x06/esp_lcd_touch_ft5x06.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -195,8 +195,8 @@ static esp_err_t esp_lcd_touch_ft5x06_read_data(esp_lcd_touch_handle_t tp) /* Fill all coordinates */ for (i = 0; i < points; i++) { - tp->data.coords[i].x = (((uint16_t)data[(i * 6) + 0] & 0x0f) << 8) + data[(i * 6) + 1]; - tp->data.coords[i].y = (((uint16_t)data[(i * 6) + 2] & 0x0f) << 8) + data[(i * 6) + 3]; + tp->data.points_data[i].x = (((uint16_t)data[(i * 6) + 0] & 0x0f) << 8) + data[(i * 6) + 1]; + tp->data.points_data[i].y = (((uint16_t)data[(i * 6) + 2] & 0x0f) << 8) + data[(i * 6) + 3]; } portEXIT_CRITICAL(&tp->data.lock); @@ -218,11 +218,11 @@ static bool esp_lcd_touch_ft5x06_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, *point_num = (tp->data.points > max_point_num ? max_point_num : tp->data.points); for (size_t i = 0; i < *point_num; i++) { - x[i] = tp->data.coords[i].x; - y[i] = tp->data.coords[i].y; + x[i] = tp->data.points_data[i].x; + y[i] = tp->data.points_data[i].y; if (strength) { - strength[i] = tp->data.coords[i].strength; + strength[i] = tp->data.points_data[i].strength; } } diff --git a/components/lcd_touch/esp_lcd_touch_ft5x06/idf_component.yml b/components/lcd_touch/esp_lcd_touch_ft5x06/idf_component.yml index c30c4e444..571504bef 100644 --- a/components/lcd_touch/esp_lcd_touch_ft5x06/idf_component.yml +++ b/components/lcd_touch/esp_lcd_touch_ft5x06/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.0.7" +version: "1.0.8" description: ESP LCD Touch FT5x06 - touch controller FT5x06 url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch_ft5x06 dependencies: diff --git a/components/lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c b/components/lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c index 24fecf8fb..b1e3b2415 100644 --- a/components/lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c +++ b/components/lcd_touch/esp_lcd_touch_gt1151/esp_lcd_touch_gt1151.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -143,9 +143,9 @@ static esp_err_t read_data(esp_lcd_touch_handle_t tp) /* Fill all coordinates */ for (int i = 0; i < touch_cnt; i++) { - tp->data.coords[i].x = touch_report->touch_record[i].x; - tp->data.coords[i].y = touch_report->touch_record[i].y; - tp->data.coords[i].strength = touch_report->touch_record[i].strength; + tp->data.points_data[i].x = touch_report->touch_record[i].x; + tp->data.points_data[i].y = touch_report->touch_record[i].y; + tp->data.points_data[i].strength = touch_report->touch_record[i].strength; } portEXIT_CRITICAL(&tp->data.lock); @@ -158,11 +158,11 @@ static bool get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, uint16_t *y, uint16_t /* Count of points */ *point_num = (tp->data.points > max_point_num ? max_point_num : tp->data.points); for (size_t i = 0; i < *point_num; i++) { - x[i] = tp->data.coords[i].x; - y[i] = tp->data.coords[i].y; + x[i] = tp->data.points_data[i].x; + y[i] = tp->data.points_data[i].y; if (strength) { - strength[i] = tp->data.coords[i].strength; + strength[i] = tp->data.points_data[i].strength; } } /* Invalidate */ diff --git a/components/lcd_touch/esp_lcd_touch_gt1151/idf_component.yml b/components/lcd_touch/esp_lcd_touch_gt1151/idf_component.yml index 92a474521..7f8ca31a4 100644 --- a/components/lcd_touch/esp_lcd_touch_gt1151/idf_component.yml +++ b/components/lcd_touch/esp_lcd_touch_gt1151/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.0.5~2" +version: "1.0.6" description: ESP LCD Touch GT1151 - touch controller GT1151 url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch_gt1151 dependencies: diff --git a/components/lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c b/components/lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c index 429faebf3..ef89d8be5 100644 --- a/components/lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c +++ b/components/lcd_touch/esp_lcd_touch_stmpe610/esp_lcd_touch_stmpe610.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -200,9 +200,9 @@ static esp_err_t esp_lcd_touch_stmpe610_read_data(esp_lcd_touch_handle_t tp) ESP_RETURN_ON_ERROR(touch_stmpe610_write(tp, ESP_LCD_TOUCH_STMPE610_REG_INT_STA, 0xFF), TAG, "STMPE610 write error!"); portENTER_CRITICAL(&tp->data.lock); - tp->data.coords[0].x = data_convert(x / cnt, 150, 3800, 0, tp->config.x_max); - tp->data.coords[0].y = data_convert(y / cnt, 150, 3800, 0, tp->config.y_max); - tp->data.coords[0].strength = z / cnt; + tp->data.points_data[0].x = data_convert(x / cnt, 150, 3800, 0, tp->config.x_max); + tp->data.points_data[0].y = data_convert(y / cnt, 150, 3800, 0, tp->config.y_max); + tp->data.points_data[0].strength = z / cnt; tp->data.points = 1; portEXIT_CRITICAL(&tp->data.lock); @@ -223,11 +223,11 @@ static bool esp_lcd_touch_stmpe610_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x *point_num = (tp->data.points > max_point_num ? max_point_num : tp->data.points); for (size_t i = 0; i < *point_num; i++) { - x[i] = tp->data.coords[i].x; - y[i] = tp->data.coords[i].y; + x[i] = tp->data.points_data[i].x; + y[i] = tp->data.points_data[i].y; if (strength) { - strength[i] = tp->data.coords[i].strength; + strength[i] = tp->data.points_data[i].strength; } } diff --git a/components/lcd_touch/esp_lcd_touch_stmpe610/idf_component.yml b/components/lcd_touch/esp_lcd_touch_stmpe610/idf_component.yml index 4e8f7e126..849ac4dfb 100644 --- a/components/lcd_touch/esp_lcd_touch_stmpe610/idf_component.yml +++ b/components/lcd_touch/esp_lcd_touch_stmpe610/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.0.7" +version: "1.0.8" description: ESP LCD Touch STMPE610 - touch controller STMPE610 url: https://github.com/espressif/esp-bsp/tree/master/components/esp_lcd_touch_stmpe610 dependencies: diff --git a/components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c b/components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c index 2b4c12410..1fe9b3077 100644 --- a/components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c +++ b/components/lcd_touch/esp_lcd_touch_tt21100/esp_lcd_touch_tt21100.c @@ -237,9 +237,9 @@ static esp_err_t esp_lcd_touch_tt21100_read_data(esp_lcd_touch_handle_t tp) for (i = 0; i < tp_num; i++) { p_touch_data = &p_report_data->touch_record[i]; - tp->data.coords[i].x = p_touch_data->x; - tp->data.coords[i].y = p_touch_data->y; - tp->data.coords[i].strength = p_touch_data->pressure; + tp->data.points_data[i].x = p_touch_data->x; + tp->data.points_data[i].y = p_touch_data->y; + tp->data.points_data[i].strength = p_touch_data->pressure; } portEXIT_CRITICAL(&tp->data.lock); @@ -268,11 +268,11 @@ static bool esp_lcd_touch_tt21100_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, *point_num = (tp->data.points > max_point_num ? max_point_num : tp->data.points); for (size_t i = 0; i < *point_num; i++) { - x[i] = tp->data.coords[i].x; - y[i] = tp->data.coords[i].y; + x[i] = tp->data.points_data[i].x; + y[i] = tp->data.points_data[i].y; if (strength) { - strength[i] = tp->data.coords[i].strength; + strength[i] = tp->data.points_data[i].strength; } } diff --git a/components/lcd_touch/esp_lcd_touch_tt21100/idf_component.yml b/components/lcd_touch/esp_lcd_touch_tt21100/idf_component.yml index b4027e8b0..0a59593e1 100644 --- a/components/lcd_touch/esp_lcd_touch_tt21100/idf_component.yml +++ b/components/lcd_touch/esp_lcd_touch_tt21100/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.1.1" +version: "1.1.2" description: ESP LCD Touch TT21100 - touch controller TT21100 url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch_tt21100 dependencies: