FastLED mirroring with fill_palette

Hi all,
I’ve got two single horizontal rows of 20 LEDs (40 in total) and the effect I’m after is a VU meter that radiates out from the center on both rows (like the old magic eye tubes). I’ve managed to get half of the effects working (radiating out from the middle going left) but I need some help finding a way of mirroring this for both rows.

const int offset = NUM_LEDS / 4;
uint8_t paletteIndex = 0;
int VolLevel = 0;

void loop() {



  VolLevel = int(vol_info.volume()) / 2100;
  Serial.println(VolLevel);

  fill_palette(&leds[offset * 1], VolLevel, paletteIndex, 255 / (offset), myPal, 255, LINEARBLEND);
  fill_palette(&leds[offset * 3], VolLevel, paletteIndex, 255 / (offset), myPal, 255, LINEARBLEND);
  EVERY_N_MILLIS(10) {
    fadeToBlackBy(leds, NUM_LEDS, 4);
  }

  FastLED.show();
}



I did try playing with this mirror code I found, but I'm not clever enough to make it do what I want.

void mirror() {
  for (uint8_t i = 0; i > offset; i++) {
    leds[NUM_LEDS - 1 - i] = leds[i];
  }
}

For this effect both rows will be the same, but I may want to use both rows independently for other effects, so ideally I’d like to keep them as one 40LED string rather than two parallel 20s.
Any help would be greatly appreciated.

Are they NeoPixels? If you parallel two strips on one output, they will display the same colours. No extra code.

Thanks. They’re WS2815, but as I said in the op, I’d like address them all individually for other modes so parallel isn’t an option. Plus, I’d still not have the mirrored effect I’m looking for.

void mirror() {
  for (uint8_t i = 0; i < offset; i++) {
    leds[i] = leds[2*offset-1 - i];
    leds[2*offset + i] = leds[NUM_LEDS-1 - i];
  }
}

The code it almost correct, you only need to invert the condition:

void mirror() {
  offset = NUM_LEDS / 2;
  for (uint8_t i = 0; i < offset; i++) {
    leds[NUM_LEDS - 1 - i] = leds[i];
  }
}

Perhaps I did not understand your layout? If they are parallel electrically, but running in opposite directions from a centre point, the pattern should be mirrored in the middle.

I’d like address them all individually for other modes

Please mention things like that up front in future.

Sorted! Many Thanks

Now you see the answer, do you still think you are not clever enough to work it out? I think you probably are clever enough but lack self confidence when it comes to coding.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.