Making Teensy-4 and an ST7789 240x240 display work.

Blackdog

New member
Hi,

I've been struggling today with a Teesy-4 and a ST7789 240x240 1.3 Inch display without a CS pin.

Whatever library I try, I don't get an image, only a vague gray background.
I use the standard SPI0 pins 11(SDA) and 13(SCL) and pin 8(RES) and 9(DC) and of course the power pins. :)

Can somebody explain to me which library to use and give me some sample code without code for any other display in it or al kind of test in it.
All I need is the setup for this display and an *.ino file with Hello World example.
None of the libraries I found have such an example...

used this library: ST7735_t3-master
used this library: Arduino_ST7789_Fast-master
And this library: Adafruit_ST7735_and_ST7789_Library

I am grateful for all the help,
Bram
 
The rather complex example of uncanny eyes (Examples -> ST8835_t3 -> uncannyEyes_async_st7789_240x240) has an example using two displays on the two SPI buses, with each display not having a CS pin.

Note, you can have nothing else on the SPI bus, since the display would interpret commands set to any other device.

In general you want to include <ST7789_t3.h>. The constructor arguments used in uncanny eyes for the first display are:

  • {-1, 9, 11, 13, 8 }
  • CS pin: -1
  • DC pin: 9 (feel free to change this)
  • MOSI pin: 11
  • SCLK pin: 13
  • reset pin: 8 (feel free to change this)

Then the init call has 3 arguments:
  • init(240, 240, SPI_MODE2)
  • I.e. screen is 240x240
  • Use SPI_MODE2 for the display
 
Hi Michael,

Look @ the picture!
NA-AD9833-Gen-15.png

Basic code to make ik work on a Teensy LC...

#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <ST7789_t3.h>
#include <SPI.h>

#define TFT_CS -1
#define TFT_RST 9 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 8

// For 1.14", 1.3", 1.54", and 2.0" TFT with ST7789:
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);

void setup(void) {
// Use this initializer (uncomment) if you're using a 1.54" 240x240 TFT
tft.init(240, 240, SPI_MODE2); // initialize a ST7789 chip, 240x240 pixels

// tft.setSPISpeed(40000000);

tft.setRotation(tft.getRotation() + 2);
tft.fillScreen(ST77XX_BLACK);
}

void loop() {

tft.setCursor(0, 5);
tft.setTextColor(ST77XX_RED);
tft.setTextSize(2);
tft.print("Its Alive, a live...");

tft.setCursor(30, 40);
tft.setTextColor(ST77XX_GREEN);
tft.setTextSize(2);
tft.print("Thanks Michael");

tft.setCursor(30, 80);
tft.setTextColor(ST77XX_BLUE);
tft.setTextSize(2);
tft.print("Kind Regards");

tft.setCursor(30, 120);
tft.setTextColor(ST77XX_YELLOW);
tft.setTextSize(2);
tft.print("Bram");
}


Thanks!
 

Attachments

  • Display-ST7789-01.png
    Display-ST7789-01.png
    379.5 KB · Views: 90
I am sort of confused by this set of postings as you mention T4 but then show T-LC...

Also looks like you are including two different sets of drivers for this display:

That is you have:
Code:
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <ST7789_t3.h>
#include <SPI.h>
Either use the Adafruit_St7789 or the ST7789_t3 (don't remember when using this if you also need to include the ST7735.h file as well.

But if you look at the ST7735_t3 library and open up the example sketch graphictest, you will see that it can be configured for multiple displays.

The first part you need to make sure of, is it creating an ST7735 or an ST7789 display object. That is there are options toward the start of the sketch: like:

Code:
ST7789_t3 tft = ST7789_t3(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCK, TFT_RST);

Then there are options for several different initialize or begin methods to be called. Only one should be uncommented. Probably in your case:

Code:
 // OR use this initializer (uncomment) if using a 240x240 clone 
  // that does not have a CS pin2.0" 320x240 TFT:
  tft.init(240, 240, SPI_MODE2);           // Init ST7789 240x240 no CS
Then hopefully it should work.

But warning with these displays you can not have any other SPI object on that buss as there is no way to signal the display if the SPI data is for it or for some other device.
 
Hello,
I am just trying to find out whether anyone has got one of these st7789 displays to operate in the 4 line serial, 18-bit 262k colour mode - as the data sheet says it can.
Try as I might, I can't and every library I look at uses 16-bit 65k. I have no problems at all with 16-bit and it works fine but only get grey scales with 18, I know what to look for in a library but I only ever see 565 not 666 and register 0x3A as 0x05 and never 0x06. I have found libraries that claim to be full 18-bit but when I delve deep - there it is - 0x3A is set to 0x05.
I am coming to the conclusion that these chips are fake and don't have that much memory at all. Also, I can't find any module with MISO broken out, If I could i could get one and do some RAM writes and reads to confirm my suspicions,
 
I am not sure if any of them bring the MISO pin out.

So I don't think you will have much luck reading the states of the registers.

As for 18 bit, have not tried it on these as so far I have not seen any reason to. My guess is that you would not see much(any) discernible differences visually, and you end up having to send 1.5 times as many bytes to the system as it requires 24 bits of transfers.

Then depending on which Teensy (assuming teensy) you try to output from you end up either then holding things in 32 bit words or you end up doing it bytes... Sort of a pain, but do have this in the ILI9488_t3 library as it mainly supports 18 bit mode when you are in SPI...
 
Hello Kurt,
Many thanks and I am sure you are right. I have no need for full 18 bit and have used 16 bit happily - it was just a nagging challenge to try and get it to work, I don't think there are any MISO capable modules so I can not confirm my suspicion that there are no 18 bit libraries because the makers claims are fake and the st7789 does not have that amount of memory at all,
But many thanks again.
 
Hello Kurt,
Ignore my last, sorry, I found two contradictory errors in my code so 16 worked but 18 not (a MALLOC issue as I use DMA). So 18 bit works fine now.
Sorry again
 
Back
Top