About 1.54" TFT 240x240 pixel with ST7789 and 22 pin connector

Status
Not open for further replies.

gimpo

Well-known member
Here my little contribution, hope it helps. :cool:

I bought a cheap 1.54 inch TFT display. Despite all my doubts I was able to make it working by using the standard Adafruit libs on my Teensy 3.2
P1060196_small.JPG

Very helpful was the datasheet sent me from the vendor (see attachments): 1pcs 1.54 inch IPS tft display 220PPI 240*240 pixels SPI Serial and parallel Interface st7789v

The wiring I adopted is depicted below:
wiring.jpg
(Note: a resistor of 20 Ohm is okay for indoor usage. If you want more brightness then you can lower it to 15 Ohm or less - but I didn't measured yet the current absorption.)


Here below, a simple sketch for testing the TFT:
Code:
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library
#include <Adafruit_ST77xx.h> // just for colo defs
#include <SPI.h>

#define TFT_RST    2   // chip reset
#define TFT_DC     3   // tells the display if you're sending data (D) or commands (C)   --> A0 or WR pin on TFT
#define TFT_MOSI   11  // Data out    (SPI standard)
#define TFT_SCLK   13  // Clock out   (SPI standard)
#define TFT_CS     15  // chip select (SPI standard)
int x, y;
bool toogle;

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

void setup(void) {
  pinMode(23, OUTPUT);
  pinMode(22, OUTPUT);
  pinMode(21, OUTPUT);
  digitalWrite(23, HIGH);
  digitalWrite(22, HIGH);
  digitalWrite(21, LOW);

  tft.init(240, 240);
  tft.setRotation(2);
  tft.fillScreen(ST77XX_BLACK);

  // up left
  tft.fillRect(0, 0, 10, 10, ST77XX_BLUE);
  tft.setCursor(12, 12);
  tft.println("UP-LEFT");
  delay(500);

  // bottom right
  tft.fillRect(tft.width() - 10, tft.height() - 10, 10, 10, ST77XX_RED);
  tft.setCursor(tft.width() - 82, tft.height() - 20);
  tft.println("BOTTOM-RIGHT");
  delay(500);

  // area frame
  tft.drawRect(0, 0, tft.width(), tft.height(), ST77XX_GREEN);
  delay(3000);
}

void loop()
{
  tft.fillScreen(ST77XX_BLACK);
  x = 0;
  y = 0;
  toogle = true;
  for (int i = 0; i < 20; i++)
  {
    tft.fillRect(x, y, 50, 50, toogle ? ST77XX_BLUE : ST77XX_YELLOW);
    tft.fillRect(190 - x, y, 50, 50, toogle ? ST77XX_RED : ST77XX_ORANGE);
    x += 10;
    y += 10;
    toogle = toogle == true ? false : true;
  }
  delay(1000);
}
 

Attachments

  • 1.54-Shenzhen-high-quality-np.pdf
    317.6 KB · Views: 189
UPDATE

The pin 11 in the wiring image is wrongly named. It should be "MOSI", not "MISO".
Here below the right wiring:
wiring.jpg
 
Even better: This display works with Pauls ILI9341_t3 library. In fact I managed to use KurtE's ILI9341_t3n library to drive this display including its frame buffer functionality and at full 30MHz SPI Speed.
There are only a few things to change, mainly one register (MADCTL, 36h) in the initialization sequence and in the setrotation() function (due to its write access to MADCTL). Additionally the display has to be inverted since it is an IPS display which is "normally black".

There are a few more things to do in the initialization sequence due to odd looking color gradients. Furthermore I did only test the standard graphicstest sketch and a few of my own sketches, which do not use all functions of the library.
Obviously this display has no MISO pin, so everything which has to read data from the display will not work.
 
Hi - sorry for reviving this old thread. Would you elaborate on "a few more things to do in the initialization sequence due to odd looking color gradients"? I've been working with these IPS displays and noticed really poor colors for the first few minutes after the display has powered up, and have been looking for solutions.
 
Status
Not open for further replies.
Back
Top