russhughes / st7789py_mpy

Driver for 320x240, 240x240, 135x240 and 128x128 ST7789 displays written in MicroPython
MIT License
142 stars 57 forks source link

ESP or RP2040? #2

Closed slabua closed 10 months ago

slabua commented 2 years ago

Is this driver for the ESP or the RP2040 version? Doesn't seem to work on the RP board.

russhughes commented 2 years ago

The driver will work on an RP2040. However, I've run into issues with hardware SPI and non-standard pin use with some displays. In addition, the stock MicroPython 1.17 I've been using has issues with MISO=None. SoftSPI works but is slower. I've added examples for Waveshare Pico-LCD-1.14 and Pico-LCD-1.3 displays using SoftSPI.

slabua commented 2 years ago

Hm, that's strange then. I tried it on a LILYGO TTGO T-Display RP2040, there is no error but also nothing shows up in the display, so I thought the pins were wrongly assigned by default, but then again probably it would has spit some kind of error.

slabua commented 2 years ago

@russhughes the pins for the RP version are different https://github.com/Xinyuan-LilyGO/LILYGO-T-display-RP2040#product- despite changing them in your examples, still no luck for me.

russhughes commented 2 years ago

What does your st7789 init code look like? Are you using SPI or SoftSPI?

I have a T-Display RP2040 in transit somewhere between ShaTian and the USA, scheduled to arrive around January 24 - February 14. Once it comes, I'll check it out.

slabua commented 2 years ago

@russhughes Hi I fixed it with the following settings. The display needs to be explicitly powered on with the first line and the pins are as follows. One thing though, miso pin is supposed to be left unused. I had to forcibly use some other pin, I didn't pick yet into the lib itself to check whether it can be skipped.

(Meanwhile today I received also the ESP version of the board and the driver works good with that.)

Btw, SPI doesn't seem to work. Specifying id=0 gives no results, id=1 complains about the wrong sck pin.

    Pin(22, Pin.OUT, value=1)

    spi = SoftSPI(
        baudrate=20000000,
        polarity=1,
        phase=0,
        sck=Pin(2),
        mosi=Pin(3),
        miso=Pin(13))

    tft = st7789.ST7789(
        spi,
        135,
        240,
        reset=Pin(0, Pin.OUT),
        cs=Pin(5, Pin.OUT),
        dc=Pin(1, Pin.OUT),
        backlight=Pin(4, Pin.OUT),
        rotation=1)
Gruftgrabbler commented 2 years ago

Honestly I wasn't able to use Hardware SPI even on an esp32 module and SoftSPI is way to slow for the application I need.

So I might gonna need to compile a custom firmware using the fast driver combined with uLab. That will be a lot of fun todo I guess ^^