diff --git a/Holiday_LED_2.0_6_Zones.ino b/Holiday_LED_2.0_6_Zones.ino index b623fa9..144e3c5 100644 --- a/Holiday_LED_2.0_6_Zones.ino +++ b/Holiday_LED_2.0_6_Zones.ino @@ -12,10 +12,7 @@ #include //ArduinoOTA is now included with the ArduinoIDE /***************** START USER CONFIG SECTION *********************************/ -/***************** START USER CONFIG SECTION *********************************/ -/***************** START USER CONFIG SECTION *********************************/ -/***************** START USER CONFIG SECTION *********************************/ - + #define USER_SSID "YOUR_WIRELESS_SSID" #define USER_PASSWORD "YOUR_WIRELESS_PW" #define USER_MQTT_SERVER "YOUR_MQTT_SERVER_ADDRESS" @@ -31,8 +28,8 @@ #define FIRSTZONE_COLOR_ORDER GRB //Color orders, can be RGB, RBG, GRB, GBR, BRG, BGR #define ZONETWO 1 //ZONETWO is pin D2, 1 = zone used 0 = zone unused -#define SECONDZONE_SECTIONS 1 //Number of roof sections setup below -#define SECONDZONE_LEDS 300 //Number of LEDS in this zone +#define SECONDZONE_SECTIONS 3 //Number of roof sections setup below +#define SECONDZONE_LEDS 389 //Number of LEDS in this zone #define SECONDZONE_COLOR_ORDER GRB //Color orders, can be RGB, RBG, GRB, GBR, BRG, BGR #define ZONETHREE 1 //ZONETHREE is pin D3, 1 = zone used 0 = zone unused @@ -455,12 +452,9 @@ #endif -/***************** END USER CONFIG SECTION *********************************/ -/***************** END USER CONFIG SECTION *********************************/ -/***************** END USER CONFIG SECTION *********************************/ -/***************** END USER CONFIG SECTION *********************************/ /***************** END USER CONFIG SECTION *********************************/ + /*********************** WIFI AND MQTT SETUP *****************************/ /*********************** DON'T CHANGE THIS INFO *****************************/ @@ -477,12 +471,23 @@ WiFiClient espClient; PubSubClient client(espClient); SimpleTimer timer; +struct Ball { + float position; + float velocity; + bool loaded; + bool reverse; + CRGB color; + int exploding; + float particlePosition; +}; + #if ZONEONE == 1 CRGB firstZone[FIRSTZONE_LEDS]; const int Pin_firstZone = 5; //marked as D1 on the board -int center_firstZone = 0; +int center_firstZone = 25; int step_firstZone = -1; int previousLED_firstZone = 0; +const int fireworkCount_firstZone = 1; #endif #if ZONETWO == 1 @@ -491,6 +496,7 @@ const int Pin_secondZone = 4; //marked as D2 on the board int center_secondZone = 0; int step_secondZone = -1; int previousLED_secondZone = 0; +const int fireworkCount_secondZone = 3; #endif #if ZONETHREE == 1 @@ -499,6 +505,7 @@ const int Pin_thirdZone = 0; //marked as D3 on the board int center_thirdZone = 0; int step_thirdZone = -1; int previousLED_thirdZone = 0; +const int fireworkCount_thirdZone = 1; #endif #if ZONEFOUR == 1 @@ -507,6 +514,7 @@ const int Pin_fourthZone = 14; //marked as D5 on the board int center_fourthZone = 0; int step_fourthZone = -1; int previousLED_fourthZone = 0; +const int fireworkCount_fourthZone = 1; #endif #if ZONEFIVE == 1 @@ -515,6 +523,7 @@ const int Pin_fifthZone = 12; //marked as D6 on the board int center_fifthZone = 0; int step_fifthZone = -1; int previousLED_fifthZone = 0; +const int fireworkCount_fifthZone = 1; #endif #if ZONESIX == 1 @@ -523,37 +532,26 @@ const int Pin_sixthZone = 13; //marked as D7 on the board int center_sixthZone = 0; int step_sixthZone = -1; int previousLED_sixthZone = 0; +const int fireworkCount_sixthZone = 1; #endif - /***************** GENERAL VARIABLES *************************************/ CRGBPalette16 gPal; int glitterFrequency = 100; int lightningChance = 65280; -int firesize = 40; int SPARKING = 85; int COOLING = 120; bool gReverseDirection = false; uint8_t mark = 0; uint8_t gHue = 0; -uint8_t startPosition = 0; -uint8_t glitterChance = 250; -int chaseDelay = 1000; int lastPosition = 1; int lightning = 1; -int raceSpeed = 12; -int BeatsPerMinute = 62; -uint8_t numberOfRainbows = 7; -int twinkleChance = 250; -int eyeChance = 248; bool boot = true; -String effect = "None"; bool showGlitter = false; bool showLightning = false; bool audioEffects = false; -bool showLights = false; byte red1 = 255; byte green1 = 0; byte blue1 = 0; @@ -566,12 +564,21 @@ byte blue3 = 255; byte redG = 255; byte greenG = 255; byte blueG = 255; -byte brightness = 255; char charPayload[50]; int maxLEDs = 500; int locatorLED = 0; char MQTT_locatorLED[50]; int locatorDelay = 1000; +String zoneEffects[6] = {"None","None","None","None","None","None"}; +int zoneModifer[6] = { 100, 100, 100, 100, 100, 100 }; +byte zoneBrightness[6] = {255,255,255,255,255,255}; +uint8_t zoneStartPosition[6] = { 0, 0, 0, 0, 0, 0 }; +bool showZoneLights[6] = { false, false, false, false, false, false }; +const int colorsCount = 5; +String colorStates[colorsCount+1] = { "broken", "ON", "ON", "ON", "OFF", "OFF" }; +byte rgbArray[colorsCount][3] = {{255,0,0},{255,0,0},{255,0,0},{255,0,0},{255,0,0}}; +uint8_t colorsEnabled = 3; +CRGB availableColors[5] = {}; /***************** SYSTEM FUNCTIONS *************************************/ @@ -623,16 +630,24 @@ void reconnect() { client.publish(USER_MQTT_CLIENT_NAME"/checkIn","Reconnected"); } + publishStates(); // ... and resubscribe client.subscribe(USER_MQTT_CLIENT_NAME"/configure"); client.subscribe(USER_MQTT_CLIENT_NAME"/modifier"); + client.subscribe(USER_MQTT_CLIENT_NAME"/modifier/+"); client.subscribe(USER_MQTT_CLIENT_NAME"/effect"); + client.subscribe(USER_MQTT_CLIENT_NAME"/effect/+"); client.subscribe(USER_MQTT_CLIENT_NAME"/state"); + client.subscribe(USER_MQTT_CLIENT_NAME"/ColorSelector/+/Toggle"); client.subscribe(USER_MQTT_CLIENT_NAME"/color1"); client.subscribe(USER_MQTT_CLIENT_NAME"/color2"); client.subscribe(USER_MQTT_CLIENT_NAME"/color3"); + client.subscribe(USER_MQTT_CLIENT_NAME"/color4"); + client.subscribe(USER_MQTT_CLIENT_NAME"/color5"); client.subscribe(USER_MQTT_CLIENT_NAME"/power"); + client.subscribe(USER_MQTT_CLIENT_NAME"/power/+"); client.subscribe(USER_MQTT_CLIENT_NAME"/brightness"); + client.subscribe(USER_MQTT_CLIENT_NAME"/brightness/+"); client.subscribe(USER_MQTT_CLIENT_NAME"/addEffects"); client.subscribe(USER_MQTT_CLIENT_NAME"/lightningChance"); client.subscribe(USER_MQTT_CLIENT_NAME"/glitterChance"); @@ -682,10 +697,72 @@ void calculateMax() #endif } -/************************** MQTT CALLBACK ***********************/ -/************************** MQTT CALLBACK ***********************/ -/************************** MQTT CALLBACK ***********************/ -/************************** MQTT CALLBACK ***********************/ +String boolToOnOff(bool setting) +{ + String state = "OFF"; + if(setting == true) + { + state = ("ON"); + } + + return state; +} + +void publishStates() +{ + char buff[50]; + client.publish(USER_MQTT_CLIENT_NAME"/modifierState", itoa(zoneModifer[0], buff, 10)); + client.publish(USER_MQTT_CLIENT_NAME"/audio/state", boolToOnOff(audioEffects).c_str()); + client.publish(USER_MQTT_CLIENT_NAME"/glitter/state", boolToOnOff(showGlitter).c_str()); + client.publish(USER_MQTT_CLIENT_NAME"/lightning/state", boolToOnOff(showLightning).c_str()); + client.publish(USER_MQTT_CLIENT_NAME"/effectState", zoneEffects[0].c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/color1State", String(String(red1) + "," + String(green1) + "," + String(blue1)).c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/color2State", String(String(red2) + "," + String(green2) + "," + String(blue2)).c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/color3State", String(String(red3) + "," + String(green3) + "," + String(blue3)).c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/glitterColorState", String(String(redG) + "," + String(greenG) + "," + String(blueG)).c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/glitterChanceState", itoa(glitterFrequency, buff, 10)); + client.publish(USER_MQTT_CLIENT_NAME "/lightningChanceState", itoa(65535-lightningChance, buff, 10)); + client.publish(USER_MQTT_CLIENT_NAME "/brightnessState", itoa(zoneBrightness[0], buff, 10)); + client.publish(USER_MQTT_CLIENT_NAME "/powerState", boolToOnOff(showZoneLights[0]).c_str()); + + #if ZONEONE == 1 + client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone1", itoa(zoneModifer[0], buff, 10)); + client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone1", boolToOnOff(showZoneLights[0]).c_str()); + client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone1", zoneEffects[0].c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/brightnessStateZone1", itoa(zoneBrightness[0], buff, 10)); + #endif + #if ZONETWO == 1 + client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone2", itoa(zoneModifer[1], buff, 10)); + client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone2", boolToOnOff(showZoneLights[1]).c_str()); + client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone2", zoneEffects[1].c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/brightnessStateZone2", itoa(zoneBrightness[1], buff, 10)); + #endif + #if ZONETHREE == 1 + client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone3", itoa(zoneModifer[2], buff, 10)); + client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone3", boolToOnOff(showZoneLights[2]).c_str()); + client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone3", zoneEffects[2].c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/brightnessStateZone3", itoa(zoneBrightness[2], buff, 10)); + #endif + #if ZONEFOUR == 1 + client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone4", itoa(zoneModifer[3], buff, 10)); + client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone4", boolToOnOff(showZoneLights[3]).c_str()); + client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone4", zoneEffects[3].c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/brightnessStateZone4", itoa(zoneBrightness[3], buff, 10)); + #endif + #if ZONEFIVE == 1 + client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone5", itoa(zoneModifer[4], buff, 10)); + client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone5", boolToOnOff(showZoneLights[4]).c_str()); + client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone5", zoneEffects[4].c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/brightnessStateZone5", itoa(zoneBrightness[4], buff, 10)); + #endif + #if ZONESIX == 1 + client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone6", itoa(zoneModifer[5], buff, 10)); + client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone6", boolToOnOff(showZoneLights[5]).c_str()); + client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone6", zoneEffects[5].c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/brightnessStateZone6", itoa(zoneBrightness[5], buff, 10)); + #endif +} + /************************** MQTT CALLBACK ***********************/ @@ -703,48 +780,55 @@ void callback(char* topic, byte* payload, unsigned int length) newPayload.toCharArray(charPayload, newPayload.length() + 1); if (newTopic == USER_MQTT_CLIENT_NAME"/modifier") { - client.publish(USER_MQTT_CLIENT_NAME"/modifierState", charPayload); - if(effect == "Double_Crash" || effect == "Single_Race") - { - raceSpeed = (intPayload/20); - } - if(effect == "BPM") - { - BeatsPerMinute = (intPayload/4); - } - if(effect == "Color_Chase" || effect == "Blocked_Colors") - { - chaseDelay = (intPayload*5); - if(chaseDelay < 100) - { - chaseDelay = 100; - } - } - if(effect == "Color_Glitter") - { - glitterChance = (intPayload/2); - } - if(effect == "Rainbow") - { - numberOfRainbows = (intPayload/30); - } - if(effect == "Twinkle") - { - twinkleChance = map(intPayload, 0, 500, 0, 255); - } - if(effect == "Spooky_Eyes") - { - eyeChance = map(intPayload, 0, 500, 200, 255); - } - if(effect == "Fire") - { - firesize = map(intPayload, 0, 500, 10, 120); - } - if(effect == "LED_Locator") - { - locatorDelay = map(intPayload, 0, 500, 500, 5000); + for (byte i = 0; i < 6; i = i + 1) { + zoneModifer[i] = intPayload; } + client.publish(USER_MQTT_CLIENT_NAME"/modifierState", charPayload); + + locatorDelay = map(intPayload, 0, 500, 500, 5000); + } + #if ZONEONE == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/modifier/Zone1") + { + zoneModifer[0] = intPayload; + client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone1", charPayload); } + #endif + #if ZONETWO == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/modifier/Zone2") + { + zoneModifer[1] = intPayload; + client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone2", charPayload); + } + #endif + #if ZONETHREE == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/modifier/Zone3") + { + zoneModifer[2] = intPayload; + client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone3", charPayload); + } + #endif + #if ZONEFOUR == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/modifier/Zone4") + { + zoneModifer[3] = intPayload; + client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone4", charPayload); + } + #endif + #if ZONEFIVE == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/modifier/Zone5") + { + zoneModifer[4] = intPayload; + client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone5", charPayload); + } + #endif + #if ZONESIX == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/modifier/Zone6") + { + zoneModifer[5] = intPayload; + client.publish(USER_MQTT_CLIENT_NAME"/modifierState/Zone6", charPayload); + } + #endif if (newTopic == USER_MQTT_CLIENT_NAME"/addEffects") { if(newPayload == "Audio On") @@ -780,37 +864,97 @@ void callback(char* topic, byte* payload, unsigned int length) } if (newTopic == USER_MQTT_CLIENT_NAME"/effect") { - effect = newPayload; + zoneEffects[0] = newPayload; client.publish(USER_MQTT_CLIENT_NAME"/effectState", charPayload); - #if ZONEONE == 1 + if(newPayload == "LED_Locator") + { + locator_Move(); + } + } + + #if ZONEONE == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/effect/Zone1" || newTopic == USER_MQTT_CLIENT_NAME"/effect") + { + zoneEffects[0] = newPayload; fill_solid(firstZone, FIRSTZONE_LEDS, CRGB::Black); - #endif + client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone1", charPayload); + } + #endif - #if ZONETWO == 1 - fill_solid(secondZone, SECONDZONE_LEDS, CRGB::Black); - #endif + #if ZONETWO == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/effect/Zone2" || newTopic == USER_MQTT_CLIENT_NAME"/effect") + { + zoneEffects[1] = newPayload; + fill_solid(secondZone, SECONDZONE_LEDS, CRGB::Black); + client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone2", charPayload); + } + #endif - #if ZONETHREE == 1 + #if ZONETHREE == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/effect/Zone3" || newTopic == USER_MQTT_CLIENT_NAME"/effect") + { + zoneEffects[2] = newPayload; fill_solid(thirdZone, THIRDZONE_LEDS, CRGB::Black); - #endif + client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone3", charPayload); + } + #endif - #if ZONEFOUR == 1 + #if ZONEFOUR == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/effect/Zone4" || newTopic == USER_MQTT_CLIENT_NAME"/effect") + { + zoneEffects[3] = newPayload; fill_solid(fourthZone, FOURTHZONE_LEDS, CRGB::Black); - #endif + client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone4", charPayload); + } + #endif - #if ZONEFIVE == 1 - fill_solid(fifthZone, FIFTHZONE_LEDS, CRGB::Black); - #endif + #if ZONEFIVE == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/effect/Zone5" || newTopic == USER_MQTT_CLIENT_NAME"/effect") + { + zoneEffects[4] = newPayload; + fill_solid(fifthZone, FIFTHZONE_LEDS, CRGB::Black); + client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone5", charPayload); + } + #endif - #if ZONESIX == 1 + #if ZONESIX == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/effect/Zone6" || newTopic == USER_MQTT_CLIENT_NAME"/effect") + { + zoneEffects[5] = newPayload; fill_solid(sixthZone, SIXTHZONE_LEDS, CRGB::Black); - #endif + client.publish(USER_MQTT_CLIENT_NAME"/effectState/Zone6", charPayload); + } + #endif - if(effect == "LED_Locator") - { - locator_Move(); - } + if (newTopic == USER_MQTT_CLIENT_NAME "/ColorSelector/1/Toggle") + { + colorStates[1] = newPayload; + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/1/ToggleState", colorStates[1].c_str()); + } + + if (newTopic == USER_MQTT_CLIENT_NAME "/ColorSelector/2/Toggle") + { + colorStates[2] = newPayload; + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/2/ToggleState", colorStates[2].c_str()); + } + + if (newTopic == USER_MQTT_CLIENT_NAME "/ColorSelector/3/Toggle") + { + colorStates[3] = newPayload; + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/3/ToggleState", colorStates[3].c_str()); + } + + if (newTopic == USER_MQTT_CLIENT_NAME "/ColorSelector/4/Toggle") + { + colorStates[4] = newPayload; + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/4/ToggleState", colorStates[4].c_str()); + } + + if (newTopic == USER_MQTT_CLIENT_NAME "/ColorSelector/5/Toggle") + { + colorStates[5] = newPayload; + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/5/ToggleState", colorStates[5].c_str()); } if (newTopic == USER_MQTT_CLIENT_NAME "/color1") @@ -825,6 +969,7 @@ void callback(char* topic, byte* payload, unsigned int length) return; } else { red1 = rgb_red; + rgbArray[0][0] = rgb_red; } uint8_t rgb_green = newPayload.substring(firstIndex + 1, lastIndex).toInt(); @@ -832,6 +977,7 @@ void callback(char* topic, byte* payload, unsigned int length) return; } else { green1 = rgb_green; + rgbArray[0][1] = rgb_green; } uint8_t rgb_blue = newPayload.substring(lastIndex + 1).toInt(); @@ -839,6 +985,7 @@ void callback(char* topic, byte* payload, unsigned int length) return; } else { blue1 = rgb_blue; + rgbArray[0][2] = rgb_blue; } } @@ -854,6 +1001,7 @@ void callback(char* topic, byte* payload, unsigned int length) return; } else { red2 = rgb_red; + rgbArray[1][0] = rgb_red; } uint8_t rgb_green = newPayload.substring(firstIndex + 1, lastIndex).toInt(); @@ -861,6 +1009,7 @@ void callback(char* topic, byte* payload, unsigned int length) return; } else { green2 = rgb_green; + rgbArray[1][1] = rgb_green; } uint8_t rgb_blue = newPayload.substring(lastIndex + 1).toInt(); @@ -868,6 +1017,7 @@ void callback(char* topic, byte* payload, unsigned int length) return; } else { blue2 = rgb_blue; + rgbArray[1][2] = rgb_blue; } } @@ -883,6 +1033,7 @@ void callback(char* topic, byte* payload, unsigned int length) return; } else { red3 = rgb_red; + rgbArray[2][0] = rgb_red; } uint8_t rgb_green = newPayload.substring(firstIndex + 1, lastIndex).toInt(); @@ -890,6 +1041,7 @@ void callback(char* topic, byte* payload, unsigned int length) return; } else { green3 = rgb_green; + rgbArray[2][1] = rgb_green; } uint8_t rgb_blue = newPayload.substring(lastIndex + 1).toInt(); @@ -897,6 +1049,65 @@ void callback(char* topic, byte* payload, unsigned int length) return; } else { blue3 = rgb_blue; + rgbArray[2][2] = rgb_blue; + } + } + + if (newTopic == USER_MQTT_CLIENT_NAME "/color4") + { + client.publish(USER_MQTT_CLIENT_NAME "/color4State", charPayload); + // get the position of the first and second commas + uint8_t firstIndex = newPayload.indexOf(','); + uint8_t lastIndex = newPayload.lastIndexOf(','); + + uint8_t rgb_red = newPayload.substring(0, firstIndex).toInt(); + if (rgb_red < 0 || rgb_red > 255) { + return; + } else { + rgbArray[3][0] = rgb_red; + } + + uint8_t rgb_green = newPayload.substring(firstIndex + 1, lastIndex).toInt(); + if (rgb_green < 0 || rgb_green > 255) { + return; + } else { + rgbArray[3][1] = rgb_green; + } + + uint8_t rgb_blue = newPayload.substring(lastIndex + 1).toInt(); + if (rgb_blue < 0 || rgb_blue > 255) { + return; + } else { + rgbArray[3][2] = rgb_blue; + } + } + + if (newTopic == USER_MQTT_CLIENT_NAME "/color5") + { + client.publish(USER_MQTT_CLIENT_NAME "/color5State", charPayload); + // get the position of the first and second commas + uint8_t firstIndex = newPayload.indexOf(','); + uint8_t lastIndex = newPayload.lastIndexOf(','); + + uint8_t rgb_red = newPayload.substring(0, firstIndex).toInt(); + if (rgb_red < 0 || rgb_red > 255) { + return; + } else { + rgbArray[4][0] = rgb_red; + } + + uint8_t rgb_green = newPayload.substring(firstIndex + 1, lastIndex).toInt(); + if (rgb_green < 0 || rgb_green > 255) { + return; + } else { + rgbArray[4][1] = rgb_green; + } + + uint8_t rgb_blue = newPayload.substring(lastIndex + 1).toInt(); + if (rgb_blue < 0 || rgb_blue > 255) { + return; + } else { + rgbArray[4][2] = rgb_blue; } } @@ -943,653 +1154,672 @@ void callback(char* topic, byte* payload, unsigned int length) if (newTopic == USER_MQTT_CLIENT_NAME"/brightness") { - client.publish(USER_MQTT_CLIENT_NAME "/brightnessState", charPayload); - brightness = intPayload; + zoneBrightness[0] = intPayload; + client.publish(USER_MQTT_CLIENT_NAME "/brightnessState", itoa(zoneBrightness[0], charPayload, 10)); + } + #if ZONEONE == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/brightness/Zone1" || newTopic == USER_MQTT_CLIENT_NAME"/brightness") + { + zoneBrightness[0] = intPayload; + client.publish(USER_MQTT_CLIENT_NAME "/brightnessState/Zone1", itoa(zoneBrightness[0], charPayload, 10)); } + #endif + #if ZONETWO == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/brightness/Zone2" || newTopic == USER_MQTT_CLIENT_NAME"/brightness") + { + zoneBrightness[1] = intPayload; + client.publish(USER_MQTT_CLIENT_NAME "/brightnessState/Zone2", itoa(zoneBrightness[1], charPayload, 10)); + } + #endif + #if ZONETHREE == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/brightness/Zone3" || newTopic == USER_MQTT_CLIENT_NAME"/brightness") + { + zoneBrightness[2] = intPayload; + client.publish(USER_MQTT_CLIENT_NAME "/brightnessState/Zone3", itoa(zoneBrightness[2], charPayload, 10)); + } + #endif + #if ZONEFOUR == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/brightness/Zone4" || newTopic == USER_MQTT_CLIENT_NAME"/brightness") + { + zoneBrightness[3] = intPayload; + client.publish(USER_MQTT_CLIENT_NAME "/brightnessState/Zone4", itoa(zoneBrightness[3], charPayload, 10)); + } + #endif + #if ZONEFIVE == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/brightness/Zone5" || newTopic == USER_MQTT_CLIENT_NAME"/brightness") + { + zoneBrightness[4] = intPayload; + client.publish(USER_MQTT_CLIENT_NAME "/brightnessState/Zone5", itoa(zoneBrightness[4], charPayload, 10)); + } + #endif + #if ZONESIX == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/brightness/Zone6" || newTopic == USER_MQTT_CLIENT_NAME"/brightness") + { + zoneBrightness[5] = intPayload; + client.publish(USER_MQTT_CLIENT_NAME "/brightnessState/Zone6", itoa(zoneBrightness[5], charPayload, 10)); + } + #endif if (newTopic == USER_MQTT_CLIENT_NAME"/power") { - client.publish(USER_MQTT_CLIENT_NAME "/powerState", charPayload); - if(newPayload == "ON") + showZoneLights[0] = newPayload == "ON"; + client.publish(USER_MQTT_CLIENT_NAME "/powerState", boolToOnOff(showZoneLights[0]).c_str()); + if(newPayload == "OFF") { - showLights = true; + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/1/ToggleState", charPayload); + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/2/ToggleState", charPayload); + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/3/ToggleState", charPayload); + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/4/ToggleState", charPayload); + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/5/ToggleState", charPayload); } - if(newPayload == "OFF") + if(newPayload == "ON") { - showLights = false; + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/1/ToggleState", colorStates[1].c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/2/ToggleState", colorStates[2].c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/3/ToggleState", colorStates[3].c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/4/ToggleState", colorStates[4].c_str()); + client.publish(USER_MQTT_CLIENT_NAME "/ColorSelector/5/ToggleState", colorStates[5].c_str()); } } + #if ZONEONE == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/power/Zone1" || newTopic == USER_MQTT_CLIENT_NAME"/power") + { + showZoneLights[0] = newPayload == "ON"; + client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone1", boolToOnOff(showZoneLights[0]).c_str()); + } + #endif + #if ZONETWO == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/power/Zone2" || newTopic == USER_MQTT_CLIENT_NAME"/power") + { + showZoneLights[1] = newPayload == "ON"; + client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone2", boolToOnOff(showZoneLights[1]).c_str()); + } + #endif + #if ZONETHREE == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/power/Zone3" || newTopic == USER_MQTT_CLIENT_NAME"/power") + { + showZoneLights[2] = newPayload == "ON"; + client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone3", boolToOnOff(showZoneLights[2]).c_str()); + } + #endif + #if ZONEFOUR == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/power/Zone4" || newTopic == USER_MQTT_CLIENT_NAME"/power") + { + showZoneLights[3] = newPayload == "ON"; + client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone4", boolToOnOff(showZoneLights[3]).c_str()); + } + #endif + #if ZONEFIVE == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/power/Zone5" || newTopic == USER_MQTT_CLIENT_NAME"/power") + { + showZoneLights[4] = newPayload == "ON"; + client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone5", boolToOnOff(showZoneLights[4]).c_str()); + } + #endif + #if ZONESIX == 1 + if (newTopic == USER_MQTT_CLIENT_NAME"/power/Zone6" || newTopic == USER_MQTT_CLIENT_NAME"/power") + { + showZoneLights[5] = newPayload == "ON"; + client.publish(USER_MQTT_CLIENT_NAME "/powerState/Zone6", boolToOnOff(showZoneLights[5]).c_str()); + } + #endif } /***************** GLOBAL LIGHT FUNCTIONS *******************************/ -/***************** GLOBAL LIGHT FUNCTIONS *******************************/ -/***************** GLOBAL LIGHT FUNCTIONS *******************************/ -/***************** GLOBAL LIGHT FUNCTIONS *******************************/ -/***************** GLOBAL LIGHT FUNCTIONS *******************************/ - -void chase() +void chase(void* args) { - if(startPosition == 5) + + int i = (int)args; + if(zoneStartPosition[i] == ((colorsEnabled*2)-1)) { - startPosition = 0; + zoneStartPosition[i] = 0; } else { - startPosition++; + zoneStartPosition[i] = zoneStartPosition[i] + 1; } - timer.setTimeout(chaseDelay, chase); -} - -void checkIn() -{ - client.publish(USER_MQTT_CLIENT_NAME"/checkIn","OK"); - timer.setTimeout(120000, checkIn); -} -void choosePattern() -{ - if(showLights == true) + int chaseDelay = 1000; + + if (zoneEffects[i] == "Color_Chase" || zoneEffects[i] == "Blocked_Colors") { - if(effect == "Color_Chase") - { - #if ZONEONE == 1 - RGB_firstZone(); - #endif - - #if ZONETWO == 1 - RGB_secondZone(); - #endif - - #if ZONETHREE == 1 - RGB_thirdZone(); - #endif + chaseDelay = (zoneModifer[i]*5); + if(chaseDelay < 100) + { + chaseDelay = 100; + } + } + else if (zoneEffects[i] == "Heartbeat") + { + chaseDelay = map(zoneModifer[i], 0, 500, 150, 350); + } - #if ZONEFOUR == 1 - RGB_fourthZone(); - #endif + timer.setTimeout(chaseDelay, chase, args); +} - #if ZONEFIVE == 1 - RGB_fifthZone(); - #endif - - #if ZONESIX == 1 - RGB_sixthZone(); - #endif - - } - if(effect == "Color_Glitter") - { +void checkIn() +{ + client.publish(USER_MQTT_CLIENT_NAME"/checkIn","OK"); + timer.setTimeout(120000, checkIn); +} - #if ZONEONE == 1 - ColorGlitter_firstZone(glitterChance); - #endif +void updateColorsEnabled() +{ + uint8_t count = 0; + availableColors[5] = {}; + for(uint8_t i = 1; i <= colorsCount; i++) + { + if(colorStates[i] == "ON") + { + availableColors[count] = CRGB(rgbArray[i-1][0],rgbArray[i-1][1],rgbArray[i-1][2]); + count++; + } + } - #if ZONETWO == 1 - ColorGlitter_secondZone(glitterChance); - #endif + if(colorsEnabled != count) + { + colorsEnabled = count; + for(uint8_t i = 0; i < 5; i++) + { + zoneStartPosition[i] = 0; + } + } + + if(colorsEnabled == 0) + { + availableColors[0] = CRGB(255,0,0); + colorsEnabled = 1; + } +} - #if ZONETHREE == 1 - ColorGlitter_thirdZone(glitterChance); - #endif +void setSectionPattern(CRGB zone[], int zoneLEDS, int sectionStart, int sectionEnd, byte heat[], int fireStart, int fireEnd, int zoneIndex) +{ + String effect = zoneEffects[zoneIndex]; + int modifier = zoneModifer[zoneIndex]; + if(effect == "Double_Crash") + { + fadeToBlackBy(zone, zoneLEDS, 15); + Crash(zone, zoneLEDS, sectionStart, sectionEnd, (modifier/20)); + } + if(effect == "Fire") + { + fire(zone, heat, sectionStart, sectionEnd, fireStart, fireEnd, map(modifier, 0, 500, 10, 120)); + } +} - #if ZONEFOUR == 1 - ColorGlitter_fourthZone(glitterChance); - #endif +void setZonePattern(CRGB zone[], int zoneLEDS, int previousZoneLED, Ball balls[], int fireworkCount, int zoneCenter, int zoneStep, int zoneIndex) +{ + String effect = zoneEffects[zoneIndex]; + int modifier = zoneModifer[zoneIndex]; + uint8_t startPosition = zoneStartPosition[zoneIndex]; + + if(effect == "Color_Chase") + { + rGB(zone, zoneLEDS, startPosition); + } + if(effect == "Color_Glitter") + { + ColorGlitter(zone, zoneLEDS, (modifier/2), startPosition); + } + if(effect == "Single_Race") + { + previousZoneLED = SingleRace(zone, zoneLEDS, previousZoneLED, (modifier/20)); + } + if(effect == "Rainbow") + { + Rainbow(zone, zoneLEDS, (modifier/30)); + } + if(effect == "Blocked_Colors") + { + Blocked(zone, zoneLEDS, startPosition); + } + if(effect == "BPM") + { + BPM(zone, zoneLEDS,(modifier/4)); + } + if(effect == "Twinkle") + { + Twinkle(zone, zoneLEDS, map(modifier, 0, 500, 0, 255)); + } + if(effect == "Fill_Solid") + { + Solid(zone, zoneLEDS); + } + if(effect == "Spooky_Eyes") + { + Eyes(zone, zoneLEDS, map(modifier, 0, 500, 200, 255)); + } + if(effect == "LED_Locator") + { + Locator(zone, zoneLEDS); + } + if(effect == "Ripple") + { + zoneStep = Ripple(zone, zoneLEDS, zoneCenter, zoneStep); + } + if(effect == "Fireworks") + { + fadeToBlackBy(zone, zoneLEDS, 8); + fireworks(zone, zoneLEDS, balls, fireworkCount, map(modifier, 0, 500, 0, 50)); + } + if(effect == "Heartbeat") + { + heartbeat(zone, zoneLEDS, startPosition); + } + if(effect == "Traditional") + { + traditionalSolid(zone, zoneLEDS); + } +} - #if ZONEFIVE == 1 - ColorGlitter_fifthZone(glitterChance); - #endif - - #if ZONESIX == 1 - ColorGlitter_sixthZone(glitterChance); - #endif - } - if(effect == "Single_Race") - { +void choosePattern() +{ + #if ZONEONE == 1 + if(showZoneLights[0] == true) + { + static Ball zone1balls[fireworkCount_firstZone]; + setZonePattern(firstZone, FIRSTZONE_LEDS, previousLED_firstZone, zone1balls, fireworkCount_firstZone, center_firstZone, step_firstZone, 0); + #ifdef ZONEONE_SECTION1_START + static byte zOneS1heat[ZONEONE_SECTION1_END-ZONEONE_SECTION1_START]; + setSectionPattern(firstZone, FIRSTZONE_LEDS, ZONEONE_SECTION1_START, ZONEONE_SECTION1_END, + zOneS1heat, ZONEONE_SECTION1_START_FIRE, ZONEONE_SECTION1_END_FIRE, 0); + #endif + #ifdef ZONEONE_SECTION2_START + static byte zOneS2heat[ZONEONE_SECTION2_END-ZONEONE_SECTION2_START]; + setSectionPattern(firstZone, FIRSTZONE_LEDS, ZONEONE_SECTION2_START, ZONEONE_SECTION2_END, + zOneS2heat, ZONEONE_SECTION2_START_FIRE, ZONEONE_SECTION2_END_FIRE, 0); + #endif + #ifdef ZONEONE_SECTION3_START + static byte zOneS3heat[ZONEONE_SECTION3_END-ZONEONE_SECTION3_START]; + setSectionPattern(firstZone, FIRSTZONE_LEDS, ZONEONE_SECTION3_START, ZONEONE_SECTION3_END, + zOneS3heat, ZONEONE_SECTION3_START_FIRE, ZONEONE_SECTION3_END_FIRE , 0); + #endif + #ifdef ZONEONE_SECTION4_START + static byte zOneS4heat[ZONEONE_SECTION4_END-ZONEONE_SECTION4_START]; + setSectionPattern(firstZone, FIRSTZONE_LEDS, ZONEONE_SECTION4_START, ZONEONE_SECTION4_END, + zOneS4heat, ZONEONE_SECTION4_START_FIRE, ZONEONE_SECTION4_END_FIRE, 0); + #endif + #ifdef ZONEONE_SECTION5_START + static byte zOneS5heat[ZONEONE_SECTION5_END-ZONEONE_SECTION5_START]; + setSectionPattern(firstZone, FIRSTZONE_LEDS, ZONEONE_SECTION5_START, ZONEONE_SECTION5_END, + zOneS5heat, ZONEONE_SECTION5_START_FIRE, ZONEONE_SECTION5_END_FIRE, 0); + #endif + #ifdef ZONEONE_SECTION6_START + static byte zOneS6heat[ZONEONE_SECTION6_END-ZONEONE_SECTION6_START]; + setSectionPattern(firstZone, FIRSTZONE_LEDS, ZONEONE_SECTION6_START, ZONEONE_SECTION6_END, + zOneS6heat, ZONEONE_SECTION6_START_FIRE, ZONEONE_SECTION6_END_FIRE, 0); + #endif + #ifdef ZONEONE_SECTION7_START + static byte zOneS7heat[ZONEONE_SECTION7_END-ZONEONE_SECTION7_START]; + setSectionPattern(firstZone, FIRSTZONE_LEDS, ZONEONE_SECTION7_START, ZONEONE_SECTION7_END, + zOneS7heat, ZONEONE_SECTION7_START_FIRE, ZONEONE_SECTION7_END_FIRE, 0); + #endif + #ifdef ZONEONE_SECTION8_START + static byte zOneS8heat[ZONEONE_SECTION8_END-ZONEONE_SECTION8_START]; + setSectionPattern(firstZone, FIRSTZONE_LEDS, ZONEONE_SECTION8_START, ZONEONE_SECTION8_END, + zOneS8heat, ZONEONE_SECTION8_START_FIRE, ZONEONE_SECTION8_END_FIRE, 0); + #endif + #ifdef ZONEONE_SECTION9_START + static byte zOneS9heat[ZONEONE_SECTION9_END-ZONEONE_SECTION9_START]; + setSectionPattern(firstZone, FIRSTZONE_LEDS, ZONEONE_SECTION9_START, ZONEONE_SECTION9_END, + zOneS9heat, ZONEONE_SECTION9_START_FIRE, ZONEONE_SECTION9_END_FIRE, 0); + #endif + } + else { + fill_solid(firstZone, FIRSTZONE_LEDS, CRGB::Black); + } + #endif - #if ZONEONE == 1 - SingleRace_firstZone(); - #endif + #if ZONETWO == 1 + if(showZoneLights[1] == true) + { + static Ball zone2balls[fireworkCount_secondZone]; + setZonePattern(secondZone, SECONDZONE_LEDS, previousLED_secondZone, zone2balls, fireworkCount_secondZone, center_secondZone, step_secondZone, 1); + + #ifdef ZONETWO_SECTION1_START + static byte zTwoS1heat[ZONETWO_SECTION1_END-ZONETWO_SECTION1_START]; + setSectionPattern(secondZone, SECONDZONE_LEDS, ZONETWO_SECTION1_START, ZONETWO_SECTION1_END, + zTwoS1heat, ZONETWO_SECTION1_START_FIRE, ZONETWO_SECTION1_END_FIRE, 1); + #endif + #ifdef ZONETWO_SECTION2_START + static byte zTwoS2heat[ZONETWO_SECTION2_END-ZONETWO_SECTION2_START]; + setSectionPattern(secondZone, SECONDZONE_LEDS, ZONETWO_SECTION2_START, ZONETWO_SECTION2_END, + zTwoS2heat, ZONETWO_SECTION2_START_FIRE, ZONETWO_SECTION2_END_FIRE, 1); + #endif + #ifdef ZONETWO_SECTION3_START + static byte zTwoS3heat[ZONETWO_SECTION3_END-ZONETWO_SECTION3_START]; + setSectionPattern(secondZone, SECONDZONE_LEDS, ZONETWO_SECTION3_START, ZONETWO_SECTION3_END, + zTwoS3heat, ZONETWO_SECTION3_START_FIRE, ZONETWO_SECTION3_END_FIRE, 1); + #endif + #ifdef ZONETWO_SECTION4_START + static byte zTwoS4heat[ZONETWO_SECTION4_END-ZONETWO_SECTION4_START]; + setSectionPattern(secondZone, SECONDZONE_LEDS, ZONETWO_SECTION4_START, ZONETWO_SECTION4_END, + zTwoS4heat, ZONETWO_SECTION4_START_FIRE, ZONETWO_SECTION4_END_FIRE, 1); + #endif + #ifdef ZONETWO_SECTION5_START + static byte zTwoS5heat[ZONETWO_SECTION5_END-ZONETWO_SECTION5_START]; + setSectionPattern(secondZone, SECONDZONE_LEDS, ZONETWO_SECTION5_START, ZONETWO_SECTION5_END, + zTwoS5heat, ZONETWO_SECTION5_START_FIRE, ZONETWO_SECTION5_END_FIRE, 1); + #endif + #ifdef ZONETWO_SECTION6_START + static byte zTwoS6heat[ZONETWO_SECTION6_END-ZONETWO_SECTION6_START]; + setSectionPattern(secondZone, SECONDZONE_LEDS, ZONETWO_SECTION6_START, ZONETWO_SECTION6_END, + zTwoS6heat, ZONETWO_SECTION6_START_FIRE, ZONETWO_SECTION6_END_FIRE, 1); + #endif + #ifdef ZONETWO_SECTION7_START + static byte zTwoS7heat[ZONETWO_SECTION7_END-ZONETWO_SECTION7_START]; + setSectionPattern(secondZone, SECONDZONE_LEDS, ZONETWO_SECTION7_START, ZONETWO_SECTION7_END, + zTwoS7heat, ZONETWO_SECTION7_START_FIRE, ZONETWO_SECTION7_END_FIRE, 1); + #endif + #ifdef ZONETWO_SECTION8_START + static byte zTwoS8heat[ZONETWO_SECTION8_END-ZONETWO_SECTION8_START]; + setSectionPattern(secondZone, SECONDZONE_LEDS, ZONETWO_SECTION8_START, ZONETWO_SECTION8_END, + zTwoS8heat, ZONETWO_SECTION8_START_FIRE, ZONETWO_SECTION8_END_FIRE, 1); + #endif + #ifdef ZONETWO_SECTION9_START + static byte zTwoS9heat[ZONETWO_SECTION9_END-ZONETWO_SECTION9_START]; + setSectionPattern(secondZone, SECONDZONE_LEDS, ZONETWO_SECTION9_START, ZONETWO_SECTION9_END, + zTwoS9heat, ZONETWO_SECTION9_START_FIRE, ZONETWO_SECTION9_END_FIRE, 1); + #endif + } + else { + fill_solid(secondZone, SECONDZONE_LEDS, CRGB::Black); + } + #endif - #if ZONETWO == 1 - SingleRace_secondZone(); - #endif + #if ZONETHREE == 1 + if(showZoneLights[2] == true) + { + static Ball zone3balls[fireworkCount_thirdZone]; + setZonePattern(thirdZone, THIRDZONE_LEDS, previousLED_thirdZone, zone3balls, fireworkCount_thirdZone, center_thirdZone, step_thirdZone, 2); - #if ZONETHREE == 1 - SingleRace_thirdZone(); - #endif + #ifdef ZONETHREE_SECTION1_START + static byte zThreeS1heat[ZONETHREE_SECTION1_END-ZONETHREE_SECTION1_START]; + setSectionPattern(thirdZone, THIRDZONE_LEDS, ZONETHREE_SECTION1_START, ZONETHREE_SECTION1_END, + zThreeS1heat, ZONETHREE_SECTION1_START_FIRE, ZONETHREE_SECTION1_END_FIRE, 2); + #endif + #ifdef ZONETHREE_SECTION2_START + static byte zThreeS2heat[ZONETHREE_SECTION2_END-ZONETHREE_SECTION2_START]; + setSectionPattern(thirdZone, THIRDZONE_LEDS, ZONETHREE_SECTION2_START, ZONETHREE_SECTION2_END, + zThreeS2heat, ZONETHREE_SECTION2_START_FIRE, ZONETHREE_SECTION2_END_FIRE, 2); + #endif + #ifdef ZONETHREE_SECTION3_START + static byte zThreeS3heat[ZONETHREE_SECTION3_END-ZONETHREE_SECTION3_START]; + setSectionPattern(thirdZone, THIRDZONE_LEDS, ZONETHREE_SECTION3_START, ZONETHREE_SECTION3_END, + zThreeS3heat, ZONETHREE_SECTION3_START_FIRE, ZONETHREE_SECTION3_END_FIRE, 2); + #endif + #ifdef ZONETHREE_SECTION4_START + static byte zThreeS4heat[ZONETHREE_SECTION4_END-ZONETHREE_SECTION4_START]; + setSectionPattern(thirdZone, THIRDZONE_LEDS, ZONETHREE_SECTION4_START, ZONETHREE_SECTION4_END, + zThreeS4heat, ZONETHREE_SECTION4_START_FIRE, ZONETHREE_SECTION4_END_FIRE, 2); + #endif + #ifdef ZONETHREE_SECTION5_START + static byte zThreeS5heat[ZONETHREE_SECTION5_END-ZONETHREE_SECTION5_START]; + setSectionPattern(thirdZone, THIRDZONE_LEDS, ZONETHREE_SECTION5_START, ZONETHREE_SECTION5_END, + zThreeS5heat, ZONETHREE_SECTION5_START_FIRE, ZONETHREE_SECTION5_END_FIRE, 2); + #endif + #ifdef ZONETHREE_SECTION6_START + static byte zThreeS6heat[ZONETHREE_SECTION6_END-ZONETHREE_SECTION6_START]; + setSectionPattern(thirdZone, THIRDZONE_LEDS, ZONETHREE_SECTION6_START, ZONETHREE_SECTION6_END, + zThreeS6heat, ZONETHREE_SECTION6_START_FIRE, ZONETHREE_SECTION6_END_FIRE, 2); + #endif + #ifdef ZONETHREE_SECTION7_START + static byte zThreeS7heat[ZONETHREE_SECTION7_END-ZONETHREE_SECTION7_START]; + setSectionPattern(thirdZone, THIRDZONE_LEDS, ZONETHREE_SECTION7_START, ZONETHREE_SECTION7_END, + zThreeS7heat, ZONETHREE_SECTION7_START_FIRE, ZONETHREE_SECTION7_END_FIRE, 2); + #endif + #ifdef ZONETHREE_SECTION8_START + static byte zThreeS8heat[ZONETHREE_SECTION8_END-ZONETHREE_SECTION8_START]; + setSectionPattern(thirdZone, THIRDZONE_LEDS, ZONETHREE_SECTION8_START, ZONETHREE_SECTION8_END, + zThreeS8heat, ZONETHREE_SECTION8_START_FIRE, ZONETHREE_SECTION8_END_FIRE, 2); + #endif + #ifdef ZONETHREE_SECTION9_START + static byte zThreeS9heat[ZONETHREE_SECTION9_END-ZONETHREE_SECTION9_START]; + setSectionPattern(thirdZone, THIRDZONE_LEDS, ZONETHREE_SECTION9_START, ZONETHREE_SECTION9_END, + zThreeS9heat, ZONETHREE_SECTION9_START_FIRE, ZONETHREE_SECTION9_END_FIRE, 2); + #endif + } + else { + fill_solid(thirdZone, THIRDZONE_LEDS, CRGB::Black); + } + #endif - #if ZONEFOUR == 1 - SingleRace_fourthZone(); - #endif + #if ZONEFOUR == 1 + if(showZoneLights[3] == true) + { + static Ball zone4balls[fireworkCount_fourthZone]; + setZonePattern(fourthZone, FOURTHZONE_LEDS, previousLED_fourthZone, zone4balls, fireworkCount_fourthZone, center_fourthZone, step_fourthZone, 3); + + #ifdef ZONEFOUR_SECTION1_START + static byte zFourS1heat[ZONEFOUR_SECTION1_END-ZONEFOUR_SECTION1_START]; + setSectionPattern(fourthZone, FOURTHZONE_LEDS, ZONEFOUR_SECTION1_START, ZONEFOUR_SECTION1_END, + zFourS1heat, ZONEFOUR_SECTION1_START_FIRE, ZONEFOUR_SECTION1_END_FIRE, 3); + #endif + #ifdef ZONEFOUR_SECTION2_START + static byte zFourS2heat[ZONEFOUR_SECTION2_END-ZONEFOUR_SECTION2_START]; + setSectionPattern(fourthZone, FOURTHZONE_LEDS, ZONEFOUR_SECTION2_START, ZONEFOUR_SECTION2_END, + zFourS2heat, ZONEFOUR_SECTION2_START_FIRE, ZONEFOUR_SECTION2_END_FIRE, 3); + #endif + #ifdef ZONEFOUR_SECTION3_START + static byte zFourS3heat[ZONEFOUR_SECTION3_END-ZONEFOUR_SECTION3_START]; + setSectionPattern(fourthZone, FOURTHZONE_LEDS, ZONEFOUR_SECTION3_START, ZONEFOUR_SECTION3_END, + zFourS3heat, ZONEFOUR_SECTION3_START_FIRE, ZONEFOUR_SECTION3_END_FIRE, 3); + #endif + #ifdef ZONEFOUR_SECTION4_START + static byte zFourS4heat[ZONEFOUR_SECTION4_END-ZONEFOUR_SECTION4_START]; + setSectionPattern(fourthZone, FOURTHZONE_LEDS, ZONEFOUR_SECTION4_START, ZONEFOUR_SECTION4_END, + zFourS4heat, ZONEFOUR_SECTION4_START_FIRE, ZONEFOUR_SECTION4_END_FIRE, 3); + #endif + #ifdef ZONEFOUR_SECTION5_START + static byte zFourS5heat[ZONEFOUR_SECTION5_END-ZONEFOUR_SECTION5_START]; + setSectionPattern(fourthZone, FOURTHZONE_LEDS, ZONEFOUR_SECTION5_START, ZONEFOUR_SECTION5_END, + zFourS5heat, ZONEFOUR_SECTION5_START_FIRE, ZONEFOUR_SECTION5_END_FIRE, 3); + #endif + #ifdef ZONEFOUR_SECTION6_START + static byte zFourS6heat[ZONEFOUR_SECTION6_END-ZONEFOUR_SECTION6_START]; + setSectionPattern(fourthZone, FOURTHZONE_LEDS, ZONEFOUR_SECTION6_START, ZONEFOUR_SECTION6_END, + zFourS6heat, ZONEFOUR_SECTION6_START_FIRE, ZONEFOUR_SECTION6_END_FIRE, 3); + #endif + #ifdef ZONEFOUR_SECTION7_START + static byte zFourS7heat[ZONEFOUR_SECTION7_END-ZONEFOUR_SECTION7_START]; + setSectionPattern(fourthZone, FOURTHZONE_LEDS, ZONEFOUR_SECTION7_START, ZONEFOUR_SECTION7_END, + zFourS7heat, ZONEFOUR_SECTION7_START_FIRE, ZONEFOUR_SECTION7_END_FIRE, 3); + #endif + #ifdef ZONEFOUR_SECTION8_START + static byte zFourS8heat[ZONEFOUR_SECTION8_END-ZONEFOUR_SECTION8_START]; + setSectionPattern(fourthZone, FOURTHZONE_LEDS, ZONEFOUR_SECTION8_START, ZONEFOUR_SECTION8_END, + zFourS8heat, ZONEFOUR_SECTION8_START_FIRE, ZONEFOUR_SECTION8_END_FIRE, 3); + #endif + #ifdef ZONEFOUR_SECTION9_START + static byte zFourS9heat[ZONEFOUR_SECTION9_END-ZONEFOUR_SECTION9_START]; + setSectionPattern(fourthZone, FOURTHZONE_LEDS, ZONEFOUR_SECTION9_START, ZONEFOUR_SECTION9_END, + zFourS9heat, ZONEFOUR_SECTION9_START_FIRE, ZONEFOUR_SECTION9_END_FIRE, 3); + #endif + } + else { + fill_solid(fourthZone, FOURTHZONE_LEDS, CRGB::Black); + } + #endif - #if ZONEFIVE == 1 - SingleRace_fifthZone(); - #endif + #if ZONEFIVE == 1 + if(showZoneLights[4] == true) + { + static Ball zone5balls[fireworkCount_fifthZone]; + setZonePattern(fifthZone, FIFTHZONE_LEDS, previousLED_fifthZone, zone5balls, fireworkCount_fifthZone, center_fifthZone, step_fifthZone, 4); + + #ifdef ZONEFIVE_SECTION1_START + static byte zFiveS1heat[ZONEFIVE_SECTION1_END-ZONEFIVE_SECTION1_START]; + setSectionPattern(fifthZone, FIFTHZONE_LEDS, ZONEFIVE_SECTION1_START, ZONEFIVE_SECTION1_END, + zFiveS1heat, ZONEFIVE_SECTION1_START_FIRE, ZONEFIVE_SECTION1_END_FIRE, 4); + #endif + #ifdef ZONEFIVE_SECTION2_START + static byte zFiveS2heat[ZONEFIVE_SECTION2_END-ZONEFIVE_SECTION2_START]; + setSectionPattern(fifthZone, FIFTHZONE_LEDS, ZONEFIVE_SECTION2_START, ZONEFIVE_SECTION2_END, + zFiveS2heat, ZONEFIVE_SECTION2_START_FIRE, ZONEFIVE_SECTION2_END_FIRE, 4); + #endif + #ifdef ZONEFIVE_SECTION3_START + static byte zFiveS3heat[ZONEFIVE_SECTION3_END-ZONEFIVE_SECTION3_START]; + setSectionPattern(fifthZone, FIFTHZONE_LEDS, ZONEFIVE_SECTION3_START, ZONEFIVE_SECTION3_END, + zFiveS3heat, ZONEFIVE_SECTION3_START_FIRE, ZONEFIVE_SECTION3_END_FIRE, 4); + #endif + #ifdef ZONEFIVE_SECTION4_START + static byte zFiveS4heat[ZONEFIVE_SECTION4_END-ZONEFIVE_SECTION4_START]; + setSectionPattern(fifthZone, FIFTHZONE_LEDS, ZONEFIVE_SECTION4_START, ZONEFIVE_SECTION4_END, + zFiveS4heat, ZONEFIVE_SECTION4_START_FIRE, ZONEFIVE_SECTION4_END_FIRE, 4); + #endif + #ifdef ZONEFIVE_SECTION5_START + static byte zFiveS5heat[ZONEFIVE_SECTION5_END-ZONEFIVE_SECTION5_START]; + setSectionPattern(fifthZone, FIFTHZONE_LEDS, ZONEFIVE_SECTION5_START, ZONEFIVE_SECTION5_END, + zFiveS5heat, ZONEFIVE_SECTION5_START_FIRE, ZONEFIVE_SECTION5_END_FIRE, 4); + #endif + #ifdef ZONEFIVE_SECTION6_START + static byte zFiveS6heat[ZONEFIVE_SECTION6_END-ZONEFIVE_SECTION6_START]; + setSectionPattern(fifthZone, FIFTHZONE_LEDS, ZONEFIVE_SECTION6_START, ZONEFIVE_SECTION6_END, + zFiveS6heat, ZONEFIVE_SECTION6_START_FIRE, ZONEFIVE_SECTION6_END_FIRE, 4); + #endif + #ifdef ZONEFIVE_SECTION7_START + static byte zFiveS7heat[ZONEFIVE_SECTION7_END-ZONEFIVE_SECTION7_START]; + setSectionPattern(fifthZone, FIFTHZONE_LEDS, ZONEFIVE_SECTION7_START, ZONEFIVE_SECTION7_END, + zFiveS7heat, ZONEFIVE_SECTION7_START_FIRE, ZONEFIVE_SECTION7_END_FIRE, 4); + #endif + #ifdef ZONEFIVE_SECTION8_START + static byte zFiveS8heat[ZONEFIVE_SECTION8_END-ZONEFIVE_SECTION8_START]; + setSectionPattern(fifthZone, FIFTHZONE_LEDS, ZONEFIVE_SECTION8_START, ZONEFIVE_SECTION8_END, + zFiveS8heat, ZONEFIVE_SECTION8_START_FIRE, ZONEFIVE_SECTION8_END_FIRE, 4); + #endif + #ifdef ZONEFIVE_SECTION9_START + static byte zFiveS9heat[ZONEFIVE_SECTION9_END-ZONEFIVE_SECTION9_START]; + setSectionPattern(fifthZone, FIFTHZONE_LEDS, ZONEFIVE_SECTION9_START, ZONEFIVE_SECTION9_END, + zFiveS9heat, ZONEFIVE_SECTION9_START_FIRE, ZONEFIVE_SECTION9_END_FIRE, 4); + #endif + } + else { + fill_solid(fifthZone, FIFTHZONE_LEDS, CRGB::Black); + } + #endif - #if ZONESIX == 1 - SingleRace_sixthZone(); - #endif - } - if(effect == "Double_Crash") - { - #if ZONEONE == 1 - Crash_firstZone(); - #endif + #if ZONESIX == 1 + if(showZoneLights[5] == true) + { + static Ball zone6balls[fireworkCount_sixthZone]; + setZonePattern(sixthZone, SIXTHZONE_LEDS, previousLED_sixthZone, zone6balls, fireworkCount_sixthZone, center_sixthZone, step_sixthZone, 5); + + #ifdef ZONESIX_SECTION1_START + static byte zSixS1heat[ZONESIX_SECTION1_END-ZONESIX_SECTION1_START]; + setSectionPattern(sixthZone, SIXTHZONE_LEDS, ZONESIX_SECTION1_START, ZONESIX_SECTION1_END, + zSixS1heat, ZONESIX_SECTION1_START_FIRE, ZONESIX_SECTION1_END_FIRE, 5); + #endif + #ifdef ZONESIX_SECTION2_START + static byte zSixS2heat[ZONESIX_SECTION2_END-ZONESIX_SECTION2_START]; + setSectionPattern(sixthZone, SIXTHZONE_LEDS, ZONESIX_SECTION2_START, ZONESIX_SECTION2_END, + zSixS2heat, ZONESIX_SECTION2_START_FIRE, ZONESIX_SECTION2_END_FIRE, 5); + #endif + #ifdef ZONESIX_SECTION3_START + static byte zSixS3heat[ZONESIX_SECTION3_END-ZONESIX_SECTION3_START]; + setSectionPattern(sixthZone, SIXTHZONE_LEDS, ZONESIX_SECTION3_START, ZONESIX_SECTION3_END, + zSixS3heat, ZONESIX_SECTION3_START_FIRE, ZONESIX_SECTION3_END_FIRE, 5); + #endif + #ifdef ZONESIX_SECTION4_START + static byte zSixS4heat[ZONESIX_SECTION4_END-ZONESIX_SECTION4_START]; + setSectionPattern(sixthZone, SIXTHZONE_LEDS, ZONESIX_SECTION4_START, ZONESIX_SECTION4_END, + zSixS4heat, ZONESIX_SECTION4_START_FIRE, ZONESIX_SECTION4_END_FIRE, 5); + #endif + #ifdef ZONESIX_SECTION5_START + static byte zSixS5heat[ZONESIX_SECTION5_END-ZONESIX_SECTION5_START]; + setSectionPattern(sixthZone, SIXTHZONE_LEDS, ZONESIX_SECTION5_START, ZONESIX_SECTION5_END, + zSixS5heat, ZONESIX_SECTION5_START_FIRE, ZONESIX_SECTION5_END_FIRE, 5); + #endif + #ifdef ZONESIX_SECTION6_START + static byte zSixS6heat[ZONESIX_SECTION6_END-ZONESIX_SECTION6_START]; + setSectionPattern(sixthZone, SIXTHZONE_LEDS, ZONESIX_SECTION6_START, ZONESIX_SECTION6_END, + zSixS6heat, ZONESIX_SECTION6_START_FIRE, ZONESIX_SECTION6_END_FIRE, 5); + #endif + #ifdef ZONESIX_SECTION7_START + static byte zSixS7heat[ZONESIX_SECTION7_END-ZONESIX_SECTION7_START]; + setSectionPattern(sixthZone, SIXTHZONE_LEDS, ZONESIX_SECTION7_START, ZONESIX_SECTION7_END, + zSixS7heat, ZONESIX_SECTION7_START_FIRE, ZONESIX_SECTION7_END_FIRE, 5); + #endif + #ifdef ZONESIX_SECTION8_START + static byte zSixS8heat[ZONESIX_SECTION8_END-ZONESIX_SECTION8_START]; + setSectionPattern(sixthZone, SIXTHZONE_LEDS, ZONESIX_SECTION8_START, ZONESIX_SECTION8_END, + zSixS8heat, ZONESIX_SECTION8_START_FIRE, ZONESIX_SECTION8_END_FIRE, 5); + #endif + #ifdef ZONESIX_SECTION9_START + static byte zSixS9heat[ZONESIX_SECTION9_END-ZONESIX_SECTION9_START]; + setSectionPattern(sixthZone, SIXTHZONE_LEDS, ZONESIX_SECTION9_START, ZONESIX_SECTION9_END, + zSixS9heat, ZONESIX_SECTION9_START_FIRE, ZONESIX_SECTION9_END_FIRE, 5); + #endif + } + else + { + fill_solid(sixthZone, SIXTHZONE_LEDS, CRGB::Black); + } + #endif - #if ZONETWO == 1 - Crash_secondZone(); - #endif + addGlitter(); + addLightning(); +} - #if ZONETHREE == 1 - Crash_thirdZone(); - #endif +/*********************** PATTERN MODIFIERS ***************************/ - #if ZONEFOUR == 1 - Crash_fourthZone(); - #endif - #if ZONEFIVE == 1 - Crash_fifthZone(); - #endif - - #if ZONESIX == 1 - Crash_sixthZone(); - #endif - } - if(effect == "Rainbow") - { - #if ZONEONE == 1 - Rainbow_firstZone(); +void addLightning() +{ + if(showLightning == true) + { + #if ZONEONE == 1 + fadeToBlackBy(firstZone, FIRSTZONE_LEDS, 1); #endif #if ZONETWO == 1 - Rainbow_secondZone(); + fadeToBlackBy(secondZone, SECONDZONE_LEDS, 1); #endif #if ZONETHREE == 1 - Rainbow_thirdZone(); + fadeToBlackBy(thirdZone, THIRDZONE_LEDS, 1); #endif #if ZONEFOUR == 1 - Rainbow_fourthZone(); + fadeToBlackBy(fourthZone, FOURTHZONE_LEDS, 1); #endif #if ZONEFIVE == 1 - Rainbow_fifthZone(); + fadeToBlackBy(fifthZone, FIFTHZONE_LEDS, 1); #endif #if ZONESIX == 1 - Rainbow_sixthZone(); - #endif - } - if(effect == "Blocked_Colors") - { - #if ZONEONE == 1 - Blocked_firstZone(); - #endif - - #if ZONETWO == 1 - Blocked_secondZone(); - #endif - - #if ZONETHREE == 1 - Blocked_thirdZone(); - #endif - - #if ZONEFOUR == 1 - Blocked_fourthZone(); - #endif - - #if ZONEFIVE == 1 - Blocked_fifthZone(); + fadeToBlackBy(sixthZone, SIXTHZONE_LEDS, 1); #endif - #if ZONESIX == 1 - Blocked_sixthZone(); - #endif - - } - if(effect == "BPM") - { - - #if ZONEONE == 1 - BPM_firstZone(); - #endif - - #if ZONETWO == 1 - BPM_secondZone(); - #endif - - #if ZONETHREE == 1 - BPM_thirdZone(); - #endif - - #if ZONEFOUR == 1 - BPM_fourthZone(); - #endif - - #if ZONEFIVE == 1 - BPM_fifthZone(); - #endif - - #if ZONESIX == 1 - BPM_sixthZone(); - #endif - } - if(effect == "Twinkle") - { - #if ZONEONE == 1 - Twinkle_firstZone(); - #endif - - #if ZONETWO == 1 - Twinkle_secondZone(); - #endif - - #if ZONETHREE == 1 - Twinkle_thirdZone(); - #endif - - #if ZONEFOUR == 1 - Twinkle_fourthZone(); - #endif - - #if ZONEFIVE == 1 - Twinkle_fifthZone(); - #endif - - #if ZONESIX == 1 - Twinkle_sixthZone(); - #endif - - } - if(effect == "Fill_Solid") - { - #if ZONEONE == 1 - Solid_firstZone(); - #endif - - #if ZONETWO == 1 - Solid_secondZone(); - #endif - - #if ZONETHREE == 1 - Solid_thirdZone(); - #endif - - #if ZONEFOUR == 1 - Solid_fourthZone(); - #endif - - #if ZONEFIVE == 1 - Solid_fifthZone(); - #endif - - #if ZONESIX == 1 - Solid_sixthZone(); - #endif - - } - if(effect == "Spooky_Eyes") - { - #if ZONEONE == 1 - Eyes_firstZone(); - #endif - - #if ZONETWO == 1 - Eyes_secondZone(); - #endif - - #if ZONETHREE == 1 - Eyes_thirdZone(); - #endif - - #if ZONEFOUR == 1 - Eyes_fourthZone(); - #endif - - #if ZONEFIVE == 1 - Eyes_fifthZone(); - #endif - - #if ZONESIX == 1 - Eyes_sixthZone(); - #endif - - } - - if(effect == "LED_Locator") - { - #if ZONEONE == 1 - Locator_firstZone(); - #endif - - #if ZONETWO == 1 - Locator_secondZone(); - #endif - - #if ZONETHREE == 1 - Locator_thirdZone(); - #endif - - #if ZONEFOUR == 1 - Locator_fourthZone(); - #endif - - #if ZONEFIVE == 1 - Locator_fifthZone(); - #endif - - #if ZONESIX == 1 - Locator_sixthZone(); - #endif - - } - if(effect == "Ripple") - { - - #if ZONEONE == 1 - Ripple_firstZone(); - #endif - - #if ZONETWO == 1 - Ripple_secondZone(); - #endif - - #if ZONETHREE == 1 - Ripple_thirdZone(); - #endif - - #if ZONEFOUR == 1 - Ripple_fourthZone(); - #endif - - #if ZONEFIVE == 1 - Ripple_fifthZone(); - #endif - - #if ZONESIX == 1 - Ripple_sixthZone(); - #endif - } - if(effect == "Fire") - { - - #if ZONEONE == 1 - #if FIRSTZONE_SECTIONS >= 1 - fire_firstZone_SECTION1(); - #endif - #if FIRSTZONE_SECTIONS >= 2 - fire_firstZone_SECTION2(); - #endif - #if FIRSTZONE_SECTIONS >= 3 - fire_firstZone_SECTION3(); - #endif - #if FIRSTZONE_SECTIONS >= 4 - fire_firstZone_SECTION4(); - #endif - #if FIRSTZONE_SECTIONS >= 5 - fire_firstZone_SECTION5(); - #endif - #if FIRSTZONE_SECTIONS >= 6 - fire_firstZone_SECTION6(); - #endif - #if FIRSTZONE_SECTIONS >= 7 - fire_firstZone_SECTION7(); - #endif - #if FIRSTZONE_SECTIONS >= 8 - fire_firstZone_SECTION8(); - #endif - #if FIRSTZONE_SECTIONS >= 9 - fire_firstZone_SECTION9(); - #endif - #endif - - #if ZONETWO == 1 - #if SECONDZONE_SECTIONS >= 1 - fire_secondZone_SECTION1(); - #endif - #if SECONDZONE_SECTIONS >= 2 - fire_secondZone_SECTION2(); - #endif - #if SECONDZONE_SECTIONS >= 3 - fire_secondZone_SECTION3(); - #endif - #if SECONDZONE_SECTIONS >= 4 - fire_secondZone_SECTION4(); - #endif - #if SECONDZONE_SECTIONS >= 5 - fire_secondZone_SECTION5(); - #endif - #if SECONDZONE_SECTIONS >= 6 - fire_secondZone_SECTION6(); - #endif - #if SECONDZONE_SECTIONS >= 7 - fire_secondZone_SECTION7(); - #endif - #if SECONDZONE_SECTIONS >= 8 - fire_secondZone_SECTION8(); - #endif - #if SECONDZONE_SECTIONS >= 9 - fire_secondZone_SECTION9(); - #endif - #endif - - #if ZONETHREE == 1 - #if THIRDZONE_SECTIONS >= 1 - fire_thirdZone_SECTION1(); - #endif - #if THIRDZONE_SECTIONS >= 2 - fire_thirdZone_SECTION2(); - #endif - #if THIRDZONE_SECTIONS >= 3 - fire_thirdZone_SECTION3(); - #endif - #if THIRDZONE_SECTIONS >= 4 - fire_thirdZone_SECTION4(); - #endif - #if THIRDZONE_SECTIONS >= 5 - fire_thirdZone_SECTION5(); - #endif - #if THIRDZONE_SECTIONS >= 6 - fire_thirdZone_SECTION6(); - #endif - #if THIRDZONE_SECTIONS >= 7 - fire_thirdZone_SECTION7(); - #endif - #if THIRDZONE_SECTIONS >= 8 - fire_thirdZone_SECTION8(); - #endif - #if THIRDZONE_SECTIONS >= 9 - fire_thirdZone_SECTION9(); - #endif - #endif - - #if ZONEFOUR == 1 - #if FOURTHZONE_SECTIONS >= 1 - fire_fourthZone_SECTION1(); - #endif - #if FOURTHZONE_SECTIONS >= 2 - fire_fourthZone_SECTION2(); - #endif - #if FOURTHZONE_SECTIONS >= 3 - fire_fourthZone_SECTION3(); - #endif - #if FOURTHZONE_SECTIONS >= 4 - fire_fourthZone_SECTION4(); - #endif - #if FOURTHZONE_SECTIONS >= 5 - fire_fourthZone_SECTION5(); - #endif - #if FOURTHZONE_SECTIONS >= 6 - fire_fourthZone_SECTION6(); - #endif - #if FOURTHZONE_SECTIONS >= 7 - fire_fourthZone_SECTION7(); - #endif - #if FOURTHZONE_SECTIONS >= 8 - fire_fourthZone_SECTION8(); - #endif - #if FOURTHZONE_SECTIONS >= 9 - fire_fourthZone_SECTION9(); - #endif - #endif - - #if ZONEFIVE == 1 - #if FIFTHZONE_SECTIONS >= 1 - fire_fifthZone_SECTION1(); - #endif - #if FIFTHZONE_SECTIONS >= 2 - fire_fifthZone_SECTION2(); - #endif - #if FIFTHZONE_SECTIONS >= 3 - fire_fifthZone_SECTION3(); - #endif - #if FIFTHZONE_SECTIONS >= 4 - fire_fifthZone_SECTION4(); - #endif - #if FIFTHZONE_SECTIONS >= 5 - fire_fifthZone_SECTION5(); - #endif - #if FIFTHZONE_SECTIONS >= 6 - fire_fifthZone_SECTION6(); - #endif - #if FIFTHZONE_SECTIONS >= 7 - fire_fifthZone_SECTION7(); - #endif - #if FIFTHZONE_SECTIONS >= 8 - fire_fifthZone_SECTION8(); - #endif - #if FIFTHZONE_SECTIONS >= 9 - fire_fifthZone_SECTION9(); - #endif - #endif - - #if ZONESIX == 1 - #if SIXTHZONE_SECTIONS >= 1 - fire_sixthZone_SECTION1(); - #endif - #if SIXTHZONE_SECTIONS >= 2 - fire_sixthZone_SECTION2(); - #endif - #if SIXTHZONE_SECTIONS >= 3 - fire_sixthZone_SECTION3(); - #endif - #if SIXTHZONE_SECTIONS >= 4 - fire_sixthZone_SECTION4(); - #endif - #if SIXTHZONE_SECTIONS >= 5 - fire_sixthZone_SECTION5(); - #endif - #if SIXTHZONE_SECTIONS >= 6 - fire_sixthZone_SECTION6(); - #endif - #if SIXTHZONE_SECTIONS >= 7 - fire_sixthZone_SECTION7(); - #endif - #if SIXTHZONE_SECTIONS >= 8 - fire_sixthZone_SECTION8(); - #endif - #if SIXTHZONE_SECTIONS >= 9 - fire_sixthZone_SECTION9(); - #endif - #endif - } - } - if(showLights == false) - { - #if ZONEONE == 1 - fill_solid(firstZone, FIRSTZONE_LEDS, CRGB::Black); - #endif - - #if ZONETWO == 1 - fill_solid(secondZone, SECONDZONE_LEDS, CRGB::Black); - #endif - - #if ZONETHREE == 1 - fill_solid(thirdZone, THIRDZONE_LEDS, CRGB::Black); - #endif - - #if ZONEFOUR == 1 - fill_solid(fourthZone, FOURTHZONE_LEDS, CRGB::Black); - #endif - - #if ZONEFIVE == 1 - fill_solid(fifthZone, FIFTHZONE_LEDS, CRGB::Black); - #endif - - #if ZONESIX == 1 - fill_solid(sixthZone, SIXTHZONE_LEDS, CRGB::Black); - #endif - } - addGlitter(); - addLightning(); -} - -/*********************** PATTERN MODIFIERS ***************************/ -/*********************** PATTERN MODIFIERS ***************************/ -/*********************** PATTERN MODIFIERS ***************************/ -/*********************** PATTERN MODIFIERS ***************************/ -/*********************** PATTERN MODIFIERS ***************************/ - -void addLightning() -{ - if(showLightning == true) - { - #if ZONEONE == 1 - fadeToBlackBy(firstZone, FIRSTZONE_LEDS, 1); - #endif - - #if ZONETWO == 1 - fadeToBlackBy(secondZone, SECONDZONE_LEDS, 1); - #endif - - #if ZONETHREE == 1 - fadeToBlackBy(thirdZone, THIRDZONE_LEDS, 1); - #endif - - #if ZONEFOUR == 1 - fadeToBlackBy(fourthZone, FOURTHZONE_LEDS, 1); - #endif - - #if ZONEFIVE == 1 - fadeToBlackBy(fifthZone, FIFTHZONE_LEDS, 1); - #endif - - #if ZONESIX == 1 - fadeToBlackBy(sixthZone, SIXTHZONE_LEDS, 1); - #endif - - unsigned int chance = random16(); - if( chance > lightningChance) - { - #if ZONEONE == 1 - fill_solid(firstZone, FIRSTZONE_LEDS, CRGB::White); - #endif - - #if ZONETWO == 1 - fill_solid(secondZone, SECONDZONE_LEDS, CRGB::White); - #endif - - #if ZONETHREE == 1 - fill_solid(thirdZone, THIRDZONE_LEDS, CRGB::White); - #endif - - #if ZONEFOUR == 1 - fill_solid(fourthZone, FOURTHZONE_LEDS, CRGB::White); - #endif - - #if ZONEFIVE == 1 - fill_solid(fifthZone, FIFTHZONE_LEDS, CRGB::White); - #endif - - #if ZONESIX == 1 - fill_solid(sixthZone, SIXTHZONE_LEDS, CRGB::White); - #endif + unsigned int chance = random16(); + if( chance > lightningChance) + { + #if ZONEONE == 1 + fill_solid(firstZone, FIRSTZONE_LEDS, CRGB::White); + #endif + + #if ZONETWO == 1 + fill_solid(secondZone, SECONDZONE_LEDS, CRGB::White); + #endif + + #if ZONETHREE == 1 + fill_solid(thirdZone, THIRDZONE_LEDS, CRGB::White); + #endif + + #if ZONEFOUR == 1 + fill_solid(fourthZone, FOURTHZONE_LEDS, CRGB::White); + #endif + + #if ZONEFIVE == 1 + fill_solid(fifthZone, FIFTHZONE_LEDS, CRGB::White); + #endif + + #if ZONESIX == 1 + fill_solid(sixthZone, SIXTHZONE_LEDS, CRGB::White); + #endif lightning = 20; if(audioEffects == true) @@ -1769,4869 +1999,415 @@ void addGlitter() #if ZONETHREE == 1 { thirdZone[ random16(THIRDZONE_LEDS) ] = CRGB(redG, greenG, blueG); - } - #endif - - #if ZONEFOUR == 1 - { - fourthZone[ random16(FOURTHZONE_LEDS) ] = CRGB(redG, greenG, blueG); - } - #endif - - #if ZONEFIVE == 1 - { - fifthZone[ random16(FIFTHZONE_LEDS) ] = CRGB(redG, greenG, blueG); - } - #endif - - #if ZONESIX == 1 - { - sixthZone[ random16(SIXTHZONE_LEDS) ] = CRGB(redG, greenG, blueG); - } - #endif - } - } -} - -void setupZones() -{ - #if ZONEONE == 1 - FastLED.addLeds(firstZone, FIRSTZONE_LEDS); - #endif - - #if ZONETWO == 1 - FastLED.addLeds(secondZone, SECONDZONE_LEDS); - #endif - - #if ZONETHREE == 1 - FastLED.addLeds(thirdZone, THIRDZONE_LEDS); - #endif - - #if ZONEFOUR == 1 - FastLED.addLeds(fourthZone, FOURTHZONE_LEDS); - #endif - - #if ZONEFIVE == 1 - FastLED.addLeds(fifthZone, FIFTHZONE_LEDS); - #endif - - #if ZONESIX == 1 - FastLED.addLeds(sixthZone, SIXTHZONE_LEDS); - #endif -} - - -void locator_Move() -{ - if(effect == "LED_Locator") - { - if(locatorLED <= maxLEDs) - { - String temp_str = String(locatorLED); - temp_str.toCharArray(MQTT_locatorLED, temp_str.length() + 1); - client.publish(USER_MQTT_CLIENT_NAME"/locator", MQTT_locatorLED); - locatorLED++; - } - else - { - locatorLED = 0; - } - timer.setTimeout(locatorDelay, locator_Move); - } -} - - - -/***************** SETUP FUNCTION ****************************************/ -/***************** SETUP FUNCTION ****************************************/ -/***************** SETUP FUNCTION ****************************************/ -/***************** SETUP FUNCTION ****************************************/ -/***************** SETUP FUNCTION ****************************************/ - - -void setup() { - Serial.begin(115200); - calculateMax(); - setupZones(); - FastLED.setDither( 0 ); - WiFi.setSleepMode(WIFI_NONE_SLEEP); - WiFi.mode(WIFI_STA); - setup_wifi(); - client.setServer(mqtt_server, mqtt_port); - client.setCallback(callback); - ArduinoOTA.setHostname(USER_MQTT_CLIENT_NAME); - ArduinoOTA.begin(); - - gPal = HeatColors_p; - - timer.setTimeout(10000, chase); - timer.setTimeout(120000, checkIn); - -} - - -/***************** MAIN LOOP ****************************************/ -/***************** MAIN LOOP ****************************************/ -/***************** MAIN LOOP ****************************************/ -/***************** MAIN LOOP ****************************************/ -/***************** MAIN LOOP ****************************************/ - - -void loop() -{ - if (!client.connected()) - { - reconnect(); - } - client.loop(); - if(showLights == false) - { - ArduinoOTA.handle(); - } - timer.run(); - EVERY_N_MILLISECONDS( 20 ) { gHue++; } - choosePattern(); - - #if ZONEONE == 1 - FastLED[0].showLeds(brightness); - #endif - - #if ZONETWO == 1 - FastLED[1].showLeds(brightness); - #endif - - #if ZONETHREE == 1 - FastLED[2].showLeds(brightness); - #endif - - #if ZONEFOUR == 1 - FastLED[3].showLeds(brightness); - #endif - - #if ZONEFIVE == 1 - FastLED[4].showLeds(brightness); - #endif - - #if ZONESIX == 1 - FastLED[5].showLeds(brightness); - #endif - -} - - - -/***************** firstZone Animations ****************************************/ -/***************** firstZone Animations ****************************************/ -/***************** firstZone Animations ****************************************/ -/***************** firstZone Animations ****************************************/ -/***************** firstZone Animations ****************************************/ - -#if ZONEONE == 1 - - -void Ripple_firstZone() -{ - for (int i = 0; i < FIRSTZONE_LEDS; i++) - { - firstZone[i] = CRGB((red2/75), (green2/75), (blue2/75)); - } - switch (step_firstZone) - { - case -1: - center_firstZone = random16(FIRSTZONE_LEDS); - step_firstZone = 0; - break; - case 0: - firstZone[center_firstZone] = CRGB(red1, green1, blue1); - step_firstZone ++; - break; - case 12: - step_firstZone = -1; - break; - default: // Middle of the ripples. - firstZone[(center_firstZone + step_firstZone + FIRSTZONE_LEDS) % FIRSTZONE_LEDS] += CRGB((red1/(step_firstZone * 5)), (green1/(step_firstZone * 5)), (blue1/(step_firstZone * 5))); - firstZone[(center_firstZone - step_firstZone + FIRSTZONE_LEDS) % FIRSTZONE_LEDS] += CRGB((red1/(step_firstZone * 5)), (green1/(step_firstZone * 5)), (blue1/(step_firstZone * 5))); - step_firstZone ++; - break; - } -} - -void RGB_firstZone() -{ - if(startPosition < 6) - { - fadeToBlackBy( firstZone, FIRSTZONE_LEDS, 80); - for(int pixel = startPosition+1; pixel < FIRSTZONE_LEDS; pixel+=6) - { - if(pixel <= FIRSTZONE_LEDS) - { - firstZone[pixel] = CRGB(red1,green1,blue1); - } - } - for(int pixel = startPosition+3; pixel < FIRSTZONE_LEDS; pixel+=6) - { - if(pixel <= FIRSTZONE_LEDS) - { - firstZone[pixel] = CRGB(red2,green2,blue2); - } - } - for(int pixel = startPosition+5; pixel < FIRSTZONE_LEDS; pixel+=6) - { - if(pixel <= FIRSTZONE_LEDS) - { - firstZone[pixel] = CRGB(red3,green3,blue3); - } - } - } - if(startPosition == 1) - { - firstZone[0]=CRGB(red3,green3,blue3); - } - if(startPosition == 2) - { - firstZone[1]=CRGB(red3,green3,blue3); - } - if(startPosition == 3) - { - firstZone[2]=CRGB(red3,green3,blue3); - firstZone[0]=CRGB(red2,green2,blue2); - } - if(startPosition == 4) - { - firstZone[3]=CRGB(red3,green3,blue3); - firstZone[1]=CRGB(red2,green2,blue2); - } - if(startPosition == 5) - { - firstZone[4]=CRGB(red3,green3,blue3); - firstZone[2]=CRGB(red2,green2,blue2); - firstZone[0]=CRGB(red1,green1,blue1); - } -} - -void ColorGlitter_firstZone( fract8 chanceOfGlitter) -{ - fadeToBlackBy( firstZone, FIRSTZONE_LEDS, 2); - if(startPosition == 0) - { - if( random8() < chanceOfGlitter) - { - firstZone[ random16(FIRSTZONE_LEDS) ] += CRGB::Red; - } - } - if(startPosition == 1) - { - if( random8() < chanceOfGlitter) - { - firstZone[ random16(FIRSTZONE_LEDS) ] += CRGB::Orange; - } - } - if(startPosition == 2) - { - if( random8() < chanceOfGlitter) - { - firstZone[ random16(FIRSTZONE_LEDS) ] += CRGB::Yellow; - } - } - if(startPosition == 3) - { - if( random8() < chanceOfGlitter) - { - firstZone[ random16(FIRSTZONE_LEDS) ] += CRGB::Green; - } - } - if(startPosition == 4) - { - if( random8() < chanceOfGlitter) - { - firstZone[ random16(FIRSTZONE_LEDS) ] += CRGB::Blue; - } - } - if(startPosition == 5) - { - if( random8() < chanceOfGlitter) - { - firstZone[ random16(FIRSTZONE_LEDS) ] += CRGB::Violet; - } - } -} - -void SingleRace_firstZone() -{ - fadeToBlackBy( firstZone, FIRSTZONE_LEDS, 1); - int pos = beatsin16( raceSpeed, 0, FIRSTZONE_LEDS); - if(pos > previousLED_firstZone) - { - firstZone[pos] = CRGB(red1,green1,blue1); - previousLED_firstZone = pos; - } - if(pos < previousLED_firstZone) - { - firstZone[pos] = CRGB(red2,green2,blue2); - previousLED_firstZone = pos; - } -} - -void Crash_firstZone() -{ - fadeToBlackBy( firstZone, FIRSTZONE_LEDS, 15); - #ifdef ZONEONE_SECTION1_START - int pos_SECTION1 = beatsin16( raceSpeed, 0, (ZONEONE_SECTION1_END - ZONEONE_SECTION1_START) ); - firstZone[ZONEONE_SECTION1_START + pos_SECTION1] = CRGB(red1,green1,blue1); - firstZone[ZONEONE_SECTION1_END - pos_SECTION1] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONEONE_SECTION2_START - int pos_SECTION2 = beatsin16( raceSpeed, 0, (ZONEONE_SECTION2_END - ZONEONE_SECTION2_START) ); - firstZone[ZONEONE_SECTION2_START + pos_SECTION2] = CRGB(red2,green2,blue2); - firstZone[ZONEONE_SECTION2_END - pos_SECTION2] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONEONE_SECTION3_START - int pos_SECTION3 = beatsin16( raceSpeed, 0, (ZONEONE_SECTION3_END - ZONEONE_SECTION3_START) ); - firstZone[ZONEONE_SECTION3_START + pos_SECTION3] = CRGB(red1,green1,blue1); - firstZone[ZONEONE_SECTION3_END - pos_SECTION3] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONEONE_SECTION4_START - int pos_SECTION4 = beatsin16( raceSpeed, 0, (ZONEONE_SECTION4_END - ZONEONE_SECTION4_START) ); - firstZone[ZONEONE_SECTION4_START + pos_SECTION4] = CRGB(red2,green2,blue2); - firstZone[ZONEONE_SECTION4_END - pos_SECTION4] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONEONE_SECTION5_START - int pos_SECTION5 = beatsin16( raceSpeed, 0, (ZONEONE_SECTION5_END - ZONEONE_SECTION5_START) ); - firstZone[ZONEONE_SECTION5_START + pos_SECTION5] = CRGB(red1,green1,blue1); - firstZone[ZONEONE_SECTION5_END - pos_SECTION5] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONEONE_SECTION6_START - int pos_SECTION6 = beatsin16( raceSpeed, 0, (ZONEONE_SECTION6_END - ZONEONE_SECTION6_START) ); - firstZone[ZONEONE_SECTION6_START + pos_SECTION6] = CRGB(red2,green2,blue2); - firstZone[ZONEONE_SECTION6_END - pos_SECTION6] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONEONE_SECTION7_START - int pos_SECTION7 = beatsin16( raceSpeed, 0, (ZONEONE_SECTION7_END - ZONEONE_SECTION7_START) ); - firstZone[ZONEONE_SECTION7_START + pos_SECTION7] = CRGB(red1,green1,blue1); - firstZone[ZONEONE_SECTION7_END - pos_SECTION7] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONEONE_SECTION8_START - int pos_SECTION8 = beatsin16( raceSpeed, 0, (ZONEONE_SECTION8_END - ZONEONE_SECTION8_START) ); - firstZone[ZONEONE_SECTION8_START + pos_SECTION8] = CRGB(red2,green2,blue2); - firstZone[ZONEONE_SECTION8_END - pos_SECTION8] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONEONE_SECTION9_START - int pos_SECTION9 = beatsin16( raceSpeed, 0, (ZONEONE_SECTION9_END - ZONEONE_SECTION9_START) ); - firstZone[ZONEONE_SECTION9_START + pos_SECTION9] = CRGB(red1,green1,blue1); - firstZone[ZONEONE_SECTION9_END - pos_SECTION9] = CRGB(red2,green2,blue2); - #endif - -} - -void Rainbow_firstZone() -{ - fill_rainbow( firstZone, FIRSTZONE_LEDS, gHue, numberOfRainbows); -} - -void Blocked_firstZone() -{ - fadeToBlackBy( firstZone, FIRSTZONE_LEDS, 2); - for( int mark = 0; mark < FIRSTZONE_LEDS; mark+=30) - { - for( int i = 0; i < 9; i++) - { - if(startPosition == 0 || startPosition == 1) - { - if(i+mark <= FIRSTZONE_LEDS) - { - firstZone[i+mark] = CRGB(red1,green1,blue1); - } - if(i+10+mark <= FIRSTZONE_LEDS) - { - firstZone[i+10+mark] = CRGB(red2,green2,blue2); - } - if(i+20+mark <= FIRSTZONE_LEDS) - { - firstZone[i+20+mark] = CRGB(red3,green3,blue3); - } - } - if(startPosition == 2 || startPosition == 3) - { - if(i+mark <= FIRSTZONE_LEDS) - { - firstZone[i+mark] = CRGB(red2,green2,blue2); - } - if(i+10+mark <= FIRSTZONE_LEDS) - { - firstZone[i+10+mark] = CRGB(red3,green3,blue3); - } - if(i+20+mark <= FIRSTZONE_LEDS) - { - firstZone[i+20+mark] = CRGB(red1,green1,blue1); - } - } - if(startPosition == 4 || startPosition == 5) - { - if(i+mark <= FIRSTZONE_LEDS) - { - firstZone[i+mark] = CRGB(red3,green3,blue3); - } - if(i+10+mark <= FIRSTZONE_LEDS) - { - firstZone[i+10+mark] = CRGB(red1,green1,blue1); - } - if(i+20+mark <= FIRSTZONE_LEDS) - { - firstZone[i+20+mark] = CRGB(red2,green2,blue2); - } - } - } - } -} - -void BPM_firstZone() -{ - if((red1*2) > (green1 + blue1)) - { - CRGBPalette16 palette_firstZone = LavaColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < FIRSTZONE_LEDS; i++) - { - firstZone[i] = ColorFromPalette(palette_firstZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((green1*2) > (red1 + blue1)) - { - CRGBPalette16 palette_firstZone = ForestColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < FIRSTZONE_LEDS; i++) - { - firstZone[i] = ColorFromPalette(palette_firstZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((blue1*2) > (green1 + red1)) - { - CRGBPalette16 palette_firstZone = CloudColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < FIRSTZONE_LEDS; i++) - { - firstZone[i] = ColorFromPalette(palette_firstZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((blue1*2) == (green1 + red1)) - { - CRGBPalette16 palette_firstZone = PartyColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < FIRSTZONE_LEDS; i++) - { - firstZone[i] = ColorFromPalette(palette_firstZone, gHue+(i*2), beat-gHue+(i*10)); - } - } -} - -void Twinkle_firstZone() -{ - fadeToBlackBy( firstZone, FIRSTZONE_LEDS, 80); - for( int i = 0; i < FIRSTZONE_LEDS-5; i+=5) - { - if(i <= FIRSTZONE_LEDS) - { - if (random8() > twinkleChance) - { - firstZone[i] = CRGB( red1, green1, blue1); - } - else - { - firstZone[i] = CRGB( 150, 100, 40); - } - } - } -} - -void Eyes_firstZone() -{ - unsigned int chance = random8(); - if( chance > eyeChance) - { - unsigned int eye = random16(FIRSTZONE_LEDS); - firstZone[eye] = CRGB(red1,green1,blue1); - firstZone[eye-4] = CRGB(red1,green1,blue1); - } - if( chance > 39) - { - fadeToBlackBy( firstZone, FIRSTZONE_LEDS, 10); - } -} - -void Solid_firstZone() -{ - fill_solid(firstZone, FIRSTZONE_LEDS, CRGB(red1, green1, blue1)); -} - -void Locator_firstZone() -{ - if(locatorLED <= FIRSTZONE_LEDS) - { - fill_solid(firstZone, FIRSTZONE_LEDS, CRGB::Black); - firstZone[locatorLED]=CRGB(red1, green1, blue1); - } -} - -#ifdef ZONEONE_SECTION1_START -void fire_firstZone_SECTION1() -{ - static byte heat[ZONEONE_SECTION1_END - ZONEONE_SECTION1_START]; - for( int i = 0; i < ZONEONE_SECTION1_END - ZONEONE_SECTION1_START; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / ZONEONE_SECTION1_END - ZONEONE_SECTION1_START) + 2)); - } - - for( int k= ZONEONE_SECTION1_END - ZONEONE_SECTION1_START - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < ZONEONE_SECTION1_END - ZONEONE_SECTION1_START; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (ZONEONE_SECTION1_END - ZONEONE_SECTION1_START -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEONE_SECTION1_START_FIRE == 1 - if(thisFlame <= ZONEONE_SECTION1_END - ZONEONE_SECTION1_START ) - { - firstZone[ZONEONE_SECTION1_START + thisFlame] = color; - } - #endif - - #if ZONEONE_SECTION1_END_FIRE == 1 - if(thisFlame <= ZONEONE_SECTION1_END - ZONEONE_SECTION1_START ) - { - firstZone[ZONEONE_SECTION1_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEONE_SECTION2_START -void fire_firstZone_SECTION2() -{ - const int sizeOfSection = ZONEONE_SECTION2_END - ZONEONE_SECTION2_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEONE_SECTION2_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION2_START + thisFlame] = color; - } - #endif - - #if ZONEONE_SECTION2_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION2_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEONE_SECTION3_START -void fire_firstZone_SECTION3() -{ - const int sizeOfSection = ZONEONE_SECTION3_END - ZONEONE_SECTION3_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEONE_SECTION3_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION3_START + thisFlame] = color; - } - #endif - - #if ZONEONE_SECTION3_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION3_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEONE_SECTION4_START -void fire_firstZone_SECTION4() -{ - const int sizeOfSection = ZONEONE_SECTION4_END - ZONEONE_SECTION4_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEONE_SECTION4_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION4_START + thisFlame] = color; - } - #endif - - #if ZONEONE_SECTION4_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION4_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEONE_SECTION5_START -void fire_firstZone_SECTION5() -{ - const int sizeOfSection = ZONEONE_SECTION5_END - ZONEONE_SECTION5_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEONE_SECTION5_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION5_START + thisFlame] = color; - } - #endif - - #if ZONEONE_SECTION5_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION5_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEONE_SECTION6_START -void fire_firstZone_SECTION6() -{ - const int sizeOfSection = ZONEONE_SECTION6_END - ZONEONE_SECTION6_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEONE_SECTION6_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION6_START + thisFlame] = color; - } - #endif - - #if ZONEONE_SECTION6_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION6_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEONE_SECTION7_START -void fire_firstZone_SECTION7() -{ - const int sizeOfSection = ZONEONE_SECTION7_END - ZONEONE_SECTION7_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEONE_SECTION7_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION7_START + thisFlame] = color; - } - #endif - - #if ZONEONE_SECTION7_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION7_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEONE_SECTION8_START -void fire_firstZone_SECTION8() -{ - const int sizeOfSection = ZONEONE_SECTION8_END - ZONEONE_SECTION8_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEONE_SECTION8_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION8_START + thisFlame] = color; - } - #endif - - #if ZONEONE_SECTION8_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION8_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEONE_SECTION9_START -void fire_firstZone_SECTION9() -{ - const int sizeOfSection = ZONEONE_SECTION9_END - ZONEONE_SECTION9_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEONE_SECTION9_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION9_START + thisFlame] = color; - } - #endif - - #if ZONEONE_SECTION9_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - firstZone[ZONEONE_SECTION9_END - thisFlame] = color; - } - #endif - } -} -#endif - -#endif - -/***************** secondZone Animations ****************************************/ -/***************** secondZone Animations ****************************************/ -/***************** secondZone Animations ****************************************/ -/***************** secondZone Animations ****************************************/ -/***************** secondZone Animations ****************************************/ - -#if ZONETWO == 1 - -void Ripple_secondZone() -{ - for (int i = 0; i < SECONDZONE_LEDS; i++) - { - secondZone[i] = CRGB((red2/75), (green2/75), (blue2/75)); - } - switch (step_secondZone) - { - case -1: - center_secondZone = random16(SECONDZONE_LEDS); - step_secondZone = 0; - break; - case 0: - secondZone[center_secondZone] = CRGB(red1, green1, blue1); - step_secondZone ++; - break; - case 12: - step_secondZone = -1; - break; - default: // Middle of the ripples. - secondZone[(center_secondZone + step_secondZone + SECONDZONE_LEDS) % SECONDZONE_LEDS] += CRGB((red1/(step_secondZone * 5)), (green1/(step_secondZone * 5)), (blue1/(step_secondZone * 5))); - secondZone[(center_secondZone - step_secondZone + SECONDZONE_LEDS) % SECONDZONE_LEDS] += CRGB((red1/(step_secondZone * 5)), (green1/(step_secondZone * 5)), (blue1/(step_secondZone * 5))); - step_secondZone ++; - break; - } -} - -void RGB_secondZone() -{ - if(startPosition < 6) - { - fadeToBlackBy( secondZone, SECONDZONE_LEDS, 80); - for(int pixel = startPosition+1; pixel < SECONDZONE_LEDS; pixel+=6) - { - if(pixel <= SECONDZONE_LEDS) - { - secondZone[pixel] = CRGB(red1,green1,blue1); - } - } - for(int pixel = startPosition+3; pixel < SECONDZONE_LEDS; pixel+=6) - { - if(pixel <= SECONDZONE_LEDS) - { - secondZone[pixel] = CRGB(red2,green2,blue2); - } - } - for(int pixel = startPosition+5; pixel < SECONDZONE_LEDS; pixel+=6) - { - if(pixel <= SECONDZONE_LEDS) - { - secondZone[pixel] = CRGB(red3,green3,blue3); - } - } - } - if(startPosition == 1) - { - secondZone[0]=CRGB(red3,green3,blue3); - } - if(startPosition == 2) - { - secondZone[1]=CRGB(red3,green3,blue3); - } - if(startPosition == 3) - { - secondZone[2]=CRGB(red3,green3,blue3); - secondZone[0]=CRGB(red2,green2,blue2); - } - if(startPosition == 4) - { - secondZone[3]=CRGB(red3,green3,blue3); - secondZone[1]=CRGB(red2,green2,blue2); - } - if(startPosition == 5) - { - secondZone[4]=CRGB(red3,green3,blue3); - secondZone[2]=CRGB(red2,green2,blue2); - secondZone[0]=CRGB(red1,green1,blue1); - } -} - -void ColorGlitter_secondZone( fract8 chanceOfGlitter) -{ - fadeToBlackBy( secondZone, SECONDZONE_LEDS, 2); - if(startPosition == 0) - { - if( random8() < chanceOfGlitter) - { - secondZone[ random16(SECONDZONE_LEDS) ] += CRGB::Red; - } - } - if(startPosition == 1) - { - if( random8() < chanceOfGlitter) - { - secondZone[ random16(SECONDZONE_LEDS) ] += CRGB::Orange; - } - } - if(startPosition == 2) - { - if( random8() < chanceOfGlitter) - { - secondZone[ random16(SECONDZONE_LEDS) ] += CRGB::Yellow; - } - } - if(startPosition == 3) - { - if( random8() < chanceOfGlitter) - { - secondZone[ random16(SECONDZONE_LEDS) ] += CRGB::Green; - } - } - if(startPosition == 4) - { - if( random8() < chanceOfGlitter) - { - secondZone[ random16(SECONDZONE_LEDS) ] += CRGB::Blue; - } - } - if(startPosition == 5) - { - if( random8() < chanceOfGlitter) - { - secondZone[ random16(SECONDZONE_LEDS) ] += CRGB::Violet; - } - } -} - -void SingleRace_secondZone() -{ - fadeToBlackBy( secondZone, SECONDZONE_LEDS, 1); - int pos = beatsin16( raceSpeed, 0, SECONDZONE_LEDS); - if(pos > previousLED_secondZone) - { - secondZone[pos] = CRGB(red1,green1,blue1); - previousLED_secondZone = pos; - } - if(pos < previousLED_secondZone) - { - secondZone[pos] = CRGB(red2,green2,blue2); - previousLED_secondZone = pos; - } -} - -void Crash_secondZone() -{ - fadeToBlackBy( secondZone, SECONDZONE_LEDS, 15); - #ifdef ZONETWO_SECTION1_START - int pos_SECTION1 = beatsin16( raceSpeed, 0, (ZONETWO_SECTION1_END - ZONETWO_SECTION1_START) ); - secondZone[ZONETWO_SECTION1_START + pos_SECTION1] = CRGB(red1,green1,blue1); - secondZone[ZONETWO_SECTION1_END - pos_SECTION1] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONETWO_SECTION2_START - int pos_SECTION2 = beatsin16( raceSpeed, 0, (ZONETWO_SECTION2_END - ZONETWO_SECTION2_START) ); - secondZone[ZONETWO_SECTION2_START + pos_SECTION2] = CRGB(red2,green2,blue2); - secondZone[ZONETWO_SECTION2_END - pos_SECTION2] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONETWO_SECTION3_START - int pos_SECTION3 = beatsin16( raceSpeed, 0, (ZONETWO_SECTION3_END - ZONETWO_SECTION3_START) ); - secondZone[ZONETWO_SECTION3_START + pos_SECTION3] = CRGB(red1,green1,blue1); - secondZone[ZONETWO_SECTION3_END - pos_SECTION3] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONETWO_SECTION4_START - int pos_SECTION4 = beatsin16( raceSpeed, 0, (ZONETWO_SECTION4_END - ZONETWO_SECTION4_START) ); - secondZone[ZONETWO_SECTION4_START + pos_SECTION4] = CRGB(red2,green2,blue2); - secondZone[ZONETWO_SECTION4_END - pos_SECTION4] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONETWO_SECTION5_START - int pos_SECTION5 = beatsin16( raceSpeed, 0, (ZONETWO_SECTION5_END - ZONETWO_SECTION5_START) ); - secondZone[ZONETWO_SECTION5_START + pos_SECTION5] = CRGB(red1,green1,blue1); - secondZone[ZONETWO_SECTION5_END - pos_SECTION5] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONETWO_SECTION6_START - int pos_SECTION6 = beatsin16( raceSpeed, 0, (ZONETWO_SECTION6_END - ZONETWO_SECTION6_START) ); - secondZone[ZONETWO_SECTION6_START + pos_SECTION6] = CRGB(red2,green2,blue2); - secondZone[ZONETWO_SECTION6_END - pos_SECTION6] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONETWO_SECTION7_START - int pos_SECTION7 = beatsin16( raceSpeed, 0, (ZONETWO_SECTION7_END - ZONETWO_SECTION7_START) ); - secondZone[ZONETWO_SECTION7_START + pos_SECTION7] = CRGB(red1,green1,blue1); - secondZone[ZONETWO_SECTION7_END - pos_SECTION7] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONETWO_SECTION8_START - int pos_SECTION8 = beatsin16( raceSpeed, 0, (ZONETWO_SECTION8_END - ZONETWO_SECTION8_START) ); - secondZone[ZONETWO_SECTION8_START + pos_SECTION8] = CRGB(red2,green2,blue2); - secondZone[ZONETWO_SECTION8_END - pos_SECTION8] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONETWO_SECTION9_START - int pos_SECTION9 = beatsin16( raceSpeed, 0, (ZONETWO_SECTION9_END - ZONETWO_SECTION9_START) ); - secondZone[ZONETWO_SECTION9_START + pos_SECTION9] = CRGB(red1,green1,blue1); - secondZone[ZONETWO_SECTION9_END - pos_SECTION9] = CRGB(red2,green2,blue2); - #endif - -} - -void Rainbow_secondZone() -{ - fill_rainbow( secondZone, SECONDZONE_LEDS, gHue, numberOfRainbows); -} - -void Blocked_secondZone() -{ - fadeToBlackBy( secondZone, SECONDZONE_LEDS, 2); - for( int mark = 0; mark < SECONDZONE_LEDS; mark+=30) - { - for( int i = 0; i < 9; i++) - { - if(startPosition == 0 || startPosition == 1) - { - if(i+mark <= SECONDZONE_LEDS) - { - secondZone[i+mark] = CRGB(red1,green1,blue1); - } - if(i+10+mark <= SECONDZONE_LEDS) - { - secondZone[i+10+mark] = CRGB(red2,green2,blue2); - } - if(i+20+mark <= SECONDZONE_LEDS) - { - secondZone[i+20+mark] = CRGB(red3,green3,blue3); - } - } - if(startPosition == 2 || startPosition == 3) - { - if(i+mark <= SECONDZONE_LEDS) - { - secondZone[i+mark] = CRGB(red2,green2,blue2); - } - if(i+10+mark <= SECONDZONE_LEDS) - { - secondZone[i+10+mark] = CRGB(red3,green3,blue3); - } - if(i+20+mark <= SECONDZONE_LEDS) - { - secondZone[i+20+mark] = CRGB(red1,green1,blue1); - } - } - if(startPosition == 4 || startPosition == 5) - { - if(i+mark <= SECONDZONE_LEDS) - { - secondZone[i+mark] = CRGB(red3,green3,blue3); - } - if(i+10+mark <= SECONDZONE_LEDS) - { - secondZone[i+10+mark] = CRGB(red1,green1,blue1); - } - if(i+20+mark <= SECONDZONE_LEDS) - { - secondZone[i+20+mark] = CRGB(red2,green2,blue2); - } - } - } - } -} - -void BPM_secondZone() -{ - if((red1*2) > (green1 + blue1)) - { - CRGBPalette16 palette_secondZone = LavaColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < SECONDZONE_LEDS; i++) - { - secondZone[i] = ColorFromPalette(palette_secondZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((green1*2) > (red1 + blue1)) - { - CRGBPalette16 palette_secondZone = ForestColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < SECONDZONE_LEDS; i++) - { - secondZone[i] = ColorFromPalette(palette_secondZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((blue1*2) > (green1 + red1)) - { - CRGBPalette16 palette_secondZone = CloudColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < SECONDZONE_LEDS; i++) - { - secondZone[i] = ColorFromPalette(palette_secondZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((blue1*2) == (green1 + red1)) - { - CRGBPalette16 palette_secondZone = PartyColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < SECONDZONE_LEDS; i++) - { - secondZone[i] = ColorFromPalette(palette_secondZone, gHue+(i*2), beat-gHue+(i*10)); - } - } -} - -void Twinkle_secondZone() -{ - fadeToBlackBy( secondZone, SECONDZONE_LEDS, 80); - for( int i = 0; i < SECONDZONE_LEDS-5; i+=5) - { - if(i <= SECONDZONE_LEDS) - { - if (random8() > twinkleChance) - { - secondZone[i] = CRGB( red1, green1, blue1); - } - else - { - secondZone[i] = CRGB( 150, 100, 40); - } - } - } -} - -void Eyes_secondZone() -{ - unsigned int chance = random8(); - if( chance > eyeChance) - { - unsigned int eye = random16(SECONDZONE_LEDS); - secondZone[eye] = CRGB(red1,green1,blue1); - secondZone[eye-4] = CRGB(red1,green1,blue1); - } - if( chance > 39) - { - fadeToBlackBy( secondZone, SECONDZONE_LEDS, 10); - } -} - -void Solid_secondZone() -{ - fill_solid(secondZone, SECONDZONE_LEDS, CRGB(red1, green1, blue1)); -} - -void Locator_secondZone() -{ - if(locatorLED <= SECONDZONE_LEDS) - { - fill_solid(secondZone, SECONDZONE_LEDS, CRGB::Black); - secondZone[locatorLED]=CRGB(red1, green1, blue1); - } -} - -#ifdef ZONETWO_SECTION1_START -void fire_secondZone_SECTION1() -{ - static byte heat[ZONETWO_SECTION1_END - ZONETWO_SECTION1_START]; - for( int i = 0; i < ZONETWO_SECTION1_END - ZONETWO_SECTION1_START; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / ZONETWO_SECTION1_END - ZONETWO_SECTION1_START) + 2)); - } - - for( int k= ZONETWO_SECTION1_END - ZONETWO_SECTION1_START - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < ZONETWO_SECTION1_END - ZONETWO_SECTION1_START; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (ZONETWO_SECTION1_END - ZONETWO_SECTION1_START -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETWO_SECTION1_START_FIRE == 1 - if(thisFlame <= ZONETWO_SECTION1_END - ZONETWO_SECTION1_START ) - { - secondZone[ZONETWO_SECTION1_START + thisFlame] = color; - } - #endif - - #if ZONETWO_SECTION1_END_FIRE == 1 - if(thisFlame <= ZONETWO_SECTION1_END - ZONETWO_SECTION1_START ) - { - secondZone[ZONETWO_SECTION1_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETWO_SECTION2_START -void fire_secondZone_SECTION2() -{ - const int sizeOfSection = ZONETWO_SECTION2_END - ZONETWO_SECTION2_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETWO_SECTION2_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION2_START + thisFlame] = color; - } - #endif - - #if ZONETWO_SECTION2_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION2_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETWO_SECTION3_START -void fire_secondZone_SECTION3() -{ - const int sizeOfSection = ZONETWO_SECTION3_END - ZONETWO_SECTION3_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETWO_SECTION3_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION3_START + thisFlame] = color; - } - #endif - - #if ZONETWO_SECTION3_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION3_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETWO_SECTION4_START -void fire_secondZone_SECTION4() -{ - const int sizeOfSection = ZONETWO_SECTION4_END - ZONETWO_SECTION4_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETWO_SECTION4_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION4_START + thisFlame] = color; - } - #endif - - #if ZONETWO_SECTION4_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION4_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETWO_SECTION5_START -void fire_secondZone_SECTION5() -{ - const int sizeOfSection = ZONETWO_SECTION5_END - ZONETWO_SECTION5_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETWO_SECTION5_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION5_START + thisFlame] = color; - } - #endif - - #if ZONETWO_SECTION5_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION5_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETWO_SECTION6_START -void fire_secondZone_SECTION6() -{ - const int sizeOfSection = ZONETWO_SECTION6_END - ZONETWO_SECTION6_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETWO_SECTION6_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION6_START + thisFlame] = color; - } - #endif - - #if ZONETWO_SECTION6_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION6_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETWO_SECTION7_START -void fire_secondZone_SECTION7() -{ - const int sizeOfSection = ZONETWO_SECTION7_END - ZONETWO_SECTION7_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETWO_SECTION7_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION7_START + thisFlame] = color; - } - #endif - - #if ZONETWO_SECTION7_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION7_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETWO_SECTION8_START -void fire_secondZone_SECTION8() -{ - const int sizeOfSection = ZONETWO_SECTION8_END - ZONETWO_SECTION8_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETWO_SECTION8_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION8_START + thisFlame] = color; - } - #endif - - #if ZONETWO_SECTION8_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION8_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETWO_SECTION9_START -void fire_secondZone_SECTION9() -{ - const int sizeOfSection = ZONETWO_SECTION9_END - ZONETWO_SECTION9_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETWO_SECTION9_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION9_START + thisFlame] = color; - } - #endif - - #if ZONETWO_SECTION9_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - secondZone[ZONETWO_SECTION9_END - thisFlame] = color; - } - #endif - } -} -#endif - -#endif - -/***************** thirdZone Animations ****************************************/ -/***************** thirdZone Animations ****************************************/ -/***************** thirdZone Animations ****************************************/ -/***************** thirdZone Animations ****************************************/ -/***************** thirdZone Animations ****************************************/ - -#if ZONETHREE == 1 - -void Ripple_thirdZone() -{ - for (int i = 0; i < THIRDZONE_LEDS; i++) - { - thirdZone[i] = CRGB((red2/75), (green2/75), (blue2/75)); - } - switch (step_thirdZone) - { - case -1: - center_thirdZone = random16(THIRDZONE_LEDS); - step_thirdZone = 0; - break; - case 0: - thirdZone[center_thirdZone] = CRGB(red1, green1, blue1); - step_thirdZone ++; - break; - case 12: - step_thirdZone = -1; - break; - default: // Middle of the ripples. - thirdZone[(center_thirdZone + step_thirdZone + THIRDZONE_LEDS) % THIRDZONE_LEDS] += CRGB((red1/(step_thirdZone * 5)), (green1/(step_thirdZone * 5)), (blue1/(step_thirdZone * 5))); - thirdZone[(center_thirdZone - step_thirdZone + THIRDZONE_LEDS) % THIRDZONE_LEDS] += CRGB((red1/(step_thirdZone * 5)), (green1/(step_thirdZone * 5)), (blue1/(step_thirdZone * 5))); - step_thirdZone ++; - break; - } -} - -void RGB_thirdZone() -{ - if(startPosition < 6) - { - fadeToBlackBy( thirdZone, THIRDZONE_LEDS, 80); - for(int pixel = startPosition+1; pixel < THIRDZONE_LEDS; pixel+=6) - { - if(pixel <= THIRDZONE_LEDS) - { - thirdZone[pixel] = CRGB(red1,green1,blue1); - } - } - for(int pixel = startPosition+3; pixel < THIRDZONE_LEDS; pixel+=6) - { - if(pixel <= THIRDZONE_LEDS) - { - thirdZone[pixel] = CRGB(red2,green2,blue2); - } - } - for(int pixel = startPosition+5; pixel < THIRDZONE_LEDS; pixel+=6) - { - if(pixel <= THIRDZONE_LEDS) - { - thirdZone[pixel] = CRGB(red3,green3,blue3); - } - } - } - if(startPosition == 1) - { - thirdZone[0]=CRGB(red3,green3,blue3); - } - if(startPosition == 2) - { - thirdZone[1]=CRGB(red3,green3,blue3); - } - if(startPosition == 3) - { - thirdZone[2]=CRGB(red3,green3,blue3); - thirdZone[0]=CRGB(red2,green2,blue2); - } - if(startPosition == 4) - { - thirdZone[3]=CRGB(red3,green3,blue3); - thirdZone[1]=CRGB(red2,green2,blue2); - } - if(startPosition == 5) - { - thirdZone[4]=CRGB(red3,green3,blue3); - thirdZone[2]=CRGB(red2,green2,blue2); - thirdZone[0]=CRGB(red1,green1,blue1); - } -} - -void ColorGlitter_thirdZone( fract8 chanceOfGlitter) -{ - fadeToBlackBy( thirdZone, THIRDZONE_LEDS, 2); - if(startPosition == 0) - { - if( random8() < chanceOfGlitter) - { - thirdZone[ random16(THIRDZONE_LEDS) ] += CRGB::Red; - } - } - if(startPosition == 1) - { - if( random8() < chanceOfGlitter) - { - thirdZone[ random16(THIRDZONE_LEDS) ] += CRGB::Orange; - } - } - if(startPosition == 2) - { - if( random8() < chanceOfGlitter) - { - thirdZone[ random16(THIRDZONE_LEDS) ] += CRGB::Yellow; - } - } - if(startPosition == 3) - { - if( random8() < chanceOfGlitter) - { - thirdZone[ random16(THIRDZONE_LEDS) ] += CRGB::Green; - } - } - if(startPosition == 4) - { - if( random8() < chanceOfGlitter) - { - thirdZone[ random16(THIRDZONE_LEDS) ] += CRGB::Blue; - } - } - if(startPosition == 5) - { - if( random8() < chanceOfGlitter) - { - thirdZone[ random16(THIRDZONE_LEDS) ] += CRGB::Violet; - } - } -} - -void SingleRace_thirdZone() -{ - fadeToBlackBy( thirdZone, THIRDZONE_LEDS, 1); - int pos = beatsin16( raceSpeed, 0, THIRDZONE_LEDS); - if(pos > previousLED_thirdZone) - { - thirdZone[pos] = CRGB(red1,green1,blue1); - previousLED_thirdZone = pos; - } - if(pos < previousLED_thirdZone) - { - thirdZone[pos] = CRGB(red2,green2,blue2); - previousLED_thirdZone = pos; - } -} - - void Crash_thirdZone() -{ - fadeToBlackBy( thirdZone, THIRDZONE_LEDS, 15); - #ifdef ZONETHREE_SECTION1_START - int pos_SECTION1 = beatsin16( raceSpeed, 0, (ZONETHREE_SECTION1_END - ZONETHREE_SECTION1_START) ); - thirdZone[ZONETHREE_SECTION1_START + pos_SECTION1] = CRGB(red1,green1,blue1); - thirdZone[ZONETHREE_SECTION1_END - pos_SECTION1] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONETHREE_SECTION2_START - int pos_SECTION2 = beatsin16( raceSpeed, 0, (ZONETHREE_SECTION2_END - ZONETHREE_SECTION2_START) ); - thirdZone[ZONETHREE_SECTION2_START + pos_SECTION2] = CRGB(red2,green2,blue2); - thirdZone[ZONETHREE_SECTION2_END - pos_SECTION2] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONETHREE_SECTION3_START - int pos_SECTION3 = beatsin16( raceSpeed, 0, (ZONETHREE_SECTION3_END - ZONETHREE_SECTION3_START) ); - thirdZone[ZONETHREE_SECTION3_START + pos_SECTION3] = CRGB(red1,green1,blue1); - thirdZone[ZONETHREE_SECTION3_END - pos_SECTION3] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONETHREE_SECTION4_START - int pos_SECTION4 = beatsin16( raceSpeed, 0, (ZONETHREE_SECTION4_END - ZONETHREE_SECTION4_START) ); - thirdZone[ZONETHREE_SECTION4_START + pos_SECTION4] = CRGB(red2,green2,blue2); - thirdZone[ZONETHREE_SECTION4_END - pos_SECTION4] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONETHREE_SECTION5_START - int pos_SECTION5 = beatsin16( raceSpeed, 0, (ZONETHREE_SECTION5_END - ZONETHREE_SECTION5_START) ); - thirdZone[ZONETHREE_SECTION5_START + pos_SECTION5] = CRGB(red1,green1,blue1); - thirdZone[ZONETHREE_SECTION5_END - pos_SECTION5] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONETHREE_SECTION6_START - int pos_SECTION6 = beatsin16( raceSpeed, 0, (ZONETHREE_SECTION6_END - ZONETHREE_SECTION6_START) ); - thirdZone[ZONETHREE_SECTION6_START + pos_SECTION6] = CRGB(red2,green2,blue2); - thirdZone[ZONETHREE_SECTION6_END - pos_SECTION6] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONETHREE_SECTION7_START - int pos_SECTION7 = beatsin16( raceSpeed, 0, (ZONETHREE_SECTION7_END - ZONETHREE_SECTION7_START) ); - thirdZone[ZONETHREE_SECTION7_START + pos_SECTION7] = CRGB(red1,green1,blue1); - thirdZone[ZONETHREE_SECTION7_END - pos_SECTION7] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONETHREE_SECTION8_START - int pos_SECTION8 = beatsin16( raceSpeed, 0, (ZONETHREE_SECTION8_END - ZONETHREE_SECTION8_START) ); - thirdZone[ZONETHREE_SECTION8_START + pos_SECTION8] = CRGB(red2,green2,blue2); - thirdZone[ZONETHREE_SECTION8_END - pos_SECTION8] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONETHREE_SECTION9_START - int pos_SECTION9 = beatsin16( raceSpeed, 0, (ZONETHREE_SECTION9_END - ZONETHREE_SECTION9_START) ); - thirdZone[ZONETHREE_SECTION9_START + pos_SECTION9] = CRGB(red1,green1,blue1); - thirdZone[ZONETHREE_SECTION9_END - pos_SECTION9] = CRGB(red2,green2,blue2); - #endif - -} - -void Rainbow_thirdZone() -{ - fill_rainbow( thirdZone, THIRDZONE_LEDS, gHue, numberOfRainbows); -} - -void Blocked_thirdZone() -{ - fadeToBlackBy( thirdZone, THIRDZONE_LEDS, 2); - for( int mark = 0; mark < THIRDZONE_LEDS; mark+=30) - { - for( int i = 0; i < 9; i++) - { - if(startPosition == 0 || startPosition == 1) - { - if(i+mark <= THIRDZONE_LEDS) - { - thirdZone[i+mark] = CRGB(red1,green1,blue1); - } - if(i+10+mark <= THIRDZONE_LEDS) - { - thirdZone[i+10+mark] = CRGB(red2,green2,blue2); - } - if(i+20+mark <= THIRDZONE_LEDS) - { - thirdZone[i+20+mark] = CRGB(red3,green3,blue3); - } - } - if(startPosition == 2 || startPosition == 3) - { - if(i+mark <= THIRDZONE_LEDS) - { - thirdZone[i+mark] = CRGB(red2,green2,blue2); - } - if(i+10+mark <= THIRDZONE_LEDS) - { - thirdZone[i+10+mark] = CRGB(red3,green3,blue3); - } - if(i+20+mark <= THIRDZONE_LEDS) - { - thirdZone[i+20+mark] = CRGB(red1,green1,blue1); - } - } - if(startPosition == 4 || startPosition == 5) - { - if(i+mark <= THIRDZONE_LEDS) - { - thirdZone[i+mark] = CRGB(red3,green3,blue3); - } - if(i+10+mark <= THIRDZONE_LEDS) - { - thirdZone[i+10+mark] = CRGB(red1,green1,blue1); - } - if(i+20+mark <= THIRDZONE_LEDS) - { - thirdZone[i+20+mark] = CRGB(red2,green2,blue2); - } - } - } - } -} - -void BPM_thirdZone() -{ - if((red1*2) > (green1 + blue1)) - { - CRGBPalette16 palette_thirdZone = LavaColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < THIRDZONE_LEDS; i++) - { - thirdZone[i] = ColorFromPalette(palette_thirdZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((green1*2) > (red1 + blue1)) - { - CRGBPalette16 palette_thirdZone = ForestColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < THIRDZONE_LEDS; i++) - { - thirdZone[i] = ColorFromPalette(palette_thirdZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((blue1*2) > (green1 + red1)) - { - CRGBPalette16 palette_thirdZone = CloudColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < THIRDZONE_LEDS; i++) - { - thirdZone[i] = ColorFromPalette(palette_thirdZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((blue1*2) == (green1 + red1)) - { - CRGBPalette16 palette_thirdZone = PartyColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < THIRDZONE_LEDS; i++) - { - thirdZone[i] = ColorFromPalette(palette_thirdZone, gHue+(i*2), beat-gHue+(i*10)); - } - } -} - -void Twinkle_thirdZone() -{ - fadeToBlackBy( thirdZone, THIRDZONE_LEDS, 80); - for( int i = 0; i < THIRDZONE_LEDS-5; i+=5) - { - if(i <= THIRDZONE_LEDS) - { - if (random8() > twinkleChance) - { - thirdZone[i] = CRGB( red1, green1, blue1); - } - else - { - thirdZone[i] = CRGB( 150, 100, 40); - } - } - } -} - -void Eyes_thirdZone() -{ - unsigned int chance = random8(); - if( chance > eyeChance) - { - unsigned int eye = random16(THIRDZONE_LEDS); - thirdZone[eye] = CRGB(red1,green1,blue1); - thirdZone[eye-4] = CRGB(red1,green1,blue1); - } - if( chance > 39) - { - fadeToBlackBy( thirdZone, THIRDZONE_LEDS, 10); - } -} - -void Solid_thirdZone() -{ - fill_solid(thirdZone, THIRDZONE_LEDS, CRGB(red1, green1, blue1)); -} - -void Locator_thirdZone() -{ - if(locatorLED <= THIRDZONE_LEDS) - { - fill_solid(thirdZone, THIRDZONE_LEDS, CRGB::Black); - thirdZone[locatorLED]=CRGB(red1, green1, blue1); - } -} - -#ifdef ZONETHREE_SECTION1_START -void fire_thirdZone_SECTION1() -{ - static byte heat[ZONETHREE_SECTION1_END - ZONETHREE_SECTION1_START]; - for( int i = 0; i < ZONETHREE_SECTION1_END - ZONETHREE_SECTION1_START; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / ZONETHREE_SECTION1_END - ZONETHREE_SECTION1_START) + 2)); - } - - for( int k= ZONETHREE_SECTION1_END - ZONETHREE_SECTION1_START - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < ZONETHREE_SECTION1_END - ZONETHREE_SECTION1_START; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (ZONETHREE_SECTION1_END - ZONETHREE_SECTION1_START -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETHREE_SECTION1_START_FIRE == 1 - if(thisFlame <= ZONETHREE_SECTION1_END - ZONETHREE_SECTION1_START ) - { - thirdZone[ZONETHREE_SECTION1_START + thisFlame] = color; - } - #endif - - #if ZONETHREE_SECTION1_END_FIRE == 1 - if(thisFlame <= ZONETHREE_SECTION1_END - ZONETHREE_SECTION1_START ) - { - thirdZone[ZONETHREE_SECTION1_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETHREE_SECTION2_START -void fire_thirdZone_SECTION2() -{ - const int sizeOfSection = ZONETHREE_SECTION2_END - ZONETHREE_SECTION2_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETHREE_SECTION2_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION2_START + thisFlame] = color; - } - #endif - - #if ZONETHREE_SECTION2_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION2_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETHREE_SECTION3_START -void fire_thirdZone_SECTION3() -{ - const int sizeOfSection = ZONETHREE_SECTION3_END - ZONETHREE_SECTION3_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETHREE_SECTION3_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION3_START + thisFlame] = color; - } - #endif - - #if ZONETHREE_SECTION3_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION3_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETHREE_SECTION4_START -void fire_thirdZone_SECTION4() -{ - const int sizeOfSection = ZONETHREE_SECTION4_END - ZONETHREE_SECTION4_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETHREE_SECTION4_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION4_START + thisFlame] = color; - } - #endif - - #if ZONETHREE_SECTION4_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION4_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETHREE_SECTION5_START -void fire_thirdZone_SECTION5() -{ - const int sizeOfSection = ZONETHREE_SECTION5_END - ZONETHREE_SECTION5_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETHREE_SECTION5_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION5_START + thisFlame] = color; - } - #endif - - #if ZONETHREE_SECTION5_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION5_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETHREE_SECTION6_START -void fire_thirdZone_SECTION6() -{ - const int sizeOfSection = ZONETHREE_SECTION6_END - ZONETHREE_SECTION6_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETHREE_SECTION6_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION6_START + thisFlame] = color; - } - #endif - - #if ZONETHREE_SECTION6_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION6_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETHREE_SECTION7_START -void fire_thirdZone_SECTION7() -{ - const int sizeOfSection = ZONETHREE_SECTION7_END - ZONETHREE_SECTION7_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETHREE_SECTION7_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION7_START + thisFlame] = color; - } - #endif - - #if ZONETHREE_SECTION7_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION7_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETHREE_SECTION8_START -void fire_thirdZone_SECTION8() -{ - const int sizeOfSection = ZONETHREE_SECTION8_END - ZONETHREE_SECTION8_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETHREE_SECTION8_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION8_START + thisFlame] = color; - } - #endif - - #if ZONETHREE_SECTION8_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION8_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONETHREE_SECTION9_START -void fire_thirdZone_SECTION9() -{ - const int sizeOfSection = ZONETHREE_SECTION9_END - ZONETHREE_SECTION9_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONETHREE_SECTION9_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION9_START + thisFlame] = color; - } - #endif - - #if ZONETHREE_SECTION9_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - thirdZone[ZONETHREE_SECTION9_END - thisFlame] = color; - } - #endif - } -} -#endif - -#endif - -/***************** fourthZone Animations ****************************************/ -/***************** fourthZone Animations ****************************************/ -/***************** fourthZone Animations ****************************************/ -/***************** fourthZone Animations ****************************************/ -/***************** fourthZone Animations ****************************************/ - -#if ZONEFOUR == 1 - -void Ripple_fourthZone() -{ - for (int i = 0; i < FOURTHZONE_LEDS; i++) - { - fourthZone[i] = CRGB((red2/75), (green2/75), (blue2/75)); - } - switch (step_fourthZone) - { - case -1: - center_fourthZone = random16(FOURTHZONE_LEDS); - step_fourthZone = 0; - break; - case 0: - fourthZone[center_fourthZone] = CRGB(red1, green1, blue1); - step_fourthZone ++; - break; - case 12: - step_fourthZone = -1; - break; - default: // Middle of the ripples. - fourthZone[(center_fourthZone + step_fourthZone + FOURTHZONE_LEDS) % FOURTHZONE_LEDS] += CRGB((red1/(step_fourthZone * 5)), (green1/(step_fourthZone * 5)), (blue1/(step_fourthZone * 5))); - fourthZone[(center_fourthZone - step_fourthZone + FOURTHZONE_LEDS) % FOURTHZONE_LEDS] += CRGB((red1/(step_fourthZone * 5)), (green1/(step_fourthZone * 5)), (blue1/(step_fourthZone * 5))); - step_fourthZone ++; - break; - } -} - -void RGB_fourthZone() -{ - if(startPosition < 6) - { - fadeToBlackBy( fourthZone, FOURTHZONE_LEDS, 80); - for(int pixel = startPosition+1; pixel < FOURTHZONE_LEDS; pixel+=6) - { - if(pixel <= FOURTHZONE_LEDS) - { - fourthZone[pixel] = CRGB(red1,green1,blue1); - } - } - for(int pixel = startPosition+3; pixel < FOURTHZONE_LEDS; pixel+=6) - { - if(pixel <= FOURTHZONE_LEDS) - { - fourthZone[pixel] = CRGB(red2,green2,blue2); - } - } - for(int pixel = startPosition+5; pixel < FOURTHZONE_LEDS; pixel+=6) - { - if(pixel <= FOURTHZONE_LEDS) - { - fourthZone[pixel] = CRGB(red3,green3,blue3); - } - } - } - if(startPosition == 1) - { - fourthZone[0]=CRGB(red3,green3,blue3); - } - if(startPosition == 2) - { - fourthZone[1]=CRGB(red3,green3,blue3); - } - if(startPosition == 3) - { - fourthZone[2]=CRGB(red3,green3,blue3); - fourthZone[0]=CRGB(red2,green2,blue2); - } - if(startPosition == 4) - { - fourthZone[3]=CRGB(red3,green3,blue3); - fourthZone[1]=CRGB(red2,green2,blue2); - } - if(startPosition == 5) - { - fourthZone[4]=CRGB(red3,green3,blue3); - fourthZone[2]=CRGB(red2,green2,blue2); - fourthZone[0]=CRGB(red1,green1,blue1); - } -} - -void ColorGlitter_fourthZone( fract8 chanceOfGlitter) -{ - fadeToBlackBy( fourthZone, FOURTHZONE_LEDS, 2); - if(startPosition == 0) - { - if( random8() < chanceOfGlitter) - { - fourthZone[ random16(FOURTHZONE_LEDS) ] += CRGB::Red; - } - } - if(startPosition == 1) - { - if( random8() < chanceOfGlitter) - { - fourthZone[ random16(FOURTHZONE_LEDS) ] += CRGB::Orange; - } - } - if(startPosition == 2) - { - if( random8() < chanceOfGlitter) - { - fourthZone[ random16(FOURTHZONE_LEDS) ] += CRGB::Yellow; - } - } - if(startPosition == 3) - { - if( random8() < chanceOfGlitter) - { - fourthZone[ random16(FOURTHZONE_LEDS) ] += CRGB::Green; - } - } - if(startPosition == 4) - { - if( random8() < chanceOfGlitter) - { - fourthZone[ random16(FOURTHZONE_LEDS) ] += CRGB::Blue; - } - } - if(startPosition == 5) - { - if( random8() < chanceOfGlitter) - { - fourthZone[ random16(FOURTHZONE_LEDS) ] += CRGB::Violet; - } - } -} - -void SingleRace_fourthZone() -{ - fadeToBlackBy( fourthZone, FOURTHZONE_LEDS, 1); - int pos = beatsin16( raceSpeed, 0, FOURTHZONE_LEDS); - if(pos > previousLED_fourthZone) - { - fourthZone[pos] = CRGB(red1,green1,blue1); - previousLED_fourthZone = pos; - } - if(pos < previousLED_fourthZone) - { - fourthZone[pos] = CRGB(red2,green2,blue2); - previousLED_fourthZone = pos; - } -} - - void Crash_fourthZone() -{ - fadeToBlackBy( fourthZone, FOURTHZONE_LEDS, 15); - #ifdef ZONEFOUR_SECTION1_START - int pos_SECTION1 = beatsin16( raceSpeed, 0, (ZONEFOUR_SECTION1_END - ZONEFOUR_SECTION1_START) ); - fourthZone[ZONEFOUR_SECTION1_START + pos_SECTION1] = CRGB(red1,green1,blue1); - fourthZone[ZONEFOUR_SECTION1_END - pos_SECTION1] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONEFOUR_SECTION2_START - int pos_SECTION2 = beatsin16( raceSpeed, 0, (ZONEFOUR_SECTION2_END - ZONEFOUR_SECTION2_START) ); - fourthZone[ZONEFOUR_SECTION2_START + pos_SECTION2] = CRGB(red2,green2,blue2); - fourthZone[ZONEFOUR_SECTION2_END - pos_SECTION2] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONEFOUR_SECTION3_START - int pos_SECTION3 = beatsin16( raceSpeed, 0, (ZONEFOUR_SECTION3_END - ZONEFOUR_SECTION3_START) ); - fourthZone[ZONEFOUR_SECTION3_START + pos_SECTION3] = CRGB(red1,green1,blue1); - fourthZone[ZONEFOUR_SECTION3_END - pos_SECTION3] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONEFOUR_SECTION4_START - int pos_SECTION4 = beatsin16( raceSpeed, 0, (ZONEFOUR_SECTION4_END - ZONEFOUR_SECTION4_START) ); - fourthZone[ZONEFOUR_SECTION4_START + pos_SECTION4] = CRGB(red2,green2,blue2); - fourthZone[ZONEFOUR_SECTION4_END - pos_SECTION4] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONEFOUR_SECTION5_START - int pos_SECTION5 = beatsin16( raceSpeed, 0, (ZONEFOUR_SECTION5_END - ZONEFOUR_SECTION5_START) ); - fourthZone[ZONEFOUR_SECTION5_START + pos_SECTION5] = CRGB(red1,green1,blue1); - fourthZone[ZONEFOUR_SECTION5_END - pos_SECTION5] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONEFOUR_SECTION6_START - int pos_SECTION6 = beatsin16( raceSpeed, 0, (ZONEFOUR_SECTION6_END - ZONEFOUR_SECTION6_START) ); - fourthZone[ZONEFOUR_SECTION6_START + pos_SECTION6] = CRGB(red2,green2,blue2); - fourthZone[ZONEFOUR_SECTION6_END - pos_SECTION6] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONEFOUR_SECTION7_START - int pos_SECTION7 = beatsin16( raceSpeed, 0, (ZONEFOUR_SECTION7_END - ZONEFOUR_SECTION7_START) ); - fourthZone[ZONEFOUR_SECTION7_START + pos_SECTION7] = CRGB(red1,green1,blue1); - fourthZone[ZONEFOUR_SECTION7_END - pos_SECTION7] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONEFOUR_SECTION8_START - int pos_SECTION8 = beatsin16( raceSpeed, 0, (ZONEFOUR_SECTION8_END - ZONEFOUR_SECTION8_START) ); - fourthZone[ZONEFOUR_SECTION8_START + pos_SECTION8] = CRGB(red2,green2,blue2); - fourthZone[ZONEFOUR_SECTION8_END - pos_SECTION8] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONEFOUR_SECTION9_START - int pos_SECTION9 = beatsin16( raceSpeed, 0, (ZONEFOUR_SECTION9_END - ZONEFOUR_SECTION9_START) ); - fourthZone[ZONEFOUR_SECTION9_START + pos_SECTION9] = CRGB(red1,green1,blue1); - fourthZone[ZONEFOUR_SECTION9_END - pos_SECTION9] = CRGB(red2,green2,blue2); - #endif - -} - -void Rainbow_fourthZone() -{ - fill_rainbow( fourthZone, FOURTHZONE_LEDS, gHue, numberOfRainbows); -} - -void Blocked_fourthZone() -{ - fadeToBlackBy( fourthZone, FOURTHZONE_LEDS, 2); - for( int mark = 0; mark < FOURTHZONE_LEDS; mark+=30) - { - for( int i = 0; i < 9; i++) - { - if(startPosition == 0 || startPosition == 1) - { - if(i+mark <= FOURTHZONE_LEDS) - { - fourthZone[i+mark] = CRGB(red1,green1,blue1); - } - if(i+10+mark <= FOURTHZONE_LEDS) - { - fourthZone[i+10+mark] = CRGB(red2,green2,blue2); - } - if(i+20+mark <= FOURTHZONE_LEDS) - { - fourthZone[i+20+mark] = CRGB(red3,green3,blue3); - } - } - if(startPosition == 2 || startPosition == 3) - { - if(i+mark <= FOURTHZONE_LEDS) - { - fourthZone[i+mark] = CRGB(red2,green2,blue2); - } - if(i+10+mark <= FOURTHZONE_LEDS) - { - fourthZone[i+10+mark] = CRGB(red3,green3,blue3); - } - if(i+20+mark <= FOURTHZONE_LEDS) - { - fourthZone[i+20+mark] = CRGB(red1,green1,blue1); - } - } - if(startPosition == 4 || startPosition == 5) - { - if(i+mark <= FOURTHZONE_LEDS) - { - fourthZone[i+mark] = CRGB(red3,green3,blue3); - } - if(i+10+mark <= FOURTHZONE_LEDS) - { - fourthZone[i+10+mark] = CRGB(red1,green1,blue1); - } - if(i+20+mark <= FOURTHZONE_LEDS) - { - fourthZone[i+20+mark] = CRGB(red2,green2,blue2); - } - } - } - } -} - -void BPM_fourthZone() -{ - if((red1*2) > (green1 + blue1)) - { - CRGBPalette16 palette_fourthZone = LavaColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < FOURTHZONE_LEDS; i++) - { - fourthZone[i] = ColorFromPalette(palette_fourthZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((green1*2) > (red1 + blue1)) - { - CRGBPalette16 palette_fourthZone = ForestColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < FOURTHZONE_LEDS; i++) - { - fourthZone[i] = ColorFromPalette(palette_fourthZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((blue1*2) > (green1 + red1)) - { - CRGBPalette16 palette_fourthZone = CloudColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < FOURTHZONE_LEDS; i++) - { - fourthZone[i] = ColorFromPalette(palette_fourthZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((blue1*2) == (green1 + red1)) - { - CRGBPalette16 palette_fourthZone = PartyColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < FOURTHZONE_LEDS; i++) - { - fourthZone[i] = ColorFromPalette(palette_fourthZone, gHue+(i*2), beat-gHue+(i*10)); - } - } -} - -void Twinkle_fourthZone() -{ - fadeToBlackBy( fourthZone, FOURTHZONE_LEDS, 80); - for( int i = 0; i < FOURTHZONE_LEDS-5; i+=5) - { - if(i <= FOURTHZONE_LEDS) - { - if (random8() > twinkleChance) - { - fourthZone[i] = CRGB( red1, green1, blue1); - } - else - { - fourthZone[i] = CRGB( 150, 100, 40); - } - } - } -} - -void Eyes_fourthZone() -{ - unsigned int chance = random8(); - if( chance > eyeChance) - { - unsigned int eye = random16(FOURTHZONE_LEDS); - fourthZone[eye] = CRGB(red1,green1,blue1); - fourthZone[eye-4] = CRGB(red1,green1,blue1); - } - if( chance > 39) - { - fadeToBlackBy( fourthZone, FOURTHZONE_LEDS, 10); - } -} - -void Solid_fourthZone() -{ - fill_solid(fourthZone, FOURTHZONE_LEDS, CRGB(red1, green1, blue1)); -} - -void Locator_fourthZone() -{ - if(locatorLED <= FOURTHZONE_LEDS) - { - fill_solid(fourthZone, FOURTHZONE_LEDS, CRGB::Black); - fourthZone[locatorLED]=CRGB(red1, green1, blue1); - } -} - -#ifdef ZONEFOUR_SECTION1_START -void fire_fourthZone_SECTION1() -{ - static byte heat[ZONEFOUR_SECTION1_END - ZONEFOUR_SECTION1_START]; - for( int i = 0; i < ZONEFOUR_SECTION1_END - ZONEFOUR_SECTION1_START; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / ZONEFOUR_SECTION1_END - ZONEFOUR_SECTION1_START) + 2)); - } - - for( int k= ZONEFOUR_SECTION1_END - ZONEFOUR_SECTION1_START - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < ZONEFOUR_SECTION1_END - ZONEFOUR_SECTION1_START; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (ZONEFOUR_SECTION1_END - ZONEFOUR_SECTION1_START -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFOUR_SECTION1_START_FIRE == 1 - if(thisFlame <= ZONEFOUR_SECTION1_END - ZONEFOUR_SECTION1_START ) - { - fourthZone[ZONEFOUR_SECTION1_START + thisFlame] = color; - } - #endif - - #if ZONEFOUR_SECTION1_END_FIRE == 1 - if(thisFlame <= ZONEFOUR_SECTION1_END - ZONEFOUR_SECTION1_START ) - { - fourthZone[ZONEFOUR_SECTION1_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFOUR_SECTION2_START -void fire_fourthZone_SECTION2() -{ - const int sizeOfSection = ZONEFOUR_SECTION2_END - ZONEFOUR_SECTION2_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFOUR_SECTION2_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION2_START + thisFlame] = color; - } - #endif - - #if ZONEFOUR_SECTION2_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION2_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFOUR_SECTION3_START -void fire_fourthZone_SECTION3() -{ - const int sizeOfSection = ZONEFOUR_SECTION3_END - ZONEFOUR_SECTION3_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFOUR_SECTION3_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION3_START + thisFlame] = color; - } - #endif - - #if ZONEFOUR_SECTION3_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION3_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFOUR_SECTION4_START -void fire_fourthZone_SECTION4() -{ - const int sizeOfSection = ZONEFOUR_SECTION4_END - ZONEFOUR_SECTION4_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFOUR_SECTION4_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION4_START + thisFlame] = color; - } - #endif - - #if ZONEFOUR_SECTION4_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION4_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFOUR_SECTION5_START -void fire_fourthZone_SECTION5() -{ - const int sizeOfSection = ZONEFOUR_SECTION5_END - ZONEFOUR_SECTION5_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFOUR_SECTION5_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION5_START + thisFlame] = color; - } - #endif - - #if ZONEFOUR_SECTION5_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION5_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFOUR_SECTION6_START -void fire_fourthZone_SECTION6() -{ - const int sizeOfSection = ZONEFOUR_SECTION6_END - ZONEFOUR_SECTION6_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFOUR_SECTION6_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION6_START + thisFlame] = color; - } - #endif - - #if ZONEFOUR_SECTION6_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION6_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFOUR_SECTION7_START -void fire_fourthZone_SECTION7() -{ - const int sizeOfSection = ZONEFOUR_SECTION7_END - ZONEFOUR_SECTION7_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFOUR_SECTION7_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION7_START + thisFlame] = color; - } - #endif - - #if ZONEFOUR_SECTION7_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION7_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFOUR_SECTION8_START -void fire_fourthZone_SECTION8() -{ - const int sizeOfSection = ZONEFOUR_SECTION8_END - ZONEFOUR_SECTION8_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFOUR_SECTION8_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION8_START + thisFlame] = color; - } - #endif - - #if ZONEFOUR_SECTION8_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION8_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFOUR_SECTION9_START -void fire_fourthZone_SECTION9() -{ - const int sizeOfSection = ZONEFOUR_SECTION9_END - ZONEFOUR_SECTION9_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFOUR_SECTION9_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION9_START + thisFlame] = color; - } - #endif - - #if ZONEFOUR_SECTION9_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fourthZone[ZONEFOUR_SECTION9_END - thisFlame] = color; - } - #endif - } -} -#endif - -#endif - -/***************** fifthZone Animations ****************************************/ -/***************** fifthZone Animations ****************************************/ -/***************** fifthZone Animations ****************************************/ -/***************** fifthZone Animations ****************************************/ -/***************** fifthZone Animations ****************************************/ - -#if ZONEFIVE == 1 - -void Ripple_fifthZone() -{ - for (int i = 0; i < FIFTHZONE_LEDS; i++) - { - fifthZone[i] = CRGB((red2/75), (green2/75), (blue2/75)); - } - switch (step_fifthZone) - { - case -1: - center_fifthZone = random16(FIFTHZONE_LEDS); - step_fifthZone = 0; - break; - case 0: - fifthZone[center_fifthZone] = CRGB(red1, green1, blue1); - step_fifthZone ++; - break; - case 12: - step_fifthZone = -1; - break; - default: // Middle of the ripples. - fifthZone[(center_fifthZone + step_fifthZone + FIFTHZONE_LEDS) % FIFTHZONE_LEDS] += CRGB((red1/(step_fifthZone * 5)), (green1/(step_fifthZone * 5)), (blue1/(step_fifthZone * 5))); - fifthZone[(center_fifthZone - step_fifthZone + FIFTHZONE_LEDS) % FIFTHZONE_LEDS] += CRGB((red1/(step_fifthZone * 5)), (green1/(step_fifthZone * 5)), (blue1/(step_fifthZone * 5))); - step_fifthZone ++; - break; - } -} - -void RGB_fifthZone() -{ - if(startPosition < 6) - { - fadeToBlackBy( fifthZone, FIFTHZONE_LEDS, 80); - for(int pixel = startPosition+1; pixel < FIFTHZONE_LEDS; pixel+=6) - { - if(pixel <= FIFTHZONE_LEDS) - { - fifthZone[pixel] = CRGB(red1,green1,blue1); - } - } - for(int pixel = startPosition+3; pixel < FIFTHZONE_LEDS; pixel+=6) - { - if(pixel <= FIFTHZONE_LEDS) - { - fifthZone[pixel] = CRGB(red2,green2,blue2); - } - } - for(int pixel = startPosition+5; pixel < FIFTHZONE_LEDS; pixel+=6) - { - if(pixel <= FIFTHZONE_LEDS) - { - fifthZone[pixel] = CRGB(red3,green3,blue3); - } - } - } - if(startPosition == 1) - { - fifthZone[0]=CRGB(red3,green3,blue3); - } - if(startPosition == 2) - { - fifthZone[1]=CRGB(red3,green3,blue3); - } - if(startPosition == 3) - { - fifthZone[2]=CRGB(red3,green3,blue3); - fifthZone[0]=CRGB(red2,green2,blue2); - } - if(startPosition == 4) - { - fifthZone[3]=CRGB(red3,green3,blue3); - fifthZone[1]=CRGB(red2,green2,blue2); - } - if(startPosition == 5) - { - fifthZone[4]=CRGB(red3,green3,blue3); - fifthZone[2]=CRGB(red2,green2,blue2); - fifthZone[0]=CRGB(red1,green1,blue1); - } -} - -void ColorGlitter_fifthZone( fract8 chanceOfGlitter) -{ - fadeToBlackBy( fifthZone, FIFTHZONE_LEDS, 2); - if(startPosition == 0) - { - if( random8() < chanceOfGlitter) - { - fifthZone[ random16(FIFTHZONE_LEDS) ] += CRGB::Red; - } - } - if(startPosition == 1) - { - if( random8() < chanceOfGlitter) - { - fifthZone[ random16(FIFTHZONE_LEDS) ] += CRGB::Orange; - } - } - if(startPosition == 2) - { - if( random8() < chanceOfGlitter) - { - fifthZone[ random16(FIFTHZONE_LEDS) ] += CRGB::Yellow; - } - } - if(startPosition == 3) - { - if( random8() < chanceOfGlitter) - { - fifthZone[ random16(FIFTHZONE_LEDS) ] += CRGB::Green; - } - } - if(startPosition == 4) - { - if( random8() < chanceOfGlitter) - { - fifthZone[ random16(FIFTHZONE_LEDS) ] += CRGB::Blue; - } - } - if(startPosition == 5) - { - if( random8() < chanceOfGlitter) - { - fifthZone[ random16(FIFTHZONE_LEDS) ] += CRGB::Violet; - } - } -} - -void SingleRace_fifthZone() -{ - fadeToBlackBy( fifthZone, FIFTHZONE_LEDS, 1); - int pos = beatsin16( raceSpeed, 0, FIFTHZONE_LEDS); - if(pos > previousLED_fifthZone) - { - fifthZone[pos] = CRGB(red1,green1,blue1); - previousLED_fifthZone = pos; - } - if(pos < previousLED_fifthZone) - { - fifthZone[pos] = CRGB(red2,green2,blue2); - previousLED_fifthZone = pos; - } -} - - void Crash_fifthZone() -{ - fadeToBlackBy( fifthZone, FIFTHZONE_LEDS, 15); - #ifdef ZONEFIVE_SECTION1_START - int pos_SECTION1 = beatsin16( raceSpeed, 0, (ZONEFIVE_SECTION1_END - ZONEFIVE_SECTION1_START) ); - fifthZone[ZONEFIVE_SECTION1_START + pos_SECTION1] = CRGB(red1,green1,blue1); - fifthZone[ZONEFIVE_SECTION1_END - pos_SECTION1] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONEFIVE_SECTION2_START - int pos_SECTION2 = beatsin16( raceSpeed, 0, (ZONEFIVE_SECTION2_END - ZONEFIVE_SECTION2_START) ); - fifthZone[ZONEFIVE_SECTION2_START + pos_SECTION2] = CRGB(red2,green2,blue2); - fifthZone[ZONEFIVE_SECTION2_END - pos_SECTION2] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONEFIVE_SECTION3_START - int pos_SECTION3 = beatsin16( raceSpeed, 0, (ZONEFIVE_SECTION3_END - ZONEFIVE_SECTION3_START) ); - fifthZone[ZONEFIVE_SECTION3_START + pos_SECTION3] = CRGB(red1,green1,blue1); - fifthZone[ZONEFIVE_SECTION3_END - pos_SECTION3] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONEFIVE_SECTION4_START - int pos_SECTION4 = beatsin16( raceSpeed, 0, (ZONEFIVE_SECTION4_END - ZONEFIVE_SECTION4_START) ); - fifthZone[ZONEFIVE_SECTION4_START + pos_SECTION4] = CRGB(red2,green2,blue2); - fifthZone[ZONEFIVE_SECTION4_END - pos_SECTION4] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONEFIVE_SECTION5_START - int pos_SECTION5 = beatsin16( raceSpeed, 0, (ZONEFIVE_SECTION5_END - ZONEFIVE_SECTION5_START) ); - fifthZone[ZONEFIVE_SECTION5_START + pos_SECTION5] = CRGB(red1,green1,blue1); - fifthZone[ZONEFIVE_SECTION5_END - pos_SECTION5] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONEFIVE_SECTION6_START - int pos_SECTION6 = beatsin16( raceSpeed, 0, (ZONEFIVE_SECTION6_END - ZONEFIVE_SECTION6_START) ); - fifthZone[ZONEFIVE_SECTION6_START + pos_SECTION6] = CRGB(red2,green2,blue2); - fifthZone[ZONEFIVE_SECTION6_END - pos_SECTION6] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONEFIVE_SECTION7_START - int pos_SECTION7 = beatsin16( raceSpeed, 0, (ZONEFIVE_SECTION7_END - ZONEFIVE_SECTION7_START) ); - fifthZone[ZONEFIVE_SECTION7_START + pos_SECTION7] = CRGB(red1,green1,blue1); - fifthZone[ZONEFIVE_SECTION7_END - pos_SECTION7] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONEFIVE_SECTION8_START - int pos_SECTION8 = beatsin16( raceSpeed, 0, (ZONEFIVE_SECTION8_END - ZONEFIVE_SECTION8_START) ); - fifthZone[ZONEFIVE_SECTION8_START + pos_SECTION8] = CRGB(red2,green2,blue2); - fifthZone[ZONEFIVE_SECTION8_END - pos_SECTION8] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONEFIVE_SECTION9_START - int pos_SECTION9 = beatsin16( raceSpeed, 0, (ZONEFIVE_SECTION9_END - ZONEFIVE_SECTION9_START) ); - fifthZone[ZONEFIVE_SECTION9_START + pos_SECTION9] = CRGB(red1,green1,blue1); - fifthZone[ZONEFIVE_SECTION9_END - pos_SECTION9] = CRGB(red2,green2,blue2); - #endif - -} - -void Rainbow_fifthZone() -{ - fill_rainbow( fifthZone, FIFTHZONE_LEDS, gHue, numberOfRainbows); -} - -void Blocked_fifthZone() -{ - fadeToBlackBy( fifthZone, FIFTHZONE_LEDS, 2); - for( int mark = 0; mark < FIFTHZONE_LEDS; mark+=30) - { - for( int i = 0; i < 9; i++) - { - if(startPosition == 0 || startPosition == 1) - { - if(i+mark <= FIFTHZONE_LEDS) - { - fifthZone[i+mark] = CRGB(red1,green1,blue1); - } - if(i+10+mark <= FIFTHZONE_LEDS) - { - fifthZone[i+10+mark] = CRGB(red2,green2,blue2); - } - if(i+20+mark <= FIFTHZONE_LEDS) - { - fifthZone[i+20+mark] = CRGB(red3,green3,blue3); - } - } - if(startPosition == 2 || startPosition == 3) - { - if(i+mark <= FIFTHZONE_LEDS) - { - fifthZone[i+mark] = CRGB(red2,green2,blue2); - } - if(i+10+mark <= FIFTHZONE_LEDS) - { - fifthZone[i+10+mark] = CRGB(red3,green3,blue3); - } - if(i+20+mark <= FIFTHZONE_LEDS) - { - fifthZone[i+20+mark] = CRGB(red1,green1,blue1); - } - } - if(startPosition == 4 || startPosition == 5) - { - if(i+mark <= FIFTHZONE_LEDS) - { - fifthZone[i+mark] = CRGB(red3,green3,blue3); - } - if(i+10+mark <= FIFTHZONE_LEDS) - { - fifthZone[i+10+mark] = CRGB(red1,green1,blue1); - } - if(i+20+mark <= FIFTHZONE_LEDS) - { - fifthZone[i+20+mark] = CRGB(red2,green2,blue2); - } - } - } - } -} - -void BPM_fifthZone() -{ - if((red1*2) > (green1 + blue1)) - { - CRGBPalette16 palette_fifthZone = LavaColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < FIFTHZONE_LEDS; i++) - { - fifthZone[i] = ColorFromPalette(palette_fifthZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((green1*2) > (red1 + blue1)) - { - CRGBPalette16 palette_fifthZone = ForestColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < FIFTHZONE_LEDS; i++) - { - fifthZone[i] = ColorFromPalette(palette_fifthZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((blue1*2) > (green1 + red1)) - { - CRGBPalette16 palette_fifthZone = CloudColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < FIFTHZONE_LEDS; i++) - { - fifthZone[i] = ColorFromPalette(palette_fifthZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((blue1*2) == (green1 + red1)) - { - CRGBPalette16 palette_fifthZone = PartyColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < FIFTHZONE_LEDS; i++) - { - fifthZone[i] = ColorFromPalette(palette_fifthZone, gHue+(i*2), beat-gHue+(i*10)); - } - } -} - -void Twinkle_fifthZone() -{ - fadeToBlackBy( fifthZone, FIFTHZONE_LEDS, 80); - for( int i = 0; i < FIFTHZONE_LEDS-5; i+=5) - { - if(i <= FIFTHZONE_LEDS) - { - if (random8() > twinkleChance) - { - fifthZone[i] = CRGB( red1, green1, blue1); - } - else - { - fifthZone[i] = CRGB( 150, 100, 40); - } - } - } -} - -void Eyes_fifthZone() -{ - unsigned int chance = random8(); - if( chance > eyeChance) - { - unsigned int eye = random16(FIFTHZONE_LEDS); - fifthZone[eye] = CRGB(red1,green1,blue1); - fifthZone[eye-4] = CRGB(red1,green1,blue1); - } - if( chance > 39) - { - fadeToBlackBy( fifthZone, FIFTHZONE_LEDS, 10); - } -} - -void Solid_fifthZone() -{ - fill_solid(fifthZone, FIFTHZONE_LEDS, CRGB(red1, green1, blue1)); -} - -void Locator_fifthZone() -{ - if(locatorLED <= FIFTHZONE_LEDS) - { - fill_solid(fifthZone, FIFTHZONE_LEDS, CRGB::Black); - fifthZone[locatorLED]=CRGB(red1, green1, blue1); - } -} - -#ifdef ZONEFIVE_SECTION1_START -void fire_fifthZone_SECTION1() -{ - static byte heat[ZONEFIVE_SECTION1_END - ZONEFIVE_SECTION1_START]; - for( int i = 0; i < ZONEFIVE_SECTION1_END - ZONEFIVE_SECTION1_START; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / ZONEFIVE_SECTION1_END - ZONEFIVE_SECTION1_START) + 2)); - } - - for( int k= ZONEFIVE_SECTION1_END - ZONEFIVE_SECTION1_START - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < ZONEFIVE_SECTION1_END - ZONEFIVE_SECTION1_START; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (ZONEFIVE_SECTION1_END - ZONEFIVE_SECTION1_START -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFIVE_SECTION1_START_FIRE == 1 - if(thisFlame <= ZONEFIVE_SECTION1_END - ZONEFIVE_SECTION1_START ) - { - fifthZone[ZONEFIVE_SECTION1_START + thisFlame] = color; - } - #endif - - #if ZONEFIVE_SECTION1_END_FIRE == 1 - if(thisFlame <= ZONEFIVE_SECTION1_END - ZONEFIVE_SECTION1_START ) - { - fifthZone[ZONEFIVE_SECTION1_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFIVE_SECTION2_START -void fire_fifthZone_SECTION2() -{ - const int sizeOfSection = ZONEFIVE_SECTION2_END - ZONEFIVE_SECTION2_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFIVE_SECTION2_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION2_START + thisFlame] = color; - } - #endif - - #if ZONEFIVE_SECTION2_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION2_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFIVE_SECTION3_START -void fire_fifthZone_SECTION3() -{ - const int sizeOfSection = ZONEFIVE_SECTION3_END - ZONEFIVE_SECTION3_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFIVE_SECTION3_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION3_START + thisFlame] = color; - } - #endif - - #if ZONEFIVE_SECTION3_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION3_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFIVE_SECTION4_START -void fire_fifthZone_SECTION4() -{ - const int sizeOfSection = ZONEFIVE_SECTION4_END - ZONEFIVE_SECTION4_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFIVE_SECTION4_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION4_START + thisFlame] = color; - } - #endif - - #if ZONEFIVE_SECTION4_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION4_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFIVE_SECTION5_START -void fire_fifthZone_SECTION5() -{ - const int sizeOfSection = ZONEFIVE_SECTION5_END - ZONEFIVE_SECTION5_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFIVE_SECTION5_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION5_START + thisFlame] = color; - } - #endif - - #if ZONEFIVE_SECTION5_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION5_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFIVE_SECTION6_START -void fire_fifthZone_SECTION6() -{ - const int sizeOfSection = ZONEFIVE_SECTION6_END - ZONEFIVE_SECTION6_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFIVE_SECTION6_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION6_START + thisFlame] = color; - } - #endif - - #if ZONEFIVE_SECTION6_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION6_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFIVE_SECTION7_START -void fire_fifthZone_SECTION7() -{ - const int sizeOfSection = ZONEFIVE_SECTION7_END - ZONEFIVE_SECTION7_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFIVE_SECTION7_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION7_START + thisFlame] = color; - } - #endif - - #if ZONEFIVE_SECTION7_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION7_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFIVE_SECTION8_START -void fire_fifthZone_SECTION8() -{ - const int sizeOfSection = ZONEFIVE_SECTION8_END - ZONEFIVE_SECTION8_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFIVE_SECTION8_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION8_START + thisFlame] = color; - } - #endif - - #if ZONEFIVE_SECTION8_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION8_END - thisFlame] = color; - } - #endif - } -} -#endif - -#ifdef ZONEFIVE_SECTION9_START -void fire_fifthZone_SECTION9() -{ - const int sizeOfSection = ZONEFIVE_SECTION9_END - ZONEFIVE_SECTION9_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONEFIVE_SECTION9_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION9_START + thisFlame] = color; - } - #endif - - #if ZONEFIVE_SECTION9_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - fifthZone[ZONEFIVE_SECTION9_END - thisFlame] = color; - } - #endif - } -} -#endif - -#endif - -/***************** sixthZone Animations ****************************************/ -/***************** sixthZone Animations ****************************************/ -/***************** sixthZone Animations ****************************************/ -/***************** sixthZone Animations ****************************************/ -/***************** sixthZone Animations ****************************************/ - -#if ZONESIX == 1 - -void Ripple_sixthZone() -{ - for (int i = 0; i < SIXTHZONE_LEDS; i++) - { - sixthZone[i] = CRGB((red2/75), (green2/75), (blue2/75)); - } - switch (step_sixthZone) - { - case -1: - center_sixthZone = random16(SIXTHZONE_LEDS); - step_sixthZone = 0; - break; - case 0: - sixthZone[center_sixthZone] = CRGB(red1, green1, blue1); - step_sixthZone ++; - break; - case 12: - step_sixthZone = -1; - break; - default: // Middle of the ripples. - sixthZone[(center_sixthZone + step_sixthZone + SIXTHZONE_LEDS) % SIXTHZONE_LEDS] += CRGB((red1/(step_sixthZone * 5)), (green1/(step_sixthZone * 5)), (blue1/(step_sixthZone * 5))); - sixthZone[(center_sixthZone - step_sixthZone + SIXTHZONE_LEDS) % SIXTHZONE_LEDS] += CRGB((red1/(step_sixthZone * 5)), (green1/(step_sixthZone * 5)), (blue1/(step_sixthZone * 5))); - step_sixthZone ++; - break; - } -} - -void RGB_sixthZone() -{ - if(startPosition < 6) - { - fadeToBlackBy( sixthZone, SIXTHZONE_LEDS, 80); - for(int pixel = startPosition+1; pixel < SIXTHZONE_LEDS; pixel+=6) - { - if(pixel <= SIXTHZONE_LEDS) - { - sixthZone[pixel] = CRGB(red1,green1,blue1); - } - } - for(int pixel = startPosition+3; pixel < SIXTHZONE_LEDS; pixel+=6) - { - if(pixel <= SIXTHZONE_LEDS) - { - sixthZone[pixel] = CRGB(red2,green2,blue2); - } - } - for(int pixel = startPosition+5; pixel < SIXTHZONE_LEDS; pixel+=6) - { - if(pixel <= SIXTHZONE_LEDS) - { - sixthZone[pixel] = CRGB(red3,green3,blue3); - } - } - } - if(startPosition == 1) - { - sixthZone[0]=CRGB(red3,green3,blue3); - } - if(startPosition == 2) - { - sixthZone[1]=CRGB(red3,green3,blue3); - } - if(startPosition == 3) - { - sixthZone[2]=CRGB(red3,green3,blue3); - sixthZone[0]=CRGB(red2,green2,blue2); - } - if(startPosition == 4) - { - sixthZone[3]=CRGB(red3,green3,blue3); - sixthZone[1]=CRGB(red2,green2,blue2); - } - if(startPosition == 5) - { - sixthZone[4]=CRGB(red3,green3,blue3); - sixthZone[2]=CRGB(red2,green2,blue2); - sixthZone[0]=CRGB(red1,green1,blue1); - } -} - -void ColorGlitter_sixthZone( fract8 chanceOfGlitter) -{ - fadeToBlackBy( sixthZone, SIXTHZONE_LEDS, 2); - if(startPosition == 0) - { - if( random8() < chanceOfGlitter) - { - sixthZone[ random16(SIXTHZONE_LEDS) ] += CRGB::Red; - } - } - if(startPosition == 1) - { - if( random8() < chanceOfGlitter) - { - sixthZone[ random16(SIXTHZONE_LEDS) ] += CRGB::Orange; - } - } - if(startPosition == 2) - { - if( random8() < chanceOfGlitter) - { - sixthZone[ random16(SIXTHZONE_LEDS) ] += CRGB::Yellow; - } - } - if(startPosition == 3) - { - if( random8() < chanceOfGlitter) - { - sixthZone[ random16(SIXTHZONE_LEDS) ] += CRGB::Green; - } - } - if(startPosition == 4) - { - if( random8() < chanceOfGlitter) - { - sixthZone[ random16(SIXTHZONE_LEDS) ] += CRGB::Blue; - } - } - if(startPosition == 5) - { - if( random8() < chanceOfGlitter) - { - sixthZone[ random16(SIXTHZONE_LEDS) ] += CRGB::Violet; - } - } -} - -void SingleRace_sixthZone() -{ - fadeToBlackBy( sixthZone, SIXTHZONE_LEDS, 1); - int pos = beatsin16( raceSpeed, 0, SIXTHZONE_LEDS); - if(pos > previousLED_sixthZone) - { - sixthZone[pos] = CRGB(red1,green1,blue1); - previousLED_sixthZone = pos; - } - if(pos < previousLED_sixthZone) - { - sixthZone[pos] = CRGB(red2,green2,blue2); - previousLED_sixthZone = pos; - } -} - - void Crash_sixthZone() -{ - fadeToBlackBy( sixthZone, SIXTHZONE_LEDS, 15); - #ifdef ZONESIX_SECTION1_START - int pos_SECTION1 = beatsin16( raceSpeed, 0, (ZONESIX_SECTION1_END - ZONESIX_SECTION1_START) ); - sixthZone[ZONESIX_SECTION1_START + pos_SECTION1] = CRGB(red1,green1,blue1); - sixthZone[ZONESIX_SECTION1_END - pos_SECTION1] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONESIX_SECTION2_START - int pos_SECTION2 = beatsin16( raceSpeed, 0, (ZONESIX_SECTION2_END - ZONESIX_SECTION2_START) ); - sixthZone[ZONESIX_SECTION2_START + pos_SECTION2] = CRGB(red2,green2,blue2); - sixthZone[ZONESIX_SECTION2_END - pos_SECTION2] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONESIX_SECTION3_START - int pos_SECTION3 = beatsin16( raceSpeed, 0, (ZONESIX_SECTION3_END - ZONESIX_SECTION3_START) ); - sixthZone[ZONESIX_SECTION3_START + pos_SECTION3] = CRGB(red1,green1,blue1); - sixthZone[ZONESIX_SECTION3_END - pos_SECTION3] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONESIX_SECTION4_START - int pos_SECTION4 = beatsin16( raceSpeed, 0, (ZONESIX_SECTION4_END - ZONESIX_SECTION4_START) ); - sixthZone[ZONESIX_SECTION4_START + pos_SECTION4] = CRGB(red2,green2,blue2); - sixthZone[ZONESIX_SECTION4_END - pos_SECTION4] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONESIX_SECTION5_START - int pos_SECTION5 = beatsin16( raceSpeed, 0, (ZONESIX_SECTION5_END - ZONESIX_SECTION5_START) ); - sixthZone[ZONESIX_SECTION5_START + pos_SECTION5] = CRGB(red1,green1,blue1); - sixthZone[ZONESIX_SECTION5_END - pos_SECTION5] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONESIX_SECTION6_START - int pos_SECTION6 = beatsin16( raceSpeed, 0, (ZONESIX_SECTION6_END - ZONESIX_SECTION6_START) ); - sixthZone[ZONESIX_SECTION6_START + pos_SECTION6] = CRGB(red2,green2,blue2); - sixthZone[ZONESIX_SECTION6_END - pos_SECTION6] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONESIX_SECTION7_START - int pos_SECTION7 = beatsin16( raceSpeed, 0, (ZONESIX_SECTION7_END - ZONESIX_SECTION7_START) ); - sixthZone[ZONESIX_SECTION7_START + pos_SECTION7] = CRGB(red1,green1,blue1); - sixthZone[ZONESIX_SECTION7_END - pos_SECTION7] = CRGB(red2,green2,blue2); - #endif - - #ifdef ZONESIX_SECTION8_START - int pos_SECTION8 = beatsin16( raceSpeed, 0, (ZONESIX_SECTION8_END - ZONESIX_SECTION8_START) ); - sixthZone[ZONESIX_SECTION8_START + pos_SECTION8] = CRGB(red2,green2,blue2); - sixthZone[ZONESIX_SECTION8_END - pos_SECTION8] = CRGB(red1,green1,blue1); - #endif - - #ifdef ZONESIX_SECTION9_START - int pos_SECTION9 = beatsin16( raceSpeed, 0, (ZONESIX_SECTION9_END - ZONESIX_SECTION9_START) ); - sixthZone[ZONESIX_SECTION9_START + pos_SECTION9] = CRGB(red1,green1,blue1); - sixthZone[ZONESIX_SECTION9_END - pos_SECTION9] = CRGB(red2,green2,blue2); - #endif - -} - -void Rainbow_sixthZone() -{ - fill_rainbow( sixthZone, SIXTHZONE_LEDS, gHue, numberOfRainbows); -} - -void Blocked_sixthZone() -{ - fadeToBlackBy( sixthZone, SIXTHZONE_LEDS, 2); - for( int mark = 0; mark < SIXTHZONE_LEDS; mark+=30) - { - for( int i = 0; i < 9; i++) - { - if(startPosition == 0 || startPosition == 1) + } + #endif + + #if ZONEFOUR == 1 { - if(i+mark <= SIXTHZONE_LEDS) - { - sixthZone[i+mark] = CRGB(red1,green1,blue1); - } - if(i+10+mark <= SIXTHZONE_LEDS) - { - sixthZone[i+10+mark] = CRGB(red2,green2,blue2); - } - if(i+20+mark <= SIXTHZONE_LEDS) - { - sixthZone[i+20+mark] = CRGB(red3,green3,blue3); - } + fourthZone[ random16(FOURTHZONE_LEDS) ] = CRGB(redG, greenG, blueG); } - if(startPosition == 2 || startPosition == 3) + #endif + + #if ZONEFIVE == 1 { - if(i+mark <= SIXTHZONE_LEDS) - { - sixthZone[i+mark] = CRGB(red2,green2,blue2); - } - if(i+10+mark <= SIXTHZONE_LEDS) - { - sixthZone[i+10+mark] = CRGB(red3,green3,blue3); - } - if(i+20+mark <= SIXTHZONE_LEDS) - { - sixthZone[i+20+mark] = CRGB(red1,green1,blue1); - } + fifthZone[ random16(FIFTHZONE_LEDS) ] = CRGB(redG, greenG, blueG); } - if(startPosition == 4 || startPosition == 5) + #endif + + #if ZONESIX == 1 { - if(i+mark <= SIXTHZONE_LEDS) - { - sixthZone[i+mark] = CRGB(red3,green3,blue3); - } - if(i+10+mark <= SIXTHZONE_LEDS) - { - sixthZone[i+10+mark] = CRGB(red1,green1,blue1); - } - if(i+20+mark <= SIXTHZONE_LEDS) - { - sixthZone[i+20+mark] = CRGB(red2,green2,blue2); - } + sixthZone[ random16(SIXTHZONE_LEDS) ] = CRGB(redG, greenG, blueG); } + #endif } } } -void BPM_sixthZone() +void setupZones() { - if((red1*2) > (green1 + blue1)) - { - CRGBPalette16 palette_sixthZone = LavaColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < SIXTHZONE_LEDS; i++) - { - sixthZone[i] = ColorFromPalette(palette_sixthZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((green1*2) > (red1 + blue1)) - { - CRGBPalette16 palette_sixthZone = ForestColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < SIXTHZONE_LEDS; i++) - { - sixthZone[i] = ColorFromPalette(palette_sixthZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((blue1*2) > (green1 + red1)) - { - CRGBPalette16 palette_sixthZone = CloudColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < SIXTHZONE_LEDS; i++) - { - sixthZone[i] = ColorFromPalette(palette_sixthZone, gHue+(i*2), beat-gHue+(i*10)); - } - } - if((blue1*2) == (green1 + red1)) - { - CRGBPalette16 palette_sixthZone = PartyColors_p; - uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); - for( int i = 0; i < SIXTHZONE_LEDS; i++) - { - sixthZone[i] = ColorFromPalette(palette_sixthZone, gHue+(i*2), beat-gHue+(i*10)); - } - } -} + #if ZONEONE == 1 + FastLED.addLeds(firstZone, FIRSTZONE_LEDS); + timer.setTimeout(10000, chase, (void *)0); + #endif -void Twinkle_sixthZone() -{ - fadeToBlackBy( sixthZone, SIXTHZONE_LEDS, 80); - for( int i = 0; i < SIXTHZONE_LEDS-5; i+=5) - { - if(i <= SIXTHZONE_LEDS) - { - if (random8() > twinkleChance) - { - sixthZone[i] = CRGB( red1, green1, blue1); - } - else - { - sixthZone[i] = CRGB( 150, 100, 40); - } - } - } + #if ZONETWO == 1 + FastLED.addLeds(secondZone, SECONDZONE_LEDS); + timer.setTimeout(10000, chase, (void *)1); + #endif + + #if ZONETHREE == 1 + FastLED.addLeds(thirdZone, THIRDZONE_LEDS); + timer.setTimeout(10000, chase, (void *)2); + #endif + + #if ZONEFOUR == 1 + FastLED.addLeds(fourthZone, FOURTHZONE_LEDS); + timer.setTimeout(10000, chase, (void *)3); + #endif + + #if ZONEFIVE == 1 + FastLED.addLeds(fifthZone, FIFTHZONE_LEDS); + timer.setTimeout(10000, chase, (void *)4); + #endif + + #if ZONESIX == 1 + FastLED.addLeds(sixthZone, SIXTHZONE_LEDS); + timer.setTimeout(10000, chase, (void *)5); + #endif } -void Eyes_sixthZone() + +void locator_Move() { - unsigned int chance = random8(); - if( chance > eyeChance) + if(locatorLED <= maxLEDs) { - unsigned int eye = random16(SIXTHZONE_LEDS); - sixthZone[eye] = CRGB(red1,green1,blue1); - sixthZone[eye-4] = CRGB(red1,green1,blue1); + String temp_str = String(locatorLED); + temp_str.toCharArray(MQTT_locatorLED, temp_str.length() + 1); + client.publish(USER_MQTT_CLIENT_NAME"/locator", MQTT_locatorLED); + locatorLED++; } - if( chance > 39) + else { - fadeToBlackBy( sixthZone, SIXTHZONE_LEDS, 10); + locatorLED = 0; + } + for (byte i = 0; i < 6; i = i + 1) { + if(zoneEffects[i] != "LED_Locator") + { + return; + } } + timer.setTimeout(locatorDelay, locator_Move); } -void Solid_sixthZone() -{ - fill_solid(sixthZone, SIXTHZONE_LEDS, CRGB(red1, green1, blue1)); -} -void Locator_sixthZone() -{ - if(locatorLED <= SIXTHZONE_LEDS) - { - fill_solid(sixthZone, SIXTHZONE_LEDS, CRGB::Black); - sixthZone[locatorLED]=CRGB(red1, green1, blue1); - } + +/***************** SETUP FUNCTION ****************************************/ + + +void setup() { + Serial.begin(115200); + calculateMax(); + setupZones(); + FastLED.setDither( 0 ); + WiFi.setSleepMode(WIFI_NONE_SLEEP); + WiFi.mode(WIFI_STA); + setup_wifi(); + client.setServer(mqtt_server, mqtt_port); + client.setCallback(callback); + ArduinoOTA.setHostname(USER_MQTT_CLIENT_NAME); + ArduinoOTA.begin(); + + gPal = HeatColors_p; + + timer.setTimeout(120000, checkIn); } -#ifdef ZONESIX_SECTION1_START -void fire_sixthZone_SECTION1() -{ - static byte heat[ZONESIX_SECTION1_END - ZONESIX_SECTION1_START]; - for( int i = 0; i < ZONESIX_SECTION1_END - ZONESIX_SECTION1_START; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / ZONESIX_SECTION1_END - ZONESIX_SECTION1_START) + 2)); - } - for( int k= ZONESIX_SECTION1_END - ZONESIX_SECTION1_START - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) +/***************** MAIN LOOP ****************************************/ + + +void loop() +{ + if (!client.connected()) { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); + reconnect(); } - for( int j = 0; j < ZONESIX_SECTION1_END - ZONESIX_SECTION1_START; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (ZONESIX_SECTION1_END - ZONESIX_SECTION1_START -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONESIX_SECTION1_START_FIRE == 1 - if(thisFlame <= ZONESIX_SECTION1_END - ZONESIX_SECTION1_START ) - { - sixthZone[ZONESIX_SECTION1_START + thisFlame] = color; - } - #endif - - #if ZONESIX_SECTION1_END_FIRE == 1 - if(thisFlame <= ZONESIX_SECTION1_END - ZONESIX_SECTION1_START ) + client.loop(); + + bool canUpdate = true; + for (byte i = 0; i < 6; i = i + 1) { + if (showZoneLights[i] == true) { - sixthZone[ZONESIX_SECTION1_END - thisFlame] = color; + canUpdate = false; } - #endif } -} -#endif - -#ifdef ZONESIX_SECTION2_START -void fire_sixthZone_SECTION2() -{ - const int sizeOfSection = ZONESIX_SECTION2_END - ZONESIX_SECTION2_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) + + if(canUpdate == true) { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); + ArduinoOTA.handle(); } + timer.run(); + EVERY_N_MILLISECONDS( 20 ) { gHue++; } + updateColorsEnabled(); + choosePattern(); - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONESIX_SECTION2_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - sixthZone[ZONESIX_SECTION2_START + thisFlame] = color; - } - #endif - - #if ZONESIX_SECTION2_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - sixthZone[ZONESIX_SECTION2_END - thisFlame] = color; - } - #endif - } + #if ZONEONE == 1 + FastLED[0].showLeds(zoneBrightness[0]); + #endif + + #if ZONETWO == 1 + FastLED[1].showLeds(zoneBrightness[1]); + #endif + + #if ZONETHREE == 1 + FastLED[2].showLeds(zoneBrightness[2]); + #endif + + #if ZONEFOUR == 1 + FastLED[3].showLeds(zoneBrightness[3]); + #endif + + #if ZONEFIVE == 1 + FastLED[4].showLeds(zoneBrightness[4]); + #endif + + #if ZONESIX == 1 + FastLED[5].showLeds(zoneBrightness[5]); + #endif + } -#endif -#ifdef ZONESIX_SECTION3_START -void fire_sixthZone_SECTION3() -{ - const int sizeOfSection = ZONESIX_SECTION3_END - ZONESIX_SECTION3_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - for( int k= sizeOfSection - 1; k >= 2; k--) +/***************** Animation Functions ****************************************/ + +int Ripple(CRGB zone[], int ledCount, int zoneCenter, int zoneStep) +{ + for (int i = 0; i < ledCount; i++) { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) + zone[i] = CRGB((red2/75), (green2/75), (blue2/75)); + } + switch (zoneStep) { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); + case -1: + zoneCenter = random16(ledCount); + zoneStep = 0; + break; + case 0: + zone[zoneCenter] = CRGB(red1, green1, blue1); + zoneStep ++; + break; + case 12: + zoneStep = -1; + break; + default: // Middle of the ripples. + zone[(zoneCenter + zoneStep + ledCount) % ledCount] += CRGB((red1/(zoneStep * 5)), (green1/(zoneStep * 5)), (blue1/(zoneStep * 5))); + zone[(zoneCenter - zoneStep + ledCount) % ledCount] += CRGB((red1/(zoneStep * 5)), (green1/(zoneStep * 5)), (blue1/(zoneStep * 5))); + zoneStep ++; + break; } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONESIX_SECTION3_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - sixthZone[ZONESIX_SECTION3_START + thisFlame] = color; - } - #endif - - #if ZONESIX_SECTION3_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) + return zoneStep; +} + +void rGB(CRGB zone[], int zoneLEDS, uint8_t startPosition) +{ + int squenceLength = colorsEnabled*2; + if(startPosition < squenceLength) + { + fadeToBlackBy( zone, zoneLEDS, 80); + for(int skip = 1; skip < squenceLength; skip+=2) { - sixthZone[ZONESIX_SECTION3_END - thisFlame] = color; + for(int pixel = startPosition+skip; pixel < zoneLEDS; pixel+=squenceLength) + { + if(pixel <= zoneLEDS) + { + int currentColor = ((skip+1)/2)-1; + zone[pixel] = availableColors[currentColor]; + } + } } - #endif + } + + int colorIndex = colorsEnabled-1; + for(int pos = startPosition-1; pos >= 0; pos-=2) + { + zone[pos] = availableColors[colorIndex]; + colorIndex--; } } -#endif -#ifdef ZONESIX_SECTION4_START -void fire_sixthZone_SECTION4() +void ColorGlitter(CRGB zone[], int zoneLEDS, fract8 chanceOfGlitter, uint8_t startPosition) { - const int sizeOfSection = ZONESIX_SECTION4_END - ZONESIX_SECTION4_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) + fadeToBlackBy( zone, zoneLEDS, 2); + if(startPosition == 0) { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); + if( random8() < chanceOfGlitter) + { + zone[ random16(zoneLEDS) ] += CRGB::Red; + } } - - for( int k= sizeOfSection - 1; k >= 2; k--) + if(startPosition == 1) { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; + if( random8() < chanceOfGlitter) + { + zone[ random16(zoneLEDS) ] += CRGB::Orange; + } } - if( random8() < SPARKING ) + if(startPosition == 2) { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); + if( random8() < chanceOfGlitter) + { + zone[ random16(zoneLEDS) ] += CRGB::Yellow; + } } - for( int j = 0; j < sizeOfSection; j++) + if(startPosition == 3) { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONESIX_SECTION4_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) + if( random8() < chanceOfGlitter) { - sixthZone[ZONESIX_SECTION4_START + thisFlame] = color; + zone[ random16(zoneLEDS) ] += CRGB::Green; } - #endif - - #if ZONESIX_SECTION4_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) + } + if(startPosition == 4) + { + if( random8() < chanceOfGlitter) { - sixthZone[ZONESIX_SECTION4_END - thisFlame] = color; + zone[ random16(zoneLEDS) ] += CRGB::Blue; } - #endif } + if(startPosition == 5) + { + if( random8() < chanceOfGlitter) + { + zone[ random16(zoneLEDS) ] += CRGB::Violet; + } + } } -#endif -#ifdef ZONESIX_SECTION5_START -void fire_sixthZone_SECTION5() +int SingleRace(CRGB zone[], int zoneLEDS, int previousZoneLED, int raceSpeed) { - const int sizeOfSection = ZONESIX_SECTION5_END - ZONESIX_SECTION5_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) - { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } - - for( int k= sizeOfSection - 1; k >= 2; k--) + fadeToBlackBy( zone, zoneLEDS, 1); + int pos = beatsin16( raceSpeed, 0, zoneLEDS); + if(pos > previousZoneLED) { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; + zone[pos] = CRGB(red1,green1,blue1); } - if( random8() < SPARKING ) + if(pos < previousZoneLED) { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); + zone[pos] = CRGB(red2,green2,blue2); } - for( int j = 0; j < sizeOfSection; j++) + return pos; +} + +void Crash(CRGB zone[], int zoneLEDS, int sectionStart, int sectionEnd, int raceSpeed) +{ + int pos = beatsin16( raceSpeed, 0, (sectionEnd - sectionStart) ); + zone[sectionStart + pos] = CRGB(red1,green1,blue1); + zone[sectionEnd - pos] = CRGB(red2,green2,blue2); +} + +void Rainbow(CRGB zone[], int zoneLEDS, uint8_t numberOfRainbows) +{ + fill_rainbow( zone, zoneLEDS, gHue, numberOfRainbows); +} + +void Blocked(CRGB zone[], int zoneLEDS, uint8_t startPosition) +{ + fadeToBlackBy( zone, zoneLEDS, 2); + uint8_t startColorIndex = map(startPosition, 0, (colorsEnabled*2)-1, 0, colorsEnabled-1); + + for( int mark = 0; mark < zoneLEDS; mark+=(colorsEnabled*10)) //repeat color block sequence { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONESIX_SECTION5_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - sixthZone[ZONESIX_SECTION5_START + thisFlame] = color; - } - #endif - - #if ZONESIX_SECTION5_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) + for( int i = 0; i < 9; i++) // repeat for each pixel in color block size { - sixthZone[ZONESIX_SECTION5_END - thisFlame] = color; + for(int blockNum = 0; blockNum < (colorsEnabled*10); blockNum+=10) //set one of each color in each block + { + if((i+blockNum+mark) <= zoneLEDS) + { + zone[i+blockNum+mark] = availableColors[startColorIndex]; + if(startColorIndex < colorsEnabled-1) + { + startColorIndex++; + } + else + { + startColorIndex = 0; + } + } + } } - #endif } } -#endif -#ifdef ZONESIX_SECTION6_START -void fire_sixthZone_SECTION6() +void BPM(CRGB zone[], int zoneLEDS, int BeatsPerMinute) { - const int sizeOfSection = ZONESIX_SECTION6_END - ZONESIX_SECTION6_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) + if((red1*2) > (green1 + blue1)) { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); + CRGBPalette16 palette = LavaColors_p; + uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); + for( int i = 0; i < zoneLEDS; i++) + { + zone[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); + } } - - for( int k= sizeOfSection - 1; k >= 2; k--) + if((green1*2) > (red1 + blue1)) { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; + CRGBPalette16 palette = ForestColors_p; + uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); + for( int i = 0; i < zoneLEDS; i++) + { + zone[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); + } } - if( random8() < SPARKING ) + if((blue1*2) > (green1 + red1)) { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); + CRGBPalette16 palette = CloudColors_p; + uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); + for( int i = 0; i < zoneLEDS; i++) + { + zone[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); + } } - for( int j = 0; j < sizeOfSection; j++) + if((blue1*2) == (green1 + red1)) { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONESIX_SECTION6_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - sixthZone[ZONESIX_SECTION6_START + thisFlame] = color; - } - #endif - - #if ZONESIX_SECTION6_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) + CRGBPalette16 palette = PartyColors_p; + uint8_t beat = beatsin16( BeatsPerMinute, 64, 255); + for( int i = 0; i < zoneLEDS; i++) { - sixthZone[ZONESIX_SECTION6_END - thisFlame] = color; - } - #endif + zone[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); + } } } -#endif -#ifdef ZONESIX_SECTION7_START -void fire_sixthZone_SECTION7() +void Twinkle(CRGB zone[], int zoneLEDS, int twinkleChance) { - const int sizeOfSection = ZONESIX_SECTION7_END - ZONESIX_SECTION7_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) + fadeToBlackBy( zone, zoneLEDS, 80); + for( int i = 0; i < zoneLEDS-5; i+=5) { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); - } + if(i <= zoneLEDS) + { + if (random8() > twinkleChance) + { + zone[i] = CRGB( red1, green1, blue1); + } + else + { + zone[i] = CRGB( 150, 100, 40); + } + } + } +} - for( int k= sizeOfSection - 1; k >= 2; k--) +void Eyes(CRGB zone[], int zoneLEDS, int eyeChance) +{ + unsigned int chance = random8(); + if( chance > eyeChance) { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; + unsigned int eye = random16(zoneLEDS); + zone[eye] = CRGB(red1,green1,blue1); + zone[eye-4] = CRGB(red1,green1,blue1); } - if( random8() < SPARKING ) + if( chance > 39) { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); + fadeToBlackBy( zone, zoneLEDS, 10); } - for( int j = 0; j < sizeOfSection; j++) +} + +void Solid(CRGB zone[], int zoneLEDS) +{ + fill_solid(zone, zoneLEDS, CRGB(red1, green1, blue1)); +} + +void Locator(CRGB zone[], int zoneLEDS) +{ + if(locatorLED <= zoneLEDS) { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONESIX_SECTION7_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - sixthZone[ZONESIX_SECTION7_START + thisFlame] = color; - } - #endif - - #if ZONESIX_SECTION7_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - sixthZone[ZONESIX_SECTION7_END - thisFlame] = color; - } - #endif + fill_solid(zone, zoneLEDS, CRGB::Black); + zone[locatorLED]=CRGB(red1, green1, blue1); } } -#endif -#ifdef ZONESIX_SECTION8_START -void fire_sixthZone_SECTION8() +void fire(CRGB zone[], byte heat[], int sectionStart, int sectionEnd, int fireStart, int fireEnd, int firesize) { - const int sizeOfSection = ZONESIX_SECTION8_END - ZONESIX_SECTION8_START; - static byte heat[sizeOfSection]; + int sizeOfSection = sectionEnd - sectionStart; for( int i = 0; i < sizeOfSection; i++) { heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); @@ -6659,70 +2435,172 @@ void fire_sixthZone_SECTION8() int thisFlame = ((pixelnumber * firesize)/100); - #if ZONESIX_SECTION8_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) + if(fireStart == 1 && thisFlame <= sizeOfSection) { - sixthZone[ZONESIX_SECTION8_START + thisFlame] = color; + zone[sectionStart + thisFlame] = color; } - #endif - #if ZONESIX_SECTION8_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) + if(fireEnd == 1 && thisFlame <= sizeOfSection ) { - sixthZone[ZONESIX_SECTION8_END - thisFlame] = color; + zone[sectionEnd - thisFlame] = color; } - #endif } } -#endif -#ifdef ZONESIX_SECTION9_START -void fire_sixthZone_SECTION9() +void heartbeat(CRGB zone[], int zoneLEDS, uint8_t startPosition) { + uint8_t beatIndex = map(startPosition, 0, (colorsEnabled*2)-1, 0, 5); + if(beatIndex == 1 || beatIndex == 3) { + fill_solid(zone, zoneLEDS, CRGB(red1, green1, blue1)); + } else { + fill_solid(zone, zoneLEDS, CRGB(red1/2, green1/2, blue1/2)); + } +} + +void traditionalSolid(CRGB zone[], int zoneLEDS) { - const int sizeOfSection = ZONESIX_SECTION9_END - ZONESIX_SECTION9_START; - static byte heat[sizeOfSection]; - for( int i = 0; i < sizeOfSection; i++) + uint8_t gap = 4; + for(int pixel = 0; pixel < zoneLEDS; pixel+= (gap*colorsEnabled)) { - heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / sizeOfSection) + 2)); + for(int color = 0; color < colorsEnabled; color++) + { + zone[pixel+(color*gap)] = availableColors[color]; + } } +} - for( int k= sizeOfSection - 1; k >= 2; k--) - { - heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; - } - if( random8() < SPARKING ) - { - int y = random8(7); - heat[y] = qadd8( heat[y], random8(160,255) ); - } - for( int j = 0; j < sizeOfSection; j++) - { - byte colorindex = scale8( heat[j], 240); - CRGB color = ColorFromPalette( gPal, colorindex); - int pixelnumber; - if( gReverseDirection ) { - pixelnumber = (sizeOfSection -1) - j; - } else { - pixelnumber = j; - } - int thisFlame = ((pixelnumber * firesize)/100); - - - #if ZONESIX_SECTION9_START_FIRE == 1 - if(thisFlame <= sizeOfSection ) +void fireworks(CRGB zone[], int zoneLEDS, Ball balls[], int fireworkCount, uint8_t chance) { + + const float ballVelocityDecay = 0.0036; + + for (uint8_t i = 0; i < fireworkCount; i++) { + // initialize if not loaded + if(!balls[i].loaded) { - sixthZone[ZONESIX_SECTION9_START + thisFlame] = color; + balls[i].position = -1; + balls[i].exploding = 0; + switch(random8(colorsEnabled)) + { + case 0: + balls[i].color = availableColors[0]; + break; + case 1: + balls[i].color = availableColors[1]; + break; + case 2: + balls[i].color = availableColors[2]; + break; + case 3: + balls[i].color = availableColors[3]; + break; + case 4: + balls[i].color = availableColors[4]; + break; + } + balls[i].reverse = random8(2) == 0; + balls[i].loaded = true; } - #endif - #if ZONESIX_SECTION9_END_FIRE == 1 - if(thisFlame <= sizeOfSection ) - { - sixthZone[ZONESIX_SECTION9_END - thisFlame] = color; + // launch firework + if(balls[i].position < 0 && random8() < chance) { + if(balls[i].reverse) + { + zone[zoneLEDS] += CHSV(0, 0, 128); + balls[i].position = zoneLEDS; + balls[i].velocity = -1.0; + } + else { + zone[0] += CHSV(0, 0, 128); + balls[i].position = 0; + balls[i].velocity = 1.0; + } + } + else if (balls[i].exploding < 1 && balls[i].position > 15 + && balls[i].position < zoneLEDS - 15 && random8(1,80) == 2) { + // detonate firework + balls[i].exploding = 1; + } + + // update + if (balls[i].position >= 0) { + uint8_t exploding = balls[i].exploding; + + if (exploding == 0) { + balls[i].position += balls[i].velocity; + balls[i].velocity -= ballVelocityDecay; + if (balls[i].position >= zoneLEDS) { + balls[i].velocity *= -1.0; + balls[i].position = zoneLEDS - 1; + } + else if (balls[i].position <= 0) { + balls[i].velocity = 1.0; + balls[i].position = 1; + } + } + + // draw + if (exploding == 0) { + zone[(uint8_t) balls[i].position] += CHSV(0, 0, 16); + } + else if (exploding == 1) { + zone[(uint8_t) balls[i].position] += CRGB::White; + balls[i].exploding++; + balls[i].velocity = 1; + balls[i].particlePosition = 50; + } + else if (exploding == 2) { + int16_t explosionPosition = balls[i].position; + int pos = map(balls[i].particlePosition, 50, 0, 1, 5); + int particles = 2; + if(pos > 3) { particles = 4; } + for (uint8_t j = 0; j < particles; j++) { + + int topPos = explosionPosition+(j*pos); + if(topPos <= zoneLEDS) + { + zone[topPos] = balls[i].color; + } + int bottomPos = explosionPosition-(j*pos); + if(bottomPos >= 0) + { + zone[bottomPos] = balls[i].color; + } + } + if( balls[i].particlePosition >= 0) + { + balls[i].particlePosition -= balls[i].velocity; + } + else + { + balls[i].exploding++; + } + if(balls[i].velocity > 0) + { + balls[i].velocity -= .01; + } + } + else { + balls[i].exploding = 0; + balls[i].position = -1; + balls[i].reverse = random8(2) == 0; + switch(random8(colorsEnabled)) + { + case 0: + balls[i].color = availableColors[0]; + break; + case 1: + balls[i].color = availableColors[1]; + break; + case 2: + balls[i].color = availableColors[2]; + break; + case 3: + balls[i].color = availableColors[3]; + break; + case 4: + balls[i].color = availableColors[4]; + break; + } + } } - #endif } } -#endif - -#endif diff --git a/README.md b/README.md index ddef65c..fb5334a 100644 --- a/README.md +++ b/README.md @@ -60,29 +60,46 @@ light: - Fire - Fill_Solid - Spooky_Eyes + - Heartbeat + - Fireworks + - Traditional - LED_Locator retain: true - platform: mqtt name: "Color 1" - command_topic: "[MQTT_CLIENT_ID]/ColorPower" - state_topic: "[MQTT_CLIENT_ID]/powerState" + command_topic: "[MQTT_CLIENT_ID]/ColorSelector/1/Toggle" + state_topic: "[MQTT_CLIENT_ID]/ColorSelector/1/ToggleState" rgb_command_topic: "[MQTT_CLIENT_ID]/color1" rgb_state_topic: "[MQTT_CLIENT_ID]/color1State" retain: true - platform: mqtt name: "Color 2" - command_topic: "[MQTT_CLIENT_ID]/ColorPower" - state_topic: "[MQTT_CLIENT_ID]/powerState" + command_topic: "[MQTT_CLIENT_ID]/ColorSelector/2/Toggle" + state_topic: "[MQTT_CLIENT_ID]/ColorSelector/2/ToggleState" rgb_command_topic: "[MQTT_CLIENT_ID]/color2" rgb_state_topic: "[MQTT_CLIENT_ID]/color2State" retain: true - platform: mqtt name: "Color 3" - command_topic: "[MQTT_CLIENT_ID]/ColorPower" - state_topic: "[MQTT_CLIENT_ID]/powerState" + command_topic: "[MQTT_CLIENT_ID]/ColorSelector/3/Toggle" + state_topic: "[MQTT_CLIENT_ID]/ColorSelector/3/ToggleState" rgb_command_topic: "[MQTT_CLIENT_ID]/color3" rgb_state_topic: "[MQTT_CLIENT_ID]/color3State" retain: true + - platform: mqtt + name: "Color 4" + command_topic: "[MQTT_CLIENT_ID]/ColorSelector/4/Toggle" + state_topic: "[MQTT_CLIENT_ID]/ColorSelector/4/ToggleState" + rgb_command_topic: "[MQTT_CLIENT_ID]/color4" + rgb_state_topic: "[MQTT_CLIENT_ID]/color4State" + retain: true + - platform: mqtt + name: "Color 5" + command_topic: "[MQTT_CLIENT_ID]/ColorSelector/5/Toggle" + state_topic: "[MQTT_CLIENT_ID]/ColorSelector/5/ToggleState" + rgb_command_topic: "[MQTT_CLIENT_ID]/color5" + rgb_state_topic: "[MQTT_CLIENT_ID]/color5State" + retain: true - platform: mqtt name: "Glitter" state_topic: "[MQTT_CLIENT_ID]/glitter/state" @@ -105,6 +122,64 @@ light: white_value_state_topic: "[MQTT_CLIENT_ID]/lightningChanceState" white_value_scale: 500 retain: true + - platform: mqtt + name: "Holiday Lights Zone 1" + command_topic: "[MQTT_CLIENT_ID]/power/Zone1" + state_topic: "[MQTT_CLIENT_ID]/powerState/Zone1" + brightness_command_topic: "[MQTT_CLIENT_ID]/brightness/Zone1" + brightness_state_topic: "[MQTT_CLIENT_ID]/brightnessState/Zone1" + brightness_scale: 255 + white_value_command_topic: "[MQTT_CLIENT_ID]/modifier/Zone1" + white_value_state_topic: "[MQTT_CLIENT_ID]/modifierState/Zone1" + white_value_scale: 500 + effect_command_topic: "[MQTT_CLIENT_ID]/effect/Zone1" + effect_state_topic: "[MQTT_CLIENT_ID]/effectState/Zone1" + effect_list: + - Color_Chase + - Color_Glitter + - Single_Race + - Double_Crash + - Rainbow + - Blocked_Colors + - BPM + - Twinkle + - Fire + - Fill_Solid + - Spooky_Eyes + - Heartbeat + - Fireworks + - Traditional + - LED_Locator + retain: true + - platform: mqtt + name: "Holiday Lights Zone 2" + command_topic: "[MQTT_CLIENT_ID]/power/Zone2" + state_topic: "[MQTT_CLIENT_ID]/powerState/Zone2" + brightness_command_topic: "[MQTT_CLIENT_ID]/brightness/Zone2" + brightness_state_topic: "[MQTT_CLIENT_ID]/brightnessState/Zone2" + brightness_scale: 255 + white_value_command_topic: "[MQTT_CLIENT_ID]/modifier/Zone2" + white_value_state_topic: "[MQTT_CLIENT_ID]/modifierState/Zone2" + white_value_scale: 500 + effect_command_topic: "[MQTT_CLIENT_ID]/effect/Zone2" + effect_state_topic: "[MQTT_CLIENT_ID]/effectState/Zone2" + effect_list: + - Color_Chase + - Color_Glitter + - Single_Race + - Double_Crash + - Rainbow + - Blocked_Colors + - BPM + - Twinkle + - Fire + - Fill_Solid + - Spooky_Eyes + - Heartbeat + - Fireworks + - Traditional + - LED_Locator + retain: true ``` ## OpenHAB Support