Skip to content

adding support for the ST7796 + creating a new variant of the T-beam #6575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 81 commits into
base: master
Choose a base branch
from

Conversation

Nasimovy
Copy link
Contributor

@Nasimovy Nasimovy commented Apr 13, 2025

modified the existing library for the ST7789 to support the ST7796
created a new variant of the T-beam that supports the ST7796 shield

edit:
the touchscreen is not working yet, the address has been added to the scani2c, should i separate it?

🤝 Attestations

  • I have tested that my proposed changes behave as described.
  • I have tested that my proposed changes do not cause any obvious regressions on the following devices:
    • LilyGo T-Beam

@Nasimovy Nasimovy marked this pull request as draft April 13, 2025 14:23
@Nasimovy
Copy link
Contributor Author

converted it to draft because i seem to get SPI related errors

Copy link
Member

@caveman99 caveman99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good overall, though i'd prefer if you got the touchscreen working as well

@caveman99 caveman99 force-pushed the T-beam-display-no-touch branch from e145e10 to e0bb762 Compare April 16, 2025 09:33
@Nasimovy
Copy link
Contributor Author

Nasimovy commented Apr 16, 2025

im trying lower SPI speeds for both the LORA module and the display because it looks like the tbeam is very EMI susceptible, or the ST7796 pumps out loads of EMI.

yesterday i had a SPI related error every ~20 minutes, also next to zero Bluetooth reception

i first want to resolve that issue before i start implementing the touchscreen

edit: resolved, Bluetooth reception is resolved with higher pinheaders

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for the ST7796 display and a matching T-Beam variant, plus a new CST226SE touchscreen driver.

  • Define ST7796 pin mappings, dimensions, and backlight settings in variants/tbeam/variant.h
  • Introduce a tbeam-displayshield PlatformIO environment with ST7796 and touchscreen library dependencies
  • Update conditional compilation in display setup, NodeDB, and I2C scanning—and add TouchScreenCST226SE driver

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
variants/tbeam/variant.h ST7796 macros and screen parameters
variants/tbeam/platformio.ini New env with USE_ST7796 flag and lib_deps
src/mesh/NodeDB.cpp Include USE_ST7796 in default-config screen check
src/main.cpp Add USE_ST7796 to setup guards and CPU speed logic
src/input/TouchScreenCST226SE.h New CST226SE touchscreen interface declaration
src/input/TouchScreenCST226SE.cpp Implementation of CST226SE touchscreen handling
src/graphics/images.h Extend image conditions to include USE_ST7796
src/graphics/ScreenFonts.h Include USE_ST7796 in font-size guard
src/graphics/Screen.h Add #include <ST7796Spi.h> for the new driver
src/graphics/Screen.cpp Instantiate ST7796Spi, backlight and cleanup logic
src/detect/ScanI2CTwoWire.cpp Detect CST226SE in I2C scan sequence
src/detect/ScanI2C.h Add CST226SE to DeviceType enum
src/configuration.h Define CST226SE_ADDR and CST226SE_ADDR_ALT
Comments suppressed due to low confidence (1)

src/input/TouchScreenCST226SE.cpp:21

  • [nitpick] Consider adding unit or integration tests for the CST226SE driver initialization and touch event handling to ensure the new touchscreen code is covered and behaves as expected.
void TouchScreenCST226SE::init()

caveman99 and others added 2 commits May 25, 2025 00:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@mverch67 mverch67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using lovyanGFX (TFTDisplay.cpp) would have saved some work as it natively supports the ST7796 display driver and also the CST226 touch screen driver (in its develop branch). It would have allowed smoother integration into TFTDisplay.cpp and avoided some code duplication for the touch driver (e.g. onEvent()) as it would have been handled automatically by class TouchScreenImpl1. As a benefit screen powersave functions could have been inherited as well.

@Nasimovy
Copy link
Contributor Author

Nasimovy commented May 25, 2025

I think using lovyanGFX (TFTDisplay) would have saved some work as it natively supports the ST7796 display

lovyangfx makes the program to large to fit on the t-beam (iram overflow ~2700)

edit: maybe i'm stupid but i got the display working in the arduino ide with lovyangfx but i couldn't fit it in the meshtastic code.

@mverch67
Copy link
Collaborator

lovyangfx makes the program to large to fit on the t-beam (iram overflow ~2700)

The current tbeam size in master is:

RAM:   [=         ]   7.4% (used 96820 bytes from 1310720 bytes)
Flash: [========= ]  89.3% (used 2165385 bytes from 2424832 bytes)

I wouldn't expect lovyanGFX being that large (260kB)?!

@Nasimovy
Copy link
Contributor Author

Nasimovy commented May 25, 2025

lovyangfx makes the program to large to fit on the t-beam (iram overflow ~2700)

The current tbeam size in master is:

RAM:   [=         ]   7.4% (used 96820 bytes from 1310720 bytes)
Flash: [========= ]  89.3% (used 2165385 bytes from 2424832 bytes)

I wouldn't expect lovyanGFX being that large (260kB)?!

the IRAM is insufficient by 2736 bytes

/root/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/tbeam-displayshield/firmware.elf section `.iram0.text' will not fit in region `iram0_0_seg'
/root/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: IRAM0 segment data does not fit.
/root/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: region `iram0_0_seg' overflowed by 2736 bytes

edit: if i compile the exact same code with 1 modification it fits on a esp 32S3

@Nasimovy Nasimovy requested a review from mverch67 May 27, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants