Binding API Discussion #158
Replies: 2 comments 4 replies
-
From my point of view, you find yourself in the same situation as your predecessors. The more time goes by, the more I think that lvgl will one day have to be cloned into another simpler project maintained in pure python. By this I mean freezing most of the calculations that require a lot of c and keeping the rest out of c in python. |
Beta Was this translation helpful? Give feedback.
-
I understand, my point of view probably can't technically succeed. nop I didn't know that for drivers, good to know! By the way, I'm still wondering about the choice of integrating all this directly into the micropython firmware itself. |
Beta Was this translation helpful? Give feedback.
-
I have spent some time tearing into the generated C binding code for LVGL. While the code does work from looking at it I had always thought it could be improved upon. There are a couple of things I really didn't like about it. The first thing is everything being lumped into a single source file that has some 50k lines of code. The entire API was plopped into a single python module, The downside of this is the absolute HUGE amount of code that needs to load upon import. Python is not like compiled C code where only the bits and pieces that get used actually get loaded. Even if it's not being used it ends up betting loaded into RAM. I believe we can mitigate some of this by duplicating the LVGL file/folder structure. I would need to work out the mechanics so
from lvgl.widgets import slider
would work and ONLY the code that is needed for the slider to work would get imported. so if you don't use the button widget code if you don't import it it's not going to get loaded.Another thing I have not liked about it is how it mangles the original LVGL API. This makes the binding code generator extremely complicated and when something breaks it's a royal pain to fix. There is also the issue with documentation. If the LVGL API is followed there really would only need to be a very minimal amount of documentation written which is always a plus. The current way things are organized makes it confusing to use.
I also don't know if a code generator is the best way to go. The problem with code generation is it has to be written so it's a one size fits all kind of thing. That means it's not going to generate the best code that can possibly be written. This is because it has to be written so it is able to fit the needs of many things instead of being purpose written. As an example. I took the generated code for
lv_area_t
and placed it all into a single file. Everything that was used to create that class was put in there. It was over 900 lines of code just for that single class. I then reworked the code by flattening the API so it is the same as the LVGL API and purpose wrote the code. Now it takes up about 400 lines and all the same things are there and available. It is going to consume quite a bit less RAM, it will run faster and it is going to take up less flash space all while providing the exact same functionality.Does anyone have an input or suggestions/ideas?
I get into this because of not being able to update to LVGL 9.2 without having to spend a great deal of time hammering out the problems in the binding generation script. It is going to be easier to write the binding code manually.
Beta Was this translation helpful? Give feedback.
All reactions