Skip to content

2D effect bugfixes for large panels - #5908

Open
softhack007 wants to merge 16 commits into
mainfrom
fix_2deffects_large
Open

softhack007 wants to merge 16 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)
  • GEQ peak indicators now initialize correctly and stay within the display bounds (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, Metaballs, Polar Lights, Sun Radiation, Crazy Bees, Ghost Rider, and DNA Spiral render more reliably across different matrix sizes.
    • Effects have improved scaling, positioning, animation speed, movement, and coordinate accuracy on larger displays.
    • Animation timing is more consistent during extended operation, timer rollovers, and sudden time changes.
  • Bug Fixes

    • Graphic Equalizer peak indicators now initialize correctly and stay within the display bounds.

* 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
📥 Commits

Reviewing files that changed from the base of the PR and between 4ed45da and 70a8bff.

📒 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; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 66
  • GitHub Check: wled_build / Build Environments (esp32p4_16MB)
  • GitHub Check: wled_build / Build Environments (esp32c3dev_qio)
  • GitHub Check: wled_build / Build Environments (esp32S3_wroom2)
  • GitHub Check: wled_build / Build Environments (lolin_s2_mini)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_compat)
  • GitHub Check: wled_build / Build Environments (esp32dev_hub75_forum_pinout)
  • GitHub Check: wled_build / Build Environments (esp32_eth_V4)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_16MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_4MB_qspi_hub75)
  • GitHub Check: wled_build / Build Environments (esp32dev_debug)
  • GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_qspi)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_16MB_opi_hub75)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_none)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32c5dev_8MB_qspi)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full)
  • GitHub Check: wled_build / Build Environments (usermods)
  • GitHub Check: wled_build / Build Environments (nodemcuv2_compat)
  • GitHub Check: wled_build / Build Environments (esp32_eth)
  • GitHub Check: wled_build / Build Environments (esp32dev_V4)
  • GitHub Check: wled_build / Build Environments (esp32_wrover)
  • GitHub Check: wled_build / Build Environments (esp32dev)
  • GitHub Check: wled_build / Build Environments (esp32c5dev)
  • GitHub Check: wled_build / Build Environments (esp32c3dev)
  • GitHub Check: wled_build / Build Environments (nodemcuv2)
  • GitHub Check: wled_build / Build Environments (esp32c6dev_4MB)
  • GitHub Check: wled_build / Build Environments (esp8266_2m)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_compat)
  • GitHub Check: wled_build / Build Environments (usermods)
  • GitHub Check: wled_build / Build Environments (esp32_eth_V4)
  • GitHub Check: wled_build / Build Environments (esp32S3_wroom2)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_4MB_qspi_hub75)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_16MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32p4_16MB)
  • GitHub Check: wled_build / Build Environments (esp32c5dev_8MB_qspi)
  • GitHub Check: wled_build / Build Environments (esp32dev)
  • GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_compat)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_16MB_opi_hub75)
  • GitHub Check: wled_build / Build Environments (esp32_wrover)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32c5dev)
  • GitHub Check: wled_build / Build Environments (esp32dev_hub75_forum_pinout)
  • GitHub Check: wled_build / Build Environments (esp32c3dev)
  • GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
  • GitHub Check: wled_build / Build Environments (nodemcuv2_compat)
  • GitHub Check: wled_build / Build Environments (esp32c3dev_qio)
  • GitHub Check: wled_build / Build Environments (esp32c6dev_4MB)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_none)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_qspi)
  • GitHub Check: wled_build / Build Environments (esp8266_2m)
  • GitHub Check: wled_build / Build Environments (lolin_s2_mini)
  • GitHub Check: wled_build / Build Environments (esp32_eth)
  • GitHub Check: wled_build / Build Environments (nodemcuv2)
  • GitHub Check: wled_build / Build Environments (esp32dev_debug)
  • GitHub Check: wled_build / Build Environments (esp32dev_V4)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_compat)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full)
  • GitHub Check: wled_build / Test cdata.js
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (c-cpp)
  • GitHub Check: Analyze (actions)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: wled_build / Test cdata.js
🧰 Additional context used
📚 Code guidelines: 4
docs/hardening.instructions.md — configured
AGENTS.md — configured
docs/cpp.instructions.md — configured
.github/agent-build.instructions.md — auto-discovered
📓 Path-based instructions: 5
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.in...

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

