Open HowardAtHome opened 1 year ago
you saved my I suspected something like that with randomly working touch screen. Would you be able to do a PR to fix?
I can do that but I need to be sure @TAMCTec will allow the PR to be merged with increased version release?
also you can avoid changing this library code just adding after ts.init() in your main code
// Begin init wire, and Reset the device also, no need wire.begin() to be done here
//Wire.begin(TOUCH_GT911_SDA, TOUCH_GT911_SCL);
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);
}
// Now do your normal job
ts.setRotation(TOUCH_GT911_ROTATION);
checkCorrectAddr
When to call this function ?
After much frustration I have finally worked out the problem and solution.
The GT911 really needs the INT pin connected, this is used to set the I2C address of the chip on bootup, then can be used to drive interrupt driven touch. On my board this is not connected and floats, hence randomly changes between the 2 addresses on bootup.
Easy to sort in the TAMC_GT911.cpp. In the reset () add delay(50); checkCorrectAddr (); readBlockData(configBuf, GT911_CONFIG_START, GT911_CONFIG_SIZE);
Then create a new routine
void TAMC_GT911::checkCorrectAddr(void) { //Need to solve floating INT pin so on reset changes between the 2 addresses uint8_t returnSize; Wire.beginTransmission(addr); Wire.write(highByte(GT911_PRODUCT_ID)); Wire.write(lowByte(GT911_PRODUCT_ID)); Wire.endTransmission(); returnSize = Wire.requestFrom(addr, (uint8_t)1); //returns rxLength - if 0 we have a problem if (returnSize == 0) { addr = GT911_ADDR2; Serial.println ("setting address to ADDR2"); } }