-
Notifications
You must be signed in to change notification settings - Fork 0
enhancement: Adds IntelliTect celebration pattern #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mszym99
wants to merge
4
commits into
main
Choose a base branch
from
matthew/enhancement-IntelliTectPattern
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fc0c6d8
enhancement: add IntelliTect celebration pattern
af161de
incremental work include comments following pattern format
9d2d537
enhancement: add black to IntelliTect pattern rings
be3012f
fix: GCC "jump to case label crosses initialization" error
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | ||
| { | ||
| // 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the ESP8266 sketch is compiled as C++, this
case 1label jumps past the initializedcenterandringWidthvariables declared undercase 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 👍 / 👎.