Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
14be129
ESP32S3 Viking board config
piotrkliszka-bot Mar 18, 2026
482a62d
Fix pins for ESP32S3-Viking: TFT, touch XPT2046, disable audio/LED/SD
piotrkliszka-bot Mar 19, 2026
a97a2e9
Fix pins for ESP32S3-Viking: TFT, touch XPT2046, disable audio/LED/SD 2
piotrkliszka-bot Mar 19, 2026
bee5eb2
Fix pins for ESP32S3-Viking: TFT, touch XPT2046, disable audio/LED/SD 3
piotrkliszka-bot Mar 19, 2026
0b863a9
Correct1
piotrkliszka-bot Mar 20, 2026
3db5224
Fix pins_arduino.h: correct TFT pinout per official LCD Wiki ES3C28P …
piotrkliszka-bot Mar 20, 2026
7ecda52
Rewrite pins_arduino.h for real hardware: ESP32-S3 N16R8 + ILI9341 SP…
piotrkliszka-bot Mar 20, 2026
9f24335
Rewrite interface.cpp: XPT2046 resistive touch SPI, remove ES3C28P/FT…
piotrkliszka-bot Mar 20, 2026
1ea83ac
Update ESP32S3-Viking.ini: remove USE_SD_MMC, USE_MSPI_PORT for bare …
piotrkliszka-bot Mar 20, 2026
f1c0ca0
Fix: add build_src_filter so interface.cpp gets compiled - fixes unde…
piotrkliszka-bot Mar 20, 2026
8a778f4
Uncomment USE_HSPI_PORT build flag for display issue
piotrkliszka-bot Mar 20, 2026
cc45ea5
Fix touch (hardware SPI) and LED (FastLED WS2812, turn off on boot)
piotrkliszka-bot Mar 20, 2026
beefec7
Fix board JSON: correct variant to ESP32S3-Viking, fix flags, use qio…
piotrkliszka-bot Mar 21, 2026
ff0df47
Switch touch to USE_TFT_eSPI_TOUCH, fix include path, add HAS_TOUCH flag
piotrkliszka-bot Mar 21, 2026
d03c1fb
Rewrite interface.cpp: use tft.getTouch() for XPT2046, FastLED for RG…
piotrkliszka-bot Mar 21, 2026
57e8b86
Fix interface.cpp: remove core/powerSave.h and core/utils.h includes
piotrkliszka-bot Mar 21, 2026
3210f75
Fix interface.cpp: replace FastLED with neopixelWrite() for WS2812 LED
piotrkliszka-bot Mar 21, 2026
abeeb50
Fix interface.cpp: use extern forward decls instead of globals.h/inte…
piotrkliszka-bot Mar 21, 2026
f4a797f
Revert board to esp32-s3-devkitc-1, add PSRAM flags, keep USE_TFT_eSP…
piotrkliszka-bot Mar 21, 2026
bb73a0d
Restore interface.cpp: use project headers, neopixelWrite for LED, tf…
piotrkliszka-bot Mar 21, 2026
3a953e1
Fix interface.cpp: add core/utils.h for touchHeatMap, replace neopixe…
piotrkliszka-bot Mar 21, 2026
a8c40b5
Add BOOT-button touch recalibration trigger on startup
piotrkliszka-bot Mar 21, 2026
e02e102
Add RF 433MHz ASK pins: TX=GPIO9, RX=GPIO10
piotrkliszka-bot Mar 21, 2026
cee191c
Add RF 433MHz ASK build flags: TX=GPIO9, RX=GPIO10
piotrkliszka-bot Mar 21, 2026
29e1f3e
Fix: remove duplicate RF_TX_PINS/RF_RX_PINS from .ini (already in pin…
piotrkliszka-bot Mar 21, 2026
40430af
Disable ALLOW_ALL_GPIO_FOR_IR_RF to use fixed RF pins (GPIO9/10)
piotrkliszka-bot Mar 21, 2026
1f8ccd9
Fix: correct initializer_list syntax for IR/RF pin macros in pins_ard…
piotrkliszka-bot Mar 21, 2026
cfe02d7
configPins.h: use board-defined RF_TX/RX_DEFAULT_PIN if available
piotrkliszka-bot Mar 21, 2026
1bd10ab
pins_arduino.h: add RF_TX/RX_DEFAULT_PIN defines for GPIO9/10
piotrkliszka-bot Mar 21, 2026
7eb5f88
configPins.h: restore missing rfModule field (accidentally removed)
piotrkliszka-bot Mar 21, 2026
bfa8238
configPins.h: fix rfModule field - restore proper formatting on separ…
piotrkliszka-bot Mar 21, 2026
02bf359
pins_arduino.h: PN532 I2C->SPI (GPIO9-14), RF TX/RX->GPIO19/20
piotrkliszka-bot Mar 22, 2026
71fdd02
interface.cpp: PN532 I2C->SPI_MODULE, update wiring comments
piotrkliszka-bot Mar 22, 2026
b26b758
PN532.cpp: use dedicated PN532_*_PIN macros for SPI instead of shared…
piotrkliszka-bot Mar 22, 2026
96af7d5
pins_arduino.h: add SDA/SCL definitions required by Wire.h (GPIO3/GPI…
piotrkliszka-bot Mar 22, 2026
fca7900
pins_arduino.h: Update TFT/Touch pinout (new wiring)
piotrkliszka-bot Apr 4, 2026
d62ac18
interface.cpp: Update TFT/Touch wiring comments (new pinout)
piotrkliszka-bot Apr 4, 2026
9793258
Fix LCD backlight init IO16 pinMode OUTPUT
piotrkliszka-bot Apr 5, 2026
b334b6e
Enable PSRAM support for ESP32S3-Viking
piotrkliszka-bot Apr 5, 2026
af7d629
Configure Arduino memory type for ESP32S3-Viking
piotrkliszka-bot Apr 5, 2026
308ad17
Update ESP32S3-Viking.ini to comment out settings
piotrkliszka-bot Apr 5, 2026
20200e5
Modify TFT pin definitions for ESP32S3-Viking
piotrkliszka-bot Apr 5, 2026
2cb142a
Update TFT and touch screen pin definitions
piotrkliszka-bot Apr 5, 2026
a71a5ec
Modify CC1101 SPI pin assignments in pins_arduino.h
piotrkliszka-bot Apr 5, 2026
d1b6bd3
Disable NRF24 CE and SS pins
piotrkliszka-bot Apr 5, 2026
212241b
piotrkliszka-bot Apr 6, 2026
ac320ac
ESP32S3-Viking: CC1101 GDO0 pull-down fix for TX stability
piotrkliszka-bot Apr 6, 2026
280d105
CC1101 GDO0 pull-down fix
piotrkliszka-bot Apr 6, 2026
6c92702
Merge branch 'BruceDevices:main' into Bruce-demo
piotrkliszka-bot Apr 6, 2026
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
1 change: 1 addition & 0 deletions Bruce
Submodule Bruce added at 212241
39 changes: 39 additions & 0 deletions boards/ESP32S3-Viking/ESP32S3-Viking.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[env:esp32s3_viking]
extends = env
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
board_build.mcu = esp32s3
board_build.partitions = boards/ESP32S3-Viking/partitions_16Mb.csv
; board_build.arduino.memory_type = opi_opi
build_src_filter =${env.build_src_filter} +<../boards/ESP32S3-Viking>

build_flags =
${env.build_flags}
-DESP32S3_VIKING
-DUSE_TFT_ESPI=1
-DUSE_HSPI_PORT=1
-DUSE_TFT_eSPI_TOUCH
-DHAS_TOUCH=1
; -DUSE_SD_MMC=1 ; SD card not used
-I$PROJECT_PACKAGES_DIR/framework-arduinoespressif32-libs/esp32s3/include/fatfs/src
-I$PROJECT_PACKAGES_DIR/framework-arduinoespressif32-libs/esp32s3/include/fatfs/vfs
-I$PROJECT_PACKAGES_DIR/framework-arduinoespressif32-libs/esp32s3/include/fatfs/diskio
-I$PROJECT_PACKAGES_DIR/framework-arduinoespressif32-libs/esp32s3/include/fatfs/**
-Iboards/ESP32S3-Viking
-Os
-DCORE_DEBUG_LEVEL=1
-DARDUINO_USB_CDC_ON_BOOT=1
-DDISABLE_ALL_LIBRARY_WARNINGS
-DHAS_TOUCH=1
; -DALLOW_ALL_GPIO_FOR_IR_RF=1
-DREDRAW_DELAY=1
; ESP32-S3-WROOM-1 N16R8 = 8MB OPI PSRAM
; -DBOARD_HAS_PSRAM

lib_deps =
${env.lib_deps}

lib_ignore =
SD
FFat
204 changes: 204 additions & 0 deletions boards/ESP32S3-Viking/interface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
/*
* ESP32S3-Viking - Board interface implementation for Bruce firmware
*
* Hardware:
* - ESP32-S3-WROOM-1 N16R8 (16MB Flash, 8MB OPI PSRAM)
* - ESP32-S3 GPIO Extension Board KIT B
* - ILI9341 2.8" SPI TFT 240x320 (TENSTAR ROBOT)
* - XPT2046 Resistive Touchscreen (TOUCH_CS=IO18, T_IRQ=IO8)
* handled by TFT_eSPI built-in touch support (USE_TFT_eSPI_TOUCH)
* - PN532 NFC/RFID (SPI - osobna magistrala, GPIO 9-14)
* - WS2812 RGB LED (GPIO48)
* - BOOT button (GPIO0)
*
* Wiring TFT (left side of KIT B, top to bottom, no cable crossing):
* GND -> GND, 3V3 -> VCC
* IO4 -> T_IRQ, IO5 -> T_DO/LCD_MISO, IO6 -> T_DIN/LCD_MOSI
* IO7 -> T_CS, IO15 -> T_CLK/LCD_SCK
* IO16 -> LCD_BL, IO17 -> LCD_DC
* IO18 -> LCD_RST, IO8 -> LCD_CS *
* Wiring PN532 SPI (left side of KIT B, lower block):
* IO9 -> PN532 SCK
* IO10 -> PN532 MISO
* IO11 -> PN532 MOSI
* IO12 -> PN532 SS (CS)
* IO13 -> PN532 IRQ
* IO14 -> PN532 RSTO
*
* Wiring RF 433MHz (right side of KIT B):
* IO19 -> RF TX DATA (nadajnik)
* IO20 -> RF RX DATA (odbiornik)
*
* Touch recalibration: hold BOOT button during startup to erase saved
* calibration data and run the calibration wizard again.
*/
#include "core/powerSave.h"
#include "core/utils.h"
#include <Arduino.h>
#include <globals.h>
#include <interface.h>

/******************************************************************************
** Function name: _setup_gpio()
** Description: Initial GPIO setup for the device
******************************************************************************/
void _setup_gpio() {
// ---- WS2812 LED off at startup ----
rgbLedWrite(RGB_LED, 0, 0, 0);

// ---- Touch CS pin - TFT_eSPI will handle the rest ----
pinMode(TOUCH_CS, OUTPUT);
digitalWrite(TOUCH_CS, HIGH);

// ---- BOOT button ----
pinMode(BTN_PIN, INPUT);

// ---- Default module config ----
bruceConfigPins.rfModule = CC1101_SPI_MODULE;
bruceConfigPins.rfidModule = PN532_SPI_MODULE;
bruceConfigPins.irRx = RXLED;
bruceConfigPins.irTx = TXLED;
Serial.begin(115200);

// ---- CC1101 GDO0 pull-down (essential for TX/emulation) ----
#ifdef USE_CC1101_VIA_SPI
pinMode(CC1101_GDO0_PIN, INPUT_PULLDOWN); // GPIO42 pull-down
#endif
}

/******************************************************************************
** Function name: _post_setup_gpio()
** Description: Second stage GPIO setup - runs after TFT init
******************************************************************************/
void _post_setup_gpio() {
// ---- Touch calibration via TFT_eSPI built-in ----
pinMode(TOUCH_CS, OUTPUT);

uint16_t calData[5];
bool doCalibration = false;

// Check if BOOT button is held at startup -> force recalibration
if (digitalRead(BTN_PIN) == BTN_ACT) {
// Wait to confirm intentional press (debounce)
delay(100);
if (digitalRead(BTN_PIN) == BTN_ACT) {
// Show message on screen
tft.setRotation(ROTATION);
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setTextSize(2);
tft.setCursor(20, 100);
tft.println("Recalibrating touch...");
tft.setCursor(20, 130);
tft.println("Release BOOT button");
// Wait for button release
while (digitalRead(BTN_PIN) == BTN_ACT) delay(10);
delay(500);
// Delete saved calibration data
LittleFS.remove("/calData");
doCalibration = true;
}
}

File caldata = LittleFS.open("/calData", "r");
if (!caldata || doCalibration) {
if (caldata) caldata.close();
// No calibration data (or forced) - run calibration
tft.setRotation(ROTATION);
tft.calibrateTouch(calData, TFT_WHITE, TFT_BLACK, 10);
caldata = LittleFS.open("/calData", "w");
if (caldata) {
caldata.printf(
"%d\n%d\n%d\n%d\n%d\n", calData[0], calData[1], calData[2], calData[3], calData[4]
);
caldata.close();
}
} else {
// Load saved calibration data
for (int i = 0; i < 5; i++) { calData[i] = caldata.parseInt(); }
caldata.close();
tft.setTouch(calData);
}

// ---- Backlight on ----
if (TFT_BL >= 0) pinMode(TFT_BL, OUTPUT);
if (TFT_BL >= 0) analogWrite(TFT_BL, 255);

// ---- LED off ----
rgbLedWrite(RGB_LED, 0, 0, 0);
}

/******************************************************************************
** Function name: _setBrightness()
** Description: Set TFT backlight brightness
******************************************************************************/
void _setBrightness(uint8_t brightness) {
int bl = map(brightness, 0, 100, MINBRIGHT, 255);
analogWrite(TFT_BL, bl);
}

/******************************************************************************
** Function name: InputHandler()
** Description: Handles touch and button input for Bruce UI
******************************************************************************/
void InputHandler() {
static unsigned long lastTouch = 0;
unsigned long now = millis();

// ---- Touch input (poll every ~200ms or on LongPress) ----
if (now - lastTouch > 200 || LongPress) {
lastTouch = now;
uint16_t t_x = 0, t_y = 0;
bool touched = tft.getTouch(&t_x, &t_y);
if (touched) {
touchPoint.x = t_x;
touchPoint.y = t_y;
touchPoint.pressed = true;
if (wakeUpScreen()) AnyKeyPress = true;
else {
AnyKeyPress = true;
touchHeatMap(touchPoint);
}
} else {
touchPoint.pressed = false;
}
}

// ---- BOOT Button ----
if (digitalRead(BTN_PIN) == BTN_ACT) {
if (!wakeUpScreen()) {
AnyKeyPress = true;
SelPress = true;
}
while (digitalRead(BTN_PIN) == BTN_ACT) delay(10);
}
}

/******************************************************************************
** Function name: powerOff()
******************************************************************************/
void powerOff() {
rgbLedWrite(RGB_LED, 0, 0, 0);
if (TFT_BL >= 0) analogWrite(TFT_BL, 0);
tft.writecommand(0x10); // SLPIN
esp_sleep_enable_ext0_wakeup((gpio_num_t)BTN_PIN, BTN_ACT);
esp_deep_sleep_start();
}

void goToDeepSleep() { powerOff(); }

/******************************************************************************
** Function name: checkReboot()
******************************************************************************/
void checkReboot() {
int c = 0;
while (digitalRead(BTN_PIN) == BTN_ACT) {
delay(100);
if (++c > 20) powerOff();
}
}

/******************************************************************************
** Function name: isCharging()
******************************************************************************/
bool isCharging() { return false; }
5 changes: 5 additions & 0 deletions boards/ESP32S3-Viking/partitions_16Mb.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x6000,
app0, app, factory, 0x10000, 0x470000,
spiffs, data, spiffs, 0x480000, 0xB70000,
coredump, data, coredump, 0xFF0000, 0x10000,
Loading