Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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.

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