lv_binding_micropython icon indicating copy to clipboard operation
lv_binding_micropython copied to clipboard

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

Open bx5974 opened this issue 3 years ago • 3 comments

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 avatar Aug 23 '22 21:08 bx5974

@embeddedt can you point with an example?

bx5974 avatar Aug 25 '22 12:08 bx5974

@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.

embeddedt avatar Aug 25 '22 12:08 embeddedt

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:

  • Break your sequence to shorter event-driven sequences. uasyncio is one way to do it, there are other ways too.
  • Run your long-running sequence in a different thread.
  • Create your own event loop and call it from your long-running sequence. This is usually more complicated and we don't recommend it.

amirgon avatar Aug 26 '22 16:08 amirgon