fix white channel for "Rainbow" effect#5694
Conversation
…n Segment::color_wheel
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughTwo bug fixes for RGBW white channel handling: ChangesRGBW White Channel Fixes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
| rgbdata[1] = g; | ||
| rgbdata[2] = r; | ||
| //rgbdata[3] = 0; // white | ||
| rgbdata[3] = 0; // white |
There was a problem hiding this comment.
this was intentional, I can't recall why I commented it as it does not make sense to me now to split the two but do the same... maybe some conversion issue somewhere else
edit:
please revert this, I need to check what the proper way is, either remove the isRGBW or set it to zero
There was a problem hiding this comment.
Done.
The other part of the PR fixes the issue as well, because now it simply overwrites the garbage value.
| CRGBW rgb; | ||
| rgb = CHSV32(static_cast<uint16_t>(pos << 8), 255, 255); | ||
| return rgb.color32 | (w << 24); // add white channel | ||
| rgb.w = W(getCurrentColor(0)); // add white channel |
There was a problem hiding this comment.
good call, thanks for uncovering this. we changed this function a few times over so something must have gotten lost somewhere along the way.
This PR fixes an issue when using the "Rainbow" effect on RGBW LEDs:
CRGBWinstance allocated on the stack inSegment::color_wheelis not initialized, so all its color values may (and will) contain garbage.CHSV32instance callshsv2rgb_rainbow, which doesn't clear the white value either.Segment::color_wheelproduces (at least to a human eye) unexpected results.The issue has been introduced in WLED v16.0.0 by the FastLED replacement in #4615.
The important part of the fix is to properly clear the white value in
hsv2rgb_rainbow, because HSV only maps to RGB (not W). The line is already there, and I don't know why it had been commented out in the first place.The change in
Segment::color_wheelis merely cosmetic. Setting the white value produces the same result as OR'ing it to a (now guaranteed) zero value.Summary by CodeRabbit