Itâs not that Iâm not interested, itâs just that Iâve got other projects to be doing and I donât want to try to take on too many.
If you do go down the Lua route, send compiled Lua, not the source.
If you use compiler Lua (i.e. Lua bytecode) then only the Lua environment itself is needed.
If you allow Lua sourcecode you have to include the compiler and thatâs not going to be small, even if Lua is quite a simple language.
Also, unless you want the player to be able to program the chip, you donât need source code, you can precompile the code and load the compiled code onto the Pokitto SD card or even embed it in memory as an array of uint32_t
(all Lua bytecode instructions are 32 bits wide).
Youâd have to track the lifetime of the code and know when itâs no longer needed.
C++ has two good mechanisms that could probably help - destructors and smart pointers.
The biggest bottleneck is most likely going to be the communication between the ESP and the Pokitto, so thatâs what the âprogram uploadâ approach minimises.
Think of it like thisâŠ
Person A needs to get some work done, but they also need lunch, so so person A asks person B to make lunch.
Person B doesnât know how to cook.
Person A has two choices:
- Get up every 2 minutes to person B what to do next
- Give person B a recipe and tell them to follow the recipe
By uploading a program to the ESP, the Pokitto would be giving the ESP a ârecipeâ.
Ultimately though, the best appraoch will depend on the scope of your library.
Thus, I think rather than trying to decide how to do it you should start by deciding what things you want the library to be able to do.
You donât have to make the hat do all the things at once,
you could have one library for wireless bluetooth and one for wifi,
and maybe have only one library used at once.
That would decrease the complexity of the code,
but it would also increase the cost of the hat.
Neither choice is wrong, it depends on which is more important.
I think both would need other code in place, and again speed might be an issue.
If youâre interested in Lua by the way, the one of the best things you can read about it is the No-Frills introduction to Lua 5.1 instructions/bytecode, which can be found here.