Getstarted with LVGL and Micropython

Hi, I’m new and I’m creating a project with Squareline Studio, I exported it to the Mircopython language but I can’t understand how to proceed. To make it work do I have to download the lvgl python module (pip install lvgl) and then load it on the board? I haven’t found much documentation about it. In my case I bought an ESP32-S3 board and apart from an ILI9488 display, how can I declare the connections made with the wires? thanks for any replies.

1 Like

Hi, somebody can link me an already configured project for micropython, because i can’t figure out how go on, the documentation is not very explanatory.

Here you can find several examples and useful libs for micropython:

Your question is not related to LVGL-micropython, if you need basic guidance with micropython, you should rather look there:
https://docs.micropython.org/en/latest/

Also the wording “already configured project for micropython” is confusing. What exactly do you expect to find ?

If you want to get your hands dirty with a full-featured project using micropython and LVGL, have a look here:

Hello!

The documentation is for LVGL version 9.
The MicroPython binding master branch is not fully updated yet to LVGL v9, but we will update it soon.
If you want to play with MicroPython & LVGL v9, then please clone lv_micropython repo and checkout feat/multi-instance branch, which contains LVGL v9 updates. You should build MicroPython from that branch.

Some other info about this feat/multi-instance branch:

  • MicroPython version: 1.20.0
  • LVGL version: 9.0-rc (Release Candidate)
  • ESP32 port: supported ESP-IDF: 4.4.0 - 4.4.5 (I have not tested 5.x)

My experience is that testing and fixing the UI, or even app logic is faster in unix port. Then if it is OK, then upload the code (and assets) to device and test the app there.
You can use mpremote or other tools to upload MicroPython files and assets to device.

Some linux bash scripts to build unix & ESP32-S3 ports:

build-unix.sh

ESPIDF=~/esp/esp-idf-4-4-5
MICROPYTHON=~/src/lv_micropython

source $ESPIDF/export.sh

cd $MICROPYTHON
make -C mpy-cross

cd $MICROPYTHON/ports/unix
make submodules
make DEBUG=1

build-esp32-s3-spi.sh

ESPIDF=~/esp/esp-idf-4-4-5
MICROPYTHON=~/src/lv_micropython
BOARD=GENERIC_S3_SPIRAM
BUILD_VERBOSE=1

source $ESPIDF/export.sh

cd $MICROPYTHON
make -C mpy-cross

cd $MICROPYTHON/ports/esp32
make submodules
make BOARD=$BOARD

For Unix port use SDL:

WIDTH = 320
HEIGHT = 480

import lvgl as lv
lv.init()

display = lv.sdl_window_create(WIDTH, HEIGHT)

mouse = lv.sdl_mouse_create()
mouse.set_display(display)

keyboard = lv.sdl_keyboard_create()
keyboard.set_display(display)

import lv_utils
lv_utils.event_loop(asynchronous=False)

Initialize ILI9488 display (just an example, I have not tested):

DISPLAY_PIN_MOSI = ...
DISPLAY_PIN_MISO = ...
DISPLAY_PIN_SCK = ...
DISPLAY_PIN_DC = ...
DISPLAY_PIN_CS = ...

WIDTH = 320
HEIGHT = 480

import lvgl as lv
lv.init()

import lv_utils
lv_utils.event_loop(asynchronous=False)

from ili9XXX import ili9488
display = ili9488(mosi=DISPLAY_PIN_MOSI, miso=DISPLAY_PIN_MISO, clk=DISPLAY_PIN_SCK,
				dc=DISPLAY_PIN_DC, cs=DISPLAY_PIN_CS,
				width=WIDTH, height=HEIGHT)

If display shows nothing, then check the configuration for ILI9488 in ili9xxx.py file, and change some parameters (colormode, color_format, swap_rgb565_bytes). I did not test this ILI9488 display, so when you figured out the correct parameters, share with me please, so I can update in the file.

Just as a correction. The MicroPython binding will not compile for the ESP32-S2 or ESP32-S3.

Hi, thanks for your reply; so all those projects I’ve seen are compiled in c/c++ with arduino language?