Skip to content

Commit d0b7610

Browse files
authored
fix(gt911): Fix flickering when GT911 has no data to read
Fix flickering when GT911 has no data to read Points should only get cleared on successfully read operations. Before this patch, the touch driver reported no touch, when in fact there was touch but the GT911 was not ready to report data.
1 parent 740a580 commit d0b7610

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

components/lcd_touch/esp_lcd_touch_gt911/esp_lcd_touch_gt911.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,15 @@ static esp_err_t esp_lcd_touch_gt911_read_data(esp_lcd_touch_handle_t tp)
245245
portEXIT_CRITICAL(&tp->data.lock);
246246
#endif
247247
} else if ((buf[0] & 0x80) == 0x80) {
248-
#if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0)
249248
portENTER_CRITICAL(&tp->data.lock);
249+
/* Invalidate */
250+
tp->data.points = 0;
251+
#if (CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS > 0)
250252
for (i = 0; i < CONFIG_ESP_LCD_TOUCH_MAX_BUTTONS; i++) {
251253
tp->data.button[i].status = 0;
252254
}
253-
portEXIT_CRITICAL(&tp->data.lock);
254255
#endif
256+
portEXIT_CRITICAL(&tp->data.lock);
255257
/* Count of touched points */
256258
touch_cnt = buf[0] & 0x0f;
257259
if (touch_cnt > 5 || touch_cnt == 0) {
@@ -308,9 +310,6 @@ static bool esp_lcd_touch_gt911_get_xy(esp_lcd_touch_handle_t tp, uint16_t *x, u
308310
}
309311
}
310312

311-
/* Invalidate */
312-
tp->data.points = 0;
313-
314313
portEXIT_CRITICAL(&tp->data.lock);
315314

316315
return (*point_num > 0);

0 commit comments

Comments
 (0)