Still blown away by the work I say out on the playa this year.
I am working on adding more patterns to code that is working great and running into problems.
I have a sequence of patterns that I scroll through using a single button.
I am attempting to add a cool pattern that is a tweaked version of the “icy-fire” pattern from the Fire2012 code.
I thought the Fire pattern could be added in as an additional function to my existing working code and would be just another pattern to scroll through.
When I attempt to merge the code, things dont go well and I get an error for undeclared gPal.
Is it even possible to add my “water-fire” pattern to my existing pattern code?
you could declare “gPal” somewhere at the top with the other declarations, then set the color values.
i.e:
…
CRGBPalette16 gPal;
gPal = CRGBPalette16( CRGB::Green, CRGB::Black, CRGB::Blue, CRGB::Aqua);
…
Don’t forget to add the name of the new function to the pattern list (gPatterns)
@Andy_Smith1
I should really have checked things before posting. There was also the odd error in your merged file.
Line 18 (“gPal = …”) should really go in the setup function (eg after setBrightness line 34). My bad!
The function you add to the pattern list (line 41) is “Fire2012WithPalette”, just like other patterns (no brackets). This list contains the name of drawing functions defined lower down. Add/remove according to what you want to display.
You got to remove the gibberish between lines 208 and 212 inclusive; otherwise errors.
Finally, you got to add in the top declarations the direction flag “bool gReverseDirection = false;” as it’s a (global) variable which is used by the Fire2012WithPalette function.
I encourage you to keep trying the examples in the FastLED example folder. Maybe start with something a bit smaller and try isolating various bits of code to see what they do. The code is usually commented, detailing the logic/functioning/tips. I’d recommend you also use the “Serial.print” command here and there to check variable values/code execution progress.
@Andy_Smith1
Whereas the error console messages are often cryptic, it does mention a loose curly bracket line 212 making the compiler go into error for the last two functions. Remove the bracket. If you didn’t see that message, you’ll want to make the error window bigger and/or scroll in it to see all the messages (you can safely ignore the initial one which is a version notification: “pragma message fastled…”).
For line numbers, check the program’s preferences. I don’t really know much about Arduino IDE as I use notepad++ for writing sketches, and the IDE in “slave” mode just for compiling/uploading.