feat: add board configuration system, refactor Config.h
Board selection driven by -DTARGET_E32R35T or -DTARGET_WAVESHARE_S3_43.
Defaults to E32R35T for backward compatibility.
All hardware pin definitions moved from Config.h to board headers.
SCREEN_WIDTH/SCREEN_HEIGHT now come from board headers.
Config.h is now purely application-level configuration.
New files:
BoardConfig.h — board selector
boards/board_e32r35t.h — E32R35T pins, display, touch config
boards/board_waveshare_s3.h — Waveshare S3 4.3" pins, display, touch config
Modified:
Config.h — removed hardware pins section, added #include BoardConfig.h,
added HOLD_DURATION_MS to timing section
This commit is contained in:
18
sketches/doorbell-touch-esp32-32e/BoardConfig.h
Normal file
18
sketches/doorbell-touch-esp32-32e/BoardConfig.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// Board selector — driven by build flags
|
||||
// Pass -DTARGET_E32R35T or -DTARGET_WAVESHARE_S3_43
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
#if defined(TARGET_E32R35T)
|
||||
#include "boards/board_e32r35t.h"
|
||||
|
||||
#elif defined(TARGET_WAVESHARE_S3_43)
|
||||
#include "boards/board_waveshare_s3.h"
|
||||
|
||||
#else
|
||||
// Default to E32R35T for backward compatibility with existing builds
|
||||
#pragma message("No TARGET_* defined — defaulting to E32R35T")
|
||||
#define TARGET_E32R35T
|
||||
#include "boards/board_e32r35t.h"
|
||||
#endif
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "BoardConfig.h"
|
||||
|
||||
// =====================================================================
|
||||
// Debug
|
||||
// =====================================================================
|
||||
@@ -42,6 +44,7 @@ static const int NUM_WIFI = sizeof(wifiNetworks) / sizeof(wifiNetworks[0]);
|
||||
#define NTP_SYNC_INTERVAL_MS 3600000
|
||||
#define WAKE_DISPLAY_MS 5000
|
||||
#define TOUCH_DEBOUNCE_MS 300
|
||||
#define HOLD_DURATION_MS 2000
|
||||
#define HEARTBEAT_INTERVAL_MS 30000
|
||||
|
||||
#if DEBUG_MODE
|
||||
@@ -51,41 +54,6 @@ static const int NUM_WIFI = sizeof(wifiNetworks) / sizeof(wifiNetworks[0]);
|
||||
#endif
|
||||
|
||||
// =====================================================================
|
||||
// E32R35T Hardware Pins (hardwired on PCB — do not change)
|
||||
// Hardware pins are now in boards/board_*.h via BoardConfig.h
|
||||
// Screen dimensions (SCREEN_WIDTH, SCREEN_HEIGHT) also come from there.
|
||||
// =====================================================================
|
||||
// LCD (HSPI)
|
||||
#define PIN_LCD_CS 15
|
||||
#define PIN_LCD_DC 2
|
||||
#define PIN_LCD_MOSI 13
|
||||
#define PIN_LCD_SCLK 14
|
||||
#define PIN_LCD_MISO 12
|
||||
#define PIN_LCD_BL 27
|
||||
|
||||
// Touch (XPT2046, shares HSPI)
|
||||
#define PIN_TOUCH_CS 33
|
||||
#define PIN_TOUCH_IRQ 36
|
||||
|
||||
// SD Card (VSPI — for future use)
|
||||
#define PIN_SD_CS 5
|
||||
#define PIN_SD_MOSI 23
|
||||
#define PIN_SD_SCLK 18
|
||||
#define PIN_SD_MISO 19
|
||||
|
||||
// RGB LED (active low)
|
||||
#define PIN_LED_RED 22
|
||||
#define PIN_LED_GREEN 16
|
||||
#define PIN_LED_BLUE 17
|
||||
|
||||
// Audio
|
||||
#define PIN_AUDIO_EN 4
|
||||
#define PIN_AUDIO_DAC 26
|
||||
|
||||
// Battery ADC
|
||||
#define PIN_BAT_ADC 34
|
||||
|
||||
// =====================================================================
|
||||
// Display
|
||||
// =====================================================================
|
||||
#define SCREEN_WIDTH 480 // landscape
|
||||
#define SCREEN_HEIGHT 320
|
||||
|
||||
|
||||
50
sketches/doorbell-touch-esp32-32e/boards/board_e32r35t.h
Normal file
50
sketches/doorbell-touch-esp32-32e/boards/board_e32r35t.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// Board: E32R35T — ESP32-WROOM-32E + 3.5" ST7796S SPI + XPT2046
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
#define BOARD_NAME "E32R35T"
|
||||
|
||||
// ── Display ─────────────────────────────────────────────────────
|
||||
#define SCREEN_WIDTH 480
|
||||
#define SCREEN_HEIGHT 320
|
||||
#define DISPLAY_ROTATION 1
|
||||
|
||||
// ── Driver selection ────────────────────────────────────────────
|
||||
#define USE_TFT_ESPI 1
|
||||
#define USE_ARDUINO_GFX 0
|
||||
#define USE_TOUCH_XPT2046 1
|
||||
#define USE_TOUCH_GT911 0
|
||||
|
||||
// ── Hardware capabilities ───────────────────────────────────────
|
||||
#define HAS_PSRAM 0
|
||||
|
||||
// ── LCD (HSPI) ──────────────────────────────────────────────────
|
||||
#define PIN_LCD_CS 15
|
||||
#define PIN_LCD_DC 2
|
||||
#define PIN_LCD_MOSI 13
|
||||
#define PIN_LCD_SCLK 14
|
||||
#define PIN_LCD_MISO 12
|
||||
#define PIN_LCD_BL 27
|
||||
|
||||
// ── Touch (XPT2046, shares HSPI) ───────────────────────────────
|
||||
#define PIN_TOUCH_CS 33
|
||||
#define PIN_TOUCH_IRQ 36
|
||||
|
||||
// ── SD Card (VSPI — for future use) ────────────────────────────
|
||||
#define PIN_SD_CS 5
|
||||
#define PIN_SD_MOSI 23
|
||||
#define PIN_SD_SCLK 18
|
||||
#define PIN_SD_MISO 19
|
||||
|
||||
// ── RGB LED (active low) ───────────────────────────────────────
|
||||
#define PIN_LED_RED 22
|
||||
#define PIN_LED_GREEN 16
|
||||
#define PIN_LED_BLUE 17
|
||||
|
||||
// ── Audio ───────────────────────────────────────────────────────
|
||||
#define PIN_AUDIO_EN 4
|
||||
#define PIN_AUDIO_DAC 26
|
||||
|
||||
// ── Battery ADC ─────────────────────────────────────────────────
|
||||
#define PIN_BAT_ADC 34
|
||||
@@ -0,0 +1,73 @@
|
||||
#pragma once
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// Board: Waveshare ESP32-S3 Touch LCD 4.3"
|
||||
// 800x480 RGB parallel + GT911 capacitive touch
|
||||
//
|
||||
// NOTE: Pin assignments are typical for this board revision.
|
||||
// Verify against your specific board's schematic.
|
||||
// The Arduino board variant 'waveshare_esp32_s3_touch_lcd_43'
|
||||
// may override some of these via its pins_arduino.h.
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
#define BOARD_NAME "WS_S3_43"
|
||||
|
||||
// ── Display ─────────────────────────────────────────────────────
|
||||
#define SCREEN_WIDTH 800
|
||||
#define SCREEN_HEIGHT 480
|
||||
#define DISPLAY_ROTATION 0 // native landscape
|
||||
|
||||
// ── Driver selection ────────────────────────────────────────────
|
||||
#define USE_TFT_ESPI 0
|
||||
#define USE_ARDUINO_GFX 1
|
||||
#define USE_TOUCH_XPT2046 0
|
||||
#define USE_TOUCH_GT911 1
|
||||
|
||||
// ── Hardware capabilities ───────────────────────────────────────
|
||||
#define HAS_PSRAM 1
|
||||
|
||||
// ── Backlight ───────────────────────────────────────────────────
|
||||
#define PIN_LCD_BL 2
|
||||
|
||||
// ── GT911 I2C touch controller ──────────────────────────────────
|
||||
#define TOUCH_SDA 8
|
||||
#define TOUCH_SCL 9
|
||||
#define TOUCH_INT 4
|
||||
#define TOUCH_RST 5
|
||||
|
||||
// ── RGB LCD data pins (ESP32-S3 LCD_CAM peripheral) ─────────────
|
||||
// Adjust if your board revision differs
|
||||
#define LCD_DE 40
|
||||
#define LCD_VSYNC 41
|
||||
#define LCD_HSYNC 39
|
||||
#define LCD_PCLK 42
|
||||
#define LCD_R0 45
|
||||
#define LCD_R1 48
|
||||
#define LCD_R2 47
|
||||
#define LCD_R3 21
|
||||
#define LCD_R4 14
|
||||
#define LCD_G0 5
|
||||
#define LCD_G1 6
|
||||
#define LCD_G2 7
|
||||
#define LCD_G3 15
|
||||
#define LCD_G4 16
|
||||
#define LCD_G5 4
|
||||
#define LCD_B0 8
|
||||
#define LCD_B1 3
|
||||
#define LCD_B2 46
|
||||
#define LCD_B3 9
|
||||
#define LCD_B4 1
|
||||
|
||||
// ── Peripherals not present on this board ───────────────────────
|
||||
// These are left undefined intentionally. Code that uses them
|
||||
// should guard with #ifdef PIN_LED_RED etc.
|
||||
// Uncomment and set values if your carrier board adds them.
|
||||
//
|
||||
// #define PIN_LED_RED -1
|
||||
// #define PIN_LED_GREEN -1
|
||||
// #define PIN_LED_BLUE -1
|
||||
// #define PIN_AUDIO_EN -1
|
||||
// #define PIN_AUDIO_DAC -1
|
||||
// #define PIN_BAT_ADC -1
|
||||
// #define PIN_SD_CS -1
|
||||
// #define PIN_TOUCH_CS -1
|
||||
// #define PIN_TOUCH_IRQ -1
|
||||
Reference in New Issue
Block a user