I'm working on a translucent sculpture for Burning Man.

I’m working on a translucent sculpture for Burning Man. The ColorPalette code gets me a long way to the effect I’m shooting for. But I’m having trouble adapting it to accomplish setting specific leds to black when using some palettes but not others. Specifically, my sculpture is intended to look like a devil with the LavaColorsPalette and an Angel with a custom palette. And before I go further, huge thanks to Mark Kriegsman. I LOVE FastLED and your code excamples! I’m not a programmer so the effects I’ve achieved so far have surpassed my initial vision. However… as the vision grows, I want the devils horns and tail to go dark when I’m running the Angel palette, and some Angel bits to go dark when running the devil palette. I know exactly which LEDs they are and have code to do so, but I can’t figure out how to construct an IF statement to identify the appropriate palette when it’s getting filled by FillLEDsFromPaletteColors. My next challenge will be to replace the LavaColors with Fire2012withPalette and have multiple different sized flames over 600 LEDs. But I’ll leave that for another day. First things first. Thoughts, hints, code I can cut, paste and modify?

At the point you set a new palette such as …

if( condition ) {
currentPalette = devil_palette;
}

just set another variable that you can test later…

if( condition ) {
currentPalette = devil_palette;
int devil_or_angel = devil;
}

It might be easier/faster to not try to figure out if a pixel should be on or off when filling, but rather just fill them all and then based on if you’re in angel or devil mode turn off the appropriate pixel set.

I’ll have to come check this out on the playa!

I would set up the led so that the horns and tail at the beginning section (devil) and the wings at the end (angel). Then
devil is i=0;i< horn+tail+body;i++
Angel is I=body;I< body+wing;I++

@JP_Roy
I’m having trouble communicating between sections of code. Which I think is implied in your solution. What I’ve tried is:

String PaletteName;
(up at the top of the program with the define statements) then

in void ChangePalettePeriodically inside the “if” statement that selects the lava, I added:

PaletteName = “Lava”;

then in void FillLEDsFromPaletteColors:
// blacks out the hornes
if ( PaletteName != “Lava”) {
if (i>= 321 && 328 >=i) {
leds[i] = CRGB::Black;
}
// blacks out the tail
if (i>= 368 && 416 >=i) {
leds[i] = CRGB::Black;
}
}

But my Serial.println shows PaletteName never has a value. I also use a number of other palettes so it seemed easier to turn horns and tail off until needed.

I should add that PaletteName does get loaded inside the “if” statement that I set it equal to “Lava”. I can print it to the serial monitor but is null in FillLEDsFromPaletteColors.

Hi,

If you declare a variable outside of any function, like at the beginning with all the #defines… that variable will be global variable that can be read and modified in all your program.

Please post your complete sketch in pastebin or gist.

hi again @Daniel_Dalcorso ,

Just a comment about that string variable you used. It seems to me you only need a Boolean type variable for your purpose. That uses only 1 byte of memory.

I do not know if you have so much unused memory that you do not mind the waste.

Also it is surely faster processing wise to use the smallest possible variable for the task.

@JP_Roy
Ok - now PaletteName is being read and the correct leds are blacked out. I’m using a strip of 150 leds to test this out. But I’ve got a problem now with the index that creates the motion. The palette displays but doesn’t move.

I started with a fresh version of the ColorPalette sketch and just arbitrarily labelled one of the palettes “Lava” to try to minimize other errors I may have introduced.

the code is here:
https://gist.github.com/anonymous/d69803ed5e05093cf2cc

Did a quick check but not in a position to test anything now.

Try removing the line #72

i>=3;

Dunno what effect it would have but does not look right !?

Still can’t test anything from here.

Though your sketch seems to be ok, apart for the line…

i>=3;

That probably sets I to 3 all the time !?

I suggest the following changes for efficiency…

void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
uint8_t brightness = 255;

for( int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
colorIndex += 3;
}

// turn off horns and tail unless LavaColor is the palette
Serial.print ("PaletteName = ");
Serial.println (PaletteName);

if (PaletteName != “Lava”) {
for (i=21; i<=30; i++) {
leds[i] = CRGB::Black;
}
for (i=68; i<=120; i++) {
leds[i] = CRGB::Black;
}
}
}