Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to get ST7789 running #7

Open
cyberjunkiefr opened this issue Dec 13, 2021 · 1 comment
Open

Not able to get ST7789 running #7

cyberjunkiefr opened this issue Dec 13, 2021 · 1 comment

Comments

@cyberjunkiefr
Copy link

Hello,
I've just got a new LilyGo-T-Display-s2.
As Firmware I've loaded the micropython firmware found on MicroPython.con ESP32-S2 port (GENERIC_S2-20211212-unstable-v1.17-231-g0892ebe09.bin)
Everything is working fine for micropython, no issues there.
I took an example program for testing the ST7789 and adapted it for my board and micropython.
The program is running without any errors,
I can see the backlight coming on, but the display isn't showinf anything,
Some where I must have made a mistake in the pins for the display (SoftSPI), but I just can't figure it out.
Maybe somebody can help.
here's the progam I use:

import random
import machine
from machine import Pin, SPI, SoftSPI
import st7789py as st7789
import time
backlight = Pin(33, Pin.OUT)
backlight.value(1)
#spi = SPI(1, baudrate=40000000, polarity=1, sck=Pin(36), mosi=Pin(35), miso=Pin(37))
spi = SoftSPI(baudrate=500000, sck=Pin(36), mosi=Pin(35), miso=Pin(37))
display = st7789.ST7789(
spi, 240, 240,
reset=machine.Pin(38, Pin.OUT),
dc=machine.Pin(37, Pin.OUT),
)
display.init()
while True:
display.fill(
st7789.color565(
random.getrandbits(8),
random.getrandbits(8),
random.getrandbits(8),
),
)
# Pause 2 seconds.
time.sleep(2)

I'm thankfull for any support I can get.

Roel Jaspers

@NilsBe
Copy link

NilsBe commented Jul 23, 2022

Managed to make it work.

"""
lines.py
    Draws lines and rectangles in random colors at random locations on the
    display.
"""
import random
from machine import Pin, SPI, SoftSPI
import st7789py as st7789

def main():
    spi = SoftSPI(
        baudrate=20000000,
        polarity=1,
        phase=0,
        sck=Pin(36),
        mosi=Pin(35),
        miso=Pin(4))
    
    tft = st7789.ST7789(
        spi,
        135,
        240,
        reset=Pin(38, Pin.OUT),
        cs=Pin(34, Pin.OUT),
        dc=Pin(37, Pin.OUT),
        backlight=Pin(33, Pin.OUT),
        rotation=0)

    tft.fill(st7789.BLUE)

    while True:
        tft.line(
            random.randint(0, tft.width),
            random.randint(0, tft.height),
            random.randint(0, tft.width),
            random.randint(0, tft.height),
            st7789.color565(
                random.getrandbits(8),
                random.getrandbits(8),
                random.getrandbits(8)
                )
            )

        width = random.randint(0, tft.width // 2)
        height = random.randint(0, tft.height // 2)
        col = random.randint(0, tft.width - width)
        row = random.randint(0, tft.height - height)
        tft.fill_rect(
            col,
            row,
            width,
            height,
            st7789.color565(
                random.getrandbits(8),
                random.getrandbits(8),
                random.getrandbits(8)
            )
        )

main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants