-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
add multiple meteors and ability to slow meteors #5758
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
163d455
7ab24be
7f639d7
81bb733
0be0d7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2379,13 +2379,15 @@ void mode_meteor() { | |
| if (SEGLEN <= 1) FX_FALLBACK_STATIC; | ||
| if (!SEGENV.allocateData(SEGLEN)) FX_FALLBACK_STATIC; //allocation failed | ||
| const bool meteorSmooth = SEGMENT.check3; | ||
| const bool slow = SEGMENT.check2; | ||
| byte* trail = SEGENV.data; | ||
|
|
||
| const unsigned meteorSize = 1 + SEGLEN / 20; // 5% | ||
| const unsigned numMeteors = 1 + (SEGMENT.custom1 >> 5); // 1..8 meteors | ||
| uint16_t meteorstart; | ||
| if(meteorSmooth) meteorstart = map((SEGENV.step >> 6 & 0xFF), 0, 255, 0, SEGLEN -1); | ||
| else { | ||
| unsigned counter = strip.now * ((SEGMENT.speed >> 2) + 8); | ||
| unsigned counter = strip.now * (slow ? (SEGMENT.speed >> 4) + 1 : (SEGMENT.speed >> 2) + 8); | ||
| meteorstart = (counter * SEGLEN) >> 16; | ||
| } | ||
|
|
||
|
|
@@ -2417,29 +2419,32 @@ void mode_meteor() { | |
| } | ||
| } | ||
|
|
||
| // draw meteor | ||
| for (unsigned j = 0; j < meteorSize; j++) { | ||
| unsigned index = (meteorstart + j) % SEGLEN; | ||
| if(meteorSmooth) { | ||
| trail[index] = max; | ||
| uint32_t col = SEGMENT.check1 ? SEGMENT.color_from_palette(index, true, false, 0, trail[index]) : SEGMENT.color_from_palette(trail[index], false, true, 255); | ||
| // draw meteor(s), evenly spaced along the strip | ||
| for (unsigned m = 0; m < numMeteors; m++) { | ||
| unsigned start = (meteorstart + m * SEGLEN / numMeteors) % SEGLEN; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai i'm seeing a jump in the example shown by the PR author. Please check if the math is correct here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- Focused source ---'
ast-grep outline wled00/FX.cpp --match mode_meteor --view expanded
sed -n '2365,2460p' wled00/FX.cpp
printf '%s\n' '--- PR diff for Meteor ---'
git diff --unified=80 HEAD^ HEAD -- wled00/FX.cpp | sed -n '/void mode_meteor()/,/static const char _data_FX_MODE_METEOR/p'
printf '%s\n' '--- Spacing and wrap simulation ---'
python3 - <<'PY'
cases = [(10, 3), (17, 3), (17, 6), (30, 8), (60, 8), (144, 8)]
for length, count in cases:
print(f"\nSEGLEN={length}, numMeteors={count}")
previous = None
for meteorstart in range(length):
starts = [((meteorstart + m * length // count) % length) for m in range(count)]
ordered = sorted(starts)
gaps = [ordered[i + 1] - ordered[i] for i in range(count - 1)]
gaps.append(length + ordered[0] - ordered[-1])
if previous is not None:
moved = sorted((starts[i] - previous[i]) % length for i in range(count))
if moved != [1] * count:
print(f" discontinuity from {meteorstart - 1} to {meteorstart}: {previous} -> {starts}, movement={moved}")
break
previous = starts
print(f" starts at phase 0: {[m * length // count for m in range(count)]}")
print(f" circular gaps: {gaps}")
PYLength of output: 9010
The code does produce unequal spacing when For example, with Therefore, the pattern has fixed one-pixel spacing differences. This can look like a jump in a visual recording, especially on a short segment. Exact equal spacing is impossible on the integer pixel grid for this case. I do not find a wraparound or arithmetic discontinuity in this line. The reported effect is likely the unavoidable rounding distribution. You are interacting with an AI system.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The jump may also be due to my failed attempt at trying to get a nice looping gif.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| for (unsigned j = 0; j < meteorSize; j++) { | ||
| unsigned index = (start + j) % SEGLEN; | ||
| if(meteorSmooth) { | ||
| trail[index] = max; | ||
| uint32_t col = SEGMENT.check1 ? SEGMENT.color_from_palette(index, true, false, 0, trail[index]) : SEGMENT.color_from_palette(trail[index], false, true, 255); | ||
| SEGMENT.setPixelColor(index, col); | ||
| } | ||
| else{ | ||
| int idx = 255; | ||
| int i = trail[index] = max; | ||
| if (!SEGMENT.check1) { | ||
| i = map(index,0,SEGLEN,0,max); | ||
| idx = 0; | ||
| } | ||
| uint32_t col = SEGMENT.color_from_palette(i, false, false, idx, 255); // full brightness | ||
| SEGMENT.setPixelColor(index, col); | ||
| } | ||
| else{ | ||
| int idx = 255; | ||
| int i = trail[index] = max; | ||
| if (!SEGMENT.check1) { | ||
| i = map(index,0,SEGLEN,0,max); | ||
| idx = 0; | ||
| } | ||
| uint32_t col = SEGMENT.color_from_palette(i, false, false, idx, 255); // full brightness | ||
| SEGMENT.setPixelColor(index, col); | ||
| } | ||
| } | ||
|
|
||
| SEGENV.step += SEGMENT.speed +1; | ||
| SEGENV.step += (slow ? SEGMENT.speed >> 3 : SEGMENT.speed) + 1; | ||
| } | ||
| static const char _data_FX_MODE_METEOR[] PROGMEM = "Meteor@!,Trail,,,,Gradient,,Smooth;;!;1"; | ||
| static const char _data_FX_MODE_METEOR[] PROGMEM = "Meteor@!,Trail,# of Meteors,,,Gradient,Slow,Smooth;;!;1;c1=0"; | ||
|
|
||
|
|
||
| //Railway Crossing / Christmas Fairy lights | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.