lv_micropython_cmod
PyDevices / lv_micropython_cmod

lv_micropython_cmod

MicroPython user C module glue for LVGL: micropython.mk, CMake usermod, GC-aware allocator, and smoke tests. It consumes lv_bindings generated/lvgl_micropython.c (run regenerate_lvmp.sh) so firmware gets a native import lvgl.

Clone as a sibling of lv_bindings/ and micropython/, or use the optional cmods workspace with ./build_mp.sh. CircuitPython integration lives in lv_circuitpython_mod — a different workflow, not USER_C_MODULES.

Source on GitHub lv_bindings cmods

Generate bindings

cd lv_bindings
git submodule update --init lvgl
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
./regenerate_lvmp.sh

Build into MicroPython

Make ports (unix, …)

USER_C_MODULES is the workspace parent containing this repo.

cd micropython/ports/unix
make USER_C_MODULES=../../.. \
  FROZEN_MANIFEST=../../../lv_micropython_cmod/manifest.py

# Optional bindings override:
# BINDINGS_DIR=/path/to/lv_bindings

CMake ports (esp32, rp2)

USER_C_MODULES points at this repo (or its micropython.cmake).

cd micropython/ports/esp32
make BOARD=ESP32_GENERIC_S3 \
  USER_C_MODULES=../../../lv_micropython_cmod

# Plus other usermods:
make BOARD=ESP32_GENERIC_S3 \
  USER_C_MODULES="/abs/path/to/lv_micropython_cmod;/abs/path/to/displayif"

Smoke test

./micropython/ports/unix/build-standard/micropython \
  ./lv_micropython_cmod/test_lvgl_unix.py

# Or via cmods:
./build_mp.sh --port unix --variant standard
./build_target.sh mp-unix

Related