Xinyuan-LilyGO / TTGO-T-Display

MIT License
1.02k stars 335 forks source link

Display fails when code uploaded by PlatformIO #113

Closed iconnor closed 1 year ago

iconnor commented 1 year ago

I have a T-Display-S3 that works well but the T-Display ESP32/RP2040 that arrived recently will only show a black screen and failed to print text to it.

My platformoi.ini file:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200

lib_deps = bodmer/TFT_eSPI

build_flags =
  -Os
  -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
  -DUSER_SETUP_LOADED=1
  ; Define the TFT driver, pins etc here:
  -DST7789_DRIVER=1
  -DTFT_WIDTH=128
  -DTFT_HEIGHT=160
  -DTFT_MOSI=19
  -DTFT_SCLK=18
  -DTFT_CS=5
  -DTFT_DC=16
  -DLOAD_FONT2=1
  -DLOAD_FONT4=1
  -DLOAD_FONT6=1
  -DLOAD_FONT7=1
  -DLOAD_FONT8=1
  -DLOAD_GFXFF=1
  -DSMOOTH_FONT=1
  -DSPI_FREQUENCY=27000000

main.cpp


#define TFT_BL  4
#define I2C_SDA 21
#define I2C_SCL 22
#define ADC_IN  34
#define BUTTON1 35
#define BUTTON2 0

#include <SPI.h>
#include <TFT_eSPI.h> 

TFT_eSPI tft = TFT_eSPI();

void setup(void) {
  Serial.begin(115200);

  Serial.println("Started up");

  tft.init();
  tft.setSwapBytes(true);
  tft.setRotation(0);
  tft.fillScreen(TFT_BLACK);
  Serial.println("Screen filled black");
  tft.setCursor(0, 0);
  tft.setTextColor(TFT_WHITE);
  Serial.println("Text colour set but we never get to the next step");

  // We should be able to print text now
  tft.println("Never gets to this step");
  Serial.println("Printed text");
}

void loop(void) {
}
Wrote 313008 bytes (172800 compressed) at 0x00010000 in 4.6 seconds (effective 545.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
======================================================= [SUCCESS] Took 12.23 seconds =======================================================
--- Terminal on /dev/cu.usbserial-56440195251 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
Screen init
Screen filled white
Screen filled black
Cursor set
Text colour set
Printed text

I can see the Serial.println but the screen remains black. Thanks.

iconnor commented 1 year ago

Once I changed the platformio.ini to this it started to work:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200

lib_deps = bodmer/TFT_eSPI

build_flags =
  -Os
  -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
  -DUSER_SETUP_LOADED=1
  ; Define the TFT driver, pins etc here:
  -DST7789_DRIVER=1
  -DTFT_WIDTH=135
  -DTFT_HEIGHT=240
  -DTFT_MOSI=19
  -DTFT_SCLK=18
  -DTFT_SDA=21
  -DTFT_SCL=22
  -DTFT_CS=5
  -DTFT_BL=4
  -DTFT_DC=16
  -DLOAD_FONT2=1
  -DLOAD_FONT4=1
  -DLOAD_FONT6=1
  -DLOAD_FONT7=1
  -DLOAD_FONT8=1
  -DLOAD_GFXFF=1
  -DSMOOTH_FONT=1
  -DSPI_FREQUENCY=27000000