LVGLPlusPlus - A C++ interface to LVGL

Hey all - I’ve been using LVGL for the last year and in the process of getting to know the library a bit, I started working on a way to make it easier for myself to use in C++. After cleaning it up a bit, the result is a C++ wrapper that hopefully adds:

  • Ease of use
  • Lowering the bar for how to get started
  • Being a thin and lightweight wrapper
  • Hiding intricacies for most would-be users
  • Giving a couple of C++ sample projects that can be good starter templates

It’s not fully complete in terms of its support of all the wonderful things LVGL does today, but it is advancing and hopefully useful for many users who are wanting a way to get started without having to understand some of the underlying concepts that can be a bit confusing and error-prone, initially (Yeah - I’m speaking from my own experience here :wink: )

Take a look - the Doxygen docs are pretty complete as well. Give me feedback here or on the Github discussions forum. And go easy on me, eh? :stuck_out_tongue_winking_eye:

The Library is at: LVGLPlusPlus on Github and the Doxygen docs are at: LVGLPlusPlus Doxygen Docs

And the two Samples are at:



Wow, this looks very interesting! I could have used such a wrapper for a project two years ago. Out of curiosity I will try the examples in the next few days and see how you implemented the whole thing. Thanks for sharing.

Cool - thanks for taking a look. Lemme know some feedback. It’s a work in progress for sure but pretty darned functional in many areas and respects.


Hi Bob,

I looks great! I really like the simplicity of your binding. I think to make it really rock and easy to maintain some parts of it (more is better) should auto generated. We have already done a lot of changes in LVGL to make binding generation possible.

The MicroPython binding is fully auto generated now. It uses pycparser to generate a JSON file from LVGL’s API, and that JSON is used to generate the MicroPython binding. It was implemented by @amirgon, so he can tell more about it. :slight_smile:

1 Like

You can actually use pycparser directly but the problem is the amount of code needed in order to handle all of the “special” scenarios. Trying to use it to create a python ctypes binding would produce a large and complex code footprint that would break easily. This is because of the type conversions that have to be handled and how the classes get organized. Easier to code out a static binding and then change things that need to be changed from time to time. Really the only thing that would get changed are adding new features, removing things that are removed and changing the names of the bits that have name changes. Bindings are easy to maintain for the most part. LVGL has a lot of back end things that get changed around.

I know with version 9 there is a major overhaul of the structure and naming convention, how often is that kind of thing going to happen? I bet if there is a choice it would be never. LOL.

The reason why it works with MIcoPython is because you are not changing the language. You are writing C code and that is a whole lot easier to do with pycparser because it spits out everything for c code. MicroPython has almost all of the type conversions already built into it… I am pretty sure it would be easier to automatically generate a c extension module for Python that is written in C. That is what things like SIP and SWIG do. They generate the c code that gets compiled into a python extension module.

Maybe I’m missing something, but I can’t see why Python is relevant here. pycparser is written in Python, that’s ok, but it creates a JSON from the parsed C file. And it shouldn’t be too difficult to convert a C API to a C++ API.

I’m having a tough time visualizing the intermediate steps here. I have only taken a 2 minute cursory read of either pycparser and the lv_binding_micropython projects. What are the envisioned steps between parsing the lvgl api and re-creating something similar to what I’ve done by hand?


so the work you have put into the C++ binding you made would be an automatic thing done by a script. so if changes are made to LVGL those changes would populate out to the C++ binding without anyone having to go and manually make updates to it.

Indeed I get the ultimate purpose of it - I’m looking to get insight into the intermediate steps and how one gets from “run pycparser” to C++ bindings on the output. Not having any experience with pycparser … I suppose I’ll need to go do some reading soon, at a minimum but was hopeful for a high level sketch.

basically what pycparser does is it reads a preprocessed c source and converts it into objects in python. those objects can be looked at to determine what they are and from that you can “convert” it to whatever it is you need.