Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sketch_esp8266/sketch_esp8266.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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();


Expand Down
92 changes: 92 additions & 0 deletions sketch_esp8266/src/Patterns/IntelliTectPattern.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#ifndef IntelliTectPattern_h
#define IntelliTectPattern_h

#include "Arduino.h"
#include <FastLED.h>
#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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Scope the switch cases to keep the sketch buildable

When the ESP8266 sketch is compiled as C++, this case 1 label jumps past the initialized center and ringWidth variables declared under case 0, which GCC rejects with “jump to case label crosses initialization.” Enclose each case body in braces (as the earlier implementation did) or move those declarations outside the switch; otherwise the firmware cannot be built.

Useful? React with 👍 / 👎.

{
// 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
3 changes: 2 additions & 1 deletion sketch_esp8266/src/Patterns/Patterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -13,5 +13,6 @@
#include "./Seahawks.h"
//#include "./RandomColorCircle.h" // not working yet
#include "./ReverseRainbowStarBurst.h"
#include "./IntelliTectPattern.h"

#endif