42 lines
880 B
C++
42 lines
880 B
C++
#include <TFT_eSPI.h>
|
|
#include <SPI.h>
|
|
|
|
TFT_eSPI tft = TFT_eSPI();
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
delay(1000);
|
|
|
|
// Turn on backlight
|
|
pinMode(27, OUTPUT);
|
|
digitalWrite(27, HIGH);
|
|
|
|
tft.init();
|
|
tft.setRotation(1); // Landscape
|
|
|
|
// Cycle colors to confirm display works
|
|
uint16_t colors[] = {TFT_RED, TFT_GREEN, TFT_BLUE, TFT_WHITE};
|
|
const char* names[] = {"RED", "GREEN", "BLUE", "WHITE"};
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
tft.fillScreen(colors[i]);
|
|
Serial.printf("Screen: %s\n", names[i]);
|
|
delay(1000);
|
|
}
|
|
|
|
tft.fillScreen(TFT_BLACK);
|
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
|
tft.setTextSize(3);
|
|
tft.drawString("Hello ESP32-32E!", 30, 100);
|
|
Serial.println("Display initialized!");
|
|
}
|
|
|
|
void loop() {
|
|
uint16_t x, y;
|
|
if (tft.getTouch(&x, &y)) {
|
|
Serial.printf("Touch: %d, %d\n", x, y);
|
|
tft.fillCircle(x, y, 3, TFT_RED);
|
|
}
|
|
}
|
|
|