Could someone clarify my thinking about multiple controller examples?

Could someone clarify my thinking about multiple controller examples?

I perhaps mistakenly assumed that wiring up a matrix using leds[strip][num] (described under the heading “Array of led arrays”) might gain performance via some sort of parallel output… now I’m thinking this isn’t the case since the “One array, many strips” also specifies multiple pins but treats the array as one “thing.”

Am I right that FastLED is figuring out which pin controls any given leds[num] in the background and handles it during FastLED.show()?

Currently I did something like this (“Array of led arrays”):

void setup() {
FastLED.addLeds<NEOPIXEL, 10>(leds[0], NUM_LEDS_PER_STRIP);
FastLED.addLeds<NEOPIXEL, 11>(leds[1], NUM_LEDS_PER_STRIP);
}

But programming-wise, I think this is simpler (“One array, many strips”):

void setup() {
FastLED.addLeds<NEOPIXEL, 10>(leds, 0, NUM_LEDS_PER_STRIP);
FastLED.addLeds<NEOPIXEL, 11>(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);
}

I have 16 x 16 ws2812b strips but each set of 4 x 16 leds is joined together so I effectively have 4 pins controlling 64 LEDs each. I used the first variant, and find I need three nested for() loops for some stuff:

for(int strip = 0; strip < 4; strip++)
{

for(int seg = 0; seg < 4; seg++)

for(int pix = 0; pix < 16; pix++)

  leds[i][(seg * 16) + pix] = CHSV(255, 255, 255);

}

}

}

Hopefully that makes sense? Since programmatically I’m wanting to “walk” along 16 led strips, I need to know which one I’m on. Rather than calculate this for each physical strip and each “segment”), I could save a for() loop if it were just treated as a long array/strip:

for(int seg = 0; seg < 16; seg++)
{

for(int pix = 0; pix < 16; pix++)

leds[(16*seg) + pix] = CHSV(255, 255, 255);

}

}

I’m assuming some veterans here can let me know if I’m thinking about this the right way, and if there’s any reason for a matrix to not use the second method. Maybe the first (and they way I initially tried) is more for physically separated strips. In that case it would let each do something different, but I’ll always be treating this just as a square 256 matrix.

Thanks!
John

P.S. As an aside on controlling led matrices, my primary programming language is R which discourages for() loops in favor of vectorized operations. Do these exist for Arduino C/C++? For example in R you can do %*% for matrix multiplication without the need for an i/j loop through values…

Maybe simplified: is there any advantage to using multiple pins for this case of a standard 16x16 matrix?

I haven’t tried it yet, but there is a performance advantage to using parallel output: https://github.com/FastLED/FastLED/wiki/Parallel-Output

@Jason_Coon ​ I’ve run across that and understand that uses something a bit different than the “regular” library method, which is what I’m doing. I know the ws2812 can be a bit speed limited so when I ran into using separate data pins I perhaps falsely assumed that using 4 pins could divide the push of data into four “mini arrays” that would go at the same time (and thus faster than pushing 256 values and waiting for them to propagate through the strip). Am I crazy and separate pins are purely for doing different things on different strips more easily?

@Jason_Coon@John_Hendy ​ parallel output is much faster and is also very easy to use but is only available on certain controllers. I know it’s rock solid on the teensy 3.2 and the Due and I think it’s now working on the esp8266. I’ve used it on the teensy and the Due but have yet to try it on the esp8266…

@Jeremy_Spencer ​ the page on it makes it seem like a lot of typical functions don’t work with it, or am I not reading that right? I’m not super advanced and use things like fill_rainbow, beatsin8, fadeBy… Are those all available?

Also, to make sure we’re clear, my original question is asking about multiple pins vs. one long strip and not octo parallel output which I consider a separate thing.

If you aren’t using parallel output explicitly then output gets written one pin at a time - so 64 leds on each of four pins takes the same amount of time as 256 leds on one pin.

@Daniel_Garcia ​ perfect. Exactly the clarification I was looking for :slight_smile:

Is the wiki accurate about octo not doing things like beatsin8 (taking a guess at what is implied by it not having typical “math functions”)?

Or is there a list about what works with octo and what doesn’t?

“OctoWS2811 has two limitations for the average FastLED user, however. The first is that OctoWS2811 uses its own functions for setting color data, and doesn’t provide any of the brightness, color correction, math functions, etc… that FastLED does.” <-- The limitations are in reference to the OctoWS2811 library on its own

You only lose things if you use OctoWS2811 on its own - if you use FastLED’s parallel output, or if you use FastLED’s OctoWS2811 driver you don’t lose anything. (OctoWS2811 is a library that is not part of FastLED).