Skip to content

Commit

Permalink
Update example
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Dec 24, 2024
1 parent a178d64 commit 6579d20
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion examples/CapacitiveTouch/CapacitiveTouch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,29 @@ void setup()
}
}
}
// Press the circular touch button on the screen to get the coordinate point,
// Press the circular touch button on the screen to get the coordinate point,
// and set it as the coordinate of the touch button
// T-Display-S3 CST816 touch panel, touch button coordinates are is 85 , 160
touch.setCenterButtonCoordinate(85, 360);

// Depending on the touch panel, not all touch panels have touch buttons.
touch.setHomeButtonCallback([](void *user_data) {
Serial.println("Home key pressed!");
static uint32_t checkMs = 0;
if (millis() > checkMs) {
if (digitalRead(TFT_BL)) {
digitalWrite(TFT_BL, LOW);
} else {
digitalWrite(TFT_BL, HIGH);
}
}
checkMs = millis() + 200;
}, NULL);

// If you poll the touch, you need to turn off the automatic sleep function, otherwise there will be an I2C access error.
// If you use the interrupt method, you don't need to turn it off, saving power consumption
touch.disableAutoSleep();

// tft.setSwapBytes(true);
tft.pushColors((uint16_t *)image, tft.width() * tft.height(), true);

Expand Down

0 comments on commit 6579d20

Please sign in to comment.