MathyV / lvgl_esp32_mpy

LVGL on ESP32 with MicroPython (as a USER_C_MODULE)
MIT License
8 stars 7 forks source link

More details how to run the example #2

Closed martyy665 closed 4 months ago

martyy665 commented 4 months ago

I tried to compile the project, flash into ESP32-S3 and run the example (just joined two files into the one):

from hardware import display
import time
import machine
import lvgl as lv
import lvgl_esp32

# Adapt these values for your own configuration
spi = machine.SPI(
    2,
    baudrate=80_000_000,
    sck=machine.Pin(15, machine.Pin.OUT),
    mosi=machine.Pin(6, machine.Pin.OUT),
    miso=machine.Pin(7, machine.Pin.IN),
)

display = lvgl_esp32.Display(
    spi=spi,
    width=240,
    height=320,
    swap_xy=True,
    mirror_x=False,
    mirror_y=False,
    invert=False,
    bgr=True,
    reset=42,
    dc=16,
    cs=17,
    pixel_clock=20_000_000,
)

# Enable LCD backlight
bl = machine.Pin(18,  machine.Pin.OUT)
bl.on()

wrapper = lvgl_esp32.Wrapper(display)

wrapper.init()

screen = lv.screen_active()
screen.set_style_bg_color(lv.color_hex(0x003a57), lv.PART.MAIN)

label = lv.label(screen)
label.set_text("Hello world from MicroPython")
label.set_style_text_color(lv.color_hex(0xffffff), lv.PART.MAIN)
label.align(lv.ALIGN.CENTER, 0, 0)

a = lv.anim_t()
a.init()
a.set_var(label)
a.set_values(10, 50)
a.set_duration(1000)
a.set_playback_delay(100)
a.set_playback_duration(300)

a.set_repeat_delay(500)
a.set_repeat_count(lv.ANIM_REPEAT_INFINITE)
a.set_path_cb(lv.anim_t.path_ease_in_out)
a.set_custom_exec_cb(lambda _, v: label.set_y(v))
a.start()

while True:
    lv.timer_handler_run_in_period(5)

Resulting the following error:

ELF file SHA256: a1cf57e4c7e1548b

Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x2e (SPI_FAST_FLASH_BOOT)
Saved PC:0x403839ae
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3818,len:0x1008
load:0x403c9700,len:0x4
load:0x403c9704,len:0xb5c
load:0x403cc700,len:0x2e58
entry 0x403c989c
Start app in one sec!

E (6998) lcd_panel: esp_lcd_panel_draw_bitmap(33): invalid panel handle
ESP_ERROR_CHECK failed: esp_err_t 0x102 (ESP_ERR_INVALID_ARG) at 0x42097b8f
file: "/storage/lvgl_esp32_mpy/src/display.c" line 50
func: lvgl_esp32_Display_draw_bitmap
expression: esp_lcd_panel_draw_bitmap(self->panel, x_start, y_start, x_end, y_end, data)

abort() was called at PC 0x403869f3 on core 1

Backtrace: 0x40375c36:0x3fced720 0x403869fd:0x3fced740 0x4038ca12:0x3fced760 0x403869f3:0x3fced7d0 0x42097b8f:0x3fced800 0x4209801b:0x3fced850 0x42034785:0x3fced890 0x420346f5:0x3fced8d0 0x42033ecd:0x3fced910 0x42033c49:0x3fced960 0x4203399f:0x3fced9d0 0x42033397:0x3fceda00 0x420709e9:0x3fceda40 0x420705d9:0x3fceda80 0x4200128f:0x3fcedac0 0x42022115:0x3fcedaf0 0x42003eb1:0x3fcedb30 0x420a9835:0x3fcedb70 0x420a98f9:0x3fcedb90 0x4037974e:0x3fcedbb0 0x420a2af3:0x3fcedc50 0x420a9835:0x3fcedc80 0x420a984a:0x3fcedca0 0x420b5b92:0x3fcedcc0 0x420b5ee1:0x3fcedd50 0x420bead2:0x3fcedd80

Any idea where the error might be?

Can you please share all non-default kconfig compile option set (e.g. via menuconfig) for the ESP32-S3?

Carglglz commented 4 months ago

it seems like the example is missing display.init() before wrapper = lvgl_esp32.Wrapper(display)

martyy665 commented 4 months ago

Hi @Carglglz , yes, you are right :thumbs-up:. Thanks! I created PR #3.

MathyV commented 4 months ago

You are correct, I forgot to c/p the initialization from my code into the example.