Files:

  • wled00/FX.cpp
Source excerpt: Follow the existing style in the file you are editing Source excerpt: Avoid unexplained "magic numbers".

📄 CodeRabbit inference engine (AGENTS.md)

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/cpp.instructions.md)

Files:

  • wled00/FX.cpp
🧠 Learnings: 1
📓 Common learnings
Learnt from: softhack007
URL: https://github.com/wled/WLED/pull/5908

Timestamp: 2026-10-16T19:16:35.445Z
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.
🔇 Additional comments: 1
wled00/FX.cpp: 1

5244-5245: LGTM!

Also applies to: 5254-5280, 5333-5333, 5843-5843, 5862-5862, 5962-5979, 6071-6076, 6087-6087, 6099-6104, 6194-6194, 6204-6210, 6225-6235, 6297-6297, 6311-6313, 6703-6703, 7629-7636, 7655-7656, 7667-7667

Walkthrough

The changes add lerp16by8 and update coordinate arithmetic, matrix scaling, bump calculations, and timer handling in several 2D effects. Crazy Bees now supports up to eight bees. GEQ startup and bar-height handling also change.

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 widens coordinate, line-step, and transformed-coordinate calculations in Colored Bursts, DNA Spiral, and Plasma Rotozoomer.
2D effect matrix scaling
wled00/FX.cpp
Metaballs selects distance calibration from matrix dimensions. Polar Lights derives rendering parameters and pixel progression from dimensions. Sun Radiation uses signed bump values, dimension-based magnification and downscaling, and widened gradient calculations.
Time-based effect state
wled00/FX.cpp
Increases the Crazy Bees limit from five to eight, widens bee state and random coordinates, and updates Crazy Bees and Ghost Rider timer handling for immediate redraws, timebase jumps, and rollover.
GEQ startup and bar bounds
wled00/FX.cpp
GEQ clears its bar-height array and display on startup, uses elapsed time for ripple scheduling, clamps mapped bar heights, and bounds peak drawing.

Priority: ➖ Normal

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

Change: Bug fix

Suggested reviewers: dedehai

Merge Risk: 🔵 Low · up to 70a8b

The new interpolation helper should return the full unsigned 16-bit range before larger-coordinate callers rely on it; current effects remain otherwise low risk.

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 14 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
Title check Passed The title clearly summarizes the main change: bug fixes for 2D effects on large panels. It is concise and specific.
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
  • 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

This comment was marked as off-topic.

@coderabbitai

This comment was marked as off-topic.

avoid an effect freeze when the effect was temporarily suspended, for example by switching the "power icon" off and then back on
prevent effect freeze when timebase jumps
coderabbitai[bot]

This comment was marked as resolved.

prevents short delay before effects start
coderabbitai[bot]

This comment was marked as resolved.

Future support:For dimension 257, cols - 1 or rows - 1 is 256, but beatsin8_t converts highest to uint8_t, producing 0.

Limit cols/rows to the maximum that beatsin8_t can handle.

NB: replacing beatsin8_t with beatsin16_t did not work, it makes the effect look very boring.
@softhack007

softhack007 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member Author

Side note: width = 256 or height = 256 is possible in theorie, however it confuses the 2D panel setup. Event width=255 and offset=1 won't work; it causes 2D setup and segments to fall back into 1D mode.

This might get fixed in a future PR. For now the practical upper limit in WLED is 240 pixels width/height, achievable with 15 ws2812b panels of 16x16 pixels (alternatively: 7 HUB75 panels 32x32 = 224), or with a mixed HUB75/ws2812b panel setup.

Comment thread wled00/FX.cpp
unsigned _scale = map(SEGMENT.intensity, 0, 255, 30, adjScale);
int _speed = map(SEGMENT.speed, 0, 255, 128, 16);
// size-based mappings
float adjustHeight = (rows > 32) ? 12.0f * 32.0f / rows : mapf(max(rows, 8), 8, 32, 28, 12); // scale height inversely for larger matrices

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I dont think there is a need to use floats here, should be doable in integer math

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

challenge accepted - I'll see if the inner loop can be done with adjustHeight converted to fixed point

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@DedeHai answer is yes - we can get rid of the float calculation in the inner loop. I need to test my idea on hardware, and will push something tomorrow.

* prevent timing overflow
* prevent barHeight overflow
* hide "peak dot" when peak fade = 255
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