Makerfabs / ESP32-S3-Parallel-TFT-with-Touch-4inch

24 stars 11 forks source link

example/LvglWidgets: capacitive touch does not work upon power up #1

Open rajivk-slx opened 1 year ago

rajivk-slx commented 1 year ago

For the example at example/LvglWidgets, capacitive touch does not work upon power up, only after hitting the reset button, does the touch start working. This happens every time after power up. This issue does not occur with example/esp32s3_4.0_tft_fw_test. This looks like an issue with the sample code, could you assist in finding the issue.

rajivk-slx commented 1 year ago

Was able to fix the issue, by copying the following touch IC initialisation code from the default example. Could you kindly explain what this initialisation code does?

  pinMode(TOUCH_RST, OUTPUT);
  delay(100);
  digitalWrite(TOUCH_RST, LOW);
  delay(1000);
  digitalWrite(TOUCH_RST, HIGH);
  delay(1000);

  digitalWrite(TOUCH_RST, LOW);
  delay(1000);
  digitalWrite(TOUCH_RST, HIGH);
  delay(1000);

The datasheet at https://www.distec.de/fileadmin/pdf/produkte/Touchcontroller/DDGroup/GT911_Datasheet.pdf shows timing sequence for the following three actions. Not sure what the code above exactly does though. Would appreciate an explanation.

gpgreeff commented 1 year ago

Experienced the same issue. Thanks for mentioning it! The power-on timing diagram requires that the reset pin is toggled. There is a required time for it to be low, and then a delay time for it to be high again, before doing other things. But I don't think that is the reason why it works.

The following worked for me: GT911 stops after reset ESP32, by editing the touch.h:

// Begin init wire, and Reset the device also, no need wire.begin() to be done here
ts.begin(GT911_ADDR1);

// Need to solve floating INT pin so on reset changes between the 2 addresses
Wire.beginTransmission(GT911_ADDR1);
Wire.write(highByte(GT911_PRODUCT_ID));
Wire.write(lowByte(GT911_PRODUCT_ID));
Wire.endTransmission();
//returns rxLength - if 0 we have a problem
uint8_t returnSize = Wire.requestFrom(GT911_ADDR1, (uint8_t)1); 
if (returnSize == 0) {
  Serial.println("Setting address to ADDR2");
  // restart with other address
  ts.begin(GT911_ADDR2);
}

(note that the TAMC_GT911 library does toggle the reset pin in the reset function.)