diff --git a/sketch_esp8266/sketch_esp8266.ino b/sketch_esp8266/sketch_esp8266.ino index 7c062f8..096af38 100644 --- a/sketch_esp8266/sketch_esp8266.ino +++ b/sketch_esp8266/sketch_esp8266.ino @@ -45,6 +45,7 @@ void setup() { _CelebrationPatterns[1] = new StarBurst(); _CelebrationPatterns[2] = new Seahawks(); _CelebrationPatterns[3] = new ReverseRainbowStarBurst(); + _CelebrationPatterns[4] = new IntelliTectPattern(); //_CelebrationPatterns[4] = new RandomColorCircle(); diff --git a/sketch_esp8266/src/Patterns/IntelliTectPattern.h b/sketch_esp8266/src/Patterns/IntelliTectPattern.h new file mode 100644 index 0000000..75cffae --- /dev/null +++ b/sketch_esp8266/src/Patterns/IntelliTectPattern.h @@ -0,0 +1,92 @@ +#ifndef IntelliTectPattern_h +#define IntelliTectPattern_h + +#include "Arduino.h" +#include +#include "../CelebrationPattern.h" +#include "../LedDisplayConf.h" +#include "../UtilityFunctions.h" + +class IntelliTectPattern : public CelebrationPattern +{ + private: + static const CRGB _IntelliTectBlue; + + public: + IntelliTectPattern() + { + m_speed = 20; + }; + + bool draw(CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP], bool someoneJustScored = false) + { + static uint8_t sequence = 0; + static uint8_t radius = 0; + static uint8_t pulseFrame = 0; + + // reset your pattern to play from the beginning if someoneJustScored + if (someoneJustScored) + { + sequence = 0; + radius = 0; + pulseFrame = 0; + } + + switch (sequence) + { + case 0: + { + // expanding rings of blue and white outward from center + FastLED.clear(); + const uint8_t center = NUM_LEDS_PER_STRIP / 2; + const uint8_t ringWidth = 4; + + for (uint8_t i = 0; i < NUM_LEDS_PER_STRIP; i++) + { + uint8_t dist = (i > center) ? (i - center) : (center - i); + if (dist <= radius) + { + uint8_t ring = (dist / ringWidth) % 3; + switch (ring) + { + case 0: leds[0][i] = _IntelliTectBlue; break; + case 1: leds[0][i] = CRGB::White; break; + case 2: leds[0][i] = CRGB::Black; break; + } + } + } + + DuplicateToOtherStrips(leds); + radius++; + + // transition to pulse when rings reach the ends + if (radius > center) + { + sequence = 1; + pulseFrame = 0; + } + break; + } + + case 1: + { + // full IntelliTect blue pulse + for (uint8_t s = 0; s < NUM_STRIPS; s++) + for (uint8_t i = 0; i < NUM_LEDS_PER_STRIP; i++) + leds[s][i] = _IntelliTectBlue; + + pulseFrame++; + // hold the pulse then return true + if (pulseFrame > 12) + return true; + break; + } + } + + return false; + } +}; + +const CRGB IntelliTectPattern::_IntelliTectBlue = CRGB(31, 112, 185); + +#endif diff --git a/sketch_esp8266/src/Patterns/Patterns.h b/sketch_esp8266/src/Patterns/Patterns.h index 841d830..b51e2e6 100644 --- a/sketch_esp8266/src/Patterns/Patterns.h +++ b/sketch_esp8266/src/Patterns/Patterns.h @@ -3,7 +3,7 @@ #ifndef Patterns_h #define Patterns_h -#define NUM_PATTERNS 4 +#define NUM_PATTERNS 5 // You need to import Arduino.h to write a custom library #include "Arduino.h" @@ -13,5 +13,6 @@ #include "./Seahawks.h" //#include "./RandomColorCircle.h" // not working yet #include "./ReverseRainbowStarBurst.h" +#include "./IntelliTectPattern.h" #endif \ No newline at end of file