|
1 | 1 | /* |
2 | | - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD |
| 2 | + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: Apache-2.0 |
5 | 5 | */ |
@@ -34,6 +34,7 @@ static const char *TAG = "GT911"; |
34 | 34 | *******************************************************************************/ |
35 | 35 | static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp); |
36 | 36 | 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); |
37 | 38 | #if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) |
38 | 39 | static esp_err_t esp_lcd_touch_gt911_get_button_state(esp_lcd_touch_handle_t tp, uint8_t n, uint8_t *state); |
39 | 40 | #endif |
@@ -74,6 +75,7 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const |
74 | 75 | /* Only supported callbacks are set */ |
75 | 76 | esp_lcd_touch_gt911->read_data = esp_lcd_touch_gt911_read_data; |
76 | 77 | 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; |
77 | 79 | #if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) |
78 | 80 | esp_lcd_touch_gt911->get_button_state = esp_lcd_touch_gt911_get_button_state; |
79 | 81 | #endif |
@@ -277,6 +279,7 @@ static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp) |
277 | 279 |
|
278 | 280 | /* Fill all coordinates */ |
279 | 281 | for (i = 0; i < touch_cnt; i++) { |
| 282 | + tp->data.coords[i].track_id = buf[(i * 8) + 1]; |
280 | 283 | tp->data.coords[i].x = ((uint16_t)buf[(i * 8) + 3] << 8) + buf[(i * 8) + 2]; |
281 | 284 | tp->data.coords[i].y = (((uint16_t)buf[(i * 8) + 5] << 8) + buf[(i * 8) + 4]); |
282 | 285 | 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 |
315 | 318 | return (*point_num > 0); |
316 | 319 | } |
317 | 320 |
|
| 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 | + |
318 | 339 | #if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0) |
319 | 340 | static esp_err_t esp_lcd_touch_gt911_get_button_state(esp_lcd_touch_handle_t tp, uint8_t n, uint8_t *state) |
320 | 341 | { |
|
0 commit comments