Skip to content
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

DDP Transmit RGBW Fix #35

Merged
merged 1 commit into from
Apr 17, 2023
Merged

Conversation

troyhacks
Copy link
Collaborator

I'm gonna assume DDP RGBW needs this because of the optional 4th packet for white. I did this in Art-Net Transmit as well.

Untested (and, frankly, unlikely to be used by anyone), but seems more gooder.

@@ -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.

@troyhacks troyhacks merged commit 2e11893 into MoonModules:mdev Apr 17, 2023
@troyhacks troyhacks deleted the DDP-RGBW-Transmit-Fix branch June 21, 2023 00:02
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