|
10 | 10 | #include "esp_lcd_touch.h" |
11 | 11 | #include "esp_lvgl_port.h" |
12 | 12 | #include "esp_timer.h" |
| 13 | +#include "sdkconfig.h" |
13 | 14 |
|
14 | 15 | static const char *TAG = "LVGL"; |
15 | 16 |
|
@@ -128,19 +129,19 @@ static void lvgl_port_touchpad_read(lv_indev_t *indev_drv, lv_indev_data_t *data |
128 | 129 | /* Read data from touch controller */ |
129 | 130 | bool touchpad_pressed = esp_lcd_touch_get_coordinates(touch_ctx->handle, touchpad_x, touchpad_y, NULL, &touchpad_cnt, CONFIG_ESP_LCD_TOUCH_MAX_POINTS); |
130 | 131 |
|
131 | | -#if (CONFIG_ESP_LCD_TOUCH_MAX_POINTS > 1 && CONFIG_LVGL_PORT_ENABLE_GESTURES) |
| 132 | +#if (CONFIG_ESP_LCD_TOUCH_MAX_POINTS > 1 && CONFIG_LV_USE_GESTURE_RECOGNITION) |
132 | 133 | // Number of touch points which need to be constantly updated inside gesture recognizers |
133 | 134 | #define GESTURE_TOUCH_POINTS 2 |
134 | 135 |
|
135 | 136 | uint8_t touchpad_track_id[CONFIG_ESP_LCD_TOUCH_MAX_POINTS] = {0}; |
136 | 137 |
|
137 | | - /* Read track IDs for TODO number of touch points*/ |
| 138 | + /* Read track IDs for first two touch points*/ |
138 | 139 | esp_err_t err = esp_lcd_touch_get_track_id(touch_ctx->handle, touchpad_track_id, GESTURE_TOUCH_POINTS); |
139 | 140 |
|
140 | 141 | /* Initialize LVGL touch data for each activated touch point */ |
141 | 142 | /* static */ lv_indev_touch_data_t touches[CONFIG_ESP_LCD_TOUCH_MAX_POINTS] = {0}; |
142 | 143 | if (err != ESP_ERR_NOT_SUPPORTED) { |
143 | | - for (int i = 0; i < touchpad_cnt; i++) { |
| 144 | + for (int i = 0; i < touchpad_cnt && i < CONFIG_ESP_LCD_TOUCH_MAX_POINTS; i++) { |
144 | 145 | touches[i].state = LV_INDEV_STATE_PRESSED; |
145 | 146 | touches[i].point.x = touchpad_x[i]; |
146 | 147 | touches[i].point.y = touchpad_y[i]; |
|
0 commit comments