Arduino like C++ binding


So, I’m pleased to introduce my new project “emToile” which is a (partially) implementation in C++ of Lvgl framework targeting Arduino ecosystem. I made it to share easily GUI code b/w my Lilygo’s TWatch and LilyPI.

For the moment, only a subset of Lvgl’s objects are covered but it will increase as per my need. Obviously, everyone is welcome to join the journey :smile:


1 Like


emToile is evolving (slowly :slight_smile: ) as per the improvements needed by DomoWatch project.

I did a massive redesign to emancipate Styles vs object to be more in line with LVGL’s way of working.

Styles are now fully converted, object local styles are only partially.

I have added also some (few) example.

As example :

Simple chart :

#include <Chart.h>

	 * objects
Chart *chart;
Chart::Serie *serie;

	 * Build the chart

void start_gui( void ){
		/* Create the chart */
	chart = new Chart( 10, lv_scr_act() );
	chart->setSize( 300, 200 );
	chart->Align( LV_ALIGN_CENTER );

	chart->setCaptionString( "Chart example" );

		/* Add ticks on the left */
	chart->setPadding( 5, 5, 4 * (LV_DPI / 10), 0, LV_CHART_PART_BG );	// set space on the left
	chart->yTicks( "600\n500\n400\n300\n200" );

		/* Add data series */
	serie = chart->addSerie( LV_COLOR_RED );
	serie->Insert( 0 );
	serie->Insert( 10 );
	serie->Insert( 20 );
	serie->Insert( 20 );
	serie->Insert( 20 );
	serie->Insert( 40 );
	serie->Insert( 60 );
	serie->Insert( 70 );
	serie->Insert( 90 );
	serie->Insert( 100 );



Is emToile actually a C++ binding for LVGL?

Yes, it is (Binding and not building … but I don’t know how to modify the title :frowning: )
But for the moment, only a subset as per my needs.

Here a more complete example with a Chart and some styles and DomoWatch is a full featured appli.

Ah cool. I’ve modified the title.

We were thinking for a long about a C++ binding but I think it’d be more maintainable if the binding were auto-generated.

The Micropython binding generated a JSON file with the API of LVGL.
Seemingly it could be a good starting point. (139.4 KB) .

What do you think about it?

Thanks for the title :ok_hand:

For auto-generation, it’s definitively a must for classes having lot of methods like Styles or root objects.
But at a moment or another, manual changes are required for example to specify default values (one of the BIG added value of C++, IMO).

But for others, manual implementation leads to a better POO design : as example, Chart where Series are a sub class of Chart.
And it’s part of my knowledge ramp-up on LVGL :slight_smile:

So all in all, probably an hybrid method would be the best :

  • automatic for styles, root objects which are very tedious to implement,
  • Manual for high level ones.

In fact, it’s depending of the downward compatibility b/w versions and as I worked only on 7.x, I haven’t any clue this aspect.

v8 is not backward compatible but minor versions are. Major versions are added only in 1-2 years.