Skip to content

add multiple meteors and ability to slow meteors - #5758

Open
benjamw wants to merge 2 commits into
wled:mainfrom
benjamw:meteor-additions
Open

add multiple meteors and ability to slow meteors#5758
benjamw wants to merge 2 commits into
wled:mainfrom
benjamw:meteor-additions

Conversation

@benjamw

@benjamw benjamw commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

I really like the "Meteor" effect, and wanted to have multiple meteors going across my house. So I added a slider that adds meteors (up to 8, default 1).

The meteors also moved very quickly across my house, so I added a checkbox function to slow the meteors down (default off).

Built and tested locally and works well.

AI was used to assist me coding this.

Summary by CodeRabbit

Summary

  • New Features

    • Enhanced the Meteor effect to render multiple evenly spaced meteors.
    • Added a Slow mode for a more relaxed animation pace.
    • Introduced parameters to control # of Meteors and Slow.
  • Improvements

    • Updated meteor timing and trail behavior for smoother results and consistent rendering across both smooth and non-smooth display modes.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 784a7b87-f821-400f-a106-aed0856cc1b5

📥 Commits

Reviewing files that changed from the base of the PR and between 163d455 and 7ab24be.

📒 Files selected for processing (1)
  • wled00/FX.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • wled00/FX.cpp

Walkthrough

The Meteor effect now supports multiple evenly spaced meteors and a slow mode. Segment controls determine meteor count and timing, while rendering, trail updates, frame progression, and effect metadata reflect the new options.

Changes

Meteor effect updates

Layer / File(s) Summary
Meteor controls and rendering
wled00/FX.cpp
Adds configurable meteor count and slow mode, updates smooth and non-smooth timing, renders evenly spaced meteor trails, adjusts frame progression, and exposes the new controls in effect metadata.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested labels: effect

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: Meteor now supports multiple meteors and an optional slow mode.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
wled00/FX.cpp (1)

2427-2433: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Format the new meteor loop to match WLED C++ style.

The added block uses if(meteorSmooth) / else{ and over-indents the smooth branch. Please format it with if ( / } else { and 2-space indentation.

As per coding guidelines, wled00/**/*.{cpp,h} requires 2-space indentation, spaces after control-flow keywords, and K&R braces.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@wled00/FX.cpp` around lines 2427 - 2433, Reformat the meteorSmooth
conditional in the meteor loop to follow WLED C++ style: use “if (meteorSmooth)”
and “} else {”, with the smooth branch and its statements indented by two
spaces. Preserve the existing logic and expressions unchanged.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@wled00/FX.cpp`:
- Around line 2427-2433: Reformat the meteorSmooth conditional in the meteor
loop to follow WLED C++ style: use “if (meteorSmooth)” and “} else {”, with the
smooth branch and its statements indented by two spaces. Preserve the existing
logic and expressions unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d7448f14-eaf4-4d42-967b-8f625fd7517c

📥 Commits

Reviewing files that changed from the base of the PR and between 8db3d7a and 163d455.

📒 Files selected for processing (1)
  • wled00/FX.cpp

@DedeHai

DedeHai commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

thanks, sounds like good addition - similar to multi comet. You can also try PS Sparkler, it is different though but also can do something similar.

can you show what it looks like? there is an FX recorder tool in my wled tools repo.

@benjamw

benjamw commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author
FX_076(2)

Palette: Fire
Effect Speed: 23
Trail: 245
# of Meteors: 128
Gradient: on
Slow: on
Smooth: off

FX_076(3)

Original for comparison:
FX_076(4)

Comment thread wled00/FX.cpp
if(meteorSmooth) {
// draw meteor(s), evenly spaced along the strip
for (unsigned m = 0; m < numMeteors; m++) {
unsigned start = (meteorstart + m * SEGLEN / numMeteors) % SEGLEN;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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}")
PY

Length of output: 9010


@softhack007, I checked the position math.

(meteorstart + m * SEGLEN / numMeteors) % SEGLEN does not create a frame-to-frame jump. Each meteor advances by the same amount as meteorstart. The modulo also wraps a meteor from the last pixel to pixel zero.

The code does produce unequal spacing when SEGLEN is not divisible by numMeteors. Integer division rounds each offset down.

For example, with SEGLEN == 60 and numMeteors == 8, the gaps are:

8, 7, 8, 7, 8, 7, 8, 7

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants