Skip to content

Conversation

@mxklb
Copy link
Contributor

@mxklb mxklb commented Nov 8, 2023

Using availDMXLen to choose to utilize white channel is messy because it has nothing to do with ability of the strip. It is the number of channels available in the E1.31/Artnet package. Additional this may lead to unexpected behavior if subsequent DMX start addresses for multiple WLED controllers shall be used.

The approach here is clear, if no white channel exist:

  • Single RGB -> 3 DMX channels
  • Single DRGB -> 4 DMX channels

And if white channel exists:

  • Single RGB(W) -> 4 DMX channels
  • Single DRGB(W) -> 5 DMX channels

So number of DMX channels for both modes is +1 if LEDs have white, else number of channels is as documented.

Note: Should be changed in documentation as well, shall be named Single RGB(W) and Single DRGB(W)

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of DMX data for LED strips with or without a white channel, ensuring correct color rendering in specific DMX modes.
    • Enhanced validation to prevent issues when DMX data length is insufficient for the configured channel setup.

@mxklb mxklb marked this pull request as draft November 8, 2023 23:32
@mxklb mxklb marked this pull request as ready for review November 8, 2023 23:54
@blazoncek
Copy link
Collaborator

Please re-base this PR to 0_15 branch.

@softhack007 softhack007 added this to the 0.15.0 candidate milestone Nov 11, 2023
Copy link
Collaborator

@blazoncek blazoncek left a comment

Choose a reason for hiding this comment

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

I do not use realtime data so cannot test this PR.
Still, as WLED allows realtime data to be displayed on main segment only, and main segment may not include white channel, it is mandatory to differentiate if the underlying canvas supports white properly.

Segment has light capabilities embedded (and recalculated on each change) and white channel presence can be determined by Segment::hasWhite() method.

Copy link
Collaborator

@blazoncek blazoncek left a comment

Choose a reason for hiding this comment

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

Seems ok but please add parentheses. 😄

@mxklb mxklb changed the base branch from main to 0_15 November 17, 2023 13:35
@mxklb
Copy link
Contributor Author

mxklb commented Nov 17, 2023

@blazoncek please check bdd667d

I think it could be faster when only iterating over differentiated length as well, shall I add these checks again?

@blazoncek
Copy link
Collaborator

IDK. I have very little knowledge about realtime apart from DDP implementation.
If you can, do some testing and make appropriate changes if necessary. When you think it is ok just say so and I'll merge.

@mxklb mxklb marked this pull request as draft November 18, 2023 14:27
@mxklb
Copy link
Contributor Author

mxklb commented Nov 18, 2023

I'll change back PR draft mode, when I've tested code changes with realtime DMX console e131 input.

@softhack007
Copy link
Member

softhack007 commented Jun 25, 2024

I'll change back PR draft mode, when I've tested code changes with realtime DMX console e131 input.

@mxklb did you make progress? This PR is in draft for 8 months now, are you still working on it?

mxklb force-pushed the e131-single branch from 0360497 to bdd667 7 months ago

PS: please don't force-push - it leads to many strange effects on github, including lost review comments.

@softhack007 softhack007 added the stale This issue will be closed soon because of prolonged inactivity label Jun 25, 2024
@mxklb
Copy link
Contributor Author

mxklb commented Jul 2, 2024

I forgot to test it. Implementaion looks still good, is an improvement.

I'll try to test it the following week, and will change draft mode, when everything works as expected.

@softhack007 softhack007 added enhancement Awaiting testing and removed stale This issue will be closed soon because of prolonged inactivity labels Sep 29, 2024
@netmindz netmindz changed the base branch from 0_15 to main December 20, 2024 14:09
@netmindz netmindz removed this from the 0.15.1 candidate milestone Jan 10, 2025
@netmindz netmindz added this to the 0.16.0 candidate milestone Jan 10, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 29, 2025

Walkthrough

The handleDMXData function in wled00/e131.cpp was updated to dynamically determine and handle the presence of a white (W) channel in certain DMX modes. The code now calculates the required DMX channel count based on hardware configuration and improves bounds checking for DMX data length in relevant modes.

Changes

File(s) Change Summary
wled00/e131.cpp Updated handleDMXData to dynamically determine DMX channel count, conditionally process white channel, and improve DMX data length checks in specific DMX modes.
✨ 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.

@mxklb
Copy link
Contributor Author

mxklb commented May 29, 2025

Found some time to test, should be save to merge.

With this change, sending white channel W is possible in DMX realtime modes Single RGB(W) and Single DRGB(W).

