TFT screen Help

I have an old project that I am trying to adapt to meshtasic. It uses a TFT ST7789 display (SPI), and I am really struggling to get the firmware to play nicely with it.

Hardware:
Lolin32 v1.0.0
GPS ublox neo 7M
ST7789 240x280 TFT display

(Plan to redesign this hardware to use the E22-900m30s Lora Module)

Things I’ve tried:

  • I’ve made sure that I have set all the ST7789_CS, _RS, _SDA etc in the variant.h file

  • I have tried changing the ST7789_SPI_HOST to SPI_HOST, SPI2_HOST, SPI3_HOST, VSPI_HOST & HSPI_HOST

  • I’ve looked at the t-deck and the t-watch configurations to try and see what they are doing because they use the same driver. But have not had any luck.

I would love to get some help if anyone has any ideas of what I may be doing wrong. Please feel free to let me know.




This is my Variant.h so far, just to try to get the Display working. I will need to add the Lora Module later as well as defining buttons and battery pins etc.

// For uBlox Neo 7M
#define GPS_TX_PIN 15
#define GPS_RX_PIN 2

#define HAS_SCREEN 1

#define SPI_INTERFACES_COUNT 1

// ST7789 TFT LCD
#define ST7789_CS 5 // *
#define ST7789_RS 16  // DC
#define ST7789_SDA 23 // MOSI
#define ST7789_SCK 18 // *
#define ST7789_RESET -1 // 4
#define ST7789_MISO -1 // 19
#define ST7789_BUSY -1
#define ST7789_BL 17 // *
#define ST7789_BACKLIGHT_EN 42
#define ST7789_SPI_HOST SPI2_HOST

// #define ST7789_SPI_HOST SPI_HOST *
// #define ST7789_SPI_HOST SPI2_HOST *
// #define ST7789_SPI_HOST SPI3_HOST *
// #define ST7789_SPI_HOST HSPI_HOST *
// #define ST7789_SPI_HOST VSPI_HOST *

// #define SPI_FREQUENCY 40000000
#define SPI_FREQUENCY 27000000
#define SPI_READ_FREQUENCY 16000000

#define TFT_HEIGHT 280
#define TFT_WIDTH 240

#define TFT_OFFSET_X 0
#define TFT_OFFSET_Y 0
#define TFT_OFFSET_ROTATION 0
#define SCREEN_ROTATE
#define SCREEN_TRANSITION_FRAMERATE 5

this is a snippet from the debug console:

WARN  | ??:??:?? 0 SPI.begin(SCK=18, MISO=19, MOSI=23, NSS=22)
DEBUG | ??:??:?? 0 TFTDisplay!
DEBUG | ??:??:?? 0 Read RTC time as 0
INFO  | ??:??:?? 0 Setting GPS power=1
DEBUG | ??:??:?? 0 WANT GPS=1
INFO  | ??:??:?? 0 Setting GPS power=1
DEBUG | ??:??:?? 0 Using GPIO2 for GPS RX
DEBUG | ??:??:?? 0 Using GPIO15 for GPS TX
DEBUG | ??:??:?? 0 NeighborInfoModule is disabled
INFO  | ??:??:?? 0 External Notification Module Disabled
INFO  | ??:??:?? 0 Doing TFT init
[   528][E][esp32-hal-gpio.c:102] __pinMode(): Invalid pin selected
E (520) gpio: gpio_set_level(227): GPIO output gpio_num error
INFO  | ??:??:?? 0 Power to TFT Backlight
INFO  | ??:??:?? 0 Turning on screen
E (946) gpio: gpio_set_level(227): GPIO output gpio_num error
E (946) gpio: gpio_set_level(227): GPIO output gpio_num error
DEBUG | ??:??:?? 1 Module wants a UI Frame
INFO  | ??:??:?? 1 Not using WIFI
ERROR | ??:??:?? 1 NOTE! Recording critical error 3 at src/main.cpp:915
INFO  | ??:??:?? 1 PowerFSM init, USB power=��!T�U�| ??:??:?? 1 Enter state: BOOT
[  1026][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 320 / 4 = 80 Mhz, APB: 80000000 Hz
DEBUG | ??:??:?? 1 [Screen] Screen: Started...
DEBUG | ??:??:?? 1 [Screen] Screen: Critical error 3!