-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Added Chase Race Effect to WLED #4566
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
32dc661
Added Chase Race Effect to WLED
scattervideo 6fc2495
Updated based upon feedback from DedeHai and fixed typo.
scattervideo 74088fd
Removed extra alias function as requested per DedeHai.
scattervideo 6e667c9
Merge branch 'main' into add-new-effect
drdome 37ce66e
Removed the chase_race alias function
scattervideo f595010
Merge branch 'main' into add-new-effect
drdome 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 |
|---|---|---|
|
|
@@ -924,6 +924,49 @@ static uint16_t chase(uint32_t color1, uint32_t color2, uint32_t color3, bool do | |
| return FRAMETIME; | ||
| } | ||
|
|
||
| /** | ||
| * Chase_Race function to allow 3 colored bands to race along the LEDs with black between the colors. | ||
| * color1, color2, and color3 = colors of the three leaders in the race | ||
| */ | ||
|
|
||
| uint16_t chase_race(uint32_t color1, uint32_t color2, uint32_t color3) | ||
| { | ||
| uint16_t counter = strip.now * ((SEGMENT.speed >> 2) + 1); | ||
| uint16_t a = (counter * SEGLEN) >> 16; | ||
|
|
||
| // Use intensity setting to vary chase up to 1/2 string length | ||
| unsigned size = 1 + ((SEGMENT.intensity * SEGLEN) >> 10); | ||
| unsigned gap = 1 + size / 4; // Smaller black band size as a fraction of color size | ||
|
|
||
| // Calculate positions for each color band | ||
| uint16_t positions[] = { | ||
| a, // Start of color1 | ||
| (a + size) % SEGLEN, // End of color1 | ||
| (a + size + gap) % SEGLEN, // Start of color2 | ||
| (a + size * 2 + gap) % SEGLEN, // End of color2 | ||
| (a + size * 2 + gap * 2) % SEGLEN, // Start of color3 | ||
| (a + size * 3 + gap * 2) % SEGLEN // End of color3 | ||
| }; | ||
|
|
||
| // Define compact lambda for filling LED segments using modulo | ||
| auto fillSegment = [](uint16_t start, uint16_t end, uint32_t color) | ||
| { | ||
| for (unsigned count = 0; count < SEGLEN && count < end - start + (end < start ? SEGLEN : 0); count++) | ||
| { | ||
| SEGMENT.setPixelColor((start + count) % SEGLEN, color); | ||
| } | ||
| }; | ||
|
|
||
| // Set background to black | ||
| SEGMENT.fill(0); | ||
|
|
||
| // Fill the three color segments | ||
| fillSegment(positions[0], positions[1], color1); | ||
| fillSegment(positions[2], positions[3], color2); | ||
| fillSegment(positions[4], positions[5], color3); | ||
|
|
||
| return FRAMETIME; | ||
| } | ||
|
|
||
| /* | ||
| * Bicolor chase, more primary color. | ||
|
|
@@ -933,6 +976,14 @@ uint16_t mode_chase_color(void) { | |
| } | ||
| static const char _data_FX_MODE_CHASE_COLOR[] PROGMEM = "Chase@!,Width;!,!,!;!"; | ||
|
|
||
| /* | ||
| * Chase Race with 3 color strips | ||
| */ | ||
| uint16_t chase_race() | ||
|
||
| { | ||
| return chase_race(SEGCOLOR(0), SEGCOLOR(1), SEGCOLOR(2)); | ||
| } | ||
| static const char _data_FX_MODE_CHASE_RACE[] PROGMEM = "Chase Race@!,Width;!,!,!;!"; | ||
|
|
||
| /* | ||
| * Primary running followed by random color. | ||
|
|
@@ -10183,7 +10234,7 @@ void WS2812FX::setupEffectData() { | |
| addEffect(FX_MODE_MULTI_STROBE, &mode_multi_strobe, _data_FX_MODE_MULTI_STROBE); | ||
| addEffect(FX_MODE_BLINK_RAINBOW, &mode_blink_rainbow, _data_FX_MODE_BLINK_RAINBOW); | ||
| addEffect(FX_MODE_ANDROID, &mode_android, _data_FX_MODE_ANDROID); | ||
| addEffect(FX_MODE_CHASE_COLOR, &mode_chase_color, _data_FX_MODE_CHASE_COLOR); | ||
| addEffect(FX_MODE_CHASE_COLOR, &mode_chase_color, _data_FX_MODE_CHASE_COLOR); | ||
| addEffect(FX_MODE_CHASE_RANDOM, &mode_chase_random, _data_FX_MODE_CHASE_RANDOM); | ||
| addEffect(FX_MODE_CHASE_RAINBOW, &mode_chase_rainbow, _data_FX_MODE_CHASE_RAINBOW); | ||
| addEffect(FX_MODE_CHASE_FLASH, &mode_chase_flash, _data_FX_MODE_CHASE_FLASH); | ||
|
|
@@ -10193,6 +10244,7 @@ void WS2812FX::setupEffectData() { | |
| addEffect(FX_MODE_TRAFFIC_LIGHT, &mode_traffic_light, _data_FX_MODE_TRAFFIC_LIGHT); | ||
| addEffect(FX_MODE_COLOR_SWEEP_RANDOM, &mode_color_sweep_random, _data_FX_MODE_COLOR_SWEEP_RANDOM); | ||
| addEffect(FX_MODE_RUNNING_COLOR, &mode_running_color, _data_FX_MODE_RUNNING_COLOR); | ||
| addEffect(FX_MODE_CHASE_RACE, &chase_race, _data_FX_MODE_CHASE_RACE); | ||
| addEffect(FX_MODE_AURORA, &mode_aurora, _data_FX_MODE_AURORA); | ||
| addEffect(FX_MODE_RUNNING_RANDOM, &mode_running_random, _data_FX_MODE_RUNNING_RANDOM); | ||
| addEffect(FX_MODE_LARSON_SCANNER, &mode_larson_scanner, _data_FX_MODE_LARSON_SCANNER); | ||
|
|
@@ -10388,4 +10440,4 @@ addEffect(FX_MODE_PSFIRE1D, &mode_particleFire1D, _data_FX_MODE_PS_FIRE1D); | |
| addEffect(FX_MODE_PS1DSONICSTREAM, &mode_particle1Dsonicstream, _data_FX_MODE_PS_SONICSTREAM); | ||
| #endif // WLED_DISABLE_PARTICLESYSTEM1D | ||
|
|
||
| } | ||
| } | ||
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.
remove change