Giter VIP home page Giter VIP logo

s3lcd's People

Contributors

c-logic avatar karlp avatar russhughes avatar wind-stormger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

s3lcd's Issues

How to compile this project with lv_micropython

This is a great project, I completed the firmware compilation using esp-idf v4.4.6 version in wt32-sc01-plus. But the compilation project I used was lv_micropython, and there was no lvgl module in the final compiled firmware. How do I achieve the joint compilation of lv_micropython and s3lcd?
I want to use lvgl in wt32-sc01-plus with micropython

firmware /S3LCD_QUAD_8M firmware configured FLASH wrong size

MPY: soft reboot
Traceback (most recent call last):
  File "_boot.py", line 11, in <module>
  File "inisetup.py", line 34, in setup
  File "inisetup.py", line 7, in check_bootsec
OSError: (-24579, 'ESP_ERR_FLASH_NOT_INITIALISED')
MicroPython v1.19.1-1009-gcfd3b7093-dirty on 2023-04-22; ESP32S3 (S3LCD_QUAD_8M) with ESP32S3
Type "help()" for more information.
>>> import esp,machine
>>> print("CPU frequency = {CPU}Mhz".format(CPU = machine.freq()/1000000))# CPU 
CPU frequency = 160.0Mhz
>>> print("RAM used = {RAM_used}KB".format(RAM_used = gc.mem_alloc()/1024))# RAM 
RAM used = 10.25KB
>>> print("RAM free = {RAM_free}KB".format(RAM_free = gc.mem_free()/1024))# RAM 
RAM free = 1990.391KB
>>> print("FLASH total = {FLASH_total}KB".format(FLASH_total = esp.flash_size()/1024))# FLASH 
FLASH total = 16384.0KB
>>>
>>> 16384/1024
16.0
>>>

SUNTON 1732S019 ESP32S3 board with ST7789 170x320 display

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

Getting error when compile the fimrware with IDF 4.4.6 and micropython v1.20.0

/s3lcd.c.obj -c /s3lcd/src/s3lcd.c
/s3lcd/src/s3lcd.c: In function 's3lcd_idle_mode':
/s3lcd/src/s3lcd.c:388:52: error: 'ST7796_IDLEOFF' undeclared (first use in this function); did you mean 'ST7789_IDLEOFF'?
esp_lcd_panel_io_tx_param(self->io_handle, ST7796_IDLEOFF, NULL, 0);
^~~~~~~~~~~~~~
ST7789_IDLEOFF
/s3lcd/src/s3lcd.c:388:52: note: each undeclared identifier is reported only once for each function it appears in
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

Buttons for T-HMI

You can add the following lines in the buttons config file:

        # Buttons above the display
        self.ONOFF = Pin(21, Pin.IN)  # Sends 1 when pressed
        self.BOT   = Pin(0, Pin.IN)   # Sends 0 when pressed

Generic ILI9341 240x320 display

Nicely your driver works with ILI9341 too, but there was no example config for a generic ILI9341 and the custom_init for the m5stack m5cores3 didn't work.

So I created a tft_config.py, based on the init sequence from the adafruit ili9341 lib, which should work for nearly all these cheap ILI9341 displays with SPI.

1707750845516

Maybe you like to add this config to your examples.

tft_config.py

"""esp32s3 with ili9342c 320x240 display"""

# mosi: GPIO13
# sck:  GPIO12
# dc:   GPIO11
# cs:   GPIO10
# rst:  GPIO01
# backlight: GPIO14


from machine import Pin,freq
import s3lcd

BL = Pin(14, Pin.OUT)

TFA = 0
BFA = 0
# WIDE = 3
# TALL = 2
WIDE = 1
TALL = 0

# Set clock to 240MHz
freq(240000000)

