diff --git a/boards/_boards_json/esp-wroom32-ili9341.json b/boards/_boards_json/esp-wroom32-ili9341.json new file mode 100644 index 0000000000..922cde4025 --- /dev/null +++ b/boards/_boards_json/esp-wroom32-ili9341.json @@ -0,0 +1,42 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DESP_WROOM32_ILI9341", + "-DARDUINO_ESP32_DEV", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "pinouts" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "debug": { + "openocd_board": "esp-wroom-32.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "ESP-WROOM-32 with ILI9341 2.4 TFT", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://en.wikipedia.org/wiki/ESP32", + "vendor": "Espressif" +} diff --git a/boards/_boards_json/esp-wroom32-st7789.json b/boards/_boards_json/esp-wroom32-st7789.json new file mode 100644 index 0000000000..1f25be1905 --- /dev/null +++ b/boards/_boards_json/esp-wroom32-st7789.json @@ -0,0 +1,42 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DESP_WROOM32_ST7789", + "-DARDUINO_ESP32_DEV", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "pinouts" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "debug": { + "openocd_board": "esp-wroom-32.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "ESP-WROOM-32 with ST7789 2.8 TFT Touch", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://en.wikipedia.org/wiki/ESP32", + "vendor": "Espressif" +} diff --git a/boards/_boards_json/esp32s3-ili9341.json b/boards/_boards_json/esp32s3-ili9341.json new file mode 100644 index 0000000000..0da764519e --- /dev/null +++ b/boards/_boards_json/esp32s3-ili9341.json @@ -0,0 +1,52 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "default_8MB.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DESP32S3_ILI9341", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DARDUINO_USB_CDC_ON_BOOT" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "pinouts" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "ESP32-S3 ILI9341 Touchscreen (8MB Flash)", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" + } diff --git a/boards/_boards_json/esp32s3-st7789.json b/boards/_boards_json/esp32s3-st7789.json new file mode 100644 index 0000000000..d5e6d5095f --- /dev/null +++ b/boards/_boards_json/esp32s3-st7789.json @@ -0,0 +1,52 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "default_8MB.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DESP32S3_ST7789", + "-DARDUINO_USB_MODE=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DARDUINO_USB_CDC_ON_BOOT" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "pinouts" + }, + "connectivity": [ + "bluetooth", + "wifi" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "ESP32-S3 ST7789 Touchscreen (8MB Flash)", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8388608, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" + } diff --git a/boards/esp-wroom32-ili9341/connections.md b/boards/esp-wroom32-ili9341/connections.md new file mode 100644 index 0000000000..cfec32fa6d --- /dev/null +++ b/boards/esp-wroom32-ili9341/connections.md @@ -0,0 +1,90 @@ +# ESP-WROOM32 with ILI9341 Display Wiring Guide + +This board features an ESP32 microcontroller paired with a 2.4" ILI9341 display and supports 5-way button navigation. + +## Components + +- **MCU**: ESP-WROOM32 (ESP32) +- **Display**: ILI9341 2.4" SPI TFT LCD (240x320) +- **buttons**: 5-way tactile button pad (up/down/left/right/select) +- **LED**: Single status LED +- **Communication**: SPI for display/radio modules, I2C for sensors + +## Display Pinout (ILI9341) + +| Display Pin | ESP32 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| CS | 17 | Chip Select | +| RESET | 5 | Reset | +| DC | 16 | Data/Command | +| MOSI | 23 | Serial Data In | +| MISO | 19 | Serial Data Out | +| SCK | 18 | Clock | +| BL/LED | 32 | Backlight (PWM) | + +## Button Pinout (5-Way Tactile) + +| Button | ESP32 Pin | Function | +|---|---|---| +| Select/OK | 35 | Center button | +| Up | 34 | Navigation up | +| Down | 26 | Navigation down | +| Right | 27 | Navigation right | +| Left | 33 | Navigation left | + +All buttons are **active-LOW** (GND when pressed). + +## Radio Modules (CC1101/NRF24) - Shared SPI Bus + +| Radio Pin | ESP32 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| MOSI | 23 | Serial Data In (shared with display) | +| MISO | 19 | Serial Data Out (shared with display) | +| SCK | 18 | Clock (shared with display) | +| CS | 15 | Chip Select (software selectable) | +| *Specific to RF module* | | See module documentation | + +**Note**: Radio modules share the SPI bus with the display but have separate chip select (CS) lines. The firmware manages CS timing to prevent conflicts. + +## I2C Sensors (Grove/Standard) + +| Sensor Pin | ESP32 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| SCL | 22 | I2C Clock | +| SDA | 21 | I2C Data | + +## Status LED + +| LED Pin | ESP32 Pin | Purpose | +|---|---|---| +| Anode | 2 | Active HIGH output | +| Cathode | GND | Ground | + +## Serial Port + +| Pin | ESP32 Pin | Type | +|---|---|---| +| RX | 3 | UART0 Input (programming/debug) | +| TX | 1 | UART0 Output (programming/debug) | + +## Power Supply + +- **Logic voltage**: 3.3V +- **Supply current**: ~500mA typical (display + MCU) +- **Peak current**: ~800mA (during radio transmission) + +Use a quality USB power supply or regulated 3.3V source rated for at least 1A. + +## Wiring Notes + +1. **SPI Bus Sharing**: Display, radio, and SD card (if used) all share SCK/MOSI/MISO lines. Each device has its own CS line to prevent conflicts. +2. **Button Ground**: All 5 buttons should be pulled to GND when pressed. Use 10kΩ pull-up resistors on pins if needed. +3. **Backlight**: The BL pin (GPIO32) supports PWM for brightness control (0-255). +4. **Reset**: The display RESET (GPIO5) is active LOW. Normally tied HIGH through 10kΩ resistor. +5. **Debouncing**: The firmware handles software debouncing for buttons (typical bounce time ~20ms). diff --git a/boards/esp-wroom32-ili9341/diagrams/espwroom32_ili9341_wiring.png b/boards/esp-wroom32-ili9341/diagrams/espwroom32_ili9341_wiring.png new file mode 100644 index 0000000000..30b50a554e Binary files /dev/null and b/boards/esp-wroom32-ili9341/diagrams/espwroom32_ili9341_wiring.png differ diff --git a/boards/esp-wroom32-ili9341/esp-wroom32-ili9341.ini b/boards/esp-wroom32-ili9341/esp-wroom32-ili9341.ini new file mode 100644 index 0000000000..bf4f52f8fb --- /dev/null +++ b/boards/esp-wroom32-ili9341/esp-wroom32-ili9341.ini @@ -0,0 +1,58 @@ +; PlatformIO Project Configuration File +; ESP-WROOM-32 + ILI9341 2.4" TFT (no touch) + 5-way tactile switch +; +; TFT Pins: MISO=19, MOSI=23, SCLK=18, CS=17, DC=16, RST=5, BL=32 +; 5-Way Nav: Up=34, Down=26, Left=33, Right=27, Center=35 + +[env:esp-wroom32-ili9341] +board = esp-wroom32-ili9341 +monitor_speed = 115200 +upload_port = COM3 +upload_speed = 115200 +upload_flags = --no-stub +board_build.partitions = custom_4Mb_full.csv +build_src_filter = ${env.build_src_filter} +<../boards/esp-wroom32-ili9341> +build_flags = + ${env.build_flags} + -Iboards/esp-wroom32-ili9341 + -Os + -DCORE_DEBUG_LEVEL=0 + + -DDEVICE_NAME='"ESP32-ILI9341"' + + ; Microphone (disabled) + -DPIN_CLK=-1 + -DI2S_SCLK_PIN=-1 + -DI2S_DATA_PIN=-1 + -DPIN_DATA=-1 + + ; Speaker (disabled) + -DBCLK=-1 + -DWCLK=-1 + -DDOUT=-1 + + ; RGB LED (disabled) + -DRGB_LED=-1 + + ; CC1101 SPI + -DUSE_CC1101_VIA_SPI + -DCC1101_GDO0_PIN=2 + -DCC1101_SS_PIN=15 + -DCC1101_MOSI_PIN=SPI_MOSI_PIN + -DCC1101_SCK_PIN=SPI_SCK_PIN + -DCC1101_MISO_PIN=SPI_MISO_PIN + + ; NRF24 SPI + -DUSE_NRF24_VIA_SPI + -DNRF24_CE_PIN=4 + -DNRF24_SS_PIN=15 + -DNRF24_MOSI_PIN=SPI_MOSI_PIN + -DNRF24_SCK_PIN=SPI_SCK_PIN + -DNRF24_MISO_PIN=SPI_MISO_PIN + +lib_deps = + ${env.lib_deps} +lib_ignore = + FastLED + ESP8266Audio + ESP8266SAM diff --git a/boards/esp-wroom32-ili9341/interface.cpp b/boards/esp-wroom32-ili9341/interface.cpp new file mode 100644 index 0000000000..beb5d98126 --- /dev/null +++ b/boards/esp-wroom32-ili9341/interface.cpp @@ -0,0 +1,174 @@ +#include "core/powerSave.h" +#include +#include + +// Deselect NRF24/CC1101 before any Arduino/TFT init runs (runs before setup()) +static void __attribute__((constructor)) _early_spi_deselect() { + gpio_reset_pin(GPIO_NUM_15); // CC1101_SS / NRF24_SS + gpio_set_direction(GPIO_NUM_15, GPIO_MODE_OUTPUT); + gpio_set_level(GPIO_NUM_15, 1); // CS HIGH = deselected + + gpio_reset_pin(GPIO_NUM_4); // NRF24_CE + gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT); + gpio_set_level(GPIO_NUM_4, 0); // CE LOW = standby +} + +/*************************************************************************************** +** Function name: _setup_gpio() +** Location: main.cpp +** Description: initial setup for the device +***************************************************************************************/ +void _setup_gpio() { + // 5-way tactile switch — GPIO 34/35 are input-only (no pull-up on chip) + // Ensure external pull-up resistors are present on these pins + pinMode(UP_BTN, INPUT); + pinMode(DW_BTN, INPUT_PULLUP); + pinMode(L_BTN, INPUT_PULLUP); + pinMode(R_BTN, INPUT_PULLUP); + pinMode(SEL_BTN, INPUT); + + // Deselect CC1101 and NRF24 on shared SPI bus so they don't interfere with TFT + pinMode(CC1101_SS_PIN, OUTPUT); + digitalWrite(CC1101_SS_PIN, HIGH); + pinMode(NRF24_SS_PIN, OUTPUT); + digitalWrite(NRF24_SS_PIN, HIGH); + pinMode(NRF24_CE_PIN, OUTPUT); + digitalWrite(NRF24_CE_PIN, LOW); +} + +/*************************************************************************************** +** Function name: _post_setup_gpio() +** Location: main.cpp +** Description: second stage gpio setup +***************************************************************************************/ +void _post_setup_gpio() { + // Backlight PWM + pinMode(TFT_BL, OUTPUT); + analogWrite(TFT_BL, 255); +} + +/********************************************************************* +** Function: setBrightness +** location: settings.cpp +** set brightness value +**********************************************************************/ +void _setBrightness(uint8_t brightval) { + if (brightval == 0) { + analogWrite(TFT_BL, 0); + } else { + int bl = MINBRIGHT + round(((255 - MINBRIGHT) * brightval / 100)); + analogWrite(TFT_BL, bl); + } +} + +/********************************************************************* +** Function: InputHandler +** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress +** On 5-way joystick: hold UP for ~400ms = EscPress (back/exit) +**********************************************************************/ +void InputHandler(void) { + static unsigned long tm = 0; + static unsigned long upHoldStart = 0; + static bool upEscFired = false; + + // --- Hold-UP-for-Escape: runs every call, bypasses debounce --- + // Read UP_BTN on every task cycle (~10ms) so the hold timer + // accumulates correctly regardless of the 200ms debounce gate. + // Keep setting EscPress while held so the task can't clear it + // before the application loop reads it via check(). + bool _up_raw = (digitalRead(UP_BTN) == BTN_ACT); + if (_up_raw) { + if (upHoldStart == 0) upHoldStart = millis(); + if (millis() - upHoldStart >= 400) { + EscPress = true; + AnyKeyPress = true; + upEscFired = true; + } + } else { + upHoldStart = 0; + upEscFired = false; + } + + if (millis() - tm < 200 && !LongPress) return; + + bool _u = _up_raw; + bool _d = (digitalRead(DW_BTN) == BTN_ACT); + bool _l = (digitalRead(L_BTN) == BTN_ACT); + bool _r = (digitalRead(R_BTN) == BTN_ACT); + bool _s = (digitalRead(SEL_BTN) == BTN_ACT); + + if (_u || _d || _l || _r || _s) { + tm = millis(); + if (!wakeUpScreen()) AnyKeyPress = true; + else return; + } + + if (_l) { PrevPress = true; } + if (_r) { NextPress = true; } + if (_u && !upEscFired) { + UpPress = true; + PrevPagePress = true; + } + if (_d) { + DownPress = true; + NextPagePress = true; + } + if (_s) { SelPress = true; } + if (_l && _r) { + EscPress = true; + NextPress = false; + PrevPress = false; + } +} + +/********************************************************************* +** Function: powerOff +** location: mykeyboard.cpp +** Turns off the device (or try to) +**********************************************************************/ +void powerOff() { + esp_sleep_enable_ext0_wakeup((gpio_num_t)SEL_BTN, BTN_ACT); + esp_deep_sleep_start(); +} + +/********************************************************************* +** Function: checkReboot +** location: mykeyboard.cpp +** Btn logic to turn off the device +**********************************************************************/ +void checkReboot() { + int countDown = 0; + /* Long press Left+Right to power off */ + if (digitalRead(L_BTN) == BTN_ACT && digitalRead(R_BTN) == BTN_ACT) { + uint32_t time_count = millis(); + while (digitalRead(L_BTN) == BTN_ACT && digitalRead(R_BTN) == BTN_ACT) { + if (millis() - time_count > 500) { + if (countDown == 0) { + int textWidth = tft.textWidth("PWR OFF IN 3/3", 1); + tft.fillRect(tftWidth / 2 - textWidth / 2, 7, textWidth, 18, bruceConfig.bgColor); + } + tft.setTextSize(1); + tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor); + countDown = (millis() - time_count) / 1000 + 1; + if (countDown < 4) + tft.drawCentreString("PWR OFF IN " + String(countDown) + "/3", tftWidth / 2, 12, 1); + else { + tft.fillScreen(bruceConfig.bgColor); + while (digitalRead(L_BTN) == BTN_ACT || digitalRead(R_BTN) == BTN_ACT); + delay(200); + powerOff(); + } + delay(10); + } + } + delay(30); + if (millis() - time_count > 500) { + tft.fillRect(60, 12, tftWidth - 60, tft.fontHeight(1), bruceConfig.bgColor); + drawStatusBar(); + } + } +} + +int getBattery() { return 0; } + +bool isCharging() { return false; } diff --git a/boards/esp-wroom32-ili9341/pins_arduino.h b/boards/esp-wroom32-ili9341/pins_arduino.h new file mode 100644 index 0000000000..503c2a4174 --- /dev/null +++ b/boards/esp-wroom32-ili9341/pins_arduino.h @@ -0,0 +1,81 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +static const uint8_t SDA = 21; +static const uint8_t SCL = 22; + +static const uint8_t SS = 5; +static const uint8_t MOSI = 23; +static const uint8_t MISO = 19; +static const uint8_t SCK = 18; + +// 5-way tactile switch +#define HAS_5_BUTTONS +#define SEL_BTN 35 +#define UP_BTN 34 +#define DW_BTN 26 +#define R_BTN 27 +#define L_BTN 33 +#define BTN_ACT LOW + +#define BTN_ALIAS "\"OK\"" + +#define SERIAL_TX 1 +#define SERIAL_RX 3 +#define BAD_TX SERIAL_TX +#define BAD_RX SERIAL_RX +#define GPS_SERIAL_TX SERIAL_TX +#define GPS_SERIAL_RX SERIAL_RX + +#define TXLED 2 +#define LED_ON HIGH +#define LED_OFF LOW + +#define FP 1 +#define FM 2 +#define FG 3 + +#define HAS_SCREEN 1 +#define ROTATION 1 +#define MINBRIGHT 160 + +// TFT_eSPI Setup for ILI9341 2.4" display +#define USER_SETUP_LOADED 1 +#define ILI9341_2_DRIVER 1 +#define TFT_WIDTH 240 +#define TFT_HEIGHT 320 +#define TFT_MISO 19 +#define TFT_MOSI 23 +#define TFT_SCLK 18 +#define TFT_CS 17 +#define TFT_DC 16 +#define TFT_RST 5 +#define TFT_BL 32 +#define TFT_BACKLIGHT_ON HIGH +#define TOUCH_CS -1 +#define SMOOTH_FONT 1 +#define SPI_FREQUENCY 40000000 +#define SPI_READ_FREQUENCY 20000000 + +// SD Card (directly on main SPI bus) +#define SDCARD_CS -1 +#define SDCARD_SCK -1 +#define SDCARD_MISO -1 +#define SDCARD_MOSI -1 + +// Default I2C +#define GROVE_SDA 21 +#define GROVE_SCL 22 + +// Shared SPI bus for CC1101/NRF24 (main VSPI) +#define SPI_SCK_PIN 18 +#define SPI_MOSI_PIN 23 +#define SPI_MISO_PIN 19 +#define SPI_SS_PIN 15 + +#endif /* Pins_Arduino_h */ diff --git a/boards/esp-wroom32-st7789/connections.md b/boards/esp-wroom32-st7789/connections.md new file mode 100644 index 0000000000..afe6fb6a6c --- /dev/null +++ b/boards/esp-wroom32-st7789/connections.md @@ -0,0 +1,125 @@ +# ESP-WROOM32 with ST7789 Display & Touchscreen Wiring Guide + +This board features an ESP32 microcontroller paired with a 2.8" ST7789 display with integrated XPT2046 resistive touchscreen. + +## Components + +- **MCU**: ESP-WROOM32 (ESP32) +- **Display**: ST7789 2.8" SPI TFT LCD with RGB-BGR color order (240x320) +- **Touchscreen**: XPT2046 resistive touch controller (shares SPI bus) +- **SD Card**: Slot on main SPI bus +- **Button**: Single boot button (GPIO0; active-LOW) +- **LED**: Single status LED +- **Communication**: SPI for display/touch/SD card, I2C for sensors + +## Display Pinout (ST7789) + +| Display Pin | ESP32 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| CS | 17 | Chip Select | +| RESET | 5 | Reset | +| DC | 16 | Data/Command | +| MOSI | 23 | Serial Data In | +| MISO | 19 | Serial Data Out (not typically used) | +| SCK | 18 | Clock | +| BL/LED | 32 | Backlight (PWM) | + +## Touchscreen Pinout (XPT2046) + +The touchscreen shares the SPI bus (MOSI/MISO/SCK) with the display but has separate CS. + +| Touch Pin | ESP32 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| MOSI | 23 | Serial Data In (shared with display) | +| MISO | 19 | Serial Data Out (shared with display) | +| SCK | 18 | Clock (shared with display) | +| CS | 21 | Chip Select (touch only) | +| IRQ | Not used | Interrupt (optional) | + +## SD Card Slot Pinout + +| SD Card Pin | ESP32 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| MOSI | 23 | Serial Data In (shared with display/touch) | +| MISO | 19 | Serial Data Out (shared) | +| SCK | 18 | Clock (shared) | +| CS | 12 | Chip Select (SD card only) | + +## Radio Modules (CC1101/NRF24) - Shared SPI Bus + +| Radio Pin | ESP32 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| MOSI | 23 | Serial Data In (shared) | +| MISO | 19 | Serial Data Out (shared) | +| SCK | 18 | Clock (shared) | +| CS | 15 | Chip Select (radio only) | +| *Specific to RF module* | | See module documentation | + +**Note**: Display, touchscreen, SD card, and radio modules all share MOSI/MISO/SCK but each has its own CS line for isolation. + +## User Input + +| Input | ESP32 Pin | Type | +|---|---|---| +| Boot Button | 0 | Tactile switch, active-LOW (can be remapped as OK button) | + +## I2C Sensors (Grove/Standard) + +| Sensor Pin | ESP32 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| SCL | 22 | I2C Clock | +| SDA | 21 | I2C Data (warning: shared with touch CS—check firmware) | + +## Status LED + +| LED Pin | ESP32 Pin | Purpose | +|---|---|---| +| Anode | 2 | Active HIGH output | +| Cathode | GND | Ground | + +## Serial Port + +| Pin | ESP32 Pin | Type | +|---|---|---| +| RX | 3 | UART0 Input (programming/debug) | +| TX | 1 | UART0 Output (programming/debug) | + +## Power Supply + +- **Logic voltage**: 3.3V +- **Supply current**: ~600mA typical (display + touch + MCU) +- **Peak current**: ~1000mA (during radio transmission + backlight at full brightness) + +Use a quality USB power supply or regulated 3.3V source rated for at least 1.5A. + +## SPI Bus Architecture + +``` +ESP32 (VSPI Bus) +├─ Display (CS=17) — ST7789 + BL +├─ Touchscreen (CS=21) — XPT2046 +├─ SD Card (CS=12) — microSD +└─ Radio (CS=15) — NRF24 or CC1101 + +Shared lines: MOSI=23, MISO=19, SCK=18 +``` + +## Wiring Notes + +1. **Multi-Device SPI**: All four devices (display, touch, SD, radio) share the same MOSI/MISO/SCK lines. Each device gets its own CS line. The firmware manages CS timing automatically. +2. **Touch CS Conflict**: GPIO21 is used for both touch CS and Grove SDA (I2C). If using Grove I2C sensors, disable touch or use alternate GPIO. +3. **Backlight**: The BL pin (GPIO32) supports PWM for brightness control (0-255). +4. **Reset**: Display RESET (GPIO5) is active LOW. Normally tied HIGH through 10kΩ resistor or managed by firmware. +5. **SPI Frequency**: Write at 40MHz, read at 20MHz. Touch operations at 2.5MHz. +6. **Display Rotation**: Set to 90° rotation (landscape). +7. **Color Order**: ST7789 configured for RGB→BGR conversion. diff --git a/boards/esp-wroom32-st7789/diagrams/espwroom32_st7789_wiring.png b/boards/esp-wroom32-st7789/diagrams/espwroom32_st7789_wiring.png new file mode 100644 index 0000000000..de25987696 Binary files /dev/null and b/boards/esp-wroom32-st7789/diagrams/espwroom32_st7789_wiring.png differ diff --git a/boards/esp-wroom32-st7789/esp-wroom32-st7789.ini b/boards/esp-wroom32-st7789/esp-wroom32-st7789.ini new file mode 100644 index 0000000000..055b94e506 --- /dev/null +++ b/boards/esp-wroom32-st7789/esp-wroom32-st7789.ini @@ -0,0 +1,136 @@ +; PlatformIO Project Configuration File +; ESP-WROOM-32 + ST7789 2.8" TFT with XPT2046 Touch +; +; TFT Pins (VSPI): MISO=19, MOSI=23, SCLK=18, CS=17, DC=16, RST=5, BL=32 +; Touch (XPT2046): CS=21, shares VSPI bus (MISO=19, MOSI=23, SCLK=18) +; SD Card: CS=12, shares VSPI bus + +[env:esp-wroom32-st7789] +board = esp-wroom32-st7789 +board_build.partitions = custom_4Mb_full.csv +build_src_filter = ${env.build_src_filter} +<../boards/esp-wroom32-st7789> +build_flags = + ${env.build_flags} + -Iboards/esp-wroom32-st7789 + -Os + -DCORE_DEBUG_LEVEL=0 + -DCONFIG_ESP32_JTAG_SUPPORT_DISABLE=1 + + -DDEVICE_NAME='"ESP32-ST7789 Touch"' + + ; Boot button as OK + -DHAS_BTN=1 + -DBTN_ALIAS='"OK"' + -DBTN_PIN=0 + -DBTN_ACT=LOW + + ; Infrared Led + -DIR_TX_PINS='{ {"G4", 4}, {"G2", 2}, {"G25", 25} }' + -DIR_RX_PINS='{ {"G4", 4}, {"G2", 2}, {"G25", 25} }' + -DTXLED=2 + -DLED_ON=HIGH + -DLED_OFF=LOW + + ; Radio Frequency (one pin modules) pin setting + -DRF_TX_PINS='{ {"G4", 4}, {"G2", 2}, {"G25", 25} }' + -DRF_RX_PINS='{ {"G4", 4}, {"G2", 2}, {"G25", 25} }' + + ; CC1101 SPI connection pins + -DUSE_CC1101_VIA_SPI + -DCC1101_GDO0_PIN=2 + -DCC1101_SS_PIN=15 + -DCC1101_MOSI_PIN=SPI_MOSI_PIN + -DCC1101_SCK_PIN=SPI_SCK_PIN + -DCC1101_MISO_PIN=SPI_MISO_PIN + + ; NRF24 SPI connection pins + -DUSE_NRF24_VIA_SPI + -DNRF24_CE_PIN=4 + -DNRF24_SS_PIN=15 + -DNRF24_MOSI_PIN=SPI_MOSI_PIN + -DNRF24_SCK_PIN=SPI_SCK_PIN + -DNRF24_MISO_PIN=SPI_MISO_PIN + + ; W5500 Ethernet (disabled by default) + ;-DUSE_W5500_VIA_SPI + -DW5500_SS_PIN=-1 + -DW5500_MOSI_PIN=SPI_MOSI_PIN + -DW5500_SCK_PIN=SPI_SCK_PIN + -DW5500_MISO_PIN=SPI_MISO_PIN + -DW5500_INT_PIN=-1 + + ; Lora setup pins (not connected by default) + -DLORA_SCK=SPI_SCK_PIN + -DLORA_MISO=SPI_MISO_PIN + -DLORA_MOSI=SPI_MOSI_PIN + -DLORA_CS=-1 + -DLORA_RST=-1 + -DLORA_DIO0=-1 + + ; FM Radio + -DFM_RSTPIN=-1 + + ; Font sizes + -DFP=1 + -DFM=2 + -DFG=3 + + ; Screen Setup + -DHAS_SCREEN=1 + -DROTATION=1 + -DMINBRIGHT=1 + + ; TFT_eSPI display — ST7789 240x320 SPI (VSPI) + -DUSER_SETUP_LOADED=1 + -DST7789_DRIVER=1 + -DTFT_RGB_ORDER=TFT_BGR + -DTFT_WIDTH=240 + -DTFT_HEIGHT=320 + -DTFT_INVERSION_ON + -DTFT_CS=17 + -DTFT_DC=16 + -DTFT_RST=5 + -DTFT_BL=32 + -DTFT_MOSI=23 + -DTFT_SCLK=18 + -DTFT_MISO=19 + -DTOUCH_CS=-1 + -DSMOOTH_FONT=1 + -DSPI_FREQUENCY=40000000 + -DSPI_READ_FREQUENCY=20000000 + -DSPI_TOUCH_FREQUENCY=2500000 + + ; Touchscreen — XPT2046 resistive (shares VSPI bus with display) + -DHAS_TOUCH=1 + -DTOUCH_XPT2046_SPI=1 + -DXPT2046_SPI_BUS_MOSI_IO_NUM=23 + -DXPT2046_SPI_BUS_MISO_IO_NUM=19 + -DXPT2046_SPI_BUS_SCLK_IO_NUM=18 + -DXPT2046_SPI_CONFIG_CS_GPIO_NUM=21 + -DXPT2046_TOUCH_CONFIG_INT_GPIO_NUM=-1 + -DINPUT_HANDLER_TASK_STACK_SIZE=8192 + + ; SD Card pins (on VSPI bus) + -DSDCARD_CS=12 + -DSDCARD_SCK=18 + -DSDCARD_MISO=19 + -DSDCARD_MOSI=23 + + ; Default I2C port + -DGROVE_SDA=21 + -DGROVE_SCL=22 + + ; SERIAL (GPS) dedicated pins + -DSERIAL_TX=1 + -DSERIAL_RX=3 + -DGPS_SERIAL_TX=SERIAL_TX + -DGPS_SERIAL_RX=SERIAL_RX + + ; Main SPI bus pins (for CC1101/NRF24/etc) + -DSPI_SCK_PIN=18 + -DSPI_MOSI_PIN=23 + -DSPI_MISO_PIN=19 + -DSPI_SS_PIN=15 + +lib_deps = + ${env.lib_deps} diff --git a/boards/esp-wroom32-st7789/interface.cpp b/boards/esp-wroom32-st7789/interface.cpp new file mode 100644 index 0000000000..97493b2166 --- /dev/null +++ b/boards/esp-wroom32-st7789/interface.cpp @@ -0,0 +1,136 @@ +#include "CYD28_TouchscreenR.h" +#include "core/powerSave.h" +#include "core/utils.h" +#include + +#define CYD28_DISPLAY_HOR_RES_MAX 320 +#define CYD28_DISPLAY_VER_RES_MAX 240 +CYD28_TouchR touch(CYD28_DISPLAY_HOR_RES_MAX, CYD28_DISPLAY_VER_RES_MAX); + +/*************************************************************************************** +** Function name: _setup_gpio() +** Location: main.cpp +** Description: initial setup for the device +***************************************************************************************/ +void _setup_gpio() { + // Keep XPT2046 CS high until needed + pinMode(XPT2046_SPI_CONFIG_CS_GPIO_NUM, OUTPUT); + digitalWrite(XPT2046_SPI_CONFIG_CS_GPIO_NUM, HIGH); + + bruceConfig.colorInverted = 1; +} + +/*************************************************************************************** +** Function name: _post_setup_gpio() +** Location: main.cpp +** Description: second stage gpio setup — runs AFTER tft.init() +***************************************************************************************/ +void _post_setup_gpio() { + // Initialize XPT2046 touch using hardware SPI (shares bus with display) + if (!touch.begin(&tft.getSPIinstance())) { + Serial.println("[TOUCH] XPT2046 not started"); + } else { + Serial.println("[TOUCH] XPT2046 started OK"); + } + touch.setRotation(ROTATION); + + // Backlight on + pinMode(TFT_BL, OUTPUT); + analogWrite(TFT_BL, 255); +} + +/*************************************************************************************** +** Function name: getBattery() +** location: display.cpp +** Description: Delivers the battery value from 1-100 +***************************************************************************************/ +int getBattery() { return 0; } + +/*************************************************************************************** +** Function name: isCharging() +** Description: Determines if the device is charging +***************************************************************************************/ +bool isCharging() { return false; } + +/********************************************************************* +** Function: setBrightness +** location: settings.cpp +** set brightness value +**********************************************************************/ +void _setBrightness(uint8_t brightval) { + if (brightval == 0) { + analogWrite(TFT_BL, brightval); + } else { + analogWrite(TFT_BL, brightval); + } +} + +/********************************************************************* +** Function: InputHandler +** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress +**********************************************************************/ +void InputHandler(void) { + static long d_tmp = 0; + if (millis() - d_tmp > 200 || LongPress) { + if (touch.touched()) { + auto t = touch.getPointScaled(); + + // Coordinate transform based on rotation + if (bruceConfigPins.rotation == 3) { + t.y = (tftHeight + 20) - t.y; + t.x = tftWidth - t.x; + } + if (bruceConfigPins.rotation == 0) { + int tmp = t.x; + t.x = tftWidth - t.y; + t.y = tmp; + } + if (bruceConfigPins.rotation == 2) { + int tmp = t.x; + t.x = t.y; + t.y = (tftHeight + 20) - tmp; + } + + if (!wakeUpScreen()) AnyKeyPress = true; + else goto END; + + touchPoint.x = t.x; + touchPoint.y = t.y; + touchPoint.pressed = true; + touchHeatMap(touchPoint); + END: + d_tmp = millis(); + } + } + +#ifdef HAS_BTN + checkPowerSaveTime(); + if (digitalRead(BTN_PIN) == BTN_ACT) { + if (!wakeUpScreen()) AnyKeyPress = true; + SelPress = true; + long tmp = millis(); + while ((millis() - tmp) < 200 && digitalRead(BTN_PIN) == BTN_ACT); + } +#endif +} + +/********************************************************************* +** Function: powerOff +** location: mykeyboard.cpp +** Turns off the device (or try to) +**********************************************************************/ +void powerOff() { esp_deep_sleep_start(); } + +/********************************************************************* +** Function: goToDeepSleep +** location: mykeyboard.cpp +** Puts the device into DeepSleep +**********************************************************************/ +void goToDeepSleep() { esp_deep_sleep_start(); } + +/********************************************************************* +** Function: checkReboot +** location: mykeyboard.cpp +** Btn logic to turn off the device +**********************************************************************/ +void checkReboot() {} diff --git a/boards/esp-wroom32-st7789/pins_arduino.h b/boards/esp-wroom32-st7789/pins_arduino.h new file mode 100644 index 0000000000..43046d1978 --- /dev/null +++ b/boards/esp-wroom32-st7789/pins_arduino.h @@ -0,0 +1,128 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +static const uint8_t SDA = 21; +static const uint8_t SCL = 22; + +static const uint8_t SS = 5; +static const uint8_t MOSI = 23; +static const uint8_t MISO = 19; +static const uint8_t SCK = 18; + +// Boot button as OK (active-low) +#ifndef HAS_BTN +#define HAS_BTN 1 +#endif +#ifndef BTN_ALIAS +#define BTN_ALIAS "\"OK\"" +#endif +#ifndef BTN_PIN +#define BTN_PIN 0 +#endif +#ifndef BTN_ACT +#define BTN_ACT LOW +#endif + +#define SERIAL_TX 1 +#define SERIAL_RX 3 +#define BAD_TX SERIAL_TX +#define BAD_RX SERIAL_RX +#define GPS_SERIAL_TX SERIAL_TX +#define GPS_SERIAL_RX SERIAL_RX + +#define TXLED 2 +#define LED_ON HIGH +#define LED_OFF LOW + +#define FP 1 +#define FM 2 +#define FG 3 + +#define HAS_SCREEN 1 +#define ROTATION 1 +#define MINBRIGHT 1 + +// TFT_eSPI Setup for ST7789 2.8" display (VSPI bus) +#ifndef USER_SETUP_LOADED +#define USER_SETUP_LOADED 1 +#endif +#ifndef ST7789_DRIVER +#define ST7789_DRIVER 1 +#endif +#ifndef TFT_RGB_ORDER +#define TFT_RGB_ORDER TFT_BGR +#endif +#ifndef TFT_WIDTH +#define TFT_WIDTH 240 +#endif +#ifndef TFT_HEIGHT +#define TFT_HEIGHT 320 +#endif +#ifndef TFT_INVERSION_ON +#define TFT_INVERSION_ON +#endif +#ifndef TFT_MISO +#define TFT_MISO 19 +#endif +#ifndef TFT_MOSI +#define TFT_MOSI 23 +#endif +#ifndef TFT_SCLK +#define TFT_SCLK 18 +#endif +#ifndef TFT_CS +#define TFT_CS 17 +#endif +#ifndef TFT_DC +#define TFT_DC 16 +#endif +#ifndef TFT_RST +#define TFT_RST 5 +#endif +#ifndef TFT_BL +#define TFT_BL 32 +#endif +#ifndef TFT_BACKLIGHT_ON +#define TFT_BACKLIGHT_ON HIGH +#endif +#ifndef TOUCH_CS +#define TOUCH_CS -1 +#endif +#ifndef SMOOTH_FONT +#define SMOOTH_FONT 1 +#endif +#define SPI_FREQUENCY 40000000 +#define SPI_READ_FREQUENCY 20000000 +#define SPI_TOUCH_FREQUENCY 2500000 + +// Touchscreen — XPT2046 resistive (shares VSPI bus with display) +#define HAS_TOUCH 1 +#define TOUCH_XPT2046_SPI 1 +#define XPT2046_SPI_BUS_MOSI_IO_NUM 23 +#define XPT2046_SPI_BUS_MISO_IO_NUM 19 +#define XPT2046_SPI_BUS_SCLK_IO_NUM 18 +#define XPT2046_SPI_CONFIG_CS_GPIO_NUM 21 +#define XPT2046_TOUCH_CONFIG_INT_GPIO_NUM -1 + +// SD Card (on VSPI bus) +#define SDCARD_CS 12 +#define SDCARD_SCK 18 +#define SDCARD_MISO 19 +#define SDCARD_MOSI 23 + +// Default I2C +#define GROVE_SDA 21 +#define GROVE_SCL 22 + +// Shared SPI bus for CC1101/NRF24 (main VSPI) +#define SPI_SCK_PIN 18 +#define SPI_MOSI_PIN 23 +#define SPI_MISO_PIN 19 +#define SPI_SS_PIN 15 + +#endif /* Pins_Arduino_h */ diff --git a/boards/esp32s3-ili9341/connections.md b/boards/esp32s3-ili9341/connections.md new file mode 100644 index 0000000000..5c60050c39 --- /dev/null +++ b/boards/esp32s3-ili9341/connections.md @@ -0,0 +1,167 @@ +# ESP32-S3 with ILI9341 Display & Touchscreen Wiring Guide + +This is the most advanced board, featuring the ESP32-S3 microcontroller with dual-core processing, native USB support, and multiple wireless capabilities. + +## Components + +- **MCU**: ESP32-S3 (dual-core, USB native support) +- **Display**: ILI9341 2.8" SPI TFT LCD with RGB-BGR color order (240x320) +- **Touchscreen**: XPT2046 resistive touch controller (hardware SPI) +- **Radio Options**: CC1101, NRF24, or LoRa (SPI bus) +- **I/O**: IR transmit/receive, RF transmit/receive (IR-based and 433/868MHz RF supported) +- **Button**: Single boot button (GPIO0; active-LOW) +- **LED**: Single status LED (GPIO40) +- **USB**: Native USB support (CDC + custom HID) +- **Communication**: Dedicated SPI for display/touch, separate SPI for radio modules + +## Display Pinout (ILI9341 on HSPI) + +| Display Pin | ESP32-S3 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| CS | 10 | Chip Select | +| RESET | 5 | Reset (active-LOW) | +| DC | 7 | Data/Command | +| MOSI | 11 | Serial Data In (HSPI) | +| MISM | 13 | Serial Data Out (HSPI) | +| SCK | 12 | Clock (HSPI) | +| BL/LED | 38 | Backlight (PWM) | + +## Touchscreen Pinout (XPT2046 on HSPI) + +The touchscreen shares HSPI bus (MOSI/MISO/SCK) with the display but has separate CS. + +| Touch Pin | ESP32-S3 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| MOSI | 11 | Serial Data In (shared HSPI) | +| MISO | 13 | Serial Data Out (shared HSPI) | +| SCK | 12 | Clock (shared HSPI) | +| CS | 3 | Chip Select (touch only) | +| IRQ | Not used | Interrupt (optional) | + +## Radio Modules (CC1101/NRF24/W5500) - SPI Bus Pins + +All radio modules use the **main SPI bus** with separate chip select lines: + +### CC1101 (FSK radio module) +| CC1101 Pin | ESP32-S3 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| MOSI | 11 | Serial Data In | +| MISO | 13 | Serial Data Out | +| SCK | 12 | Clock | +| CS | 10 | Chip Select | +| GDO0 | 9 | Data Output (optional) | + +### NRF24 (2.4GHz wireless module) +| NRF24 Pin | ESP32-S3 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power (needs 3A supply!) | +| GND | GND | Ground | +| MOSI | 11 | Serial Data In | +| MISO | 13 | Serial Data Out | +| SCK | 12 | Clock | +| CS | 14 | Chip Select | +| CE | 16 | Chip Enable | + +### W5500 (Ethernet module - optional) +| W5500 Pin | ESP32-S3 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| MOSI | 11 | Serial Data In | +| MISO | 13 | Serial Data Out | +| SCK | 12 | Clock | +| CS | (varies) | Chip Select (externally configurable) | +| INT | (varies) | Interrupt (externally configurable) | + +**Note**: CC1101 and NRF24 can be used simultaneously (different CS). W5500 requires custom pin assignment. + +## IR & RF Pins (Single-Pin Modules) + +For IR LED and single-pin RF receivers/transmitters: + +| Function | GPIO Options | +|---|---| +| IR TX | GPIO1, GPIO2 (also Grove Y via GPIO8) | +| IR RX | GPIO1, GPIO2 (also Grove W via GPIO9) | +| RF TX (433/868MHz) | GPIO1, GPIO2 (also Grove Y via GPIO8) | +| RF RX (433/868MHz) | GPIO1, GPIO2 (also Grove W via GPIO9) | + +## User Input & LED + +| Input/Output | ESP32-S3 Pin | Type | +|---|---|---| +| Boot Button | 0 | Tactile switch, active-LOW (remapped as OK button) | +| Status LED | 40 | Output, active-HIGH | + +## I2C Interface (Grove/Standard Sensors) + +| Pin Name | ESP32-S3 Pin | Purpose | +|---|---|---| +| SDA | 8 | I2C Data (also used for IR RX) | +| SCL | 9 | I2C Clock (also used for RF RX) | + +**Note**: Grove pins share GPIO with RF/IR inputs. Prioritize based on your application. + +## Serial Interfaces + +| Interface | TX Pin | RX Pin | Purpose | +|---|---|---| +| UART0 (USB CDC) | — | — | Native USB serial (programming & debug) | +| UART1 (GPS/Ext) | 43 | 44 | External serial (e.g., GPS module) | + +USB is native on the ESP32-S3 via GPIO19/GPIO20 (internal). + +## Power Supply + +- **Logic voltage**: 3.3V +- **Supply current**: ~400mA typical (display + touch + MCU) +- **Peak current**: + - ~800mA with radio + backlight + - **~2500mA with NRF24** (provide dedicated 3A supply if using NRF24!) + +Use a high-quality USB power supply (2A minimum, 3A recommended if using NRF24). + +## SPI Architecture + +``` +ESP32-S3 Dual SPI +├─ HSPI Bus (Display/Touch): +│ ├─ Display (CS=10) — ILI9341 +│ └─ Touchscreen (CS=3) — XPT2046 +│ Shared: MOSI=11, MISO=13, SCK=12 +│ +└─ Main SPI Bus (Radio/Peripherals): + ├─ CC1101 (CS=10, GDO0=9) — FSK transceiver + ├─ NRF24 (CS=14, CE=16) — 2.4GHz wireless + └─ W5500 (CS=?, INT=?) — Optional Ethernet + Shared: MOSI=11, MISO=13, SCK=12 +``` + +**Note**: Display CS and CC1101 CS both use GPIO10 (hardware selectable). Use firmware configuration to choose which module is available. + +## Wiring Notes + +1. **Dual SPI Buses**: HSPI for display/touch, main SPI for radio modules. Both use GPIO11/12/13, but separate CS lines prevent conflicts. +2. **NRF24 Power**: The NRF24 module requires a dedicated 3A power supply. Do **NOT** power it from the USB port alone—use a separate 3.3V regulator. +3. **Backlight**: GPIO38 supports PWM for brightness control (0-255). +4. **Reset**: Display RESET (GPIO5) is active LOW. Normally tied HIGH through resistor or managed by firmware. +5. **Boot Button**: GPIO0 serves dual purpose: boot selection during power-up, OK button during normal operation. +6. **USB Serial**: Unlike older ESP32, this board has native USB. Use USB for uploads and debugging (no FTDI chip needed). +7. **Color Order**: ILI9341 configured for RGB→BGR conversion. +8. **SPI Frequencies**: 40MHz write, 20MHz read, 2.5MHz touch operations. +9. **Grove I2C Conflict**: GPIO8 (SDA) overlaps with IR RX, GPIO9 (SCL) overlaps with RF RX. Configure based on priority. + +## Features + +- **Dual-core 240MHz processor** — More performance-intensive tasks +- **USB Native Support** — Faster uploads, serial over USB +- **More GPIO** — Supports more peripheral devices simultaneously +- **Larger Flash** — 8MB partition for bigger firmware +- **Integrated IR LED driver** — GPIO40 for IR output +- **Advanced Radio Options** — CC1101, NRF24, and optional W5500 Ethernet diff --git a/boards/esp32s3-ili9341/diagrams/esp32s3_ili9341_wiring.png b/boards/esp32s3-ili9341/diagrams/esp32s3_ili9341_wiring.png new file mode 100644 index 0000000000..735aa04f0a Binary files /dev/null and b/boards/esp32s3-ili9341/diagrams/esp32s3_ili9341_wiring.png differ diff --git a/boards/esp32s3-ili9341/esp32s3-ili9341.ini b/boards/esp32s3-ili9341/esp32s3-ili9341.ini new file mode 100644 index 0000000000..cb58fb61c9 --- /dev/null +++ b/boards/esp32s3-ili9341/esp32s3-ili9341.ini @@ -0,0 +1,146 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp32s3-ili9341] +board = esp32s3-st7789 +board_build.partitions = custom_8Mb.csv +build_src_filter =${env.build_src_filter} +<../boards/esp32s3-ili9341> +build_flags = + ${env.build_flags} + -Iboards/esp32s3-ili9341 + -Os + -DCORE_DEBUG_LEVEL=5 + + ;Can run USB as HID + -DUSB_as_HID=1 + -DBAD_TX=GROVE_SDA + -DBAD_RX=GROVE_SCL + + ;Buttons configuration (active-low boot button on GPIO 0) + -DHAS_BTN=1 + -DBTN_ALIAS='"OK"' + -DBTN_PIN=0 + -DBTN_ACT=LOW + + ;-DALLOW_ALL_GPIO_FOR_IR_RF=1 ; Set this option to make use of all GPIOs, from 1 to 44 to be chosen, except TFT and SD pins + + ;Infrared Led + -DIR_TX_PINS='{{"Grove Y", GROVE_SDA}, {"G1", 1}, {"G2", 2}}' + -DIR_RX_PINS='{{"Grove W", GROVE_SCL}, {"G1", 1}, {"G2", 2}}' + -DTXLED=40 + -DLED_ON=HIGH + -DLED_OFF=LOW + + ;Radio Frequency (one pin modules) pin setting + -DRF_TX_PINS='{{"Grove Y", GROVE_SDA}, {"G1", 1}, {"G2", 2}}' + -DRF_RX_PINS='{{"Grove W", GROVE_SCL}, {"G1", 1}, {"G2", 2}}' + + ;CC1101 SPI connection pins + -DUSE_CC1101_VIA_SPI + -DCC1101_GDO0_PIN=9 + -DCC1101_SS_PIN=10 + -DCC1101_MOSI_PIN=SPI_MOSI_PIN + -DCC1101_SCK_PIN=SPI_SCK_PIN + -DCC1101_MISO_PIN=SPI_MISO_PIN + + ;NRF24 SPI connection pins + -DUSE_NRF24_VIA_SPI + -DNRF24_CE_PIN=16 + -DNRF24_SS_PIN=14 + -DNRF24_MOSI_PIN=SPI_MOSI_PIN + -DNRF24_SCK_PIN=SPI_SCK_PIN + -DNRF24_MISO_PIN=SPI_MISO_PIN + + ;W5500 Ethernet (disabled by default) + ;-DUSE_W5500_VIA_SPI + -DW5500_SS_PIN=-1 + -DW5500_MOSI_PIN=SPI_MOSI_PIN + -DW5500_SCK_PIN=SPI_SCK_PIN + -DW5500_MISO_PIN=SPI_MISO_PIN + -DW5500_INT_PIN=-1 + + ;Lora setup pins (not connected by default) + -DLORA_SCK=SPI_SCK_PIN + -DLORA_MISO=SPI_MISO_PIN + -DLORA_MOSI=SPI_MOSI_PIN + -DLORA_CS=-1 + -DLORA_RST=-1 + -DLORA_DIO0=-1 + + ;FM Radio + -DFM_RSTPIN=-1 + + ;Font sizes + -DFP=1 + -DFM=2 + -DFG=3 + + ;Screen Setup + -DHAS_SCREEN=1 + -DROTATION=1 + -DMINBRIGHT=1 + + ;TFT_eSPI display — ILI9341 240x320 SPI + -DUSER_SETUP_LOADED=1 + -DUSE_HSPI_PORT=1 + -DILI9341_DRIVER=1 + -DTFT_RGB_ORDER=TFT_BGR + -DTFT_WIDTH=240 + -DTFT_HEIGHT=320 + -DTFT_INVERSION_ON + -DTFT_CS=10 + -DTFT_DC=7 + -DTFT_RST=5 + -DTFT_BL=38 + -DTFT_MOSI=11 + -DTFT_SCLK=12 + -DTFT_MISO=13 + -DTOUCH_CS=-1 + -DSMOOTH_FONT=1 + -DSPI_FREQUENCY=40000000 + -DSPI_READ_FREQUENCY=20000000 + -DSPI_TOUCH_FREQUENCY=2500000 + + ;Touchscreen — XPT2046 resistive (hardware SPI via CYD28_TouchscreenR) + -DHAS_TOUCH=1 + -DTOUCH_XPT2046_SPI=1 + -DXPT2046_SPI_BUS_MOSI_IO_NUM=11 + -DXPT2046_SPI_BUS_MISO_IO_NUM=13 + -DXPT2046_SPI_BUS_SCLK_IO_NUM=12 + -DXPT2046_SPI_CONFIG_CS_GPIO_NUM=3 + -DXPT2046_TOUCH_CONFIG_INT_GPIO_NUM=-1 + -DINPUT_HANDLER_TASK_STACK_SIZE=8192 + + ;SD Card pins (no SD card by default, set your pins if connected) + -DSDCARD_CS=4 + -DSDCARD_SCK=12 + -DSDCARD_MISO=13 + -DSDCARD_MOSI=11 + + ;Default I2C port (touch + grove) + -DGROVE_SDA=8 + -DGROVE_SCL=9 + + ; SERIAL (GPS) dedicated pins + -DSERIAL_TX=43 + -DSERIAL_RX=44 + -DGPS_SERIAL_TX=SERIAL_TX + -DGPS_SERIAL_RX=SERIAL_RX + + ;Main SPI bus pins (for CC1101/NRF24/etc) + -DSPI_SCK_PIN=12 + -DSPI_MOSI_PIN=11 + -DSPI_MISO_PIN=13 + -DSPI_SS_PIN=10 + + -DDEVICE_NAME='"ESP32-S3 ILI9341"' + +lib_deps = + ${env.lib_deps} diff --git a/boards/esp32s3-ili9341/interface.cpp b/boards/esp32s3-ili9341/interface.cpp new file mode 100644 index 0000000000..97493b2166 --- /dev/null +++ b/boards/esp32s3-ili9341/interface.cpp @@ -0,0 +1,136 @@ +#include "CYD28_TouchscreenR.h" +#include "core/powerSave.h" +#include "core/utils.h" +#include + +#define CYD28_DISPLAY_HOR_RES_MAX 320 +#define CYD28_DISPLAY_VER_RES_MAX 240 +CYD28_TouchR touch(CYD28_DISPLAY_HOR_RES_MAX, CYD28_DISPLAY_VER_RES_MAX); + +/*************************************************************************************** +** Function name: _setup_gpio() +** Location: main.cpp +** Description: initial setup for the device +***************************************************************************************/ +void _setup_gpio() { + // Keep XPT2046 CS high until needed + pinMode(XPT2046_SPI_CONFIG_CS_GPIO_NUM, OUTPUT); + digitalWrite(XPT2046_SPI_CONFIG_CS_GPIO_NUM, HIGH); + + bruceConfig.colorInverted = 1; +} + +/*************************************************************************************** +** Function name: _post_setup_gpio() +** Location: main.cpp +** Description: second stage gpio setup — runs AFTER tft.init() +***************************************************************************************/ +void _post_setup_gpio() { + // Initialize XPT2046 touch using hardware SPI (shares bus with display) + if (!touch.begin(&tft.getSPIinstance())) { + Serial.println("[TOUCH] XPT2046 not started"); + } else { + Serial.println("[TOUCH] XPT2046 started OK"); + } + touch.setRotation(ROTATION); + + // Backlight on + pinMode(TFT_BL, OUTPUT); + analogWrite(TFT_BL, 255); +} + +/*************************************************************************************** +** Function name: getBattery() +** location: display.cpp +** Description: Delivers the battery value from 1-100 +***************************************************************************************/ +int getBattery() { return 0; } + +/*************************************************************************************** +** Function name: isCharging() +** Description: Determines if the device is charging +***************************************************************************************/ +bool isCharging() { return false; } + +/********************************************************************* +** Function: setBrightness +** location: settings.cpp +** set brightness value +**********************************************************************/ +void _setBrightness(uint8_t brightval) { + if (brightval == 0) { + analogWrite(TFT_BL, brightval); + } else { + analogWrite(TFT_BL, brightval); + } +} + +/********************************************************************* +** Function: InputHandler +** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress +**********************************************************************/ +void InputHandler(void) { + static long d_tmp = 0; + if (millis() - d_tmp > 200 || LongPress) { + if (touch.touched()) { + auto t = touch.getPointScaled(); + + // Coordinate transform based on rotation + if (bruceConfigPins.rotation == 3) { + t.y = (tftHeight + 20) - t.y; + t.x = tftWidth - t.x; + } + if (bruceConfigPins.rotation == 0) { + int tmp = t.x; + t.x = tftWidth - t.y; + t.y = tmp; + } + if (bruceConfigPins.rotation == 2) { + int tmp = t.x; + t.x = t.y; + t.y = (tftHeight + 20) - tmp; + } + + if (!wakeUpScreen()) AnyKeyPress = true; + else goto END; + + touchPoint.x = t.x; + touchPoint.y = t.y; + touchPoint.pressed = true; + touchHeatMap(touchPoint); + END: + d_tmp = millis(); + } + } + +#ifdef HAS_BTN + checkPowerSaveTime(); + if (digitalRead(BTN_PIN) == BTN_ACT) { + if (!wakeUpScreen()) AnyKeyPress = true; + SelPress = true; + long tmp = millis(); + while ((millis() - tmp) < 200 && digitalRead(BTN_PIN) == BTN_ACT); + } +#endif +} + +/********************************************************************* +** Function: powerOff +** location: mykeyboard.cpp +** Turns off the device (or try to) +**********************************************************************/ +void powerOff() { esp_deep_sleep_start(); } + +/********************************************************************* +** Function: goToDeepSleep +** location: mykeyboard.cpp +** Puts the device into DeepSleep +**********************************************************************/ +void goToDeepSleep() { esp_deep_sleep_start(); } + +/********************************************************************* +** Function: checkReboot +** location: mykeyboard.cpp +** Btn logic to turn off the device +**********************************************************************/ +void checkReboot() {} diff --git a/boards/esp32s3-ili9341/pins_arduino.h b/boards/esp32s3-ili9341/pins_arduino.h new file mode 100644 index 0000000000..256e2a3254 --- /dev/null +++ b/boards/esp32s3-ili9341/pins_arduino.h @@ -0,0 +1,146 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include "soc/soc_caps.h" +#include + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t SDA = 8; +static const uint8_t SCL = 9; + +static const uint8_t SS = 10; +static const uint8_t MOSI = 11; +static const uint8_t MISO = 13; +static const uint8_t SCK = 12; + +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; +static const uint8_t A3 = 4; +static const uint8_t A4 = 5; +static const uint8_t A5 = 6; +static const uint8_t A6 = 7; +static const uint8_t A7 = 8; +static const uint8_t A8 = 9; +static const uint8_t A9 = 10; +static const uint8_t A10 = 11; +static const uint8_t A11 = 12; +static const uint8_t A12 = 13; +static const uint8_t A13 = 14; +static const uint8_t A14 = 15; +static const uint8_t A15 = 16; +static const uint8_t A16 = 17; +static const uint8_t A17 = 18; +static const uint8_t A18 = 19; +static const uint8_t A19 = 20; + +static const uint8_t T1 = 1; +static const uint8_t T2 = 2; +static const uint8_t T3 = 3; +static const uint8_t T4 = 4; +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T7 = 7; +static const uint8_t T8 = 8; +static const uint8_t T9 = 9; +static const uint8_t T10 = 10; +static const uint8_t T11 = 11; +static const uint8_t T12 = 12; +static const uint8_t T13 = 13; +static const uint8_t T14 = 14; + +// Boot button as OK (active-low) +#ifndef HAS_BTN +#define HAS_BTN 1 +#endif +#ifndef BTN_ALIAS +#define BTN_ALIAS "\"OK\"" +#endif +#ifndef BTN_PIN +#define BTN_PIN 0 +#endif +#ifndef BTN_ACT +#define BTN_ACT LOW +#endif + +#define HAS_SCREEN 1 +#define ROTATION 1 +#define MINBRIGHT 1 + +// TFT_eSPI Setup for ILI9341 2.8" display (HSPI bus) +#ifndef USER_SETUP_LOADED +#define USER_SETUP_LOADED 1 +#endif +#ifndef ILI9341_DRIVER +#define ILI9341_DRIVER 1 +#endif +#ifndef TFT_RGB_ORDER +#define TFT_RGB_ORDER TFT_BGR +#endif +#ifndef TFT_WIDTH +#define TFT_WIDTH 240 +#endif +#ifndef TFT_HEIGHT +#define TFT_HEIGHT 320 +#endif +#ifndef TFT_MISO +#define TFT_MISO 13 +#endif +#ifndef TFT_MOSI +#define TFT_MOSI 11 +#endif +#ifndef TFT_SCLK +#define TFT_SCLK 12 +#endif +#ifndef TFT_CS +#define TFT_CS 10 +#endif +#ifndef TFT_DC +#define TFT_DC 7 +#endif +#ifndef TFT_RST +#define TFT_RST 5 +#endif +#ifndef TFT_BL +#define TFT_BL 38 +#endif +#ifndef TFT_BACKLIGHT_ON +#define TFT_BACKLIGHT_ON HIGH +#endif +#ifndef SMOOTH_FONT +#define SMOOTH_FONT 1 +#endif +#define SPI_FREQUENCY 40000000 +#define SPI_READ_FREQUENCY 20000000 +#define SPI_TOUCH_FREQUENCY 2500000 + +// Touchscreen — XPT2046 resistive (shares HSPI bus with display) +#define HAS_TOUCH 1 +#define TOUCH_XPT2046_SPI 1 +#define XPT2046_SPI_BUS_MOSI_IO_NUM 11 +#define XPT2046_SPI_BUS_MISO_IO_NUM 13 +#define XPT2046_SPI_BUS_SCLK_IO_NUM 12 +#define XPT2046_SPI_CONFIG_CS_GPIO_NUM 3 +#define XPT2046_TOUCH_CONFIG_INT_GPIO_NUM -1 + +// Status LED +#define TXLED 40 +#define LED_ON HIGH +#define LED_OFF LOW + +// Default I2C +#define GROVE_SDA 8 +#define GROVE_SCL 9 + +// Shared SPI bus for CC1101/NRF24 (main SPI) +#define SPI_SCK_PIN 12 +#define SPI_MOSI_PIN 11 +#define SPI_MISO_PIN 13 +#define SPI_SS_PIN 10 + +#endif /* Pins_Arduino_h */ diff --git a/boards/esp32s3-st7789/connections.md b/boards/esp32s3-st7789/connections.md new file mode 100644 index 0000000000..af28085190 --- /dev/null +++ b/boards/esp32s3-st7789/connections.md @@ -0,0 +1,167 @@ +# ESP32-S3 with ST7789 Display & Touchscreen Wiring Guide + +This is the most advanced board, featuring the ESP32-S3 microcontroller with dual-core processing, native USB support, and multiple wireless capabilities. + +## Components + +- **MCU**: ESP32-S3 (dual-core, USB native support) +- **Display**: ST7789 2.8" SPI TFT LCD with RGB-BGR color order (240x320) +- **Touchscreen**: XPT2046 resistive touch controller (hardware SPI) +- **Radio Options**: CC1101, NRF24, or LoRa (SPI bus) +- **I/O**: IR transmit/receive, RF transmit/receive (IR-based and 433/868MHz RF supported) +- **Button**: Single boot button (GPIO0; active-LOW) +- **LED**: Single status LED (GPIO40) +- **USB**: Native USB support (CDC + custom HID) +- **Communication**: Dedicated SPI for display/touch, separate SPI for radio modules + +## Display Pinout (ST7789 on HSPI) + +| Display Pin | ESP32-S3 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| CS | 10 | Chip Select | +| RESET | 5 | Reset (active-LOW) | +| DC | 7 | Data/Command | +| MOSI | 11 | Serial Data In (HSPI) | +| MISM | 13 | Serial Data Out (HSPI) | +| SCK | 12 | Clock (HSPI) | +| BL/LED | 38 | Backlight (PWM) | + +## Touchscreen Pinout (XPT2046 on HSPI) + +The touchscreen shares HSPI bus (MOSI/MISO/SCK) with the display but has separate CS. + +| Touch Pin | ESP32-S3 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| MOSI | 11 | Serial Data In (shared HSPI) | +| MISO | 13 | Serial Data Out (shared HSPI) | +| SCK | 12 | Clock (shared HSPI) | +| CS | 3 | Chip Select (touch only) | +| IRQ | Not used | Interrupt (optional) | + +## Radio Modules (CC1101/NRF24/W5500) - SPI Bus Pins + +All radio modules use the **main SPI bus** with separate chip select lines: + +### CC1101 (FSK radio module) +| CC1101 Pin | ESP32-S3 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| MOSI | 11 | Serial Data In | +| MISO | 13 | Serial Data Out | +| SCK | 12 | Clock | +| CS | 10 | Chip Select | +| GDO0 | 9 | Data Output (optional) | + +### NRF24 (2.4GHz wireless module) +| NRF24 Pin | ESP32-S3 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power (needs 3A supply!) | +| GND | GND | Ground | +| MOSI | 11 | Serial Data In | +| MISO | 13 | Serial Data Out | +| SCK | 12 | Clock | +| CS | 14 | Chip Select | +| CE | 16 | Chip Enable | + +### W5500 (Ethernet module - optional) +| W5500 Pin | ESP32-S3 Pin | Purpose | +|---|---|---| +| VCC | 3.3V | Power | +| GND | GND | Ground | +| MOSI | 11 | Serial Data In | +| MISO | 13 | Serial Data Out | +| SCK | 12 | Clock | +| CS | (varies) | Chip Select (externally configurable) | +| INT | (varies) | Interrupt (externally configurable) | + +**Note**: CC1101 and NRF24 can be used simultaneously (different CS). W5500 requires custom pin assignment. + +## IR & RF Pins (Single-Pin Modules) + +For IR LED and single-pin RF receivers/transmitters: + +| Function | GPIO Options | +|---|---| +| IR TX | GPIO1, GPIO2 (also Grove Y via GPIO8) | +| IR RX | GPIO1, GPIO2 (also Grove W via GPIO9) | +| RF TX (433/868MHz) | GPIO1, GPIO2 (also Grove Y via GPIO8) | +| RF RX (433/868MHz) | GPIO1, GPIO2 (also Grove W via GPIO9) | + +## User Input & LED + +| Input/Output | ESP32-S3 Pin | Type | +|---|---|---| +| Boot Button | 0 | Tactile switch, active-LOW (remapped as OK button) | +| Status LED | 40 | Output, active-HIGH | + +## I2C Interface (Grove/Standard Sensors) + +| Pin Name | ESP32-S3 Pin | Purpose | +|---|---|---| +| SDA | 8 | I2C Data (also used for IR RX) | +| SCL | 9 | I2C Clock (also used for RF RX) | + +**Note**: Grove pins share GPIO with RF/IR inputs. Prioritize based on your application. + +## Serial Interfaces + +| Interface | TX Pin | RX Pin | Purpose | +|---|---|---| +| UART0 (USB CDC) | — | — | Native USB serial (programming & debug) | +| UART1 (GPS/Ext) | 43 | 44 | External serial (e.g., GPS module) | + +USB is native on the ESP32-S3 via GPIO19/GPIO20 (internal). + +## Power Supply + +- **Logic voltage**: 3.3V +- **Supply current**: ~400mA typical (display + touch + MCU) +- **Peak current**: + - ~800mA with radio + backlight + - **~2500mA with NRF24** (provide dedicated 3A supply if using NRF24!) + +Use a high-quality USB power supply (2A minimum, 3A recommended if using NRF24). + +## SPI Architecture + +``` +ESP32-S3 Dual SPI +├─ HSPI Bus (Display/Touch): +│ ├─ Display (CS=10) — ST7789 +│ └─ Touchscreen (CS=3) — XPT2046 +│ Shared: MOSI=11, MISO=13, SCK=12 +│ +└─ Main SPI Bus (Radio/Peripherals): + ├─ CC1101 (CS=10, GDO0=9) — FSK transceiver + ├─ NRF24 (CS=14, CE=16) — 2.4GHz wireless + └─ W5500 (CS=?, INT=?) — Optional Ethernet + Shared: MOSI=11, MISO=13, SCK=12 +``` + +**Note**: Display CS and CC1101 CS both use GPIO10 (hardware selectable). Use firmware configuration to choose which module is available. + +## Wiring Notes + +1. **Dual SPI Buses**: HSPI for display/touch, main SPI for radio modules. Both use GPIO11/12/13, but separate CS lines prevent conflicts. +2. **NRF24 Power**: The NRF24 module requires a dedicated 3A power supply. Do **NOT** power it from the USB port alone—use a separate 3.3V regulator. +3. **Backlight**: GPIO38 supports PWM for brightness control (0-255). +4. **Reset**: Display RESET (GPIO5) is active LOW. Normally tied HIGH through resistor or managed by firmware. +5. **Boot Button**: GPIO0 serves dual purpose: boot selection during power-up, OK button during normal operation. +6. **USB Serial**: Unlike older ESP32, this board has native USB. Use USB for uploads and debugging (no FTDI chip needed). +7. **Color Order**: ST7789 configured for RGB→BGR conversion. +8. **SPI Frequencies**: 40MHz write, 20MHz read, 2.5MHz touch operations. +9. **Grove I2C Conflict**: GPIO8 (SDA) overlaps with IR RX, GPIO9 (SCL) overlaps with RF RX. Configure based on priority. + +## Features + +- **Dual-core 240MHz processor** — More performance-intensive tasks +- **USB Native Support** — Faster uploads, serial over USB +- **More GPIO** — Supports more peripheral devices simultaneously +- **Larger Flash** — 8MB partition for bigger firmware +- **Integrated IR LED driver** — GPIO40 for IR output +- **Advanced Radio Options** — CC1101, NRF24, and optional W5500 Ethernet diff --git a/boards/esp32s3-st7789/diagrams/esp32s3_st7789_wiring.png b/boards/esp32s3-st7789/diagrams/esp32s3_st7789_wiring.png new file mode 100644 index 0000000000..f5baaee7b5 Binary files /dev/null and b/boards/esp32s3-st7789/diagrams/esp32s3_st7789_wiring.png differ diff --git a/boards/esp32s3-st7789/esp32s3-st7789.ini b/boards/esp32s3-st7789/esp32s3-st7789.ini new file mode 100644 index 0000000000..07372f8860 --- /dev/null +++ b/boards/esp32s3-st7789/esp32s3-st7789.ini @@ -0,0 +1,146 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp32s3-st7789] +board = esp32s3-st7789 +board_build.partitions = custom_8Mb.csv +build_src_filter =${env.build_src_filter} +<../boards/esp32s3-st7789> +build_flags = + ${env.build_flags} + -Iboards/esp32s3-st7789 + -Os + -DCORE_DEBUG_LEVEL=5 + + ;Can run USB as HID + -DUSB_as_HID=1 + -DBAD_TX=GROVE_SDA + -DBAD_RX=GROVE_SCL + + ;Buttons configuration (active-low boot button on GPIO 0) + -DHAS_BTN=1 + -DBTN_ALIAS='"OK"' + -DBTN_PIN=0 + -DBTN_ACT=LOW + + ;-DALLOW_ALL_GPIO_FOR_IR_RF=1 ; Set this option to make use of all GPIOs, from 1 to 44 to be chosen, except TFT and SD pins + + ;Infrared Led + -DIR_TX_PINS='{{"Grove Y", GROVE_SDA}, {"G1", 1}, {"G2", 2}}' + -DIR_RX_PINS='{{"Grove W", GROVE_SCL}, {"G1", 1}, {"G2", 2}}' + -DTXLED=40 + -DLED_ON=HIGH + -DLED_OFF=LOW + + ;Radio Frequency (one pin modules) pin setting + -DRF_TX_PINS='{{"Grove Y", GROVE_SDA}, {"G1", 1}, {"G2", 2}}' + -DRF_RX_PINS='{{"Grove W", GROVE_SCL}, {"G1", 1}, {"G2", 2}}' + + ;CC1101 SPI connection pins + -DUSE_CC1101_VIA_SPI + -DCC1101_GDO0_PIN=9 + -DCC1101_SS_PIN=10 + -DCC1101_MOSI_PIN=SPI_MOSI_PIN + -DCC1101_SCK_PIN=SPI_SCK_PIN + -DCC1101_MISO_PIN=SPI_MISO_PIN + + ;NRF24 SPI connection pins + -DUSE_NRF24_VIA_SPI + -DNRF24_CE_PIN=16 + -DNRF24_SS_PIN=14 + -DNRF24_MOSI_PIN=SPI_MOSI_PIN + -DNRF24_SCK_PIN=SPI_SCK_PIN + -DNRF24_MISO_PIN=SPI_MISO_PIN + + ;W5500 Ethernet (disabled by default) + ;-DUSE_W5500_VIA_SPI + -DW5500_SS_PIN=-1 + -DW5500_MOSI_PIN=SPI_MOSI_PIN + -DW5500_SCK_PIN=SPI_SCK_PIN + -DW5500_MISO_PIN=SPI_MISO_PIN + -DW5500_INT_PIN=-1 + + ;Lora setup pins (not connected by default) + -DLORA_SCK=SPI_SCK_PIN + -DLORA_MISO=SPI_MISO_PIN + -DLORA_MOSI=SPI_MOSI_PIN + -DLORA_CS=-1 + -DLORA_RST=-1 + -DLORA_DIO0=-1 + + ;FM Radio + -DFM_RSTPIN=-1 + + ;Font sizes + -DFP=1 + -DFM=2 + -DFG=3 + + ;Screen Setup + -DHAS_SCREEN=1 + -DROTATION=1 + -DMINBRIGHT=1 + + ;TFT_eSPI display — ST7789 240x320 SPI + -DUSER_SETUP_LOADED=1 + -DUSE_HSPI_PORT=1 + -DST7789_DRIVER=1 + -DTFT_RGB_ORDER=TFT_BGR + -DTFT_WIDTH=240 + -DTFT_HEIGHT=320 + -DTFT_INVERSION_ON + -DTFT_CS=10 + -DTFT_DC=7 + -DTFT_RST=5 + -DTFT_BL=38 + -DTFT_MOSI=11 + -DTFT_SCLK=12 + -DTFT_MISO=13 + -DTOUCH_CS=-1 + -DSMOOTH_FONT=1 + -DSPI_FREQUENCY=40000000 + -DSPI_READ_FREQUENCY=20000000 + -DSPI_TOUCH_FREQUENCY=2500000 + + ;Touchscreen — XPT2046 resistive (hardware SPI via CYD28_TouchscreenR) + -DHAS_TOUCH=1 + -DTOUCH_XPT2046_SPI=1 + -DXPT2046_SPI_BUS_MOSI_IO_NUM=11 + -DXPT2046_SPI_BUS_MISO_IO_NUM=13 + -DXPT2046_SPI_BUS_SCLK_IO_NUM=12 + -DXPT2046_SPI_CONFIG_CS_GPIO_NUM=3 + -DXPT2046_TOUCH_CONFIG_INT_GPIO_NUM=-1 + -DINPUT_HANDLER_TASK_STACK_SIZE=8192 + + ;SD Card pins (no SD card by default, set your pins if connected) + -DSDCARD_CS=-1 + -DSDCARD_SCK=-1 + -DSDCARD_MISO=-1 + -DSDCARD_MOSI=-1 + + ;Default I2C port (touch + grove) + -DGROVE_SDA=8 + -DGROVE_SCL=9 + + ; SERIAL (GPS) dedicated pins + -DSERIAL_TX=43 + -DSERIAL_RX=44 + -DGPS_SERIAL_TX=SERIAL_TX + -DGPS_SERIAL_RX=SERIAL_RX + + ;Main SPI bus pins (for CC1101/NRF24/etc) + -DSPI_SCK_PIN=12 + -DSPI_MOSI_PIN=11 + -DSPI_MISO_PIN=13 + -DSPI_SS_PIN=10 + + -DDEVICE_NAME='"ESP32-S3 ST7789"' + +lib_deps = + ${env.lib_deps} diff --git a/boards/esp32s3-st7789/interface.cpp b/boards/esp32s3-st7789/interface.cpp new file mode 100644 index 0000000000..97493b2166 --- /dev/null +++ b/boards/esp32s3-st7789/interface.cpp @@ -0,0 +1,136 @@ +#include "CYD28_TouchscreenR.h" +#include "core/powerSave.h" +#include "core/utils.h" +#include + +#define CYD28_DISPLAY_HOR_RES_MAX 320 +#define CYD28_DISPLAY_VER_RES_MAX 240 +CYD28_TouchR touch(CYD28_DISPLAY_HOR_RES_MAX, CYD28_DISPLAY_VER_RES_MAX); + +/*************************************************************************************** +** Function name: _setup_gpio() +** Location: main.cpp +** Description: initial setup for the device +***************************************************************************************/ +void _setup_gpio() { + // Keep XPT2046 CS high until needed + pinMode(XPT2046_SPI_CONFIG_CS_GPIO_NUM, OUTPUT); + digitalWrite(XPT2046_SPI_CONFIG_CS_GPIO_NUM, HIGH); + + bruceConfig.colorInverted = 1; +} + +/*************************************************************************************** +** Function name: _post_setup_gpio() +** Location: main.cpp +** Description: second stage gpio setup — runs AFTER tft.init() +***************************************************************************************/ +void _post_setup_gpio() { + // Initialize XPT2046 touch using hardware SPI (shares bus with display) + if (!touch.begin(&tft.getSPIinstance())) { + Serial.println("[TOUCH] XPT2046 not started"); + } else { + Serial.println("[TOUCH] XPT2046 started OK"); + } + touch.setRotation(ROTATION); + + // Backlight on + pinMode(TFT_BL, OUTPUT); + analogWrite(TFT_BL, 255); +} + +/*************************************************************************************** +** Function name: getBattery() +** location: display.cpp +** Description: Delivers the battery value from 1-100 +***************************************************************************************/ +int getBattery() { return 0; } + +/*************************************************************************************** +** Function name: isCharging() +** Description: Determines if the device is charging +***************************************************************************************/ +bool isCharging() { return false; } + +/********************************************************************* +** Function: setBrightness +** location: settings.cpp +** set brightness value +**********************************************************************/ +void _setBrightness(uint8_t brightval) { + if (brightval == 0) { + analogWrite(TFT_BL, brightval); + } else { + analogWrite(TFT_BL, brightval); + } +} + +/********************************************************************* +** Function: InputHandler +** Handles the variables PrevPress, NextPress, SelPress, AnyKeyPress and EscPress +**********************************************************************/ +void InputHandler(void) { + static long d_tmp = 0; + if (millis() - d_tmp > 200 || LongPress) { + if (touch.touched()) { + auto t = touch.getPointScaled(); + + // Coordinate transform based on rotation + if (bruceConfigPins.rotation == 3) { + t.y = (tftHeight + 20) - t.y; + t.x = tftWidth - t.x; + } + if (bruceConfigPins.rotation == 0) { + int tmp = t.x; + t.x = tftWidth - t.y; + t.y = tmp; + } + if (bruceConfigPins.rotation == 2) { + int tmp = t.x; + t.x = t.y; + t.y = (tftHeight + 20) - tmp; + } + + if (!wakeUpScreen()) AnyKeyPress = true; + else goto END; + + touchPoint.x = t.x; + touchPoint.y = t.y; + touchPoint.pressed = true; + touchHeatMap(touchPoint); + END: + d_tmp = millis(); + } + } + +#ifdef HAS_BTN + checkPowerSaveTime(); + if (digitalRead(BTN_PIN) == BTN_ACT) { + if (!wakeUpScreen()) AnyKeyPress = true; + SelPress = true; + long tmp = millis(); + while ((millis() - tmp) < 200 && digitalRead(BTN_PIN) == BTN_ACT); + } +#endif +} + +/********************************************************************* +** Function: powerOff +** location: mykeyboard.cpp +** Turns off the device (or try to) +**********************************************************************/ +void powerOff() { esp_deep_sleep_start(); } + +/********************************************************************* +** Function: goToDeepSleep +** location: mykeyboard.cpp +** Puts the device into DeepSleep +**********************************************************************/ +void goToDeepSleep() { esp_deep_sleep_start(); } + +/********************************************************************* +** Function: checkReboot +** location: mykeyboard.cpp +** Btn logic to turn off the device +**********************************************************************/ +void checkReboot() {} diff --git a/boards/esp32s3-st7789/pins_arduino.h b/boards/esp32s3-st7789/pins_arduino.h new file mode 100644 index 0000000000..c9cb5113c8 --- /dev/null +++ b/boards/esp32s3-st7789/pins_arduino.h @@ -0,0 +1,155 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include "soc/soc_caps.h" +#include + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t SDA = 8; +static const uint8_t SCL = 9; + +static const uint8_t SS = 10; +static const uint8_t MOSI = 11; +static const uint8_t MISO = 13; +static const uint8_t SCK = 12; + +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 3; +static const uint8_t A3 = 4; +static const uint8_t A4 = 5; +static const uint8_t A5 = 6; +static const uint8_t A6 = 7; +static const uint8_t A7 = 8; +static const uint8_t A8 = 9; +static const uint8_t A9 = 10; +static const uint8_t A10 = 11; +static const uint8_t A11 = 12; +static const uint8_t A12 = 13; +static const uint8_t A13 = 14; +static const uint8_t A14 = 15; +static const uint8_t A15 = 16; +static const uint8_t A16 = 17; +static const uint8_t A17 = 18; +static const uint8_t A18 = 19; +static const uint8_t A19 = 20; + +static const uint8_t T1 = 1; +static const uint8_t T2 = 2; +static const uint8_t T3 = 3; +static const uint8_t T4 = 4; +static const uint8_t T5 = 5; +static const uint8_t T6 = 6; +static const uint8_t T7 = 7; +static const uint8_t T8 = 8; +static const uint8_t T9 = 9; +static const uint8_t T10 = 10; +static const uint8_t T11 = 11; +static const uint8_t T12 = 12; +static const uint8_t T13 = 13; +static const uint8_t T14 = 14; + +// Boot button as OK (active-low) +#ifndef HAS_BTN +#define HAS_BTN 1 +#endif +#ifndef BTN_ALIAS +#define BTN_ALIAS "\"OK\"" +#endif +#ifndef BTN_PIN +#define BTN_PIN 0 +#endif +#ifndef BTN_ACT +#define BTN_ACT LOW +#endif + +#define HAS_SCREEN 1 +#define ROTATION 1 +#define MINBRIGHT 1 + +// TFT_eSPI Setup for ST7789 2.8" display (HSPI bus) +#ifndef USER_SETUP_LOADED +#define USER_SETUP_LOADED 1 +#endif +#ifndef ST7789_DRIVER +#define ST7789_DRIVER 1 +#endif +#ifndef TFT_RGB_ORDER +#define TFT_RGB_ORDER TFT_BGR +#endif +#ifndef TFT_WIDTH +#define TFT_WIDTH 240 +#endif +#ifndef TFT_HEIGHT +#define TFT_HEIGHT 320 +#endif +#ifndef TFT_INVERSION_ON +#define TFT_INVERSION_ON +#endif +#ifndef TFT_MISO +#define TFT_MISO 13 +#endif +#ifndef TFT_MOSI +#define TFT_MOSI 11 +#endif +#ifndef TFT_SCLK +#define TFT_SCLK 12 +#endif +#ifndef TFT_CS +#define TFT_CS 10 +#endif +#ifndef TFT_DC +#define TFT_DC 7 +#endif +#ifndef TFT_RST +#define TFT_RST 5 +#endif +#ifndef TFT_BL +#define TFT_BL 38 +#endif +#ifndef TFT_BACKLIGHT_ON +#define TFT_BACKLIGHT_ON HIGH +#endif +#ifndef SMOOTH_FONT +#define SMOOTH_FONT 1 +#endif +#define SPI_FREQUENCY 40000000 +#define SPI_READ_FREQUENCY 20000000 +#define SPI_TOUCH_FREQUENCY 2500000 + +// Touchscreen — XPT2046 resistive (shares HSPI bus with display) +#define HAS_TOUCH 1 +#define TOUCH_XPT2046_SPI 1 +#define XPT2046_SPI_BUS_MOSI_IO_NUM 11 +#define XPT2046_SPI_BUS_MISO_IO_NUM 13 +#define XPT2046_SPI_BUS_SCLK_IO_NUM 12 +#define XPT2046_SPI_CONFIG_CS_GPIO_NUM 3 +#define XPT2046_TOUCH_CONFIG_INT_GPIO_NUM -1 + +// Status LED +#define TXLED 40 +#define LED_ON HIGH +#define LED_OFF LOW + +// SD Card (on HSPI bus with display/touch) +#define SDCARD_CS 4 +#define SDCARD_SCK 12 +#define SDCARD_MISO 13 +#define SDCARD_MOSI 11 + +// Default I2C +#define GROVE_SDA 8 +#define GROVE_SCL 9 + +// Shared SPI bus for CC1101/NRF24 (main SPI) +#define SPI_SCK_PIN 12 +#define SPI_MOSI_PIN 11 +#define SPI_MISO_PIN 13 +#define SPI_SS_PIN 10 + +#endif /* Pins_Arduino_h */ diff --git a/boards/pinouts/pins_arduino.h b/boards/pinouts/pins_arduino.h index 8659090498..cd0671ccf8 100644 --- a/boards/pinouts/pins_arduino.h +++ b/boards/pinouts/pins_arduino.h @@ -46,6 +46,14 @@ #include "../ESP32-C5-tft/pins_arduino.h" #elif ESP32C5_DEVKITC_1 #include "../ESP32-C5/pins_arduino.h" +#elif ESP32S3_ILI9341 +#include "../esp32s3-ili9341/pins_arduino.h" +#elif ESP32S3_ST7789 +#include "../esp32s3-st7789/pins_arduino.h" +#elif ESP_WROOM32_ILI9341 +#include "../esp-wroom32-ili9341/pins_arduino.h" +#elif ESP_WROOM32_ST7789 +#include "../esp-wroom32-st7789/pins_arduino.h" #elif NM_CYD_ESP32C5 #include "../nm-cyd-c5/pins_arduino.h" #endif diff --git a/platformio.ini b/platformio.ini index ad1849148d..dfe606e4da 100644 --- a/platformio.ini +++ b/platformio.ini @@ -20,7 +20,7 @@ default_envs = ;m5stack-core4mb ;m5stack-cores3 ;esp32-s3-devkitc-1 - ;CYD-2432S028 + ;CYD-2432S ;CYD-2USB ;CYD-2432W328C ;CYD-2432W328C_2 @@ -64,6 +64,9 @@ default_envs = ;LAUNCHER_WaveSentry-R1 ;WaveSentry-R1 ;esp32-c5-tft + ;esp32s3-st7789 + ;esp-wroom32-st7789 + ;esp-wroom32-ili9341 ;esp32-c5 ;ES3C28P ;nm-cyd-c5 @@ -75,9 +78,9 @@ build_cache_dir = .pio/buildcache cache_dir = .pio/cache boards_dir = boards/_boards_json -extra_configs = - boards/*.ini - boards/*/*.ini +;extra_configs = +; boards/*.ini +; boards/*/*.ini [env] platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.36/platform-espressif32.zip ; Arduino 3.3.6 @@ -136,17 +139,6 @@ build_flags = -DCONFIG_ASYNC_TCP_RUNNING_CORE=1 ; -DCONFIG_ASYNC_TCP_USE_WDT=0 ; Disables the Watchdog timer on Async TCP, to avoid restartings during file uploads -DGEN_MQJS_HEADERS ; Enable generation of mquickjs headers - ; mbedtls settings for crypto operations (WhisperPair/audio exploits) - -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" - -DCONFIG_MBEDTLS_ECDH_C=1 - -DCONFIG_MBEDTLS_AES_C=1 - -DCONFIG_MBEDTLS_CTR_DRBG_C=1 - ; Additional mbedtls flags that could be useful: - ;-DCONFIG_MBEDTLS_ECP_C=1 - ;-DCONFIG_MBEDTLS_SHA256_C=1 - ;-DCONFIG_MBEDTLS_SHA512_C=1 - ;-DCONFIG_MBEDTLS_HKDF_C=1 - ;-DCONFIG_MBEDTLS_GCM_C=1 extra_scripts = pre:patch.py @@ -160,7 +152,7 @@ lib_deps = ;WireGuard-ESP32 https://github.com/bmorcelli/IRremoteESP8266 ;IRremoteESP8266 - paulstoffregen/Time@1.6.1 + Time LibSSH-ESP32 Adafruit BusIO=https://github.com/emericklaw/Adafruit-BusIO_Bruce@1.17.2-bruce.1 Adafruit PN532=https://github.com/emericklaw/Adafruit-PN532_Bruce@1.3.3-bruce.1 @@ -172,8 +164,8 @@ lib_deps = https://github.com/whywilson/ESP-PN532BLE https://github.com/whywilson/ESP-PN532-UART https://github.com/whywilson/ESP-PN532Killer - NTPClient@3.2.1 - ESP32Time@2.0.6 + NTPClient + ESP32Time FFat bblanchon/ArduinoJson https://github.com/bmorcelli/rc-switch @@ -186,7 +178,7 @@ lib_deps = Adafruit Si4713 Library@1.2.3 Bodmer/JPEGDecoder https://github.com/bmorcelli/SmartRC-CC1101-Driver-Lib/ - mquickjs=https://github.com/BruceDevices/mquickjs#0.0.6 + mquickjs=https://github.com/BruceDevices/mquickjs#0.0.4 ;paulstoffregen/OneWire@^2.3.8 https://github.com/bmorcelli/OneWire#patch-1 ;jackjansen/esp32_idf5_https_server_compat @@ -227,7 +219,7 @@ lib_deps = ;WireGuard-ESP32 https://github.com/BorisKofman/IRremoteESP8266#Espressif-version-3 ;IRremoteESP8266 - paulstoffregen/Time@1.6.1 + Time ;LibSSH-ESP32 Adafruit BusIO=https://github.com/emericklaw/Adafruit-BusIO_Bruce@1.17.2-bruce.1 Adafruit PN532=https://github.com/emericklaw/Adafruit-PN532_Bruce@1.3.3-bruce.1 @@ -238,10 +230,10 @@ lib_deps = ;https://github.com/bmorcelli/ESP-PN532BLE ;https://github.com/whywilson/ESP-PN532-UART@^0.0.2 ;https://github.com/whywilson/ESP-PN532Killer#079790e - NTPClient@3.2.1 - ESP32Time@2.0.6 + NTPClient + ESP32Time FFat - bblanchon/ArduinoJson@7.4.2 + bblanchon/ArduinoJson https://github.com/bmorcelli/rc-switch ;ESP8266Audio@^2.4.1 ;earlephilhower/ESP8266SAM@^1.1.0 @@ -252,19 +244,28 @@ lib_deps = ;Adafruit Si4713 Library@1.2.3 Bodmer/JPEGDecoder https://github.com/bmorcelli/SmartRC-CC1101-Driver-Lib/ - ;mquickjs=https://github.com/BruceDevices/mquickjs#0.0.6 + ;mquickjs=https://github.com/BruceDevices/mquickjs#0.0.4 ;paulstoffregen/OneWire@^2.3.8 ;https://github.com/bmorcelli/OneWire#patch-1 ;https://github.com/bmorcelli/ESP32-PsRamFS#patch-1 ;bitbank2/AnimatedGIF ;bitbank2/PNGdec @ ^1.1.2 - ESP32Async/AsyncTCP@3.4.10 - ESP32Async/ESPAsyncWebServer@3.9.6 + ESP32Async/ESPAsyncWebServer ;https://github.com/bmorcelli/FastLED +; PlatformIO Project Configuration File +; ESP-WROOM-32 + ST7789 2.8" TFT with XPT2046 Touch +; +; TFT Pins (VSPI): MISO=19, MOSI=23, SCLK=18, CS=17, DC=16, RST=5, BL=32 +; Touch (XPT2046): CS=21, shares VSPI bus (MISO=19, MOSI=23, SCLK=18) +; SD Card: CS=12, shares VSPI bus -[env_4mb] -extends = env +[env:esp-wroom32-st7789] +board = esp-wroom32-st7789 +board_build.partitions = custom_4Mb_full.csv +build_src_filter = ${env.build_src_filter} +<../boards/esp-wroom32-st7789> build_flags = + ${env.build_flags} + -Iboards/esp-wroom32-st7789 -Os -DCORE_DEBUG_LEVEL=0 -DCONFIG_ESP32_JTAG_SUPPORT_DISABLE=1 @@ -286,7 +287,122 @@ build_flags = -DDECODE_PANASONIC=true -DSEND_RAW=true -lib_ignore = - FastLED - ESP8266Audio - ESP8266SAM + -DDEVICE_NAME='"ESP32-ST7789 Touch"' + + ; Boot button as OK + -DHAS_BTN=1 + -DBTN_ALIAS='"OK"' + -DBTN_PIN=0 + -DBTN_ACT=LOW + + ; Infrared Led + -DIR_TX_PINS='{ {"G4", 4}, {"G2", 2}, {"G25", 25} }' + -DIR_RX_PINS='{ {"G4", 4}, {"G2", 2}, {"G25", 25} }' + -DTXLED=2 + -DLED_ON=HIGH + -DLED_OFF=LOW + + ; Radio Frequency (one pin modules) pin setting + -DRF_TX_PINS='{ {"G4", 4}, {"G2", 2}, {"G25", 25} }' + -DRF_RX_PINS='{ {"G4", 4}, {"G2", 2}, {"G25", 25} }' + + ; CC1101 SPI connection pins + -DUSE_CC1101_VIA_SPI + -DCC1101_GDO0_PIN=2 + -DCC1101_SS_PIN=15 + -DCC1101_MOSI_PIN=SPI_MOSI_PIN + -DCC1101_SCK_PIN=SPI_SCK_PIN + -DCC1101_MISO_PIN=SPI_MISO_PIN + + ; NRF24 SPI connection pins + -DUSE_NRF24_VIA_SPI + -DNRF24_CE_PIN=4 + -DNRF24_SS_PIN=15 + -DNRF24_MOSI_PIN=SPI_MOSI_PIN + -DNRF24_SCK_PIN=SPI_SCK_PIN + -DNRF24_MISO_PIN=SPI_MISO_PIN + + ; W5500 Ethernet (disabled by default) + ;-DUSE_W5500_VIA_SPI + -DW5500_SS_PIN=-1 + -DW5500_MOSI_PIN=SPI_MOSI_PIN + -DW5500_SCK_PIN=SPI_SCK_PIN + -DW5500_MISO_PIN=SPI_MISO_PIN + -DW5500_INT_PIN=-1 + + ; Lora setup pins (not connected by default) + -DLORA_SCK=SPI_SCK_PIN + -DLORA_MISO=SPI_MISO_PIN + -DLORA_MOSI=SPI_MOSI_PIN + -DLORA_CS=-1 + -DLORA_RST=-1 + -DLORA_DIO0=-1 + + ; FM Radio + -DFM_RSTPIN=-1 + + ; Font sizes + -DFP=1 + -DFM=2 + -DFG=3 + + ; Screen Setup + -DHAS_SCREEN=1 + -DROTATION=1 + -DMINBRIGHT=1 + + ; TFT_eSPI display — ST7789 240x320 SPI (VSPI) + -DUSER_SETUP_LOADED=1 + -DST7789_DRIVER=1 + -DTFT_RGB_ORDER=TFT_BGR + -DTFT_WIDTH=240 + -DTFT_HEIGHT=320 + -DTFT_INVERSION_ON + -DTFT_CS=17 + -DTFT_DC=16 + -DTFT_RST=5 + -DTFT_BL=32 + -DTFT_MOSI=23 + -DTFT_SCLK=18 + -DTFT_MISO=19 + -DTOUCH_CS=-1 + -DSMOOTH_FONT=1 + -DSPI_FREQUENCY=40000000 + -DSPI_READ_FREQUENCY=20000000 + -DSPI_TOUCH_FREQUENCY=2500000 + + ; Touchscreen — XPT2046 resistive (shares VSPI bus with display) + -DHAS_TOUCH=1 + -DTOUCH_XPT2046_SPI=1 + -DXPT2046_SPI_BUS_MOSI_IO_NUM=23 + -DXPT2046_SPI_BUS_MISO_IO_NUM=19 + -DXPT2046_SPI_BUS_SCLK_IO_NUM=18 + -DXPT2046_SPI_CONFIG_CS_GPIO_NUM=21 + -DXPT2046_TOUCH_CONFIG_INT_GPIO_NUM=-1 + -DINPUT_HANDLER_TASK_STACK_SIZE=8192 + + ; SD Card pins (on VSPI bus) + -DSDCARD_CS=12 + -DSDCARD_SCK=18 + -DSDCARD_MISO=19 + -DSDCARD_MOSI=23 + + ; Default I2C port + -DGROVE_SDA=21 + -DGROVE_SCL=22 + + ; SERIAL (GPS) dedicated pins + -DSERIAL_TX=1 + -DSERIAL_RX=3 + -DGPS_SERIAL_TX=SERIAL_TX + -DGPS_SERIAL_RX=SERIAL_RX + + ; Main SPI bus pins (for CC1101/NRF24/etc) + -DSPI_SCK_PIN=18 + -DSPI_MOSI_PIN=23 + -DSPI_MISO_PIN=19 + -DSPI_SS_PIN=15 + +lib_deps = + ${env.lib_deps} +