MicroPython examples for V7?


It’s excited to see the development of the LVGL moving forward so quickly, however it’s a pity that there’s still no examples for MicroPython for V7, any plans? I remember seeing somewhere that the V8 is soon to be released, any timeline? Just don’t leave us MicroPython users behind! :slight_smile:

Hi @dukeduck!

Micropython is supported on v7 and I’m planning to keep supporting it on v8.

There is an effort led by @uraich to create many Micropython examples for LVGL v7 and add them to the official LVGL docs.


Also, the examples under the micropython binding examples directory are all compatible with v7.

If you have any specific questions, you are welcome to send them in the forum!

Thanks @amirgon! Great to know! I didn’t realize that there were examples on github already - I only checked the official docs.

I had worked with V6 and loved it a lot! Now I plan to start my new project with V7.

Keep the good work up!


1 Like

While the examples Amir pointed you to, are ports from C to Python of the examples in the lv_examples repository, I am about to port further examples which I upload to https://github.com/uraich/lv_mpy_examples.
For the moment there are 4 examples which I want to run on the LiliGo t-watch 2020. You find them in the folder t-watch_examples. Then I am working on demos that were originally written for the ST7735 driver, which I also port to lvgl. You find a graphics_demo under st7735_demos. All these examples also work on the lvgl unix port

1 Like

Thanks for the effort @uraich. Kudo to you!

It will be great if the MicroPython examples will be added to https://docs.lvgl.io/ as well.

Coming soon. :wink:

1 Like

I had been working on an IoT course for the University of Cape Coast, Ghana, for which I ported the demos originally written for the ssd1351 controller to the st7735.
Now I try to port them to lv_micropython. These examples are quite a bit bigger and more evolved such that they don’t fit into lv_examples. If interested, here they are:
This is still “work in progress” and you may expect a few more demos being uploaded in the coming weeks.

1 Like

Hi @embeddedt,

Any plan to update the docs with the micropython examples soon? :slight_smile:

Soon™. There are a few more changes to make which I haven’t had time for yet.

In some of the python examples, there’s a line of code: from lv_colors import lv_colors, but when I tried to import it in REPL, it threw an error: ImportError: no module named 'lv_colors'

How can I import lv_colors?

This paradigm confused me a bit as well when I was working with MicroPython on STM32. You have to copy this file to the MicroPython drive: https://github.com/lvgl/lv_binding_micropython/blob/master/lib/lv_colors.py

It would be great if the filesystem could be populated automatically with this but I’m not aware of a way to do that at the moment.

Thanks. I found that file as well and was scratching my head trying to figure out what went wrong when I compiled the firmware and missed it :joy:

In this case it’s better to explicitly put a comment behind that line of import.

Frozen modules would do that trick.
Added in:

1 Like

Perfect! Thanks!

This topic has been incredibly helpful to me as well, I was not aware of the examples in the GitHub repo and am looking forward to when they can be incorporated into the docs.

Going out on a limb here but has anyone converted the printer demo (from here: https://www.lvgl.io/demos ) to micropython?

Not that I know of.
If anyone is interested in working on that, it could be a very nice contribution!

I was feeling ambitious so have been giving it a go, running into an issue though.

Going through the c code there are many uses of LV_EVENT_CB_DECLARE and I am not sure how to apply these in micropython (this could just be lack of c knowledge). Any pointers on how to do this?

I know, there are a few demos I have not ported and the printer demo is one of them.
LV_EVENT_CB_DECLARE are just type declarations in C and since in Python you do not declare types …
Have a look at the btn examples to see how to implement callbacks

Thank you I will tets that out, I am trying to test out in the emulator but running into the issue of using images.

Does anyone know how to use images / image paths in the emultaor?

Which emulator: the Unix port or the online JavaScript port?