Quick question (I hope) about how to store FastLed value in Array
I’m creating this function that blends two complimentary colors together and then I cycle thru a bunch of sets of 2 color. To do that I need to store the currently blended color. I’m having trouble storing the CRGB value to the structured array and cannot figure out the format to do that successfully. Below is a portion of my sketch:
--------------------------------
void blendColors() { //blends between 2 complimentary colors randomly
blendAmount = 0;
CurrentLED = random(NUM_LEDS); // sets one of 9 leds to randomly blend
if (LEDchannelinfo[CurrentLED].toggle == 0 ) { // blend color A to color B
for ( int i = 0; i < 256; i++ ) { //coordinated with the 255 blend range
blendcolor = blend(LEDchannelinfo[CurrentLED].currentcolorA, LEDchannelinfo[CurrentLED].colorB, blendAmount);
leds[CurrentLED] = blendcolor;
FastLED.show();
blendAmount++;
FastLED.delay(blendspeed); // delays loop for blend speed
}
LEDchannelinfo[CurrentLED].toggle = 1;
LEDchannelinfo[CurrentLED].currentcolorB = blendcolor; //stores current B color for next blending loop need to know how to write current value correctly**
}
else if ( LEDchannelinfo[CurrentLED].toggle == 1 ) { // blend color B to color A
for ( int i = 0; i < 256; i++ ) { //coordinated with the 255 blend range
blendcolor = blend(LEDchannelinfo[CurrentLED].currentcolorB, LEDchannelinfo[CurrentLED].colorA, blendAmount);
leds[CurrentLED] = blendcolor;
FastLED.show();
blendAmount++;
FastLED.delay(blendspeed); // delays loop for blend speed
}
LEDchannelinfo[CurrentLED].toggle = 0;
LEDchannelinfo[CurrentLED].currentcolorA = blendcolor; //stores current A color for next blending loop
}
----------------------------------------
So my question centers around the line in my sketch. If I store the CRGB value using a predefine color from the FastLED library it works:
LEDchannelinfo[CurrentLED].currentcolorA = CRGB::Orange;
But it doesn’t work if I try to store the current “blendcolor” to the array. It seems to store it as a “0” :
LEDchannelinfo[CurrentLED].currentcolorA = blendcolor;
What must I do with the variable blendcolor (which is the current CRGB value) to get it to store in the structured array? BTW, here is the Structured Array:
------------------------------------------
typedef struct
{
int toggle; //stores current Toggle to go between A>B or B<A
int colorA; //assigned complimentary color A
int colorB; //assigned complimentary color A
int currentcolorA; //stores last value of current A color
int currentcolorB; //stores last value of current B color
} record_type;
record_type LEDchannelinfo[NUM_LEDS];
-------------------------------------------
Thanks in advance
Mark