Hi all, I've just finished building a 9 strip (each has 288 pixels) installation.

Hi all, I’ve just finished building a 9 strip (each has 288 pixels) installation.

My question is around speed.

I’ve used a arduino mega and a multidimensional array (8,288) so each pixel can be individually addressed. But due to size I’m assuming the FASTLED.show() command pushes the entire array. So changes are slow even if I’m only actually making changes to a single strip or pixel.

I’ve done it this way because each strip is associated with a pressure pad, depending on which one is pushed a strip lights, so the array was ideal.

Is it possible to only send a set part of the array to a specific strip? In other words limit the show() command so it can send less data?

Many thanks,

Gavin

Nope, has to be the entire strip.

However, if you’re using an LED type that can use any pin on the Arduino (like WS2812), you could have each of 9 strips on a different pin, with a FastLED instance for each.

Hey Tod, thanks for responding.

I am using the WS2812B strips, each on its own PIN.

But it is also ideal to use a large array to avoid lists of case statements.

Just trying to ensure my code is simple and get the performance up.

I’m using the .add method to associate them with a PIN. How would I create multiple instances so .Show() only drives a single PIN?

Thanks

It isn’t yet documented well, but if you aren’t faint of heart, addLeds returns a pointer to the CLedController instance for that strip. You can then save that pointer and then call show on the individual controllers. Look in controller.h for the methods info.

Cheers Daniel. If you happen to stumble on an example that would be a real help.

Gavin

It’s less of a stumble and more of a getting to making the example. The problem is there’s still some flux in the internals there so I haven’t put it out yet. But roughly, what you want is (apologies for sloppy code, no phone had a good keyboard for coding :slight_smile:

CLedController *ledStrips[NUM_STRIPS];

void setup() {
ledStrips[0] = LEDS.addLeds<…>(…);
ledStrips[1] = LEDS.addLeds<…>(…);

}

void loop() {
… Do stuff …,
ledStrips[0]->show();

}

That said - that will only work for choosing between your 9 strips[1], there isn’t a good way to send partial data to a strip (if you are manually calling show on a led controller instance you can give it a lower number for the count of pixels, however because of how these chips work, data will always start with the start of the strip.

[1] this is the kind of thing I am hoping to help with when I get the parallel output support published.

Wow! Thanks Daniel :slight_smile:

Hi Daniel - I’m trying your code but getting the error:-

TestLED.ino:22: error: stray '' in program

TestLED.ino:8: error: expected constructor, destructor, or type conversion before ‘*’ token

TestLED.ino: In function ‘void setup()’:

TestLED.ino:12: error: ‘ledStrips’ was not declared in this scope

TestLED.ino: In function ‘void loop()’:

TestLED.ino:19: error: ‘ledStrips’ was not declared in this scope

TestLED.ino: At global scope:

TestLED.ino:22: error: expected constructor, destructor, or type conversion at end of input

The code is:-

#include “FastLED.h”

#define NUM_STRIPS 8
#define NUM_LEDS_PER_STRIP 288

CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];

CLedController *leds[NUM_STRIPS];

void setup() {

ledStrips[0] = FastLED.addLeds<WS2812B, 2,GRB>(leds[0], NUM_LEDS_PER_STRIP);
ledStrips[1] = FastLED.addLeds<WS2812B, 3,GRB>(leds[1], NUM_LEDS_PER_STRIP);

}

void loop() {

ledStrips[0].show();

}

Any suggestions?

Thanks

I’ve tried a few permutations - I think the issue is with the line
CLedController *ledStrips[NUM_STRIPS];

Im trying to find examples where similar functionality is achieved using other libraries - seems quite thin on the ground! :frowning:

Damnit my reply got eaten. Examples are thin on the ground because not a lot of libraries tackle this. And in the case of FastLED - what you want to do is an edge case for most people - which is why i haven’t done up examples yet. Anyway, on to your code.

First up - you’re re-using the name leds for both your array of CRGB objects and your array of CLedController pointers - it should be:

CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];
CLedController *ledStrips[NUM_STRIPS];

