Skip to content

feat(boards): add LilyGO TTGO T4 v1.3 support - #2704

Open
hadifarnoud wants to merge 2 commits into
BruceDevices:devfrom
hadifarnoud:add-lilygo-t4-board
Open

feat(boards): add LilyGO TTGO T4 v1.3 support#2704
hadifarnoud wants to merge 2 commits into
BruceDevices:devfrom
hadifarnoud:add-lilygo-t4-board

Conversation

@hadifarnoud

@hadifarnoud hadifarnoud commented Jul 24, 2026

Copy link
Copy Markdown

Summary

Adds a board target for the LilyGO TTGO T4 v1.3 — ESP32-WROVER with a 2.4″ ILI9341 320×240 SPI display, microSD slot and three front buttons. There was no existing T4 target (the closest, lilygo-t-display-ttgo, is a different ST7789 135×240 device).

✅ Tested on real hardware

This board target was flashed to and verified on a physical LilyGO TTGO T4 v1.3:

  • Boots straight into the Bruce menu (replacing the factory demo firmware).
  • Display renders full-screen in landscape with the correct Bruce theme colors (dark background, purple/pink accents).
  • All three front buttons navigate the menu.
  • Flashed via esptool --chip esp32 write_flash -z 0x0 Bruce-lilygo-t4.bin after a full erase_flash.

The two follow-up commits (color inversion + rotation) are the corrections found during this on-device bring-up.

What's included

  • boards/lilygo-t4/pins_arduino.h — full pin map, ILI9341, landscape ROTATION 1
  • boards/lilygo-t4/interface.cpp — 3-button navigation (top = previous, middle = select / escape on double-click or hold, bottom = next), backlight PWM, deep-sleep power-off with wake on the middle button
  • boards/lilygo-t4/lilygo-t4.ini — PlatformIO env (4 MB, custom_4Mb_full.csv)
  • boards/lilygo-t4/connections.md — pinout documentation
  • boards/_boards_json/lilygo-t4.json — ESP32 board definition (-DLILYGO_T4)
  • boards/pinouts/pins_arduino.h — dispatcher branch for LILYGO_T4
  • Registered lilygo-t4 in platformio.ini, PR_All_envs.yml, buil_parallel.yml, manual_build_sel_env.yml and docker/run_all_envs.sh

One small core change

src/core/config.h gains an overridable default:

#ifndef DEFAULT_COLOR_INVERTED
#define DEFAULT_COLOR_INVERTED 1
#endif
...
int colorInverted = DEFAULT_COLOR_INVERTED;

begin_tft() applies tft.invertDisplay(bruceConfig.colorInverted) at runtime, so a compile-time TFT setup alone can't fix a panel that shouldn't be inverted. The default stays 1 for every existing board; this T4 panel sets -DDEFAULT_COLOR_INVERTED=0 in its .ini. Without it the T4 renders with a white background and green accents.

Pin map

Function Pins
TFT (ILI9341, VSPI) MOSI 23, MISO 12, SCLK 18, CS 27, DC 32, RST 5, BL 4 (active HIGH), 240×320, ROTATION 1
SD card (HSPI) CS 13, SCK 14, MISO 2, MOSI 15
Buttons (active LOW) 38, 37, 39
I2C (Grove) SDA 21, SCL 22

The three buttons sit on ESP32 input-only GPIOs (37/38/39), which cannot use internal pull-ups — they rely on the board's external pull-ups and are read as active LOW.

Pins were cross-checked against the official LilyGO TTGO-T4-DEMO and the TFT_eSPI Setup22_TTGO_T4_v1.3 profile.

Build

pio run -e lilygo-t4 builds clean — Flash 85.3%, RAM 30.5%, produces Bruce-lilygo-t4.bin.

hadifarnoud and others added 2 commits July 24, 2026 18:22
Adds a board target for the LilyGO TTGO T4 v1.3 (ESP32-WROVER, 2.4"
ILI9341 320x240 SPI display, microSD, three front buttons).

- boards/lilygo-t4/: pins_arduino.h, interface.cpp (3-button nav:
  Left=Prev, Center=Sel/Esc, Right=Next), PlatformIO env and pinout doc
- boards/_boards_json/lilygo-t4.json: ESP32 board definition (-DLILYGO_T4)
- boards/pinouts/pins_arduino.h: dispatcher branch for LILYGO_T4
- register lilygo-t4 in platformio.ini and the build workflows/scripts

Pins verified against the official LilyGO T4 demo and the TFT_eSPI
Setup22_TTGO_T4_v1.3 profile. Display on VSPI (MOSI23/MISO12/SCLK18/
CS27/DC32/RST5/BL4), SD on HSPI (CS13/SCK14/MISO2/MOSI15), buttons on
input-only GPIOs 38/37/39 (active LOW via the board's external pull-ups).

Builds clean: `pio run -e lilygo-t4` (Flash 85.3%, RAM 30.5%).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Hardware bring-up on a real T4 v1.3 revealed two issues:

- The panel was rendering inverted (white background, green accents)
  because Bruce defaults `colorInverted = 1` and applies it at runtime in
  begin_tft(), overriding any compile-time TFT setup. Add an overridable
  `DEFAULT_COLOR_INVERTED` hook in config.h (default 1, unchanged for all
  existing boards) and set it to 0 for this board — its ILI9341 renders
  correctly non-inverted.
- ROTATION 0 (portrait) drew the UI into the left ~60% of the panel with
  labels beside icons. The T4 is used in landscape with its three buttons
  on the right edge; ROTATION 1 fills the screen correctly.

Verified on device: menu fills the screen, colors match the Bruce theme,
and the three buttons navigate.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@hadifarnoud

Copy link
Copy Markdown
Author

Confirmed working on a physical LilyGO TTGO T4 v1.3: flashed over USB, boots into the Bruce menu full-screen in landscape with correct theme colors, and all three front buttons navigate. The color-inversion default and the rotation fix were both verified on the device.

@pr3y
pr3y changed the base branch from main to dev July 24, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants