Great library - very handy whilst working on this WS2801 project! I'm needing a

Great library - very handy whilst working on this WS2801 project!

I’m needing a function to pull the R/G/B values directly out of the leds array so I can do some math on them. I’m trying to slow “grow” a chain of pixels, and although there is a “fade” function that cranks down values, I’m trying to write one that goes up.

Simple example:
leds[0]=5,5,5
leds[1]=10,10,10

I’m trying to grow the illumination from the values in leds[0] to leds[1] in a series of predetermined intervals (spec’d or calc’d; not sure which). It’s sure be handy to have a function similar to the color setting function:
leds[i].red = 50;

but where it would return the RGB value specified.

I’ve written a function to parse values from the HEX into RGB, but they write to global variables. My C-fu isn’t strong enough to write a proper function that returns the array to the calling function.

void fadecol(long fromCol, long toCol) {
int rfromCol = (fromCol >> 16) & 0xFF; //Parse out the RGB values of the FROM color
int gfromCol = (fromCol >> 8) & 0xFF;
int bfromCol = (fromCol >> 0) & 0xFF;

byte rtoCol = (toCol >> 16) & 0xFF; //Parse out the RGB values of the TO color
byte gtoCol = (toCol >> 8) & 0xFF;
byte btoCol = (toCol >> 0) & 0xFF;

Anybody mind throwing a bone my way so I can figure out a method to do this?

(ps: The C in the pixeltype.h is impressive. Much to grok, like “return *this;” Funky…)

you can access the rgb values directly, e.g. leds[0].r - you can also used 32 bit RGB values, e.g. leds[0] = 0x00FFFFFFL; https://github.com/FastLED/FastLED/wiki/Pixel-reference has some other examples.

Why work in hex when you can work in RGB?

You can also do math on the RGB values e.g. leds[1] = leds[0]; leds[1].addToRGB(5);

But… But… I checked and… GARH!
Another case of skipping over the obvious. My apologies for wasting your time.

One other thing: Trying to use an Interrupt to trigger an animation, which works FINE outside of the ISR. If I change my delays to delayMicroseconds, there’s not good reason why fastLED shouldn’t work when called as an ISR, right?

Thanks again!

You really want your ISRs to be as short as possible. Instead, i’d say do something like this:

static boolean bRun = false;

// I forget what avr ISRs look like
void myISR() {
// keep it short and fast
bRun = true;
}

void loop() {
if(bRun) {
bRun = false;
// do animation and call show
} else {
// maybe not even needed
delayMicroseconds(10);
}
}