lv_binding_cpp icon indicating copy to clipboard operation
lv_binding_cpp copied to clipboard

Detail ways to create a C++ binding

Open boulabiar opened this issue 1 year ago • 2 comments

I opened this issue to discuss ways to create C++ bindings for lvgl.

I don't think the bounty will do it, especially with the conditions that it should be perfect and with examples.. So let's discuss how to do the binding and start with simple examples so it can be done one step each time.

Can we generate code from the rust bindings ? so we have similar APIs ?

boulabiar avatar Apr 09 '24 13:04 boulabiar

I think we should use the JSON generated from LVGL's API and generate the C++ binding based on that.

kisvegabor avatar Apr 15 '24 19:04 kisvegabor

If the JSON generation code gets added to LVGL the workload of putting together a C++ binding just got reduced by a HUGE amount. Couple that with the documentation for LVGL being available in that JSON output and now you can add that documentation to the binding code and make changes to the documentation programmatically so it would suit the C++ binding.

Examples and unit tests would probably need to be written by hand. unit tests are pretty easy to do actually. Instead of writing the data to a display in the flush callback you dump it into a buffer and you compare the data in that buffer to the data of what the expected output is supposed to be. You basically add a bunch of widgets you want to test and size them how you want and then call lv_refr_now and that will force the rendering to take place and the flush callback to get called. The only thing that you need to do special is setting the render mode to direct and making the frame buffer the same size as the "fake" displays resolution using 3 bytes per pixel.

kdschlosser avatar May 09 '24 03:05 kdschlosser