My favorite community on G+..

My favorite community on G+… I am working on a wearable project where I have two 30 led strips that originate from the center. I would like to call them all as one strip to easily be able to do functions such as fill_gradient or fill_rainbow.

Here is a current example of what I have to call them separately and fill one solid color.
int leftLeds[30];
int rightLeds[30];

for (int i = 0; i < 30; i++) {
leftLeds[i] = CRGB::White;
rightLeds[i] = CRGB::White;
}

This is some code I wrote that allows me to sequentially write leds but i don’t see a way of calling fill_rainbow or fill_gradient via this.

int totalLeds[60] = {29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29};

for (int i = 0; i < 60; i++) {
if (i < 30) {
leftLeds[totalLeds[i]] = CRGB::White;
}
if (i >= 30) {
rightLeds[totalLeds[i]] = CRGB::White;
}
}

The code below works, but is there a way to change the libraries or my code to allow me to call two strips as one? One starting at register 30 (29) and ending at register 1 (0) and the other normal from 0 to 29.

fill_gradient(botStrip, 0, CHSV(0, 255, 255), 30, CHSV(96, 255, 255), SHORTEST_HUES);
fill_gradient(topStrip, 0, CHSV(0, 255, 255), 30, CHSV(192, 255, 255), SHORTEST_HUES);

Thanks for any knowledge bombs

Take a look at this code for an old project of mine, I will show you how I did it. Also take a look at the CRGBArray code in the newer versions for addressing sections of the array.

Here’s something you might try. Along with your normal 30 pixel arrays, create an extra array where values can be temporarily stored. Make the size the sum of the two strips.

CRGB ledsTemp[NUM_LEDS*2];

You can then operate on that with fill rainbow or fill grad like you normally would:
fill_rainbow(ledsTemp, (NUM_LEDS*2), millis()/10);

And then copy the temp array values to the normal arrays. (You could make this a sub routine.)

for (int i=0; i < NUM_LEDS; i++) {
leftLeds[i] = ledsTemp[NUM_LEDS-1-i];
rightLeds[i] = ledsTemp[NUM_LEDS+i];
}