and (this is a case where i’ve recently changed the API) you need a slight tweak to the addLeds lines (note the & in front of the FastLED.addLeds - this is because you want the address of the controller, and addLeds now returns references).:

void setup() {
ledStrips[0] = & FastLED.addLeds<WS2812,2,GRB>(leds[0],NUM_LEDS_PER_STRIP);

}

and because you’re using pointers, not objects, your loop function needs to look like:

void loop() {
ledStrips[0]->show();
}

(note the -> instead of the . )

Thanks for helping me Daniel.

I’ve updated the code to this:-

#include “FastLED.h”
#define NUM_STRIPS 8
#define NUM_LEDS_PER_STRIP 288

CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];

CLedController *ledStrips[NUM_STRIPS];

void setup() {
ledStrips[0] = &FastLED.addLeds<WS2812B, 2,GRB>(leds[0], NUM_LEDS_PER_STRIP);
ledStrips[1] = &FastLED.addLeds<WS2812B, 3,GRB>(leds[1], NUM_LEDS_PER_STRIP);
}

void loop() {
ledStrips[0]->show();
}

I’m still getting an error with regard to "

TestLED.ino:18: error: stray '' in program
TestLED.ino:9: error: expected constructor, destructor, or type conversion before ‘*’ token
TestLED.ino: In function ‘void setup()’:
TestLED.ino:12: error: ‘ledStrips’ was not declared in this scope
TestLED.ino: In function ‘void loop()’:
TestLED.ino:17: error: ‘ledStrips’ was not declared in this scope
TestLED.ino: At global scope:
TestLED.ino:18: error: expected constructor, destructor, or type conversion at end of input

So i have no idea what’s going on in line 18 - or what’s causing the "error: stray ‘’ in program - it’s something that’s getting dropped out of what you’re pasting into the comment.

Ah - sorry - the line should be:

CLEDController *ledStrips[NUM_STRIPS];

(this is why i said look in controller.h - I shouldn’t trust my memory for this - and i’m in the middle of sanding a 6’ diameter acrylic disk right now :slight_smile:

But still no idea what’s going on with the complaint on line 18.

Acrylic disk! Sounds interesting - part of your new installation?

I appreciate you helping a stranger - especially on a Sunday! Thanks.

The "" error has gone, I think a stray character must has found its way in when I copied/pasted - I just retyped the same thing and it went away.

Also - the definition passes ok now - thanks.

The last issue was the .show() - but I looked in the controller.h function as you suggested and made some tweaks.

This now seems to compile (i’ve not connected it to the LEDs yet).

#include “FastLED.h”
#define NUM_STRIPS 8
#define NUM_LEDS_PER_STRIP 288

CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];

CLEDController *ledStrips[NUM_STRIPS];

void setup() {
ledStrips[0] = & FastLED.addLeds<WS2812B, 2,GRB>(leds[0], NUM_LEDS_PER_STRIP);
ledStrips[1] = & FastLED.addLeds<WS2812B, 3,GRB>(leds[1], NUM_LEDS_PER_STRIP);
}

void loop() {

ledStrips[0]->show(leds[0], NUM_LEDS_PER_STRIP,255);

}

Hi Daniel,

I’ve attached the LEDs to the above code. Does something weird! The first four pixels work but random colour appear and it looks like board crashes?

Weird?

Gavin

What are you running this on? If it’s an arduino - you’re running out of memory. It only has 2048 bytes of ram, and your led array alone uses 7k of ram (8 * 288 * 3). Even the arduino mega only has 8k of ram - and you aren’t leaving a lot of room for, well, anything else. Also, the code you have above isn’t doing anything - there’s no setting led values or such. So, once it writes out the data that’s in the memory for the leds (which may be random, you haven’t set anything to anything, yet!), it’s just going to keep writing out that same thing over and over.

I’m using a Due. I did add the various bits to update the array.

Not to worry. I’ll wait till the parallel processing is finished - gives me something to look forward to.

Thanks for your help :slight_smile: