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.