Sharing a way how to setup neopixel, set color and send simple patterns - Many thanks to @Gordon who mentioned this possibility via Uint24Array().
// load module
var np = require('neopixel');
// pin data line is attached to
var NPP= D16;
// number of neopixel
var countNP = 100;
// use Uint24Array to store an address single pixel
var neopixelStrip = new Uint24Array(countNP);
// set color for first and last pixel
var color = {r:20,g:0,b:20};
var c = color.g + (color.r << 8) + (color.b << 16);
neopixelStrip[0] = c;
neopixelStrip[countNP-1] = c;
// flip neopixel
np.write(NPP, neopixelStrip.buffer);
Send a pattern all over the neopixel strip
// Solution A
// simple pattern "_ _ Green _ _"
var fiveLEDs = new Uint24Array(5);
fiveLEDs[2] = 30;
// fill buffer with a pattern array and count
var nps = E.toUint8Array({data:fiveLEDs.buffer,count:20});
// Solution B
// fill buffer with pattern
for ( i = 2; i < countNP; i +=5 ) { neopixelStrip.buffer[i] = 30;
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.
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