• What I want to do is either output a 25 light pattern x 20

    You could try this:

    // make my pattern
    pattern = new Uint24Array(25);
    for (var i in pattern) 
      pattern[i] = E.HSBtoRGB(i*0.1,1,1) ; // or whatever you need for some RGB stuff
    
    require("neopixel").write(pin, E.toUint8Array({data:pattern.buffer, count:20}));
    
    // this may also work - but i'm not 100% sure:
    require("neopixel").write(pin, {data:pattern.buffer, count:20});
    

    Uint24Array isn't actually in the JS spec, but it's super helpful for neopixels as you can write R/G/B in one go.

    As @MaBe mentioned you can also try compiled code when you're calculating what your 25 LED pattern should be.

    Note that you could also do stuff like:

    pattern = new Uint24Array(25);
    rpattern = new Uint24Array(25);
    // ...
    rpattern.set(pattern);
    rpattern.reverse();
    
    E.toUint8Array({data:[pattern.buffer,rpattern.buffer], count:10})
    

    So then it does the pattern, but flips and repeats it so even if you start with red and end with green, there's no harsh point at which it changes

  • So I know this thread is super old but I wanted to say thanks to @Gordon that was the trick I was looking for!

    I was able to use it also to make a sound reactive LED hat using some advice you gave someone else! Thanks for helping me as I am new to the coding world!

About

Avatar for AdaMan82 @AdaMan82 started