Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions boards/_boards_json/esp-wroom32-ili9341.json
Original file line number Diff line number Diff line change
@@ -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"
}
42 changes: 42 additions & 0 deletions boards/_boards_json/esp-wroom32-st7789.json
Original file line number Diff line number Diff line change
@@ -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"
}
52 changes: 52 additions & 0 deletions boards/_boards_json/esp32s3-st7789.json
Original file line number Diff line number Diff line change
@@ -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"
}
58 changes: 58 additions & 0 deletions boards/esp-wroom32-ili9341/esp-wroom32-ili9341.ini
Original file line number Diff line number Diff line change
@@ -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
174 changes: 174 additions & 0 deletions boards/esp-wroom32-ili9341/interface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
#include "core/powerSave.h"
#include <driver/gpio.h>
#include <interface.h>

// 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; }
Loading