Yep... is all slow... so think about a different arrangement, like getting things in parallel out... set/get pixel is a slow thing, see LCD Graphics. Some users resorted to inline assembler...
As @DrAzzy mentioned, you would need to provide a little bit more details... about HW involved and SW you wrote...
Choosing typed arrays and array buffers makes it already faster because you deal just w/ bytes and not with integers. Plain arrays are resource monsters.
Furthermore, try to use Array.forEach... and pass a function name, then variable resolution happens for certain things to much lesser degree... Since Espruino runs of the source code - not like browsers who do some JIT and run from internalized/'compiled'/tokenized code - fast
algorithms reduce the number of variables used/referenced...
So you do not just have to be frugal w/ code cycles, but also with memory:
Since you crate your array, did you think of just having one bit for a byte in a UInt8Array? JavaScript allows you to shift, and that saves you tons of memory (which you will use later for many other things...). First though you can start with a UInt8Array where you put 0x00 and 0x01. Then you loop through it. For your setPixel() I assume it's monochrome what you do...
Instead of an if - which does a lot of referencing, you just setPixel with color 0 and 1... You have the zeros at hand anyway...
What is the driver/module you use to connect to your matrix display?
If your graphics can be drawn with lines, it may be done faster too. I tried some stuff where the SPI is the lock down... But it can made to work.
@Gordon mentioned also the way to push out a bit image/sprite... and 16 by 8 is small... I though assume you have larger sprites you plan to push out.
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.
Yep... is all slow... so think about a different arrangement, like getting things in parallel out... set/get pixel is a slow thing, see LCD Graphics. Some users resorted to inline assembler...
As @DrAzzy mentioned, you would need to provide a little bit more details... about HW involved and SW you wrote...
Choosing typed arrays and array buffers makes it already faster because you deal just w/ bytes and not with integers. Plain arrays are resource monsters.
Furthermore, try to use Array.forEach... and pass a function name, then variable resolution happens for certain things to much lesser degree... Since Espruino runs of the source code - not like browsers who do some JIT and run from internalized/'compiled'/tokenized code - fast
algorithms reduce the number of variables used/referenced...
So you do not just have to be frugal w/ code cycles, but also with memory:
Since you crate your array, did you think of just having one bit for a byte in a UInt8Array? JavaScript allows you to shift, and that saves you tons of memory (which you will use later for many other things...). First though you can start with a UInt8Array where you put 0x00 and 0x01. Then you loop through it. For your setPixel() I assume it's monochrome what you do...
Instead of an if - which does a lot of referencing, you just setPixel with color 0 and 1... You have the zeros at hand anyway...
What is the driver/module you use to connect to your matrix display?
If your graphics can be drawn with lines, it may be done faster too. I tried some stuff where the SPI is the lock down... But it can made to work.
@Gordon mentioned also the way to push out a bit image/sprite... and 16 by 8 is small... I though assume you have larger sprites you plan to push out.