FASTLED fill_palette question

Im trying to fill a full a strip of LED's that's been cut in half and double backed on itself (essentially two interconnected strips of 50 leds) using the fill_palette command from FASTLED.

However it's not filling the strip as I would expect.

#include <FastLED.h>

#define NUM_LEDS  100
#define LED_PIN   5

CRGB leds[NUM_LEDS];


DEFINE_GRADIENT_PALETTE (heatmap1_gp) {
  0,   0,   0,   0,   //black
  128, 255,   0,   0,   //red
  200, 255, 255,   0,   //bright yellow
  255, 255, 255, 255    //full white
};

DEFINE_GRADIENT_PALETTE (heatmap2_gp) {
  0,   255, 255, 255,    //full white
  128,  255, 255,   0,   //bright yellow
  200,  255,   0,   0,   //red
  255,  0,   0,   0,   //black



};

CRGBPalette16 myPal1 = heatmap1_gp;
CRGBPalette16 myPal2 = heatmap2_gp;

void setup() {
  FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setBrightness(50);
}

void loop() {
  FastLED.clear();
  fill_palette(leds, (NUM_LEDS / 4), (NUM_LEDS * 0), 9, myPal1, 255, NOBLEND);
  fill_palette(leds, (NUM_LEDS / 4), (NUM_LEDS * 0), 9, myPal2, 255, NOBLEND);
  fill_palette(leds, (NUM_LEDS / 4), (NUM_LEDS * 0.5), 9, myPal1, 255, NOBLEND);
  fill_palette(leds, (NUM_LEDS / 4), (NUM_LEDS * 0.5), 9, myPal2, 255, NOBLEND);





  FastLED.show();
}

Im hoping to get each row of the strip to look like this.


l

What does it do instead ?

It only fills part of the strip about maybe 25% of it is lit, the rest is blank

I might be misunderstanding the fill_palette command,
but from my understanding it works like this

fill_palette(leds, Number of LED's you want to fill; Start Position; How much it should change between LEDs; the palette it should use; brightness; Blend or not)

You are always addressing just the first 25% of your strip. If you intended those 4 commands to address each quarter of the strip, your starting led much change

  const int offset = NUM_LEDS / 4;
  fill_palette(&leds[offset*0], offset, 0, 9, myPal1, 255, NOBLEND);
  fill_palette(&leds[offset*1], offset, 0, 9, myPal2, 255, NOBLEND);
  fill_palette(&leds[offset*2], offset, offset*2, 9, myPal1, 255, NOBLEND);
  fill_palette(&leds[offset*3], offset, offset*2, 9, myPal2, 255, NOBLEND);

Awsome so that's addressed more of the LED's.
Okay so I seem to be confused about the difference between leds and &leds

leds is an array or type CRGB. By using it by itself, you are passing in the address of the first element, which would be the same as &leds[0]

The other math is just calculating the address of the 25%, 50% and 75% element. Another way would be to calculate the size of each element

const int elemSize = sizeof leds[0];
const int offset = NUM_LEDS / 4;
  fill_palette(leds, offset, 0, 9, myPal1, 255, NOBLEND);
  fill_palette(leds + elemSize *offset*1, offset, 0, 9, myPal2, 255, NOBLEND);
  fill_palette(leds + elemSize *offset*2, offset, offset*2, 9, myPal1, 255, NOBLEND);
  fill_palette(leds + elemSize *offset*3, offset, offset*2, 9, myPal2, 255, NOBLEND);

but then you are just doing the work instead of the compiler (and hint, I trust the compiler more :slight_smile: )