Hello everyone,
I have attempted to use TFT_eSPI with a Waveshare RP2040 Zero and a 1.47" 172 x 320 ST7789 LCD Screen but can't get it to work. There is no display whatsoever - just a blank screen with no text or colour evident.
I have been successful in getting the LCD Screen and RP2040 to work using the DFRobot_ST7789_172x320_HW_SPI screen library, however.
Any idea as to what's wrong?
RP2040_TFT_eSPI_Colour_Test.ino:
// Diagnostic test for the displayed colour order by Bodmer 17/2/19 for the TFT_eSPI library: https://github.com/Bodmer/TFT_eSPI
#include <SPI.h>
#include <TFT_eSPI.h> // Hardware-specific library
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
void setup()
{
tft.init();
tft.fillScreen(TFT_WHITE);
tft.drawRect(0, 0, tft.width(), tft.height(), TFT_GREEN);
tft.setCursor(0, 4, 4); // Set "cursor" at top left corner of display (0,0) and select font 4
tft.setTextColor(TFT_WHITE); // Set the font colour to be white with a black background
tft.println(" Initialised default\n"); // We can now plot text on screen using the "print" class
tft.println(" White text");
tft.setTextColor(TFT_RED);
tft.println(" Red text");
tft.setTextColor(TFT_GREEN);
tft.println(" Green text");
tft.setTextColor(TFT_BLUE);
tft.println(" Blue text");
delay(5000);
}
void loop()
{
tft.invertDisplay(false); // Where i is true or false
tft.fillScreen(TFT_BLACK);
tft.drawRect(0, 0, tft.width(), tft.height(), TFT_GREEN);
tft.setCursor(0, 4, 4);
tft.setTextColor(TFT_WHITE);
tft.println(" Invert OFF\n");
tft.println(" White text");
tft.setTextColor(TFT_RED);
tft.println(" Red text");
tft.setTextColor(TFT_GREEN);
tft.println(" Green text");
tft.setTextColor(TFT_BLUE);
tft.println(" Blue text");
delay(5000);
// Binary inversion of colours
tft.invertDisplay(true); // Where i is true or false
tft.fillScreen(TFT_BLACK);
tft.drawRect(0, 0, tft.width(), tft.height(), TFT_GREEN);
tft.setCursor(0, 4, 4);
tft.setTextColor(TFT_WHITE);
tft.println(" Invert ON\n");
tft.println(" White text");
tft.setTextColor(TFT_RED);
tft.println(" Red text");
tft.setTextColor(TFT_GREEN);
tft.println(" Green text");
tft.setTextColor(TFT_BLUE);
tft.println(" Blue text");
delay(5000);
}
User_Setup.h:
// USER DEFINED SETTINGS
// Set driver type, fonts to be loaded, pins used and SPI control method etc.
// User defined information reported by "Read_User_Setup" test & diagnostics example
/* TFT WIRE RP2040 RP2040 This Other
COLOUR (native) (pin #) Definition Pin #SCLK Brown SPI0 SCK GP2 TFT_SCLK 21 (2u)
MOSI Orange SPI0 TX GP3 TFT_MOSI 20 (3u)
CS Yellow SPI0 CSn GP1 TFT_CS 22 ()
RES Green GP GP6 TFT_RES 17
DC Blue GP GP7 TFT_DC 16
BLK Purple GP GP8 TFT_BLK 15
https://www.waveshare.com/wiki/File:900px-RP2040-Zero-details-7.jpg
| |
| | https://github.com/earlephilhower/arduino-pico/blob/master/variants/waveshare_rp2040_zero/pins_arduino.h
Pin# Pin# ? | | | |
___(_____)___ | | | | TFT_eSPI COLOUR
5v 1 | *USB C* | 23 1 GPIO0 GP0 SPI0 RX PIN_SPI0_MISO (4u) not used
GND 2 | | 22 2 GPIO1 GP1 SPI0 CSn PIN_SPI0_SS (5u) TFT_CS Yellow
3.3v 3 | | 21 4 GPIO2 GP2 SPI0 SCK PIN_SPI0_SCLK (2u) TFT_SCLK Brown
GPIO29 4 | | 20 5 GPIO3 GP3 SPI0 TX PIN_SPI0_MOSI (3u) TFT_MOSI Orange
GPIO28 5 | | 19 6 GPIO4
GPIO27 6 | | 18 7 GPIO5
GPIO26 7 | | 17 9 GPIO6 GP6 TFT_RST Green
GPIO15 8 | | 16 10 GPIO7 GP7 TFT_DC Blue
GPIO14 9 |__|_|_|_|_|__| 15 11 GPIO8 GP8 TFT_BLK Purple
1 1 1 1 1
0 1 2 3 4
Pin10 = GPIO13
Pin11 = GPIO12
Pin12 = GPIO11
Pin13 = GPIO10
Pin14 = GPIO9
? 1 1 1 1 1 ?: https://mischianti.org/wp-content/uploads/2022/09/Waveshare-rp2040-zero-Raspberry-Pi-Pico-alternative-pinout.png
7 6 5 4 2 */
#define USER_SETUP_INFO "User_Setup"
#define ST7789_DRIVER // or #define ST7789_2_DRIVER // Minimal configuration option, define additional parameters below for this display
//#define RPI_DISPLAY_TYPE // I've tried with this commented out as well - no change
#define TFT_WIDTH 172 // ST7789 172 x 320
//#define TFT_SPI_PORT 0
#define TFT_BACKLIGHT_ON HIGH // Level to turn ON back-light (HIGH or LOW)
#define TFT_CS 1
#define TFT_SCLK 2
#define TFT_MOSI 3
#define TFT_RST 6
#define TFT_DC 7
#define TFT_BLK 8 // LED back-light control pin
#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_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
#define SMOOTH_FONT // Comment out stop the SPIFFS filing system and smooth font code being loaded (will save ~20kB of FLASH)
#define SPI_FREQUENCY 25000000

