feat(multi-instance): collect all the global variables into a struct to allow running multiple instances of LVGL

Closes #4358
This commit is contained in:
Gabor Kiss-Vamosi
2023-08-19 01:42:37 +02:00
parent 1f807ae714
commit 0b83a82a07
145 changed files with 3230 additions and 2707 deletions

View File

@@ -1,40 +1,3 @@
import fs_driver
import sys
#TODO
pass
# set LV_USE_FFMPEG to True if it is enabled in lv_conf.h
LV_USE_FFMPEG = True
LV_FONT_DEFAULT = lv.font_montserrat_14
fs_drv = lv.fs_drv_t()
fs_driver.fs_register(fs_drv, 'A')
# get the directory in which the script is running
try:
script_path = __file__[:__file__.rfind('/')] if __file__.find('/') >= 0 else '.'
except NameError:
script_path = ''
def get_imgfont_path(font, unicode, unicode_next, offset_y, user_data) :
if unicode < 0xf000: None
if unicode == 0xF600:
if LV_USE_FFMPEG:
return bytes(script_path + "/../../assets/emoji/{:04X}.png".format(unicode) + "\0","ascii")
else:
return bytes("A:"+ script_path + "/../../assets/emoji/{:04X}.png".format(unicode) + "\0","ascii")
return None
#
# draw img in label or span obj
#
imgfont = lv.imgfont_create(80, get_imgfont_path, None)
if imgfont == None:
print("imgfont init error")
sys.exit(1)
imgfont.fallback = LV_FONT_DEFAULT
label1 = lv.label(lv.scr_act())
label1.set_text("12\uF600\uF617AB")
label1.set_style_text_font(imgfont, lv.PART.MAIN)
label1.center()

View File

@@ -54,7 +54,7 @@ class LV_Example_Msg_2:
# Slider
slider = lv.slider(panel)
slider.set_flex_grow(1)
slider.add_flag(lv.OBJ_FLAG_FLEX_IN_NEW_TRACK)
slider.add_flag(lv.obj.FLAG.FLEX_IN_NEW_TRACK)
slider.add_event(self.slider_event_cb, lv.EVENT.ALL, None)
lv.msg_subscribe_obj(MSG_UPDATE, slider, None)