-
• #2
Just a note that
E.HSBtoRGB(h,s,b,24)
works to get a 24 bit colour value if you ever fancy doing rainbows -
• #3
Is there a way to optimize
var nps = E.toUint8Array({data:fiveLEDs.buffer,count:20});
? -
• #4
There isn't anything I'm aware of. Ideally we'd need a new function that allows Espruino's interpreting of those
{data,count}
blocks to work on existing buffers, but that doesn't exist yet.Best bet on official boards is to use JIT:
var countNP = 100; var neopixelStrip = new Uint24Array(countNP); var fiveLEDs = new Uint24Array(5); fiveLEDs[2] = 30; function repeatPattern(strip, pattern, count) { "jit" for (var i=0;i<count;i+=5) strip.set(pattern,i); } repeatPattern(neopixelStrip, fiveLEDs, countNP);
Sharing a way how to setup neopixel, set color and send simple patterns - Many thanks to @Gordon who mentioned this possibility via Uint24Array().
Send a pattern all over the neopixel strip