Today it's a bad coding day,

Today it’s a bad coding day, for some reason I can’t figure out what goes wrong. Color palettes in an array, what’s the correct syntax?

char *colorpalettelist[] = { “FairyLight_p”, “warm_orange”, “RedWhite_p”};
CurrentPalette = colorpalettelist[1]; //this doesn’t work

Here are a few different ways I’ve found so far with a quick search:

Thanks @Jason_Coon The Twinkefox setup is what I use in most of my setups so let’s stick to that one. This time I’m adding a html interface since I’m using a Huzzah. Therefor it would be handy to output the colorpalette names from the ActivePaletteList[]. Do you know how to write this?

@Jonas_Vorwerk ​ I’ve wanted to do #1 there a few times also but haven’t learned how yet.

@marmil Would be nice, because now it’s a pulldown with a bunch of numbers ;(

What I ended up doing (as a hack) was after I finalized my colorpalettelist I made a separate simple array with the names I wanted displayed (keeping them in the same order) and would just use the number to get the name from my simple list for printing out. Always have to remember to update both places though if you update the colorpalettelist list. I would like to learn the proper way though.

I’ve been meaning to add this to my example, and will try to get to it soon. In the interim, you should be able to do this the same way I did patterns and their names: https://github.com/jasoncoon/esp8266-fastled-webserver/blob/master/esp8266-fastled-webserver.ino#L271

That looks awesome, have to dive into that! Does this mean it’s not possible to read the name out of a palette array?

It does not make any sense to try to read a name out of an array of palettes. You must use something like an enum and assign a name to each enum value then use the enum/name to index into the array of palettes.

OK, I’ve added a palette selector: https://github.com/jasoncoon/esp8266-fastled-webserver/commit/681c29a8776a40026a26365d3988dedd38526417

I tried, but could not get it to work like the patterns list, where there’s a struct that holds both the palette and the name. I tried several different ways, but could not get it to compile. It’s beyond my current expertise. :slight_smile:

I just used two arrays, one with the palettes, and another with their names. It works, if it’s not the most elegant. With significantly more palettes, it could become difficult to keep the two different lists in sync.

Anyone else see a better way?

Dit exactly the same yesterday, also ending up with two arrays. Tried to modify your PatternList[] to PaletteList[] but could’t get it working. Bigup!