Strange FastLED behaviour

I try to fill a ledstrip of 60 leds with 1 color and change the brightness

I do it this way

1.
int t = map(Spectrum[0],0,1024,0,255);
fill_solid(leds,NUM_LEDS,CHSV(255,255,t));
FastLED.delay(2);


2.
int t = map(Spectrum[0],0,1024,0,255);
fill_solid(leds,NUM_LEDS,RED);
FastLED.setBrightness(t);
FastLED.delay(2);

but by doing this, both ways, it only doesn't change the brightness, but also the colors. It is not only red, but also blue, ...

when I try

for (int u=0;u>255;u++){
    
  fill_solid(leds,NUM_LEDS,RED);
  FastLED.setBrightness(u);
  FastLED.delay(2);
  }

it changes the brightness and leave the color to red.

Why isn't it working the first way?
I really can't find the solution :frowning:

That particular library seems to have lots of issues:

So it may be a known bug in the library, or it might be you have an old version.

[ Actually now having had a look at the library its pretty byzantine for a microcontroller
library, not surprized its got issues ]

Resha:
I try to fill a ledstrip of 60 leds with 1 color and change the brightness

I do it this way

1.

int t = map(Spectrum[0],0,1024,0,255);
fill_solid(leds,NUM_LEDS,CHSV(255,255,t));
FastLED.delay(2);
...



but by doing this, both ways, it only doesn't change the brightness, but also the colors. It is not only red, but also blue, ...
...
Why isn't it working the first way?

It's because 'pure red' in the HSV color system is 0 and not 255. The color number 255 is mostly red with a small amount of blue in it. In lower brightness only pure red appears, in higher brigthness a small amout of 1, 2 or 3 blue will be mixed into.

For a pure red only you'd better try:

int t = map(Spectrum[0],0,1024,0,255);
fill_solid(leds,NUM_LEDS,CHSV(0,255,t));
FastLED.delay(2);

Or use RGB color system instead of HSV color system, if you want control the pure R, G and B colors.

I always use RGB for colour, its linear for a start. A simpler library for Neopixels would
have forced you to use RGB and finessed the whole problem.

I don't have this problem only with red, but with all colors.
I just tried it with green and blue, and it is exactly the same

Decreasing the frame rate (as in LED corruption with FastLED 3.1 and Teensy audio library · Issue #141 · FastLED/FastLED · GitHub) didn't solve the issue.

Why is it working in one way? And not in the way I want it (the 2 examples given)?