Skip to content

Fixed "Flow Stripe" FX and added palette support#4723

Merged
netmindz merged 1 commit intowled:mainfrom
DedeHai:Flow_Stripe_FX_fix
Jun 14, 2025
Merged

Fixed "Flow Stripe" FX and added palette support#4723
netmindz merged 1 commit intowled:mainfrom
DedeHai:Flow_Stripe_FX_fix

Conversation

@DedeHai
Copy link
Copy Markdown
Collaborator

@DedeHai DedeHai commented Jun 10, 2025

the effect has been broken ever since it was added in 0.14.
The original effect used a float, the ported effect does not. The division therefore always results in 0 or 1 and thus not displaying any color spectrum but the same color for all LEDs.
Multiplying before the division fixes the effect back to its original intended look.

Added palette support while I was at it.

Summary by CodeRabbit

  • Bug Fixes

    • Improved color calculation in the "Flow Stripe" effect for smoother and more accurate visual transitions.
  • Enhancements

    • Updated the "Flow Stripe" effect to use palette-based colors, allowing for richer and more customizable color schemes.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jun 10, 2025

Walkthrough

The "Flow Stripe" effect function in the FX.cpp file was updated to correct the calculation of a variable for color scaling and to change the method of setting pixel colors from a direct HSV value to a palette-based lookup. The effect's metadata string was also updated to reflect palette usage.

Changes

File(s) Change Summary
wled00/FX.cpp Fixed variable calculation in "Flow Stripe" effect, switched to palette-based color setting, and updated effect metadata string.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00d1fcc and ea231cb.

📒 Files selected for processing (1)
  • wled00/FX.cpp (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
wled00/FX.cpp (2)
wled00/FX.h (24)
  • t (898-898)
  • t (898-898)
  • t (905-905)
  • i (539-539)
  • i (539-539)
  • i (540-540)
  • i (540-540)
  • i (654-654)
  • i (654-654)
  • i (692-692)
  • i (692-692)
  • i (694-694)
  • i (695-695)
  • i (695-695)
  • i (696-696)
  • i (696-696)
  • i (698-698)
  • i (699-699)
  • i (889-889)
  • c (703-703)
  • c (764-764)
  • c (764-764)
  • c (895-895)
  • c (895-895)
wled00/wled_math.cpp (2)
  • sin8_t (82-86)
  • sin8_t (82-82)
⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: wled_build / Build Environments (esp32s3_4M_qspi)
  • GitHub Check: wled_build / Build Environments (esp32_wrover)
  • GitHub Check: wled_build / Build Environments (usermods)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_8MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32s3dev_16MB_opi)
  • GitHub Check: wled_build / Build Environments (esp32c3dev)
  • GitHub Check: wled_build / Build Environments (nodemcuv2_compat)
  • GitHub Check: wled_build / Build Environments (esp32dev_V4)
  • GitHub Check: wled_build / Build Environments (esp32dev)
  • GitHub Check: wled_build / Build Environments (lolin_s2_mini)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_compat)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_compat)
  • GitHub Check: wled_build / Build Environments (esp32_eth)
  • GitHub Check: wled_build / Build Environments (esp8266_2m_160)
  • GitHub Check: wled_build / Build Environments (nodemcuv2)
  • GitHub Check: wled_build / Build Environments (nodemcuv2_160)
  • GitHub Check: wled_build / Build Environments (esp8266_2m)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full_160)
  • GitHub Check: wled_build / Build Environments (esp01_1m_full)
🔇 Additional comments (4)
wled00/FX.cpp (4)

4820-4820: LGTM - Appropriate attribution added.

The comment update correctly credits the contributor who fixed the issue.


4828-4828: Excellent fix for the integer division precision issue.

This change correctly addresses the core problem described in the PR. The original code (abs((int)i - hl) / hl) * 127 performed integer division first, causing most values to become 0 when abs(i - hl) < hl. The fixed version ((abs((int)i - hl) * 127) / hl) multiplies first, preserving precision and restoring the intended color spectrum effect.

The mathematical correctness is sound - for typical LED strip lengths, overflow is not a concern since the maximum value would be around 50000 * 127 = 6,350,000, which fits comfortably in an int.


4832-4832: Palette support integration looks correct.

The transition from direct HSV color CHSV(b + hue, 255, 255) to palette-based lookup SEGMENT.color_from_palette(b + hue, false, true, 3) properly adds the requested palette functionality while maintaining the same hue calculation logic.


4837-4837: Metadata string correctly updated for palette support.

The addition of pal=11 and the ! flag appropriately indicates that this effect now supports palettes, matching the code changes made to the effect implementation.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netmindz netmindz merged commit 728b1e8 into wled:main Jun 14, 2025
21 checks passed
@DedeHai DedeHai deleted the Flow_Stripe_FX_fix branch June 28, 2025 07:31
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.

2 participants