Bodmer / TFT_eSPI

Arduino and PlatformIO IDE compatible TFT library optimised for the Raspberry Pi Pico (RP2040), STM32, ESP8266 and ESP32 that supports different driver chips
Other
3.81k stars 1.1k forks source link

Not working with Waveshare ST7789V2 rounded display #3452

Open step135 opened 3 months ago

step135 commented 3 months ago

I use ESP32 CAM.

User_Setup.h

#define ST7789_2_DRIVER  // Use this definition for ST7789v2

// Define the display size
#define TFT_WIDTH  240     // ST7789v2 240 x 240 pixels
#define TFT_HEIGHT 280     // Change this if your display has a different resolution

// initialization sequence
#define TFT_INIT_DELAY 0x01

// Define the pins used for the display
#define TFT_MOSI  13       // Data out (MOSI)
#define TFT_SCLK  14       // Clock out (SCLK)
#define TFT_CS    15       // Chip select control pin (if used), set to -1 if not connected
#define TFT_DC    2       // Data/Command control pin (DC)
#define TFT_RST   12       // Reset pin (RST)

// Optional: Set the backlight pin if available
// #define TFT_BL   16      // Backlight control pin

// Set the SPI frequency
#define SPI_FREQUENCY  27000000 // 27 MHz (adjust as needed)

text.ino

#include <TFT_eSPI.h>   // Include the graphics library (this includes the SPI library)

// Create an instance of the display driver
TFT_eSPI tft = TFT_eSPI();  // Invoke library, pins defined in User_Setup.h

void setup() {
  Serial.begin(115200);
  Serial.println("mx TFT2 started");

  pinMode(TFT_RST, OUTPUT);
  digitalWrite(TFT_RST, LOW);
  delay(50);  // Hold reset low for 50ms
  digitalWrite(TFT_RST, HIGH);
  delay(50);  // Wait for display to reset

  tft.init();
  tft.setRotation(1); // Set display rotation

  tft.fillScreen(TFT_BLUE); // Clear the screen
  tft.invertDisplay(true);
  tft.setTextColor(TFT_WHITE, TFT_BLACK);  // Set text color to white with black background
  tft.setTextSize(2); // Set the text size

  tft.setCursor(10, 10); // Set cursor position
  tft.print("Hello World! ST7789v2"); // Print "Hello World!" on the screen

  tft.setTextSize(6);
  tft.setTextColor(TFT_RED, TFT_ORANGE);
  tft.setCursor(10, 50);
  tft.print("end");

  Serial.println("end printed on TFT");
}

void loop() {
  if(true){
  tft.init();
  tft.setRotation(0); // Set display rotation

  //tft.fillScreen(TFT_BLUE); // Clear the screen
  tft.setTextColor(TFT_WHITE, TFT_BLACK);  // Set text color to white with black background
  tft.setTextSize(4); // Set the text size
  tft.setCursor(10, 150);
  tft.print("loop");
  Serial.println("loop on TFT");
  delay(5000);
  }
}
anishkarbhari commented 2 months ago

I'm also facing a similar issue. If you have got any update on this please do share here

anishkarbhari commented 2 months ago

https://forum.lvgl.io/t/facing-st7789v2-240-280-display-issue-using-lvgl-display-look-black-not-showing-ui/14795

You could try this once, although it did not work for me!

jcattone commented 1 month ago

I'm in a similar boat with an integrated ESP32-S3+ST7789V2 display. I'm trying to use Setup208_ST7789.h, as supplied from the Waveshare wiki's `product page', where the 'sample demo' download provides the libraries. I did update all of the included libraries to the latest releases.

The (not currently working) config provided by WaveShare is as follows:

#define USER_SETUP_ID 208

#ifdef USER_SETUP_INFO
#undef USER_SETUP_INFO
#define USER_SETUP_INFO "ESP32-S3-Touch-LCD-1.69"
#endif

#ifdef ILI9341_DRIVER
#undef ILI9341_DRIVER
#endif

#define ST7789_DRIVER

// For ESP32 Dev board (only tested with GC9A01 display)
// The hardware SPI can be mapped to any pins

#define TFT_WIDTH  240
#define TFT_HEIGHT 280

#define TFT_RGB_ORDER TFT_BGR

#define TFT_MISO -1
#define TFT_MOSI 7
#define TFT_SCLK 6
#define TFT_CS   5  // Chip select control pin
#define TFT_DC   4  // Data Command control pin
#define TFT_RST  8
#define TFT_BL  15
#define TFT_BACKLIGHT_ON HIGH

#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  80000000

I'd be happy to help test, or run diagnostics, if that would help.