#include <TouchScreen.h> // Biblioteca para o toque
TFT_eSPI tft = TFT_eSPI(); // Criar objeto TFT
TouchScreen ts = TouchScreen(); // Criar objeto TouchScreen
int currentColor = 0; // Variável para armazenar a cor atual
void setup() {
tft.init();
tft.setRotation(1); // Defina a orientação da tela
tft.fillScreen(TFT_BLACK); // Cor inicial da tela
}
void loop() {
TSPoint p = ts.getPoint(); // Ler ponto de toque
// Verifica se o ponto foi tocado
if (p.z > 100) { // Sensibilidade do toque
changeColor(); // Muda a cor
delay(500); // Debounce
}
}
void changeColor() {
// Muda a cor
if (currentColor == 0) {
tft.fillScreen(TFT_RED);
currentColor = 1;
} else if (currentColor == 1) {
tft.fillScreen(TFT_GREEN);
currentColor = 2;
} else if (currentColor == 2) {
tft.fillScreen(TFT_BLUE);
currentColor = 0;
}
}