59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
#include <TFT_eSPI.h>
|
|
#include <SPI.h>
|
|
|
|
TFT_eSPI tft = TFT_eSPI();
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
delay(2000);
|
|
|
|
// Backlight ON
|
|
pinMode(27, OUTPUT);
|
|
digitalWrite(27, HIGH);
|
|
|
|
// Config verification
|
|
Serial.println("\n=== E32R35T Config ===");
|
|
#if defined(USER_SETUP_LOADED)
|
|
Serial.println("User_Setup: LOADED");
|
|
#else
|
|
Serial.println("User_Setup: DEFAULT (BAD!)");
|
|
#endif
|
|
#if defined(USE_HSPI_PORT)
|
|
Serial.println("SPI Bus: HSPI");
|
|
#else
|
|
Serial.println("SPI Bus: VSPI");
|
|
#endif
|
|
Serial.printf("MOSI:%d SCLK:%d MISO:%d\n", TFT_MOSI, TFT_SCLK, TFT_MISO);
|
|
Serial.printf("CS:%d DC:%d RST:%d BL:%d\n", TFT_CS, TFT_DC, TFT_RST, TFT_BL);
|
|
Serial.printf("TOUCH_CS:%d\n", TOUCH_CS);
|
|
Serial.printf("SPI_FREQ:%d\n", SPI_FREQUENCY);
|
|
Serial.println("======================\n");
|
|
|
|
tft.init();
|
|
tft.setRotation(1);
|
|
|
|
uint16_t colors[] = {TFT_RED, TFT_GREEN, TFT_BLUE, TFT_WHITE, TFT_BLACK};
|
|
const char* names[] = {"RED", "GREEN", "BLUE", "WHITE", "BLACK"};
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
tft.fillScreen(colors[i]);
|
|
Serial.printf("Screen: %s\n", names[i]);
|
|
delay(1500);
|
|
}
|
|
|
|
tft.fillScreen(TFT_BLACK);
|
|
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
|
tft.setTextSize(3);
|
|
tft.drawString("E32R35T Works!", 30, 100);
|
|
Serial.println("Done!");
|
|
}
|
|
|
|
void loop() {
|
|
uint16_t x, y;
|
|
if (tft.getTouch(&x, &y)) {
|
|
Serial.printf("Touch: %d, %d\n", x, y);
|
|
tft.fillCircle(x, y, 4, TFT_YELLOW);
|
|
}
|
|
}
|
|
|