Skip to content

Using with RGBW Devices #25

Closed
Closed
@HopWorks

Description

@HopWorks

I searched around and did not find a solution for this, so I am posting this here.
If you want to use this library with RGBW LED's, you need to send an extra byte of data to your strip of RGBW's. The library, rightfully, deals with RGB so the examples show writing color.pack() to a pixel. This only writes 24 bits however, and with RGBW, you need 32, with the last 8 bits related to the white LED's.
There are more elegant ways of doing this I am sure, but a single line solution is...

color_packed=color.pack()
pixels[i] = ((color_packed & 0xff0000) >> 16, (color_packed & 0xff00) >> 8, color_packed & 0xff, white) 
# Mask and shift individual integers out of packed integer value.

'white' can be anything between 0 and 255 obviously. The 24 bit integer is masked then shifted back to an 8 bit integer to represent each color. The equivalent of pixels[x]=(r,g,b,w).

Have fun! Thanks

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions