lvgl / lv_binding_micropython

LVGL binding for MicroPython
MIT License
237 stars 156 forks source link

How to update the lvgl bar progressbar percentage when my other py function is running #231

Closed bx5974 closed 1 year ago

bx5974 commented 1 year ago

I compiled lvgl for micropython 1.19.1

How to update the lvgl bar progressbar percentage when my other py function is running

when i call my function - my function alone is running and lvgl progress bar is stuck

Could you please help with an micropython lvgl progress bar updating example

i was searching but I dont see any fitting micropython examples for this

bx5974 commented 1 year ago

@embeddedt can you point with an example?

embeddedt commented 1 year ago

@amirgon can correct me, but I believe the solution here is to make sure that your MicroPython code does not block, as LVGL can only run when Python code is not running. If you need to delay without affecting your UI, look into using a system like uasyncio.

amirgon commented 1 year ago

How to update the lvgl bar progressbar percentage when my other py function is running

The UI is updated by the Event Loop. By default, the event loop is running only when other Python code is not running. This allows us to run the GUI (and all other parts of the application) on a single thread.

You should usually write event-driven code: never "wait in a loop forever" for example. If there is some task to do, a callback is called and returns as soon as possible in order to return the control to the event loop.

If you have some long-running sequence of command you want to run without blocking the GUI, your options are: