snapshot
This commit is contained in:
@@ -1,20 +1,30 @@
|
||||
// ===== User_Setup.h (local to sketch) =====
|
||||
#define USER_SETUP_LOADED // Prevent TFT_eSPI from loading its own
|
||||
// ===== User_Setup.h for E32R35T (ESP32-32E 3.5" Display) =====
|
||||
#define USER_SETUP_LOADED
|
||||
|
||||
#define ST7796_DRIVER
|
||||
|
||||
#define TFT_WIDTH 320
|
||||
#define TFT_HEIGHT 480
|
||||
|
||||
#define TFT_CS 15
|
||||
#define TFT_DC 2
|
||||
#define TFT_RST 4
|
||||
#define TFT_MOSI 23
|
||||
#define TFT_SCLK 18
|
||||
#define TFT_MISO 19
|
||||
// LCD pins (HSPI bus)
|
||||
#define TFT_CS 15
|
||||
#define TFT_DC 2 // Called "TFT_RS" on the board
|
||||
#define TFT_RST -1 // RST is tied to EN (ESP32 reset pin), not a GPIO
|
||||
#define TFT_MOSI 13
|
||||
#define TFT_SCLK 14
|
||||
#define TFT_MISO 12
|
||||
|
||||
#define TOUCH_CS 21
|
||||
// Backlight
|
||||
#define TFT_BL 27
|
||||
#define TFT_BACKLIGHT_ON HIGH
|
||||
|
||||
// Touch (XPT2046, shares HSPI bus with LCD)
|
||||
#define TOUCH_CS 33
|
||||
|
||||
// Use HSPI port (not default VSPI)
|
||||
#define USE_HSPI_PORT
|
||||
|
||||
// SPI Frequencies
|
||||
#define SPI_FREQUENCY 27000000
|
||||
#define SPI_READ_FREQUENCY 20000000
|
||||
#define SPI_TOUCH_FREQUENCY 2500000
|
||||
|
||||
@@ -5,37 +5,54 @@ TFT_eSPI tft = TFT_eSPI();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(1000);
|
||||
delay(2000);
|
||||
|
||||
// Turn on backlight
|
||||
// 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); // Landscape
|
||||
tft.setRotation(1);
|
||||
|
||||
// Cycle colors to confirm display works
|
||||
uint16_t colors[] = {TFT_RED, TFT_GREEN, TFT_BLUE, TFT_WHITE};
|
||||
const char* names[] = {"RED", "GREEN", "BLUE", "WHITE"};
|
||||
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 < 4; i++) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
tft.fillScreen(colors[i]);
|
||||
Serial.printf("Screen: %s\n", names[i]);
|
||||
delay(1000);
|
||||
delay(1500);
|
||||
}
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
tft.setTextSize(3);
|
||||
tft.drawString("Hello ESP32-32E!", 30, 100);
|
||||
Serial.println("Display initialized!");
|
||||
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, 3, TFT_RED);
|
||||
tft.fillCircle(x, y, 4, TFT_YELLOW);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,7 @@ arduino-cli lib install "TFT_eSPI"
|
||||
"""
|
||||
|
||||
[tasks.compile]
|
||||
run = """
|
||||
arduino-cli compile \
|
||||
--fqbn $FQBN \
|
||||
--build-property "compiler.cpp.extra_flags=-DUSER_SETUP_LOADED -include ${SKETCH_DIR}/User_Setup.h" \
|
||||
--build-property "compiler.c.extra_flags=-DUSER_SETUP_LOADED -include ${SKETCH_DIR}/User_Setup.h" \
|
||||
.
|
||||
"""
|
||||
run = "arduino-cli compile --fqbn $FQBN ."
|
||||
|
||||
[tasks.upload]
|
||||
depends = ["compile"]
|
||||
|
||||
Reference in New Issue
Block a user