I have a question that I cannot seem to find the answer to and

I have a question that I cannot seem to find the answer to and maybe there is a completely different route to do this.

Goal:
Fade from CRGB::Orange > CRGB::Purple and when it is fully purple it triggers a separate function.

After this function completes it reverses going from Purple > Orange.

I have the first part working using nblendPaletteTowardPalette, changes wonderfully.

I was hoping there was a way to check to see if all the pixels where set to purple. If I can’t I will just have to build a timer.

In the documents there is a section that states “CRGB colors can be compared for exact matches using == and !=.”

I am not totally sure how to implement this. I tried:
if(leds[i] == CRGB::Purple )
{
count++
}

Assuming eventually this count would equal my total number of leds.

Thanks everyone!

Create 2 functions fade up and fade down. Use a toggling variable to switch between functions… at end of each function toggle the switch variable…

@John_Sullivan The nice simple solution! Thank you! It was starting to get a bit embarrassing that I could not figure this out.

Just in case you do want to do some sort of check on a pixel’s color in the future here are some ways.

Check using the color name:
if ( leds[i] == (CRGB)(CRGB::Red) )

Individual R,G,or B values can be checked:
if( leds[i].r == 255 )
if( leds[i].g < 128 )
etc.

Check if a pixel is off or has value.
if ( leds[i] ) {
// it is lit, not black
} else {
// it is black (off)
}