LVGL supports a python binding and they provide a pair of repositories supporting it. One contains the bindings and the other with the bindings as part of micropython. There are even drivers for the ILI9488 LCD controller and FT6236 touchscreen controller used by gCore and since Micropython runs just fine on the ESP32 getting the lv_micropython build running on gCore is easy. However there's room for an optimization that speeds drawing on gCore even more than the higher 80 MHz SPI clock.
The ILI9488 chip supports multiple interfaces: 8- or 9-bit SPI, 8-, 16- or 24-bit parallel or DSI/MIPI parallel. Most micro-based systems use the 4-wire SPI interface. gCore uses the 8-bit parallel interface. The chip also supports either 16-bit (RGB565) or 18-bit (RGB666) pixels, but only on the parallel interfaces. When using the SPI interface directly the chip is limited to 18-bit pixels which must be loaded with 3 bytes (8-bits each for R, G and B). This is why you'll see a lot of drivers with an extra step of converting data from 16-bits to 24-bits or from 32-bits down to 24-bits (as is done by the default ili9XXX.py driver in the lv_micropython repository). This is a significant performance hit. The "ili9488" class in the driver only supports LVGL in 32-bit (RGBA8888) mode and generates an error if LVGL is configured for 16-bit pixels. But since gCore uses the parallel interface we can avoid this. For this reason I modified the ili9XXX.py driver to include a new class "ili9488g" that implements the following optimizations (leaving the original ILI9488 class alone).
- Changed the default SPI peripheral to VSPI and default pins to match
- Set a default 80 MHz SPI bus frequency
- Added support for 16-bit pixels
The new driver will work with LVGL compiled for either 16- or 32-bit pixels. There is a noticeable speed-up when running with 16-bit pixels and not a lot of image degradation since the ILI9488 is really only capable of 18-bit pixels.
I also got one of the demos running.
One of the nice things about LVGL on Micropython is that it's really easy to use. The REPL makes it great for experimentation too. Just a few lines of code to get a GUI. For example the following code initializes LVGL and both the touchscreen and LCD drivers, and then creates and displays a button.
from ili9XXX import ili9488g from ft6x36 import ft6x36 disp=ili9488g() touch=ft6x36(0, 21, 22, 10000) scr=lv.obj() btn=lv.btn(scr) btn.center() label=lv.label(btn) label.set_text('Button') lv.scr_load(scr)
The main github repository has been updated with instructions and the new driver.