I'm not really sure what the plan is with cmd: new Uint8Array?
I think really the goal is to ensure that the minimizer can actually totally inline the constants and then remove C altogether, so a Uint8Array may not help.
Having extra constants doesn't matter at all as long as they can get minimized away, in fact it's probably handy for people later on.
I think the Writing Modules and Performance pages are about all there is right now. To be honest the code you had already looks really good.
Things that'd make it a bit more efficient...
Change sendCommandAndData to something with a short name, like scd - it's public so the name won't get changed, so the smaller it is the smaller the final code will be.
There's no need to return; at the end of functions, you can just ditch that
The var C thing
Make lutRegisterData a Uint8Array and define it outside the function - that'll make a big difference to memory usage.
If it's possible to use an arraybuffer Graphics instance, that'll be so much quicker than the callback one. It looks like a 2 bit instance would work fine - if the bytes are the wrong order you can define msb like:
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I'm not really sure what the plan is with
cmd: new Uint8Array
?I think really the goal is to ensure that the minimizer can actually totally inline the constants and then remove
C
altogether, so a Uint8Array may not help.Having extra constants doesn't matter at all as long as they can get minimized away, in fact it's probably handy for people later on.
I think the Writing Modules and Performance pages are about all there is right now. To be honest the code you had already looks really good.
Things that'd make it a bit more efficient...
sendCommandAndData
to something with a short name, likescd
- it's public so the name won't get changed, so the smaller it is the smaller the final code will be.return;
at the end of functions, you can just ditch thatvar C
thinglutRegisterData
aUint8Array
and define it outside the function - that'll make a big difference to memory usage.If it's possible to use an arraybuffer Graphics instance, that'll be so much quicker than the callback one. It looks like a 2 bit instance would work fine - if the bytes are the wrong order you can define
msb
like: