Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Y-mirroring with ST7789V2 on ESP32S3 #3592

Open
HonestQiao opened this issue Dec 23, 2024 · 1 comment
Open

Y-mirroring with ST7789V2 on ESP32S3 #3592

HonestQiao opened this issue Dec 23, 2024 · 1 comment

Comments

@HonestQiao
Copy link

Hardware:
Board: DFRobot K10, ESP32S3
Screen: ST7789V2

Soft:
Arduino IDE: 2.3.4
Arduino-ESP32: 3.0.7
TFT_eSPI: 2.5.43

User_Setup.h:

#define ST7789_2_DRIVER    // Minimal configuration option, define additional parameters below for this display
#define TFT_RGB_ORDER TFT_BGR  // Colour order Blue-Green-Red
#define TFT_WIDTH  240 // ST7789 240 x 240 and 240 x 320
#define TFT_HEIGHT 320 // ST7789 240 x 320
#define TFT_INVERSION_OFF
#define TFT_MOSI 21 // In some display driver board, it might be written as "SDA" and so on.
#define TFT_SCLK 12
#define TFT_CS   14  // Chip select control pin
#define TFT_DC   13  // Data Command control pin
#define TFT_RST  -1  // Reset pin (could connect to Arduino RESET pin)
#define TOUCH_CS -1
#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  27000000
#define SPI_READ_FREQUENCY  6000000
#define SPI_TOUCH_FREQUENCY  2500000
#define USE_HSPI_PORT

Code:

#include "SPI.h"
#include "TFT_eSPI.h"

TFT_eSPI tft = TFT_eSPI();

void setup() {
  Serial.begin(115200);
  tft.init();
  tft.setRotation(0);
  tft.fillScreen(TFT_BLACK);

  test_rorate();
  // test_text();
}

voide loop() {
}

void test_rorate(void)
{
  tft.fillScreen(TFT_BLACK);
  tft.setRotation(0);
  tft.setCursor(100,100);
  tft.setTextColor(TFT_WHITE);
  tft.setTextSize(2);
  tft.println("Hello World!");
  delay(1000);

  tft.fillScreen(TFT_BLACK);
  tft.setRotation(1);
  tft.setCursor(100,100);
  tft.setTextColor(TFT_WHITE);
  tft.setTextSize(2);
  tft.println("Hello World!");
  delay(1000);

  tft.fillScreen(TFT_BLACK);
  tft.setRotation(2);
  tft.setCursor(100,100);
  tft.setTextColor(TFT_WHITE);
  tft.setTextSize(2);
  tft.println("Hello World!");
  delay(1000);

  tft.fillScreen(TFT_BLACK);
  tft.setRotation(3);
  tft.setCursor(100,100);
  tft.setTextColor(TFT_WHITE);
  tft.setTextSize(2);
  tft.println("Hello World!");
  delay(1000);

  tft.fillScreen(TFT_BLACK);
  tft.setRotation(4);
  tft.setCursor(100,100);
  tft.setTextColor(TFT_WHITE);
  tft.setTextSize(2);
  tft.println("Hello World!");
  delay(1000);

  tft.fillScreen(TFT_BLACK);
  tft.setRotation(5);
  tft.setCursor(100,100);
  tft.setTextColor(TFT_WHITE);
  tft.setTextSize(2);
  tft.println("Hello World!");
  delay(1000);

  tft.fillScreen(TFT_BLACK);
  tft.setRotation(6);
  tft.setCursor(100,100);
  tft.setTextColor(TFT_WHITE);
  tft.setTextSize(2);
  tft.println("Hello World!");
  delay(1000);

  tft.fillScreen(TFT_BLACK);
  tft.setRotation(7);
  tft.setCursor(100,100);
  tft.setTextColor(TFT_WHITE);
  tft.setTextSize(2);
  tft.println("Hello World!");
  delay(10000);
}

void test_text() {
  tft.setRotation(0);
  tft.fillScreen(TFT_BLACK);

  tft.setViewport(0+2, 0+2, tft.width()-1-2, tft.height()-1-2);
  tft.frameViewport(TFT_RED, 1);

  int x0 = 5;
  int y0 = 5;
  int x1 = tft.width()-1-5;
  int y1 = tft.height()-1-5;
  int padding = 20;

  tft.drawLine(x0, y0, x1, y0, TFT_RED);    // Left Top     -> Right Top
  tft.drawLine(x1, y0, x1, y1, TFT_GREEN);  // Right Top    -> Right Bottom
  tft.drawLine(x1, y1, x0, y1, TFT_BLUE);   // Right Bottom -> Left Bottom
  tft.drawLine(x0, y1, x0, y0, TFT_YELLOW); // Left Bottom  -> Left Top

  tft.setTextSize(2);

  tft.setTextColor(TFT_RED);
  tft.setCursor(x0 + padding, y0 + padding);  // Left Top
  tft.println("1");

  tft.setTextColor(TFT_GREEN);
  tft.setCursor(x1 - padding, y0 + padding);  // Right Top
  tft.println("2");

  tft.setTextColor(TFT_BLUE);
  tft.setCursor(x1 - padding, y1 - padding);  // Right Bottom
  tft.println("3");

  tft.setTextColor(TFT_YELLOW);
  tft.setCursor(x0 + padding, y1-padding);  // Left Bottom
  tft.println("4");

  delay(10000);
}

Operational Status and Issues:

  1. Can display full screen
  2. Colors are correct
  3. But the Y-axis is mirrored

The specific display results can be seen in the image below:
WechatIMG91185
image

@Basitadam
Copy link

Have you tried #define ST7789_DRIVER also instead of #define ST7789_2_DRIVER

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants