LVGL with MicroPython problem

Hi everyone,

Can someone tell me step by step how can i add a lvgl library to my micropython project ? I read documentation, but still doesn’t work :confused:

I cannot add the library correctly so that it can be imported.

I work with ILI9341 display with XPT2046 ic for touch ,on the ESP32.

Thanks a lot for your help.

Hello,

I would recommend using the https://github.com/lvgl/lv_micropython fork, which is kept up to date with MicroPython releases and has built-in support for LVGL on ESP32.

As @embeddedt wrote, the fastest and simplest way is to fork lv_micropython.

In case you have your own Micropython fork and would like to add LVGL to your fork (instead of forking lv_micropython), you can also do that but it requires more work. LVGL cannot be used as an external module due to multiple reasons so you need to make changes to Micropython in order to build it.

You can try following “Adding Micropython Bindings to a project” but it’s a bit old and outdated.
Another options is to compare lv_micropython to micropython, understand the differences and apply the same changes on your fork. Pay special attention to Makefiles and mpconfigport.h files.

@embeddedt @amirgon thank you for your answers and advice. I work on the Windows 10 operating system. I did everything step by step according to the documentation. Maybe the whole process looks different for Windows? Perhaps I am doing something wrong, so I asked for an explanation of how the whole process should look like, step by step.

There are steps provided for Linux here. You can skip the last two lines for ports/unix and jump straight to the ESP32 port if that’s what you’re aiming to build.

I would suggest using WSL or a Linux virtual machine if you aren’t already. I’m not sure that anyone has ever tested compiling this on Windows directly.

If things still aren’t working, please provide more information about the exact error you are getting.

@embeddedt Thank you for your help. In fact, it seems to me that the operating system itself is the problem. I work on Windows 10 on a daily basis. So I’ll put Linux on a virtual machine or run RPi and check everything. If everything is fine, I’ll let you know.

@embeddedt @amirgon I understand well that the LVGL library must be included in the micropython firmware that I upload to the ESP32 board? Can you explain to me how to build such a micropython firmware with the attached LVGL library? It must be a file with the bin extension that will contain the micropython firmware with the LVGL library?

@Jarek Please take a look at the steps I linked above. If you are using lv_micropython, it already includes LVGL when you build a binary.

@embeddedt
i want to use lv_micropython. I read what you linked above, but I don’t know how to build a binary: / Can you explain to me how to build a binary? Or is it explained somewhere?

I understand you may be a bit nervous with my questions, but this is my first contact with Micropython. While I have no problem with C / C ++, I would like to try to create my project using Micropython, and for that I need the LVGL library.

Thank you for your help

It’s all explained in the README under Build Instructions.
The platforms we actively support are unix (Linux), ESP32 and STM32.

For ESP32, the makefile builds the binary firmware (that includes both Micropython and LVGL) and deploys it through USB (UART).

Did you follow the instructions there?
Could you explain what was the difficulty? Are you familiar with make and with git?

1 Like