The number of DMX channels depends on the white color capability of the strip and the selected DMX mode:

LED-Strip \ DMX Mode Single RGB(W) Single DRGB(W)
[W] doesn't have white 3 4
[W] has white channel 4 5

Breaking Change: Sending only RGB for RGBW strip will do nothing. In previous implementation W channel was set to 0, when sending RGB to RGBW strip. So MR changes makes using these realtime modes more restrictive but precise. Nevertheless sending additional W channel was possible, but it was an undocumented hidden feature.

Compared to pervious hidden W feature this makes W channel usage for those two realtime modes more clear.

@mxklb mxklb marked this pull request as ready for review May 29, 2025 20:57
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
wled00/e131.cpp (2)

148-161: Excellent implementation of dynamic white channel handling.

The changes correctly address the past review feedback by differentiating between main segment and full strip usage for white channel detection. The logic properly determines channel count and conditionally reads the white channel.

For improved readability, consider adding parentheses around the conditional expression:

-      dmxChannelCount = (useMainSegmentOnly ? strip.getMainSegment().hasWhite() : strip.hasWhiteChannel()) ? 4 : 3;
+      dmxChannelCount = ((useMainSegmentOnly ? strip.getMainSegment().hasWhite() : strip.hasWhiteChannel()) ? 4 : 3);

Also, consider adding parentheses in the for loop condition for clarity:

-      for (unsigned i = 0; i < useMainSegmentOnly ? strip.getMainSegment().length() : totalLen; i++)
+      for (unsigned i = 0; i < (useMainSegmentOnly ? strip.getMainSegment().length() : totalLen); i++)

163-181: Consistent and correct implementation for DRGB mode.

The changes mirror the RGB mode implementation correctly, accounting for the additional dimmer channel in DRGB mode. The logic properly handles 4-5 channels depending on white channel presence.

For consistency and improved readability, apply the same parentheses improvements as suggested for RGB mode:

-      dmxChannelCount = (useMainSegmentOnly ? strip.getMainSegment().hasWhite() : strip.hasWhiteChannel()) ? 5 : 4;
+      dmxChannelCount = ((useMainSegmentOnly ? strip.getMainSegment().hasWhite() : strip.hasWhiteChannel()) ? 5 : 4);
-      for (unsigned i = 0; i < useMainSegmentOnly ? strip.getMainSegment().length() : totalLen; i++)
+      for (unsigned i = 0; i < (useMainSegmentOnly ? strip.getMainSegment().length() : totalLen); i++)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4a3af81 and e4dba3f.

📒 Files selected for processing (1)
  • wled00/e131.cpp (2 hunks)
🔇 Additional comments (4)
wled00/e131.cpp (4)

125-125: Good addition of dynamic channel counting.

The introduction of dmxChannelCount variable enables dynamic determination of required DMX channels based on hardware configuration, which aligns perfectly with the PR objectives.


155-155: Improved bounds checking with dynamic channel count.

The replacement of fixed channel count checks with dynamic dmxChannelCount validation significantly improves safety and correctness. The code now properly validates that sufficient DMX data is available based on the actual hardware configuration.

Also applies to: 170-170


157-157: Safe and correct conditional white channel handling.

The conditional reading of the white channel value ensures that it's only accessed when the hardware configuration supports it and sufficient DMX data is available. The fallback to 0 when no white channel is present maintains backwards compatibility.

Also applies to: 177-177


123-181: Excellent implementation addressing the PR objectives.

The changes successfully implement the dynamic white channel handling as described in the PR objectives. Key improvements include:

  1. Dynamic channel counting: Now based on actual hardware capabilities rather than availDMXLen
  2. Proper differentiation: Correctly uses useMainSegmentOnly flag as requested in past reviews
  3. Improved safety: Better bounds checking with dynamic channel count validation
  4. Consistent implementation: Both RGB and DRGB modes handle white channels consistently
  5. Breaking change handled: The change to explicit white channel usage is properly implemented

The implementation makes white channel usage more explicit and precise, addressing the core issue where availDMXLen didn't reflect actual LED strip capabilities.

@mxklb
Copy link
Contributor Author

mxklb commented May 29, 2025

P.S. To avoid the breaking change when only sending RGB instead of RGBW, implementation could be changed to auto set W=0 as well. I don't think it's a good idea, but it would make it down compatible to pervoius versions.

What do you think?

@mxklb mxklb marked this pull request as draft May 29, 2025 21:27
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.

4 participants