Skip to content
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

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

Closed
bx5974 opened this issue Aug 23, 2022 · 3 comments
Labels
waiting for user input There is no progress in this issue since we are waiting for user to provide more inputs or answers

Comments

@bx5974
Copy link

bx5974 commented Aug 23, 2022

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
Copy link
Author

bx5974 commented Aug 25, 2022

@embeddedt can you point with an example?

@embeddedt
Copy link
Member

@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
Copy link
Collaborator

amirgon commented Aug 26, 2022

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 amirgon added the waiting for user input There is no progress in this issue since we are waiting for user to provide more inputs or answers label Aug 26, 2022
@amirgon amirgon closed this as completed Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for user input There is no progress in this issue since we are waiting for user to provide more inputs or answers
Projects
None yet
Development

No branches or pull requests

3 participants