Skip to content

Commit

Permalink
[TouchDrvGT911] Fixed the problem that GT911 interrupt fails when RST…
Browse files Browse the repository at this point in the history
… pin is not connected
  • Loading branch information
lewisxhe committed Sep 11, 2024
1 parent ab80439 commit 3f3c8e0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/TouchDrvGT911.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


#if defined(ARDUINO_ARCH_NRF52)
// NRF52840 I2C BUFFER : 64 Bytes ,
// NRF52840 I2C BUFFER : 64 Bytes ,
#warning "NRF Platform I2C Buffer expansion is not implemented , GT911 requires at least 188 bytes to read all configurations"
#endif

Expand Down Expand Up @@ -138,8 +138,14 @@ class TouchDrvGT911 :
if (__irq != SENSOR_PIN_NONE) {
this->setGpioMode(__irq, INPUT);
}
/*
* If you perform a software reset on a board without a reset pin connected,
* subsequent interrupt settings or re-writing of configurations will be invalid.
* For example, when debugging a LilyGo T-Deck, resetting the interrupt mode will
* be invalid after a software reset.
* */
// writeRegister(GT911_COMMAND, 0x02);
writeCommand(0x02);
// writeCommand(0x02);
}

void sleep()
Expand Down Expand Up @@ -464,7 +470,7 @@ class TouchDrvGT911 :
void dumpRegister()
{
size_t output_size = 0;
uint8_t *buffer = loadConfig(&output_size);
uint8_t *buffer = loadConfig(&output_size, true);
if (output_size == 0) {
return;
}
Expand All @@ -486,6 +492,12 @@ class TouchDrvGT911 :
reloadConfig();
}

uint8_t getMaxTouchPoint()
{
uint8_t num = readGT911(GT911_TOUCH_NUMBER);
return num & 0x0F;
}

private:

uint8_t readGT911(uint16_t cmd)
Expand Down Expand Up @@ -546,6 +558,8 @@ class TouchDrvGT911 :
// Reset Config
reset();

this->setGpioMode(__irq, INPUT);

} else if (__addr == GT911_SLAVE_ADDRESS_H &&
__rst != SENSOR_PIN_NONE &&
__irq != SENSOR_PIN_NONE) {
Expand Down Expand Up @@ -595,6 +609,7 @@ class TouchDrvGT911 :
log_i("Resolution : X = %d Y = %d", x, y);
log_i("Vendor id:%d", getVendorID());
log_i("Refresh Rate:%d ms", getRefreshRate());
log_i("MaxTouchPoint:%d", getMaxTouchPoint());

/*
* For the ESP32 platform, the default buffer is 128.
Expand Down

0 comments on commit 3f3c8e0

Please sign in to comment.