def config(rotation=0, options=0):
    """Configure the display and return an ESPLCD instance."""
    
    BL.value(1)
    
    custom_init = [
# original adafruit init sequence - translated to mpy
#  0xEF, 3, 0x03, 0x80, 0x02,
        (b"\xEF\x03\x80\x02",),
#  0xCF, 3, 0x00, 0xC1, 0x30,
        (b"\xCF\x00\xC1\x30",),
#  0xED, 4, 0x64, 0x03, 0x12, 0x81,
        (b"\xED\x64\x03\x12\x81",),
#  0xE8, 3, 0x85, 0x00, 0x78,
        (b"\xE8\x85\x00\x78",),
#  0xCB, 5, 0x39, 0x2C, 0x00, 0x34, 0x02,
        (b"\xCB\x39\x2C\x00\x34\x02",),
#  0xF7, 1, 0x20,
        (b"\xF7\x20",),
#  0xEA, 2, 0x00, 0x00,
        (b"\xEA\x00\x00",),
#  ILI9341_PWCTR1 - 0xC0 , 1, 0x23,             // Power control VRH[5:0]
        (b"\xC0\x23",),
#  ILI9341_PWCTR2 - 0xC1 , 1, 0x10,             // Power control SAP[2:0];BT[3:0]
        (b"\xC1\x10",),
#  ILI9341_VMCTR1 - 0xC5 , 2, 0x3e, 0x28,       // VCM control
        (b"\xC5\x3E\x28",),
#  ILI9341_VMCTR2 - 0xC6 , 1, 0x86,             // VCM control2
        (b"\xC6\x86",),
#  ILI9341_MADCTL - 0x36 , 1, 0x48,             // Memory Access Control
        (b"\x36\x08",),
# ILI9341_VSCRSADD - 0x33, 1, 0x00,             // Vertical scroll zero
        (b"\x33\x00",),
#  ILI9341_PIXFMT - 0x3A , 1, 0x55,
        (b"\x3A\x55",),
#  ILI9341_FRMCTR1 - 0xB1 , 2, 0x00, 0x18,
        (b"\xB1\x00\x18",),
#  ILI9341_DFUNCTR - 0xB6, 3, 0x08, 0x82, 0x27, // Display Function Control
        (b"\xB6\x08\x82\x27",),
#  0xF2, 1, 0x00,                         // 3Gamma Function Disable
        (b"\xF2\x00",),
#  ILI9341_GAMMASET - 0x26 , 1, 0x01,             // Gamma curve selected
        (b"\x26\x01",),
#  ILI9341_GMCTRP1 - 0xE0 , 15, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, // Set Gamma
#    0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00,
        (b"\xE0\x0F\x31\x2B\x0C\x0E\x08\x4E\xF1\x37\x07\x10\x03\x0E\x09\x00",),
#  ILI9341_GMCTRN1 - 0xE1 , 15, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, // Set Gamma
#    0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F,
        (b"\xE1\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F",),
#  ILI9341_SLPOUT - 0x11 , 0x80,                // Exit Sleep
        (b"\x11", 128),
#  ILI9341_DISPON - 0x29 , 0x80,                // Display on
        (b"\x29", 128),
#  0x00                                   // End of list
    ]
    
    custom_rotations = (
        (240, 320, 0, 0, False, True, False),
        (320, 240, 0, 0, True, False, False),
        (240, 320, 0, 0, False, False, True),
        (320, 240, 0, 0, True, True, True),
    )

    # To use baudrates above 26.6MHz you must use my firmware or modify the micropython
    # source code to increase the SPI baudrate limit by adding SPI_DEVICE_NO_DUMMY to
    # the .flag member of the spi_device_interface_config_t struct in the
    # machine_hw_spi_init_internal.c file.  Not doing so will cause the ESP32 to crash
    # if you use a baudrate that is too high.

    bus = s3lcd.SPI_BUS(
        2, mosi=13, sck=12, dc=11, cs=10, pclk=60000000, swap_color_bytes=True
    )
    
    return s3lcd.ESPLCD(
        bus,
        240,
        320,
        inversion_mode=False,
        color_space=s3lcd.BGR,
        reset=1,
        rotations=custom_rotations,
        rotation=rotation,
        dma_rows=32,
        custom_init=custom_init,
        options=options,
    )


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

Issue with firmware

Hello.

First, a thank you; I have previously used your driver/firmware with a Lilygo ESP32 T-Display. It works wonderfully.

I have recently purchased some Lilygo ESP32S3 T-HMI units (240x320, Flash and PSRAM is 16MB per demo) and wanted to use your driver/firmware again. I have downloaded the firmware and tried Thonny, esptool, and the Flash Download tool to flash the firmware to said device - all failed (device keeps repeatedly connecting/disconnecting). Please note that I have downloaded and flashed the generic ESP32S3 version of Micropython 1.20.0 multiple times with no failure.

I was wondering if you have py/mpy driver(s) and config.py files that can be dropped onto the device and used with the generic ESP32S3 Micropython instead of a full firmware flash?

Also, how would one go about creating new fonts like the old 5x7 monospace/fixedsys font (I know that is telling my age) for use by the driver?

Thank you for any assistance you may render.

Feature Request: LVGL integration

Hi Russ.
Thanks so much for your work on display drivers for the ESP32 boards to date, and providing ready-to-go firmware images. You're a star.
Have you considered adding support for LVGL into your builds? It would add an extra dimension and I'm sure I'm not the only one that would really appreciate a strong graphics library to complement your driver. Sadly, I'm too near the start of my Micropython journey to be attempt this myself.
Best
Neil

tft_config & tft_buttons for T-RGB ST7701S 480x480

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

Using SX1262 on Lilygo T-Deck causes the display to stop working

Hello,

I have been using this library on the Lilygo T-Deck and it works great. I also created a tft_config.py which I have added below in case it could be added to the repo:

""" LilyGo T-DECK 320x240 ST7789 display """

from machine import Pin, freq
import s3lcd

BACKLIGHT = Pin(42, Pin.OUT)
TOUCH = Pin(16, Pin.OUT)
KB_PWR = Pin(10, Pin.OUT)  # enabling the KB_PWR pin also enables display - "peripheral" power

KB_PWR.off()
KB_PWR.on()

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."""
    BACKLIGHT.value(1)

    bus = s3lcd.SPI_BUS(
        1,
        mosi=41,
        sck=40,
        dc=11,
        cs=12,
        pclk=80_000_000,
        swap_color_bytes=False,  # true - blue, false - yellow
    )

    return s3lcd.ESPLCD(
        bus,
        240,
        320,
        inversion_mode=True,
        color_space=s3lcd.BGR,
        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)

Unfortunately I have hit a problem while trying to operate the LoRa module at the same time - it causes the TFT display to stop working, and everything I have tried so far has not been able to activate it again. To control the LoRa module, I have used this library: https://github.com/ehong-tl/micropySX126X

To reproduce this issue:

lcd = tft_config.config(1, 0)
lcd.init()

# do anything with the LCD here
sx1262 = SX1262(spi_bus=2, clk=40, mosi=41, miso=38, cs=9, irq=45, rst=17, gpio=13)
status = self.sx1262.begin(freq=434, bw=125.0, sf=7, syncWord=0x12, power=14,
                                        currentLimit=60, preambleLength=8, implicit=False, implicitLen=0xFF,
                                        crcOn=True, txIq=False, rxIq=False, tcxoVoltage=1.7, useRegulatorLDO=False,
                                        blocking=True)

# at this point the display ceases to show any updates, although it can be deinit and init again
lcd.fill(s3lcd.WHITE)
lcd.show()  # nothing is displayed on the screen

I have tried controlling the CS pins by setting the LoRa's CS to low and the TFT to high before trying to display anything on the screen, but this does not help. I have also tried using deinit and init to recreate the SPI object, which produces a visual "refresh" but does not allow the screen to be updated.

Any help on trying to fix this problem would be much appreciated - thanks

Build From Source Fails Due to Mismatch of Micropython Version Relative to ESP-IDF Version

Hello. Thanks for your work on this driver and firmware version.

I'm attempting to include some additional support in the firmware image (like ESP NOW functionality) and I'm attempting to build via your source instructions.

However, it appears they may be outdated. Using the version of ESP-IDF specified in the instruction (v4.4.4), the latest version of micropython fails building - complaining that it requires version 5+ of ESP-IDF to build.

Updating ESP-IDF to version 5+ and attempting the build fails with the following error:

Including User C Module(s) from ../../../s3lcd/src/micropython.cmake
CMake Error at ~/esp/micropython/py/usermod.cmake:42 (include):
  include could not find requested file:

    ../../../s3lcd/src/micropython.cmake
Call Stack (most recent call first):
  esp32_common.cmake:22 (include)
  main_esp32/CMakeLists.txt:11 (include)

Did you have a specific version of micropython that we could checkout for this build process instead of checking out the latest version?

Alternatively, would you be able to update the instructions to work with the latest ESP-IDF version?

Either way, I appreciate your help.

Backend crashes when function called for second time

import utime
import s3lcd
import tft_config
import font as font
from machine import reset_cause
tft = tft_config.config( 1,0)
def showscrolltext(char1 , fg = s3lcd.WHITE, bg = s3lcd.RED, pady=60, xs = -1, ys = 0, duration = 40):  
    try:
        tft_config.config( 1,0,backlight = 1)
        tft.init()
        curr = utime.time()
        tft.fill(bg)
        height = tft.height()
        width = tft.width()
        line = height - font.HEIGHT
        while utime.time() - curr < duration:
            for c in char1:
              tft.write(font,c,width - font.WIDTH*2,line-pady,fg,bg,)
              for _ in range(font.HEIGHT // 2):
                    tft.scroll(xs, ys)
                    tft.show()
            utime.sleep(3)

    finally:
        tft_config.deinit(tft, display_off = True)
        print("scroll completed")
showscrolltext(' Hey its test for display 7809', duration = 5 )
utime.sleep(5)
showscrolltext(' Hey its test for display 7809', duration = 5 ) #  when this line is called it crashes


when the function is called second time the esp32s3 t display crashes. I would appreciate if someone helps on this. Thanks in advance

Missing files

Where is tft_config.py? In particular for TDongle S3 and t-QT Pro.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.