Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

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

  1. #1
    Member gimpo's Avatar
    Join Date
    Mar 2018
    Location
    Munich
    Posts
    51

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

    Here my little contribution, hope it helps.

    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
    Click image for larger version. 

Name:	P1060196_small.JPG 
Views:	152 
Size:	94.1 KB 
ID:	15446

    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:
    Click image for larger version. 

Name:	wiring.jpg 
Views:	636 
Size:	155.8 KB 
ID:	15445
    (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);
    }
    Attached Files Attached Files

  2. #2
    Member gimpo's Avatar
    Join Date
    Mar 2018
    Location
    Munich
    Posts
    51
    UPDATE

    The pin 11 in the wiring image is wrongly named. It should be "MOSI", not "MISO".
    Here below the right wiring:
    Click image for larger version. 

Name:	wiring.jpg 
Views:	138 
Size:	133.5 KB 
ID:	15606

  3. #3
    Junior Member
    Join Date
    Mar 2017
    Location
    Germany
    Posts
    18
    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.

  4. #4
    Senior Member
    Join Date
    Feb 2015
    Posts
    217
    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.

  5. #5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •