1

I am trying to add colors that I set to an led using FastLED library on arduino

Currently I am using fill_solid like so,

leds(8 * CLUSTER, (8 * CLUSTER) + (CLUSTER - 1)).fill_solid(CRGB(255,0 ,0));
FastLED.show();

However, I am not able to add colors to it after this has been set. Ideally I would like something like so,

leds(8 * CLUSTER, (8 * CLUSTER) + (CLUSTER - 1)).fill_solid(CRGB(255,0 ,0));
FastLED.show();
leds(8 * CLUSTER, (8 * CLUSTER) + (CLUSTER - 1)).fill_solid(CRGB(0,255 ,0));
FastLED.show();

And the led would glow with RGB = (255, 255, 0)

Is there any way to achieve this without keeping state information and just add to the existing color using FastLED?

Joel Spolsky
  • 33,372
  • 17
  • 89
  • 105
Pavan K
  • 4,085
  • 8
  • 41
  • 72

2 Answers2

0

leds(8 * CLUSTER, (8 * CLUSTER) + (CLUSTER - 1)) += CRGB(0,255,0); should do what you want (I’m pretty sure I checked that support in for the pixelviews)

rDg
  • 56
  • 4
  • Hmm I tried that .. got --> no match for 'operator+=' (operand types are 'CPixelView' and 'CRGB') – Pavan K Sep 21 '17 at 21:01
  • I did try this --> leds(8 * CLUSTER, (8 * CLUSTER) + (CLUSTER - 1)) = leds(8 * CLUSTER, (8 * CLUSTER) + (CLUSTER - 1)) + CRGB(0,255,0); which give me RGB (0,0,255) Not sure how it gets blue – Pavan K Sep 21 '17 at 21:18
  • Had to do something like --> CRGB(leds[n*CLUSTER].r,leds[n*CLUSTER].g,leds[n*CLUSTER].b ) + CRGB(r,g ,b); – Pavan K Sep 21 '17 at 21:33
0

leds is just an array of RGB values so you can just iterate through it with a for loop and modify the values. In this case += will work.

For example:

for (int i=0; i<NUM_LEDS; i++) leds[i] += CRGB(0,255,0);
Joel Spolsky
  • 33,372
  • 17
  • 89
  • 105