From 73b98006c27a25842560a4256db903a3bb5007d5 Mon Sep 17 00:00:00 2001 From: Brian Whitman Date: Sun, 29 Sep 2024 12:54:55 -0400 Subject: [PATCH] Hopefully giving the GT911 more room to breathe on boot. --- amy | 2 +- tulip/esp32s3/gt911_touchscreen.c | 64 +++++++++++++++++-------------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/amy b/amy index a399bf966..91748c91f 160000 --- a/amy +++ b/amy @@ -1 +1 @@ -Subproject commit a399bf96675bfbcd3c7f60c173491bc22146ff15 +Subproject commit 91748c91fc4a51be28971cd61651223dc72893c2 diff --git a/tulip/esp32s3/gt911_touchscreen.c b/tulip/esp32s3/gt911_touchscreen.c index 26c8cb55d..8f5f0463f 100644 --- a/tulip/esp32s3/gt911_touchscreen.c +++ b/tulip/esp32s3/gt911_touchscreen.c @@ -91,48 +91,56 @@ void run_gt911(void *param) { gpio_config(&peri_gpio_config); gpio_set_level(TOUCH_RST, 0); - delay_ms(200); + delay_ms(500); gpio_set_level(TOUCH_RST, 1); - delay_ms(200); + delay_ms(500); gpio_set_level(TOUCH_RST, 0); - delay_ms(200); + delay_ms(500); gpio_set_level(TOUCH_RST, 1); - delay_ms(200); + delay_ms(500); #endif touch_init(0); uint8_t bytes[1] = {0}; esp_err_t err= i2c_master_write_to_device(I2C_NUM_0, 0x5D, bytes, 0, pdMS_TO_TICKS(10)); - fprintf(stderr, "\nerr for writing to 0x5D is %d %s\n", err, esp_err_to_name(err)); + if(err) fprintf(stderr, "\nerr for writing to 0x5D is %d %s\n", err, esp_err_to_name(err)); + uint8_t touchscreen_ok = 1; if(err != 0) { - fprintf(stderr, "falling back on 0x14 for touch\n"); + fprintf(stderr, "attempting to fall back on 0x14 for touch\n"); touch_init(1); err= i2c_master_write_to_device(I2C_NUM_0, 0x14, bytes, 0, pdMS_TO_TICKS(10)); - fprintf(stderr, "\nerr for writing to 0x14 is %d %s\n", err, esp_err_to_name(err)); + if(err) fprintf(stderr, "\nerr for writing to 0x14 is %d %s\n", err, esp_err_to_name(err)); + if(err != 0) { + // no touchscreen. probably not connected. + fprintf(stderr, "Touchscreen could not be booted. Please try fixing the cable and restarting.\n"); + touchscreen_ok = 0; + } } - while (1) { - esp_lcd_touch_read_data(tp); - if(esp_lcd_touch_get_coordinates(tp, touch_x, touch_y, touch_strength, &touch_cnt, 3)) { - //fprintf(stderr, "TP pressed %d,%d str %d count %d\n", touch_x[0], touch_y[0], touch_strength[0], touch_cnt); - for(uint8_t i=0;i