Skip to content

2D effect bugfixes for large panels - #5908

Open
softhack007 wants to merge 10 commits into
mainfrom
fix_2deffects_large
Open

softhack007 wants to merge 10 commits into
mainfrom
fix_2deffects_large

Conversation

@softhack007

@softhack007 softhack007 commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Fixes several problems that were identified in #5903

  • Crazy Bee: keep bees on track by avoiding int8 math; allow up to 8 bees (was 5)
  • DNA Spiral: fix effect freeze (infinite loop) when width >= 128
  • Colored Bursts: Use full panel when width >= 128
  • Rotozoomer: Use full panel when width >= 128
  • Polar Light: adjust scaling and timing to make it work on fixtures > 48x24 (same look on smaller sizes)
  • Sun Radiation: fix for undefined behaviour due to wild casting between byte and int8_t + bigger sun on larger panels (WLED-MM backport)

general improvements:

  • replaced abs8() with abs() where possible
  • added lerp16by8(uint16_t a, uint16_t b, uint8_t frac) to fastled-slim

AI assistance: nothing. Just my squishy bio-brains.

Summary by CodeRabbit

  • New Features
    • Crazy Bees can now display up to eight bees.
  • Improvements
    • Colored Bursts, DNA Spiral, Metaballs, Polar Lights, Sun Radiation, Crazy Bees, and Rotozoomer use more reliable calculations across different matrix sizes.
    • Metaballs and Sun Radiation adjust visual scaling to matrix dimensions.
    • Polar Lights adapts its scale, speed, and animation to matrix dimensions.

* Crazy Bee: keep bees on track by avoiding int8 math
* DNA Spiral: fix effect freeze when width >= 128
* Colored Bursts: Use full panel when width >= 128
* Rotozoomer: Use full panel when width >= 128
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d073d8a1-8817-409c-96c7-c0fe6bbd3a9d
📥 Commits

Reviewing files that changed from the base of the PR and between 11fd61a and c568015.

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

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 55
  • GitHub Check: wled_build / Build Environments (esp32dev_hub75_forum_pinout)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_16MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_none)
  • GitHub Check: wled_build / Build Environments (esp32S3_wroom2)
  • GitHub Check: wled_build / Build Environments (esp32c3dev)
  • GitHub Check: wled_build / Build Environments (esp32p4_16MB)
  • GitHub Check: wled_build / Build Environments (esp32c5dev)
  • GitHub Check: wled_build / Build Environments (esp32_wrover)
  • GitHub Check: wled_build / Build Environments (esp32c3dev_qio)
  • GitHub Check: wled_build / Build Environments (esp8266_2m)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_compat)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_4MB_qspi_hub75)
  • GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
  • GitHub Check: wled_build / Build Environments (usermods)
  • GitHub Check: wled_build / Build Environments (esp32c6dev_4MB)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_16MB_opi_hub75)
  • GitHub Check: wled_build / Build Environments (esp32dev_debug)
  • GitHub Check: wled_build / Build Environments (esp32_eth)
  • GitHub Check: wled_build / Build Environments (esp32c5dev_8MB_qspi)
  • GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
  • GitHub Check: wled_build / Build Environments (esp32_eth_V4)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_qspi)
  • GitHub Check: wled_build / Build Environments (esp32dev)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_opi)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_compat)
  • GitHub Check: wled_build / Build Environments (esp32dev_V4)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full)
  • GitHub Check: wled_build / Build Environments (lolin_s2_mini)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_qspi)
  • GitHub Check: wled_build / Build Environments (esp32dev)
  • GitHub Check: wled_build / Build Environments (esp32_wrover)
  • GitHub Check: wled_build / Build Environments (usermods)
  • GitHub Check: wled_build / Build Environments (esp32c3dev)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_none)
  • GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_compat)
  • GitHub Check: wled_build / Build Environments (nodemcuv2)
  • GitHub Check: wled_build / Build Environments (esp32dev_debug)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32p4_16MB)
  • GitHub Check: wled_build / Build Environments (esp32c5dev)
  • GitHub Check: wled_build / Build Environments (esp32c5dev_8MB_qspi)
  • GitHub Check: wled_build / Build Environments (lolin_s2_mini)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_4MB_qspi_hub75)
  • GitHub Check: wled_build / Build Environments (esp32S3_wroom2)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_16MB_opi_hub75)
  • GitHub Check: wled_build / Build Environments (esp32c6dev_4MB)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_compat)
  • GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
  • GitHub Check: wled_build / Build Environments (esp32dev_V4)
  • GitHub Check: wled_build / Build Environments (esp32c3dev_qio)
  • GitHub Check: wled_build / Build Environments (esp32_eth)
  • GitHub Check: wled_build / Build Environments (nodemcuv2_compat)
  • GitHub Check: wled_build / Build Environments (esp32_eth_V4)
  • GitHub Check: Analyze (c-cpp)
🧰 Additional context used
📚 Code guidelines: 3
docs/hardening.instructions.md — configured
.github/agent-build.instructions.md — auto-discovered
AGENTS.md — configured
📓 Path-based instructions: 4
Apply the WLED security hardening rules from docs/hardening.instructions.md, and consult docs/securecode.instructions.md when more details are needed for actionable recommendations.

