ST7789 IPS 240x240 SPI display

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
devbis
Posts: 6
Joined: Sun Feb 17, 2019 11:03 am

ST7789 IPS 240x240 SPI display

Post by devbis » Mon Feb 18, 2019 8:50 pm

Hi!
Recently I received a tiny IPS display from AliExpress based on st7789 chip 240x240 pixels on SPI bus.
I had some problems to connect it to my esp8266, so I had to write a library to run this screen

https://github.com/devbis/st7789py_mpy/

It is greatly inspired by Arduino-ST7789-Library for Arduino and AdaFriut libraries. The performance of the library is quite low but it allows to draw some primitives on the screen. To increase the performance, it should be rewritten in pure C.
Last edited by devbis on Sun Apr 21, 2019 8:14 pm, edited 1 time in total.

gmli
Posts: 6
Joined: Mon Nov 26, 2018 1:07 pm

Re: ST7789 IPS 240x240 SPI display

Post by gmli » Sat Mar 02, 2019 1:32 pm

I try to use your lib to drive a ST7789 with a esp32, but it doesn't work.

I have used the exact same code (except I changed the .on() and .off() for .value(1) and .value(0)). No error but the screen stay black (with the backlight on).

Have you ever tried it with an esp32 ?

Edit: I tried with a freshly flashed esp8266 with uPy 1.10, and the code you provided on the repo untouched : same result. Could you provide me with the wiring you used ?

My module : https://photos.app.goo.gl/8H8JaxZw5iWax2oA6


Edit 2 : I've… just… plugged my wire in the wrong hole of the breadboard for the +3v. New breadboard kind, not used to…

So, it's works on the esp8266, nice. Thanks for your work ! Now I try on the esp32.

gmli
Posts: 6
Joined: Mon Nov 26, 2018 1:07 pm

Re: ST7789 IPS 240x240 SPI display

Post by gmli » Sat Mar 02, 2019 7:54 pm

This is quite weird to me.

Hardware SPI doesn't work, but software does (on the same Pins). Bus 1 or bus 2.
Said with code (miso isn't wired):

spi = machine.SPI(baudrate=40000000, polarity=1, phase=0, sck=Pin(14), mosi=Pin(13), miso=Pin(12)) # works
spi = machine.SPI(1, baudrate=40000000, polarity=1, phase=0, sck=Pin(14), mosi=Pin(13)) # doesn't work

Any idea ?

nickzoic
Posts: 2
Joined: Tue Feb 07, 2017 12:42 pm

Re: ST7789 IPS 240x240 SPI display

Post by nickzoic » Sun Mar 03, 2019 11:12 am

Software SPI is limited to MICROPY_HW_SOFTSPI_MAX_BAUDRATE which in this case is 800kHz.
So your hardware SPI is trying to run way quicker! I'd try slowing it down to 800kHz as well and see if it starts working.

OutoftheBOTS_
Posts: 628
Joined: Mon Nov 20, 2017 10:18 am

Re: ST7789 IPS 240x240 SPI display

Post by OutoftheBOTS_ » Mon Mar 04, 2019 3:17 am

I do have 1 of these little screens as they are quite cheap yet very high performance. It is just sitting on my desk as I have been super busy with other projects atm. I was going to use it like I have all my other screen by using Lobo port for ESP32 but with just a custom init(). Lobo port has a very high performance display module that allows custom setup for any screens not all ready supported in the module.

gmli
Posts: 6
Joined: Mon Nov 26, 2018 1:07 pm

Re: ST7789 IPS 240x240 SPI display

Post by gmli » Mon Mar 25, 2019 6:59 pm

If I initialize the SPI object like this :

Code: Select all

spi = machine.SPI(1, baudrate=60000000, polarity=1, phase=1, sck=Pin(14), mosi=Pin(13), miso=Pin(12))
It works at planned. Setting phase=1 seems to do the trick. But it's quite strange that with software spi and phase=0 it works also.

devbis
Posts: 6
Joined: Sun Feb 17, 2019 11:03 am

Re: ST7789 IPS 240x240 SPI display

Post by devbis » Sun Apr 21, 2019 9:16 pm

I re-wrote a driver for this screen in pure-C, and the performance of the screen increased significantly.

See viewtopic.php?f=14&t=6318 for details.

But you have to compile firmware by your own for it.
Also, I've changed the signature of methods for the current driver to fit new convention (as in framebuf.FrameBuffer class)

Pasindu1
Posts: 1
Joined: Sat Jun 22, 2019 8:22 pm

Re: ST7789 IPS 240x240 SPI display

Post by Pasindu1 » Sat Jun 22, 2019 8:29 pm

I am new to esp32 programming. i have ST7789 IPS and i don't know how to program it using esp32. can you provide me the wiring diagram to esp32 and the code the to test the display
Thank you :)

Post Reply