Closed QY7 closed 2 years ago
The display does not have a chip select and they do seem to be problematic. I think I have one so will try it.
In the meantime you can try adding this line to the setup file:
Also run the Read_User_Setup diagnostic sketch and check the serial monitor output is correct.
I tried mine and it is working fine.
This is the setup I used:
// ST7789 240 x 240 display with no chip select line
#define ST7789_DRIVER // Configure all registers
#define TFT_WIDTH 240
#define TFT_HEIGHT 240
#define TFT_MOSI 23 // In some display driver board, it might be written as "SDA" and so on.
#define TFT_SCLK 18
#define TFT_DC 2 // Data Command control pin
#define TFT_RST 4 // Reset pin (could connect to Arduino RESET pin)
#define TFT_BL 21 // LED back-light
#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
#define SMOOTH_FONT
#define SPI_FREQUENCY 40000000
#define SPI_READ_FREQUENCY 20000000
#define SPI_TOUCH_FREQUENCY 2500000
This is the Read_User_Setup sketch output:
TFT_eSPI ver = 2.4.31
Processor = ESP32
Frequency = 240MHz
Transactions = Yes
Interface = SPI
Display driver = 7789
Display width = 240
Display height = 240
MOSI = GPIO 23
SCK = GPIO 18
TFT_DC = GPIO 2
TFT_RST = GPIO 4
TFT_BL = GPIO 21
Font GLCD loaded
Font 2 loaded
Font 4 loaded
Font 6 loaded
Font 7 loaded
Font 8 loaded
Smooth font enabled
Display SPI frequency = 40.00
Thank you for your timely reply. Unfortunately, I tried to copy your setup content directly and the screen still shows nothing, only black screen. And the Read_User_Setup sketch output is totally the same as your result.
I have tried to modify the pin configuration in the lv_port_esp32 project, and the screen successfully shows the content. here is the pin configuration, which is the same as yours.
Is there any clue I can find? I still think it is the problem of the code. Besides, could you please provide me with the complete project you used?
The main difference now is that you are using PlatformIO and I use the Arduino IDE. Users have reported success with TFT_eSPI so this must be an environment setup problem. Which version of the Arduino board support package are you using?
Here is my platformIO configuration file and I think the board support package is for esp32 dev.
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
lib_deps = bodmer/TFT_eSPI@2.4.21
Looks like you are using the Espressif IDF platform and TFT_eSPI will not run under that.
I loaded PlatformIO on my PC and created a simple project. It compiled,uploaded and ran OK. I added the setup information to the platformio.ini so that then it is not necessary to edit files in the TFT_eSPI library. You will need to adjust the pins but try this:
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:esp32dev]
platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
board = esp32dev
framework = arduino
lib_deps = bodmer/TFT_eSPI@^2.4.31
build_flags =
-Os
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DUSER_SETUP_LOADED=1
-DST7789_DRIVER=1
-DTFT_WIDTH=240
-DTFT_HEIGHT=240
-DTFT_MOSI=23
-DTFT_SCLK=18
-DTFT_DC=2
-DTFT_RST=4
-DTFT_BL=21
-DLOAD_GLCD=1
-DLOAD_FONT2=1
-DLOAD_FONT4=1
-DLOAD_FONT6=1
-DLOAD_FONT7=1
-DLOAD_FONT8=1
-DLOAD_GFXFF=1
-DSMOOTH_FONT=1
-DSPI_FREQUENCY=40000000
I have looked deeper and the PlatformIO environment is using a fairly old version (1.0.0) of the Arduino ESP32 board package (when "platform = espressif32" is used) whereas the latest is 2.0.x
Using: platform = https://github.com/platformio/platform-espressif32.git
Forces the use of 2.0.x so that is why this works in my setup.
To maintain compatibility with older versions I have patched the TFT_eSPI library and raised to 2.4.32. So it should now work with those older board packages when: platform = espressif32 is used.
Thanks for raising this issue.
Problem description
Hi, there, I'm currently using this library on my project, which uses esp32 as the controller and st7789 as the screen driver. I downloaded this library on platformio of vscode and modified the library settings according to the instruction but when I upload my program on my board, nothing shows up. I'm pretty sure the hardware connection is correct and the screen is fine because I have tried to display things on the screen with LV_port_esp32 project, where the pin definition is the same as in the
User_Setup.h
settings.My project content
Here is my project structure I have modified the
User_Setup.h
accordingly and here is my content. I have deleted most of the commented content to make it easier for reading.And my main.cpp file content is copied from the example project, which is
My efforts for debugging
In order to figure out why doesn't it work with this library, I have tried to probe the signal with my oscilloscope. RST is set low at startup and then goes high, VCC and GND is correct. Then, I saw signals on DC pin every 1s, but I didn't see any thing on SCLK and MOSI, I guess this might be the problem. However, I didn't find any clue any more. If you can help me, I would appreciate it.