russhughes / s3lcd

ESP_LCD based MicroPython driver for ESP32-S3 Devices with ST7789 or compatible displays.
Other
60 stars 10 forks source link

SUNTON 1732S019 ESP32S3 board with ST7789 170x320 display #24

Open SvenMb opened 4 months ago

SvenMb commented 4 months ago

Just tried your Micropython firmware 'ESP32_GENERIC_S3_SPIRAM_OCT_16MiB' with the Sunton 1732S019 board and it instant worked. Very nice!

1707581371599

Maybe you like to add this config to your examples.

tft_config.py

""" SUNTON 1732S070 ESP32S3 170x320 ST7789 display """

from machine import Pin, freq
import s3lcd

BL = Pin(14, Pin.OUT)

TFA = 0
BFA = 0
WIDE = 1
TALL = 0

freq(240_000_000)

def config(rotation=0, options=0):
    """Configure the display and return an ESPLCD instance."""

    BL.value(1)

    bus = s3lcd.SPI_BUS(
        2, mosi=13, sck=12, dc=11, cs=10, pclk=50000000, swap_color_bytes=True
    )

    return s3lcd.ESPLCD(
        bus,
        170,
        320,
        inversion_mode=True,
        color_space=s3lcd.RGB,
        reset=1,
        rotation=rotation,
        dma_rows=32,
        options=options,
    )

def deinit(tft, display_off=False):
    """Take an ESPLCD instance and Deinitialize the display."""
    tft.deinit()
    if display_off:
        BL.value(0)

tft_buttons.py

since this board has no inbuild buttons, but a lot free GPIOs, here only the definition I used for the pinball example:

# use GPIO 21 and 20 for left and right button, just as example

from machine import Pin

class Buttons:
    def __init__(self):
        self.name = "1732S019"
        self.left = Pin(21, Pin.IN, Pin.PULL_UP)
        self.right = Pin(20, Pin.IN, Pin.PULL_UP)
        self.hyper = 0
        self.thrust = 0
        self.fire = 0