-
-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(color,Lua): Lvgl support for Lua scripts #4887
base: main
Are you sure you want to change the base?
Conversation
Here is a summary of the API as it currently stands (20th Apr). The Lvgl system is accessed through ‘lvgl’ object in Lua. return { name="Lvgl Test", options=opts, create=create, update=update, refresh=refresh, background=background, useLvgl=true } To clear the screen and delete all existng Lvgl objects call: lvgl.clear() This should be done if the layout changes (e.g. going to/from full screen). When creating objects some of the properties can be either a static value, or a getter function. If a getter function is supplied the property will be updated whenever the getter function returns a different value. Creating new Lvgl objects:
Creating new objects using styled EdgeTx controls (only available for standalone scripts):
All functions return a reference to the Lvgl object that can be used to set attributes later. local uiLabel = lvgl.label({text=“Hello World!”, x=10, y=10, color=WHITE, font=DBLSIZE}) It is not necessary to save the return value unless you want to change attributes. Object lifetime is managed by the system. Setting attributes: local uiLabel = lvgl.label({text=“Hello World!”, x=10, y=10, color=WHITE, font=DBLSIZE})
lvgl.set(uiLabel, {text=“New string”})
uiLabel:set({text=“New string”}) Setting state: lvgl.hide(uiLabel)
uiLabel:show() Grouping ui elements:
E.G. local box = lvgl.rectangle({x=10, y=10, w=50, h=50, thickness=1, color=WHITE})
lvgl.setParent(box)
local lbl = lvgl.label({text=“BOX”, x=10, y=10})
lvgl.setParent(nil) Creating UI elements in bulk: local lyt = {
{type="label", text="CTR", x=0, y=0, color=wgt.opts.Color, font=MIDSIZE},
{type="label", text="TMR", x=0, y=50, color=wgt.opts.Color, font=MIDSIZE},
{type="label", x=80, y=0, color=wgt.opts.Color, font=MIDSIZE, name="ctr"},
{type="label", x=120, y=0, color=wgt.opts.Color, font=MIDSIZE, name="bgctr"},
{type="label", x=80, y=50, color=wgt.opts.Color, font=MIDSIZE, name="tmr"},
{type="rectangle", x=50, y=80, w=30, h=30, thickness=4, color=COLOR_THEME_ACTIVE, name="box1"},
{type="filledRectangle", x=90, y=80, w=30, h=30, color=COLOR_THEME_EDIT, name="box2", children={
{type="circle", x=15, y=15, radius=13, thickness=2, color=WHITE, children={
{type="label", text="0", x=7, y=1, name="nctr"},
}},
}},
{type="circle", x=65, y=135, radius=15, thickness=4, color=COLOR_THEME_ACTIVE, name="cir1"},
{type="filledCircle", x=105, y=135, radius=15, color=COLOR_THEME_EDIT, name="cir2"},
{type="arc", x=15, y=95, radius=15, thickness=4, startAngle=0, endAngle=210, color=COLOR_THEME_WARNING, name="arc"},
} Elements can be nested and grouped using the ‘children’ property. local uiElements = lgvl.build(lyt) The named elements can be updated later: uiElements[“ctr”]:set({text=“New string”}) You can also copy the UI element references into other variables to make updating easier local ctr = uiElements[“ctr”]
ctr:set({color=COLOR_THEME_PRIMARY2}) |
Added the 'image' widget object to display bitmap images. |
14add66
to
36666c6
Compare
ae28dec
to
d18bce2
Compare
3e164dd
to
693f112
Compare
As discussed in #4627
Sample scripts attached.
BattAnLvgl
BattAnLvgl.zip
Lvgl
Lvgl.zip
LvglMeter
LvglMeter.zip
Lvgl Test Tool
Lvgl Test Tool.lua.zip