Argh. Another C++ syntax quickie.

Argh. Another C++ syntax quickie. How do I declare an array of Palette objects and iterate through them?

CRGBPalette16 *palettes[] = {
    &RainbowColors_p,
    &RainbowStripeColors_p
};

… gives me a “too many initialisers…” error.

I think you have to specify the array size. Put a 2 in those square brackets. :slight_smile:

Doesn’t help :frowning:

“cannot convert ‘const prog_uint32_t ()[16] {aka const long unsigned int ()[16]}’ to ‘CRGBPalette16*’ in initialisation”

(those asterisks are not doubled in the original output, I had to double them up to stop G+'s markdown interpreter being clever.)

Try:-
CRGBPalette16 palettes[] = {
CRGBPalette16(RainbowColors_p),
CRGBPalette16(RainbowStripeColors_p)
};
I think that will work but as I have only just downloaded the updated 2.1 with palettes, & blending I don’t have much experience yet :slight_smile:
I think the reason you were having problems is that the predefined palettes are defined in PROGMEM and need to be copied to regular memory to be used.

Thanks @Aaron_Liddiment , that worked great. My plasma pattern can now cycle through palettes on a button-press.