russhughes / s3lcd

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

tft_config & tft_buttons for T-RGB ST7701S 480x480 #14

Closed alfierivera closed 9 months ago

alfierivera commented 9 months ago

I think it would be a great addition to the repository.

I tried with this code, but unfortunately I couldn't make it work:

""" Custom configuration for ST7701S 480x480 display """

from machine import Pin, freq
import s3lcd  # Make sure you have the s3lcd library or equivalent for your platform

# Pin Definitions
LCD_POWER = Pin(15, Pin.OUT)  # PIN_POWER_ON
BACKLIGHT = Pin(38, Pin.OUT)  # PIN_LCD_BL
RD = Pin(9, Pin.OUT)          # PIN_LCD_RD

# Display Parameters
TFA = 0  # Top Fixed Area (number of lines)
BFA = 0  # Bottom Fixed Area (number of lines)
WIDE = 1  # Width (change accordingly)
TALL = 0  # Height (change accordingly)

# CPU Frequency
freq(240_000_000)  # Frequency of the ESP32S3 (in Hz)

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

    bus = s3lcd.I80_BUS(
        (39, 40, 41, 42, 45, 46, 47, 48),  # Data pins D0-D7
        dc=7,  # Data/Command pin (PIN_LCD_DC)
        wr=8,  # Write pin (PIN_LCD_WR)
        cs=6,  # Chip Select pin (PIN_LCD_CS)
        pclk=8_000_000,  # Pixel clock (change as needed)
        swap_color_bytes=False,
        reverse_color_bits=True,
    )

    return s3lcd.ESPLCD(
        bus,
        480,  # Horizontal Resolution
        480,  # Vertical Resolution
        inversion_mode=True,
        color_space=s3lcd.RGB,
        reset=5,  # Reset pin (PIN_LCD_RES)
        rotation=rotation,
        options=options,
    )

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

Not sure what I'm doing wrong

russhughes commented 9 months ago

They wired the LCD_CS, LCD_SDA, LCD_CLK, and LCD_RST through the XL9535 port expander not to the ESP32-S3 so the device won't work with this driver.