Colors on tft display is reversed?

Hello. I was playing around with an Adafruit ESP32 V2 and the 2.4" tft display that uses the ST7789V driver and for some reason my colors are reversed. communication is 4-wire SPI. Pixel size is 320x240. The only thing I can think of is that the display is 18-bit color and I am using the adafruit_gfx library that is 16-bit color? And if so, how would I go about tinkering this?

#include <Adafruit_GFX.h>
#include "Fonts/FreeSans24pt7b.h"
#include "Fonts/Picopixel.h"
#include <Adafruit_ST7789.h>
#include <SPI.h>
#include <Streaming.h>

// Pin configuration for your ESP32 Feather
#define TFT_SCLK    SCK  // SCLK or CLK
#define TFT_MISO    MISO  // MISO or SDI
#define TFT_MOSI    MOSI  // MOSI or SDA
#define TFT_RST     14  // Reset pin, set to -1 if not used
#define TFT_DC      27  // Data/Command select pin
#define TFT_CS      SS  // Chip select pin
#define TFT_IM0     32
#define TFT_IM1     15
#define SELECT      34
#define UP          7
#define DOWN        8

Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);

void setup() {
  pinMode(TFT_CS, OUTPUT);
  pinMode(TFT_DC, OUTPUT);
  pinMode(TFT_RST, OUTPUT);
  pinMode(TFT_IM0, OUTPUT);
  pinMode(TFT_IM1, OUTPUT);

  digitalWrite(TFT_CS, INPUT_PULLUP);
  digitalWrite(TFT_RST, LOW);
  digitalWrite(TFT_IM0, LOW);
  digitalWrite(TFT_IM1, HIGH);

  Serial.begin(115200);

  while (!Serial.available()) {
    ;
  }

  Serial << "Hello Initialization setup" << endl;

  tft.init(240, 320); // Initialize the display
  
  // Rotate the display if necessary
  tft.setRotation(3);
  display_one();
  delay(1000);
  display_two();
}

void loop() {
  
}

void display_one() {
  tft.fillScreen(0xFFFF); // supposed to be White but its Black
  tft.setCursor(30, 50);
  tft.setFont(&FreeSans24pt7b);
  tft.setTextColor(0x0000, 0XFFFF); //supposed to be white
  tft.setTextSize(1);
  tft.println("HELLO!");
}

void display_two() {
  tft.fillScreen(0x07E0); // supposed to be Green but Magenta
  tft.setCursor(30, 50);
  tft.setFont(&FreeSans24pt7b);
  tft.setTextColor(0x0000, 0XFFFF); //supposed to be white
  tft.setTextSize(1);
  tft.println("HELLO!");
}

From the library:

There seems to be, in the library (ST77xx.h), settings INVOFF and INVON.
ST77xx.h is included in ST7789.h, which has the setting INVON.
Maybe try INVOFF?
Also, see page 190 here:

Well that was very mean of them to do that. :sweat_smile:

Thank you that solved my reversed colors.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.