8000 DDP Transmit RGBW Fix by troyhacks · Pull Request #35 · MoonModules/WLED-MM · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

DDP Transmit RGBW Fix #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion wled00/udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8

// write the colors, the write write(const uint8_t *buffer, size_t size)
// function is just a loop internally too
for (size_t i = 0; i < packetSize; i += 3) {
for (size_t i = 0; i < packetSize; i += (isRGBW?4:3)) {
ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // R
ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // G
ddpUdp.write(scale8(buffer[bufferOffset++], bri)); // B
Copy link
Collaborator

Choose a reason for hiding this comment

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

if isRGBW, should the function write out the fourth value, too? Or not needed in this case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that's the idea. It will write 3 or 4 values depending on RGB or RGBW.

Right now it's always increasing by 3, but if RGBW is in use, it's going to write 4 values.

If you have 100 RGB, that's 300 values.
If you have 100 RGBW, that's 400 values.

The 300 and 400 are calculated correctly above the loop.

If it's trying to get to 400 values in steps of 3, the loop will have written 400 values by the time i is at 300 (because of the if statement) - so everything where i>300 is ??? for RGBW

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bufferOffset++ self-increments so it'll keep incrementing possibly past the actual data available if we're in RGBW mode.

Expand Down
0