This probably could have been posted in the projects group as well but seeing how it’s a modification of micropython figured I’d post here.
I noticed a few different questions and posts about getting LVGL to work with circuitpython so I thought I’d share a project I have been working on to modify the bindings to work with circuitpython. A test repo can be found here if anyone is interested: http://github.com/desterly/lv_circuitpython
This is based on:
HEAD of circuitpython (6.0 RC2)
HEAD of lv_bindings
HEAD of lvgl.
Ultimately, the main differences between the main lv_bindings are below:
- created gen_cp.py file to generate bindings source compatible with CP - this is the same as gen_mp.py with a few modifications for CP.
- renamed the “decompress” method in lv_font_fmt_txt.c to lv_decompress due to CP having it’s own decompress
- created a LVGlue C module which acts as the core display driver for LVGL by hooking into CP’s displayio
LVGlue more or less works like this:
import lvgl as lv
display = lvglue.display()
… normal LV code
During init, LVGlue’s display:
- creates a dummy displayio group and adds to CP’s displayio
- init’s lvgl and sets the displaydriver hooks
setActive sets the dummy group as active in displayio
LVGL’s tick and refresh is handled by CP’s supervisor tick module.
flush calls flush LVGL’s buffer via displayio core’s flush methods.
during flush if the dummy bitmap isn’t active (IE: lvgl isn’t current display on CP), the flush simply returns.
This process allows LVGL to act as another CP display “group” allowing use of both LVGL and CP’s display processes.
Touch is handled currently in a py module utilizing the adafruit_touchscreen module.
File storage is handled by the py storage module posted here in another topic.
Currently everything is hooked into the atmel port (specifically the pyportal board) however it should work for all CP ports with displayio.