⚙️ CodeRabbit configuration file

Files:

  • wled00/FX.cpp
Follow the C++ coding conventions documented in docs/cpp.instructions.md and the general project guidelines in AGENTS.md and .github/copilot-instructions.md.

⚙️ CodeRabbit configuration file

Files:

  • wled00/FX.cpp
Applicability reference: AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference See also: `.github/copilot-instructions.md`, `.github/agent-build.instructions.md`, `docs/cpp.instructions.md`, `docs/web.instructions.md`, `d...

📄 CodeRabbit inference engine (docs/hardening.instructions.md)

Files:

  • wled00/FX.cpp
Source excerpt: Avoid unexplained "magic numbers".

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • wled00/FX.cpp
🔇 Additional comments: 1
wled00/FX.cpp: 1

6193-6193: LGTM!

Also applies to: 6195-6195, 6198-6199, 6215-6216

Walkthrough

The changes add lerp16by8 and update arithmetic and dimension-based settings in several 2D effects. Crazy Bees now supports up to eight bees and uses wider position and target state.

Changes

2D effect arithmetic

Layer / File(s) Summary
Interpolation and coordinate arithmetic
wled00/src/dependencies/fastled_slim/fastled_slim.h, wled00/FX.cpp
Adds lerp16by8 and uses wider arithmetic for interpolation and coordinates in Colored Bursts, DNA Spiral, and Rotozoomer.
2D effect matrix scaling
wled00/FX.cpp
Metaballs selects distance calibration from the larger matrix dimension. Polar Lights derives settings from matrix dimensions and limits per-frame noise-counter advancement to 768. Sun Radiation uses signed bump-map values, dimension-based magnification and downscaling, and caps absolute gradient differences at 255.
Crazy Bees capacity and state
wled00/FX.cpp
Increases the bee limit from five to eight and widens bee positions, targets, deltas, signs, and error values.

Priority: ➖ Normal

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

Change: Bug fix

Suggested reviewers: dedehai

Merge Risk: 🔵 Low · up to c5680

The new interpolation helper can return an incorrect result when given larger 16-bit values, although its current caller uses only 8-bit values. This is a bounded risk; the reported Polar Lights timing regression does not occur at 32×24.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main changes: bug fixes for 2D effects on large panels.
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.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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[bot]

This comment was marked as resolved.

Comment thread wled00/FX.cpp
@softhack007 softhack007 assigned DedeHai and unassigned DedeHai Oct 15, 2026
@softhack007
softhack007 requested a review from DedeHai October 15, 2026 17:32
Comment thread wled00/FX.cpp Outdated
* adjusted scaling parameters to avoid going out-of-bounds
* limit effect speed on large panels (was depending on pixel count)
* parameter tuning for larger panels, to make the effect look similar to smaller sizes
* solves undefined behavior from mixing signed and unsigned math
* replace abs8() with abs()
* parameter tuning to create a bigger sun an large fixtures
* previous look preserved up to 32x32 pixels
Comment thread wled00/FX.cpp Outdated
the "black center" was never showing in larger panels => parameters tuned so the effect looks better on >32x32.
The values used come from experimenting - no idea how the math really works ....
coderabbitai[bot]

This comment was marked as resolved.

@softhack007

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

forgot to replace this - the inner loop should use pixelCount instead of SEGENV.step.
Slightly adjusted speedScale to compensate for _slower_ effect motion.
coderabbitai[bot]

This comment was marked as resolved.

@coderabbitai

This comment was marked as duplicate.

@softhack007

Copy link
Copy Markdown
Member Author

@coderabbitai for future PR's that touch 2D effects (fx.cpp or usermods), please remember to always check that the effect math is stable up to 256x256 pixels.

Consider 24x16, 32x24, 32x32, and 48x40 as typical 2D sizes when using ws2812b panels. HUB75 panels are typically 64x64, up to 4 panels can be chained for a larger fixture.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@softhack007 Thanks for the guidance. The review criteria are:

  • Check 2D effect math in wled00/FX.cpp and usermods for stability up to 256×256 pixels, including overflow, signedness, coordinate ranges, and pixel-count calculations.
  • Use 24×16, 32×24, 32×32, and 48×40 as typical WS2812B panel sizes.
  • Account for 64×64 HUB75 panels, with up to four panels chained into a larger fixture.

✏️ Learnings added
Learnt from: softhack007
URL: https://github.com/wled/WLED/pull/5908

Timestamp: 2026-10-16T19:16:35.377Z
Learning: For WLED C++ PRs that touch 2D effects in wled00/FX.cpp or usermods, always check that effect math remains stable for matrix dimensions up to 256×256 pixels. Review arithmetic overflow, signedness, coordinate ranges, and pixel-count calculations. Typical WS2812B panel sizes are 24×16, 32×24, 32×32, and 48×40. HUB75 panels are typically 64×64, and up to four panels can be chained into a larger fixture.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants