Skip to content
Micropython bindings to LittlevGL for Unix (Work in progress)
Branch: master
Clone or download
Pull request Compare This branch is 65 commits ahead, 387 commits behind micropython:master.
Latest commit 75d6127 Mar 20, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update state.yml Feb 21, 2019
drivers drivers/dht: Allow open-drain-high call to be DHT specific if needed. Jan 21, 2019
examples examples/unix/ffi_example: Clean up and update the ffi example. Oct 23, 2018
extmod py/mpconfig: Move MICROPY_VERSION macros to static ones in mpconfig.h. Dec 21, 2018
lib Added xpt2046 driver for esp32. untested yet. Mar 20, 2019
logo all: Use the name MicroPython consistently in comments Jul 31, 2017
mpy-cross Moved lv_mp_mem_custom_include.h to non unix-specific location, under… Jan 26, 2019
ports bugfix in module name Mar 20, 2019
py Add generic input device Mar 4, 2019
tests tests/basics/special_methods2: Typo fix in comment. Dec 12, 2018
tools tools/ Fix regression so tool runs under Python 2 again. Dec 29, 2018
.gitattributes .gitattributes: Remove special text handling of stm32 usbdev files. May 11, 2018
.gitignore Add and enable lvgl mpy gc support Jan 11, 2019
.gitmodules Point lv_binding to LittlevGL instead of amirgon and update it. Re-en… Jan 24, 2019
.travis.yml travis: Add nrf port to Travis CI build. Jul 20, 2018
ACKNOWLEDGEMENTS ACKNOWLEDGEMENTS: Change backer 905 info, replace city with name. Oct 22, 2016 all: Remove trailing spaces, per coding conventions. Jul 19, 2017 Link to contrib guidelines and code conventions. May 3, 2015
LICENSE Add license header to (almost) all files. May 3, 2014 Fixed errors in Build instructions in Mar 10, 2019

Micropython + lvgl

For information abound Micropython lvgl bindings please refrer to lv_bindings/

See also Micropython + LittlevGL blog post.

Build Instructions

  1. sudo apt-get install build-essential libreadline-dev libffi-dev git pkg-config libsdl2-2.0-0 libsdl2-dev python
  2. git clone --recurse-submodules
  3. cd lv_micropython
  4. make -C ports/unix/
  5. ./ports/unix/micropython

For ESP32 port

Please set ESPIDF parameter for the esp-idf install dir. It needs to match Micropython expected esp-idf, otherwise a warning will be displayed (and build will probably fail) For more details refer to Setting up the toolchain and ESP-IDF

When using IL9341 driver, the width height and color need to be set to match ILI9341. This can be done from the command line. Here is the command to build ESP32 + LittlevGL which is compatible with ILI9341 driver:

make -C ports/esp32/ ESPIDF=~/esp/projects/lv_mpy_deps/esp-idf -j4 LV_CFLAGS="-DLV_HOR_RES=240 -DLV_VER_RES=320 -DLV_COLOR_DEPTH=16" deploy

This make command will create ESP32 port of Micropython, and will try to deploy it through USB-UART bridge. LV_CFLAGS are used to override width height and color, for ILI9341 compatibility.

Super Simple Example

First, LittlevGL needs to be imported and initialized

import lvgl as lv

Then display driver and input driver needs to be registered. Refer to Porting the library for more information. Here is an example of registering SDL drivers on Micropython unix port:

import SDL

# Register SDL display driver.

disp_drv = lv.disp_drv_t()
disp_drv.disp_flush = SDL.monitor_flush
disp_drv.disp_fill = SDL.monitor_fill
disp_drv.disp_map = SDL.monitor_map

# Regsiter SDL mouse driver

indev_drv = lv.indev_drv_t()
indev_drv.type = lv.INDEV_TYPE.POINTER; = SDL.mouse_read;

Here is an alternative example, for registering ILI9341 drivers on Micropython ESP32 port:

# Import ESP32 driver (advnaces tick count and schedules tasks)

import lvesp32

# Import ILI9341, initialize it and register it to LittlevGL

import ILI9341 as ili
d = ili.display(miso=5, mosi=18, clk=19, cs=13, dc=12, rst=4, backlight=2)
disp_drv = lv.disp_drv_t()
disp_drv.disp_flush = d.flush
disp_drv.disp_fill = d.fill

Now you can create the GUI itself

# Create a screen with a button and a label

scr = lv.obj()
btn = lv.btn(scr)
btn.align(lv.scr_act(), lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)

# Load the screen


More information

More info about LittlevGL:

More info about lvgl Micropython bindings:

Discussions about the Microptyhon binding:

More info about the unix port:

You can’t perform that action at this time.