Repository navigation
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Implement and register Firefly Garden usermods/user_fx/user_fx.cpp |
Adds particle state and motion helpers, initializes and updates particles, and renders additive palette-colored glows. The effect uses a static fallback for non-2D segments, dimensions above 128 pixels, and particle allocation failures. It registers the effect with its metadata. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Feature
Suggested reviewers: bobloeffler68, dedehai
Merge Risk: 
Minimal · up to 7ea6c
-
This adds an optional 2D effect to the user_fx usermod and falls back to a static output on unsupported setups. No unresolved merge-blocking risk remains in the supplied review evidence.
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title 'New user effect: Firefly Garden 2D' matches the main change. The raw summary says the PR adds a Firefly Garden 2D matrix effect registered in usermods/user_fx/user_fx.cpp, and the objectives describe the same optional 2D effect. The title is short, specific, and free of file lists or vague terms.
-
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.
sudo-kk
left a comment
There was a problem hiding this comment.
Addressed all four findings:
- Firefly particles now initialize after allocation recovery.
- Brightness comparisons use wider arithmetic to avoid uint8_t wraparound.
- Palette hue mapping is disabled because hue is already a palette index.
- Firefly Garden registration now appends after existing effects to preserve effect IDs.
|
looks good in general, a few notes:
|
|
Thanks for the feedback. I added comments describing the effect controls, Q8.8 particle positions, SEGENV allocation, palette behavior, and 2D scope. I reduced position storage to int16_t; its range is sufficient for 64×64 coordinates, though I haven’t visually tested a 64×64 matrix. The diamond shape was unintended. It came from Manhattan distance and is now replaced with a circular falloff. The particle positions retain fractional-pixel movement, but rendering on a 16×16 LED matrix still rounds to whole pixels, so some visible stepping remains. I built the updated branch with esp32dev_user_fx and tested on my physical 16×16 matrix. I also tested 8×16 and 8×32 WLED layouts using the same hardware. I have not tested a physical 64×64 matrix. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Fixed: dimensions above 128 now fall back to static. |
|
Stored velocities are now speed-independent base values, with speed scaling applied during movement rather than rescaling in place. This preserves effect state and eliminates truncation decay across Speed changes when Drift=0 |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
@coderabbitai would visual quality be impacted if the effect uses Q12.4 (or Q10.6) instead of Q8.8? |
|
Tip For best results, initiate chat on the files or code changes. Analysis chain
The effect currently draws each glow at a whole-pixel position (
If each movement update is truncated to the position format, the effect can run slower than intended. For example, at minimum Speed, with an 80 ms update and a velocity component of 127, the current calculation advances that component by 25/256 pixel. Equivalent truncated updates would advance it by 6/64 in Q10.6 or 1/16 in Q12.4. The Q12.4 update is about 36% smaller in this example. Keeping fractional remainders between updates would reduce this error. Both formats can store coordinates for a 256×256 matrix in signed I would try Q10.6 first, then compare movement at low and high Speed with Drift set to zero and nonzero. A 64×64 virtual matrix would also help check the larger layout requested in review. Learnings used
You are interacting with an AI system. |
| for (int8_t offsetY = -glowRadius; offsetY <= glowRadius; offsetY++) { | ||
| for (int8_t offsetX = -glowRadius; offsetX <= glowRadius; offsetX++) { | ||
| const int distanceSquared = offsetX * offsetX + offsetY * offsetY; | ||
| const int glowRadiusSquared = glowRadius * glowRadius; |
There was a problem hiding this comment.
for code clarity (and maybe for a small speedup), you could move calculation of glowRadiusSqared (line 207) and fallOffRange (line 214) out of the pixel loop, i.e. before line 204. The values do not depend on offsetX or offsetY.
| for (int8_t offsetY = -glowRadius; offsetY <= glowRadius; offsetY++) { | ||
| for (int8_t offsetX = -glowRadius; offsetX <= glowRadius; offsetX++) { | ||
| const int distanceSquared = offsetX * offsetX + offsetY * offsetY; | ||
| const int glowRadiusSquared = glowRadius * glowRadius; |
There was a problem hiding this comment.
🤔 at higher glow settings, your fireflies look more like diamonds/spiked balls. In case you want them to be soft-edge circles, try
const int glowRadiusSquared = max(1, glowRadius * glowRadius + glowRadius -1); // (r+0.5)^2 = r*r + r + 0.25;For unsigned integers, glowRadius * glowRadius + glowRadius is mathematicially equivalent to (glowRadius+0.5) ^2. It avoids the spikes and creates nicer circles. The -1 preserves the default look at glow=96.
|
Another small speedup would be to replace the loop variable types You can keep 8bit for the persistent fireFly state, as it reduces RAM usage. |
What it does
Adds an optional 2D “Firefly Garden” effect to the
user_fxusermod. It displays glowing fireflies drifting around a matrix with adjustable speed, density, glow, and drift behavior.Additional references and context
No related issue.
How it works
The effect uses a bounded pool of 24 particles stored in
SEGENV.data. Each particle has a fixed-point position, velocity, color hue, brightness, and twinkle target. Motion is updated at a controlled interval, while brightness fades toward randomly changing targets. The effect uses the selected WLED palette and falls back to static output on non-2D setups.Testing and Validation
user_fxusermod.Checklist
Summary by CodeRabbit