Skip to content

Commit

Permalink
Fixed GT911 return val
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Sep 28, 2023
1 parent bbd9807 commit 29e2199
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 2 additions & 4 deletions examples/TouchDrv_GT911_GetPoint/TouchDrv_GT911_GetPoint.ino
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void setup()

touch.setPins(SENSOR_RST, SENSOR_IRQ);

if (!touch.init(Wire, SENSOR_SDA, SENSOR_SCL, GT911_SLAVE_ADDRESS_L )) {
if (!touch.init(Wire, SENSOR_SDA, SENSOR_SCL, GT911_SLAVE_ADDRESS_H )) {
while (1) {
Serial.println("Failed to find GT911 - check your wiring!");
delay(1000);
Expand All @@ -77,9 +77,7 @@ void setup()
void loop()
{
if (touch.isPressed()) {
uint8_t point = touch.getPoint(x, y, 5);
Serial.print("Point:"); Serial.println(point);
uint8_t touched = touch.getPoint(x, y, 2);
uint8_t touched = touch.getPoint(x, y, touch.getSupportTouchPoint());
for (int i = 0; i < touched; ++i) {
Serial.print("X[");
Serial.print(i);
Expand Down
11 changes: 8 additions & 3 deletions src/TouchDrvGT911.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ class TouchDrvGT911 :

void reset()
{
if (__rst != SENSOR_PIN_NONE) {
setRstPinMode(OUTPUT);
setRstValue(HIGH);
delay(10);
}
writeRegister(GT911_COMMAND, 0x02);
}

Expand Down Expand Up @@ -174,11 +179,11 @@ class TouchDrvGT911 :
uint8_t buffer[39];

if (!x_array || !y_array || size == 0)
return DEV_WIRE_ERR;
return 0;

int touchPoint = readRegister(GT911_POINT_INFO);
if (touchPoint == DEV_WIRE_ERR) {
return DEV_WIRE_ERR;
return 0;
}

touchPoint &= 0x0F;
Expand All @@ -189,7 +194,7 @@ class TouchDrvGT911 :
clearBuffer();

if (readRegister(GT911_POINT_1, buffer, 39) == DEV_WIRE_ERR) {
return DEV_WIRE_ERR;
return 0;
}


Expand Down

0 comments on commit 29e2199

Please sign in to comment.