Ordering LEDs in an array, how do this?

Ordering LEDs in an array, how do this?

So I usually set up lights so that 2 strips or strings are coming from one controller, located centrally to the strips.

When I create an array of the 2 strips the pixel order gets all outta whack yo, sorta like this brilliant paint diagram shows.

What I want is the first pixel to be the 12th, with the first strip’s pixel’s ordered back to front, starting at the end of the strip and finishing at the arduino, where the first pixel of the next strip joins the array.

I’m sure some here have had much harder pixel ordering problems than this :wink:

I think you can use the new CRGBSet feature to do this. Replace this line:
CRGB leds[NUM_LEDS];

with this:
CRGBArray<NUM_LEDS> leds;

And then also add the line as the next line:
CRGBSet leftSide(leds(11,0)); // Reverse order of leftSide strip.

More info on CRGBSet here:

https://plus.google.com/102282558639672545743/posts/a3VeZVhRnqG

Also, here’s an example using CRGBSet. It doesn’t reverse any pixels, but hopefully shows how CRGBSet can be used.

Or simply iterate the array backwards.

physical_index = 12 - mapped_index +1;

Thanks guys.

Marc, I’ll have a look into CRGBSet, sounds like the go.

Peter, how would I do that?

Bill, that maths looks like it’d work. Buggered if I know where to insert in in the code.

Here is the array code I’m using on one project as an example:

#define NUM_STRIPS 2
#define NUM_LEDS_PER_STRIP 20
#define NUM_LEDS NUM_LEDS_PER_STRIP * NUM_STRIPS

CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];

void setup() {
delay(3000); // 3 second delay for recovery

// tell FastLED there’s 20 NEOPIXEL leds on pin 10, starting at index 0 in the led array
FastLED.addLeds<NEOPIXEL, 10>(leds, 0, NUM_LEDS_PER_STRIP);

// tell FastLED there’s 20 NEOPIXEL leds on pin 11, starting at index 20 in the led array
FastLED.addLeds<NEOPIXEL, 11>(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);

uint8_t LeftSide[NUM_LEDS_PER_STRIP +1]; //always one more !
for(int x=12; x>0; x=x-1) { LeftSide[x]=x; } // this fills the array with numbers 12 down to 1