russhughes / s3lcd

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

Backend crashes when function called for second time #9

Closed HabibMCS closed 9 months ago

HabibMCS commented 11 months ago
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

russhughes commented 11 months ago

What does your tft_config.py look like?

HabibMCS commented 11 months ago

Hi, It was same as tft_config.py from t display s3.

It was fixed when I called tft = tft_config.config( 1,0)
within in the function. Seems like, when we deinit() the instance has to be called again.

HabibMCS commented 11 months ago

Thanks for your reply