Open JimB40 opened 1 year ago
@lshems @jfrickmann @offer-shmuely @frankiearzu @yaapu @ feedback appreciated
Why not add the models table as well. The structure is already defined by the introduction of yaml storage format.
In that way you can get rid of all API function to manipulate data. Only 'real' functions should remain, as getting inputs from sources, and creating output on screen. The rest is LUA data manipulation ...
AFAIK, a table will be stored in RAM, whereas functions are stored in ROM. Therefore I believe that the proposal would increase the RAM memory usage.
Why not add the models table as well. The structure is already defined by the introduction of yaml storage format.
Might be good idea
AFAIK, a table will be stored in RAM, whereas functions are stored in ROM. Therefore I believe that the proposal would increase the RAM memory usage.
Very good point Jesper. I wonder how much RAM will it consume considerng that getting rid of those read-system-value functions will free memory for new C code. I think there might be workaround for low mem radio so accesing special global "sys" variable will actually invoke C function that returns proper values.
Why not add the models table as well. The structure is already defined by the introduction of yaml storage format.
Might be good idea
What excatly do you want to do on the models? The model data structure is changing with every release, so the LUA scripts would have to adapt to those changes at every relase. This sounds problematic to me. Everything model related should be done in one place in the code and there there have to be APIs for UI and LUA to get and set model information. That way only one place in the code needs to know the data structures and those can be changed without breaking anything else.
Looks great, as long as it done for “read” operation only (not for changing data)
It will simplify the access to this information.
Is it possible in lua to make that information read only? or one script will be able to change it by mistake to other scripts?
Robert, Looks good to me. A good amount of the sys table is static (don't change after power on), but others are constantly changing (like date/time). Not familiar how internally lua table fields works, but when you access a field on a table, it will need to do a call to C/C++ to get the real-time value. or instead of a field, could be a function?? For example: sys.dt.os_run or sys.dt.os_run() instead of getTime() ???
Otherwise, you will need to constantly update the table with up-to-date values, that might be expensive.
Why not add the models table as well. The structure is already defined by the introduction of yaml storage format.
Might be good idea
What excatly do you want to do on the models? The model data structure is changing with every release, so the LUA scripts would have to adapt to those changes at every relase. This sounds problematic to me. Everything model related should be done in one place in the code and there there have to be APIs for UI and LUA to get and set model information. That way only one place in the code needs to know the data structures and those can be changed without breaking anything else.
Well, I do see the yaml format as an already existing representation of the actual eeprom settings. I know lots of implementations where the API is simply allowing get, put, patch actions on every element in such a data structure. This would make life super simple, as you only need to have one Metafunction added to all elements that would allow for that
So model.name.get() would get the model name. Model.name.set('newname') would change it.
You could also allow entire structures to be read and set. Perhaps invert the syntax:
Set(model.name,'newname') Get(model) would then return model.name and all other elements in Yaml format (or XML, or lUA table, or ...
Just ideas
PURPOSE
This proposal is to switch from pulling system data via function to read only object avalable to LUA scipts. It will allow to:
Initial proposal
sys Global LUA table holding various system data **sys.*** childeren tables holding data related to child type
sys.os.* - operating system (EdgeTX) data
sys.radio - physical radio used data
sys.fs - filesy system data
sys.lua - LUA data
sys.dt - OS date/time data
Backward compatibility and depreciation
LUA functions to depreciate over time
Providing backward compatibility should be quite easy for existing LUA scripts and it can be done during script initialization That will allow LUA dev to make smooth transition to new syntax.