Hello all!  I am trying to modify the "ColorPalette" preset to start in the

Hello all! I am trying to modify the “ColorPalette” preset to start in the middle of a strip and emanate outwards towards each end. I am using 300pixels of WS2811 with a Teensy2.

I modified the code per below, and it works, BUT there is a strange “palette overflow glitch” or somesuch. When I try to create red and green stripes, it works for the most part, but one of the green stripes keeps flashing between green and red as they move down the line. The glitch color is still part of the palette, but its getting confused somehow.

I think it happens at the beginning or end of a loop cycle because of my NUMLEDs not being a multiple of 16? I actually have no idea what is causing it. It only happens on some of the presets, not all of them. I can try to take a video tomorrow if necessary. Any guidance appreciated. Thx!

In the code below, the uncommented portion is the original code, the commented portion is my modified code with the glitch:

void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
uint8_t brightness = 255;

for( int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
colorIndex += 3;
// for( int i = 0; i <= NUM_LEDS/2; i++) {
// leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
// leds[NUM_LEDS-i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
// colorIndex += 3;
}
}

I took a quick video showing the glitch if it helps to visualize it… any guidance is appreciated!! Thx! -frenchy

Here is a pastebin of all the code:
http://pastebin.com/ERL7A34x

What happens if you add 4 LEDs in your array so you get an even multiple of 16?

Jon, Good idea. You had me convinced, but it was still there…perhaps a smaller glitch?

What if you try 320 pixels? That is a 20 pixel spread of each color in the palette (320/16=20)
I don’t understand why it is acting like that, just trying to help figure as I am curious too…

// This function makes it look like the palette
// is moving toward the center
// Call before FastLED.show()
void copyIn()
{
int maxIndex = NUM_LEDS -1;
for(int i=0;i<NUM_LEDS/2;i++)
{
leds[i] = leds[(maxIndex-i)];
}
}

// This function makes it look like the pallet
// is moving out from the center
// Call before FastLED.show()
void copyOut()
{
int maxIndex = NUM_LEDS -1;
for(int i=0;i<NUM_LEDS/2;i++)
{
leds[(maxIndex-i)] = leds[i];
}
}