Skip to content

Commit f63a083

Browse files
committed
feat(multi-touch): Add track ID API to the GT911 driver
1 parent bbd7863 commit f63a083

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -34,6 +34,7 @@ static const char *TAG = "GT911";
3434
*******************************************************************************/
3535
static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp);
3636
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);
37+
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);
3738
#if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0)
3839
static esp_err_t esp_lcd_touch_gt911_get_button_state(esp_lcd_touch_handle_t tp, uint8_t n, uint8_t *state);
3940
#endif
@@ -74,6 +75,7 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const
7475
/* Only supported callbacks are set */
7576
esp_lcd_touch_gt911->read_data = esp_lcd_touch_gt911_read_data;
7677
esp_lcd_touch_gt911->get_xy = esp_lcd_touch_gt911_get_xy;
78+
esp_lcd_touch_gt911->get_track_id = esp_lcd_touch_gt911_get_track_id;
7779
#if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0)
7880
esp_lcd_touch_gt911->get_button_state = esp_lcd_touch_gt911_get_button_state;
7981
#endif
@@ -277,6 +279,7 @@ static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp)
277279

278280
/* Fill all coordinates */
279281
for (i = 0; i < touch_cnt; i++) {
282+
tp->data.coords[i].track_id = buf[(i * 8) + 1];
280283
tp->data.coords[i].x = ((uint16_t)buf[(i * 8) + 3] << 8) + buf[(i * 8) + 2];
281284
tp->data.coords[i].y = (((uint16_t)buf[(i * 8) + 5] << 8) + buf[(i * 8) + 4]);
282285
tp->data.coords[i].strength = (((uint16_t)buf[(i * 8) + 7] << 8) + buf[(i * 8) + 6]);
@@ -315,6 +318,24 @@ static bool esp_lcd_touch_gt911_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, u
315318
return (*point_num > 0);
316319
}
317320

321+
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)
322+
{
323+
324+
assert(tp != NULL);
325+
assert(track_id != NULL);
326+
assert(max_point_num > 0);
327+
328+
portENTER_CRITICAL(&tp->data.lock);
329+
330+
for (int i = 0; i < max_point_num; i++) {
331+
track_id[i] = tp->data.coords[i].track_id;
332+
}
333+
334+
portEXIT_CRITICAL(&tp->data.lock);
335+
336+
return ESP_OK;
337+
}
338+
318339
#if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0)
319340
static esp_err_t esp_lcd_touch_gt911_get_button_state(esp_lcd_touch_handle_t tp, uint8_t n, uint8_t *state)
320341
{

components/lcd_touch/esp_lcd_touch_gt911/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.1.3"
1+
version: "1.1.4"
22
description: ESP LCD Touch GT911 - touch controller GT911
33
url: https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch_gt911
44
dependencies:

0 commit comments

Comments
 (0)