Module lvstm32 not found

I’m trying to get started with LVGL on a STM32F746-DISCO.
Following this summary, I have built and flashed the firmware.
LVGL’s Micropython binding on STM32F746 Discovery | LVGL’s Blog

However, I get stuck on the following line on the REPL:

import lvstm32 as st

The module does not seem to be present in the firmware.

Am I missing somgething? Have things changed in version v8?

Skipping over the import line, this method seem to be missing as well:

disp_buf1 = lv.disp_buf_t()

AttributeError: ‘module’ object has no attribute ‘disp_buf_t’

I have more or less recoded the example however still not working.
Any pointers would be greatly appreciated.

import time

import lvgl as lv
lv.init()

#import lvstm32 as st
#st.lvstm32()

import rk043fn48h as rk
rk.init()

# register display driver
draw_buf = lv.disp_draw_buf_t()
buf1_1 = bytearray(480*10)
draw_buf.init(buf1_1, None, len(buf1_1)//4)
disp_drv = lv.disp_drv_t()
disp_drv.init()
disp_drv.draw_buf = draw_buf
disp_drv.flush_cb = rk.flush
disp_drv.hor_res = 480
disp_drv.ver_res = 272
disp_drv.register()

# register touch driver
indev_drv = lv.indev_drv_t()
indev_drv.init()
indev_drv.type = lv.INDEV_TYPE.POINTER
indev_drv.read_cb = rk.ts_read
indev_drv.register()

time.sleep_ms(100) # board will reset without this delay

# create screen with button
scr = lv.obj()
btn = lv.btn(scr)
btn.align_to(lv.scr_act(), lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)
label.set_text("Hello World!")

# Load the screen

#lv.scr_load(scr) # will hang if run directly? REPL works but shows nothing

Answering my own questions and hopefully helping someone in the process.
I managed to get everything working with the new version given the updated examples:

In v7 every platform had its own event loop. We had lvstm32 for stm32, lvesp32 for esp32, etc.
On v8 we replaced all of these with a single platform-independent event loop, as discussed in this GitHub issue.

It has several advantages:

  • Same event loop implementation for all platforms
  • Event loop is configurable - you can set refresh frequency and some other parameters
  • Supports both timer-based event loop and uasyncio event loop
  • Solved some bugs with MP scheduler oversubscription

To use it for the simplest use case, you just create an instance of the event loop:

from lv_utils import event_loop
...
self.event_loop = event_loop()

Make sure you keep a reference to the event loop, to prevent it from being garbage-collected.

1 Like

Great info, thank you for these pointers. I’m so happy I came accross this library.
It’s powerfull and the micropython integration with uasyncio is just fantastic.

1 Like