Skip to content

Commit

Permalink
[TouchDrvGT911] Fix the problem of too large delay in Arduino ESP cau…
Browse files Browse the repository at this point in the history
…sing it to not initialize correctly
  • Loading branch information
lewisxhe committed Dec 6, 2024
1 parent f9120b1 commit a7eb492
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/TouchDrvGT911.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,13 +604,24 @@ class TouchDrvGT911 :
this->setGpioLevel(__irq, HIGH);
delayMicroseconds(120);
this->setGpioLevel(__rst, HIGH);

#if defined(ARDUINO)
// In the Arduino ESP32 platform, the test delay is 8ms and the GT911
// can be accessed correctly. If the time is too long, it will not be accessible.
delay(8);
#elif defined(ESP_PLATFORM)
// For the variant of GPIO extended RST,
// communication and delay are carried out simultaneously, and 18 ms is measured in T-RGB esp-idf new api
delay(18);
#endif

this->setGpioMode(__irq, INPUT);

} else if (__addr == GT911_SLAVE_ADDRESS_L &&
__rst != SENSOR_PIN_NONE &&
__irq != SENSOR_PIN_NONE) {


log_i("GT911 using 0xBA address!");

this->setGpioMode(__rst, OUTPUT);
Expand All @@ -620,7 +631,15 @@ class TouchDrvGT911 :
this->setGpioLevel(__irq, LOW);
delayMicroseconds(120);
this->setGpioLevel(__rst, HIGH);
#if defined(ARDUINO)
// In the Arduino ESP32 platform, the test delay is 8ms and the GT911
// can be accessed correctly. If the time is too long, it will not be accessible.
delay(8);
#elif defined(ESP_PLATFORM)
// For the variant of GPIO extended RST,
// communication and delay are carried out simultaneously, and 18 ms is measured in T-RGB esp-idf new api
delay(18);
#endif
this->setGpioMode(__irq, INPUT);

}
Expand Down

0 comments on commit a7eb492

Please sign in to comment.