WS2812 BGR possible instead of RGB?


Author Message
wolfme
Regular Member

Joined: 26/10/2021
Location: Germany
Posts: 43
Posted: 08:42pm 17 Jan 2025      

Is it possible to drive BGR WS2812 LEDs?

SetPin GP16, DOUT
WS2812 B, GP16, 1, RGB(red)


lights up the LED green and

SetPin GP16, DOUT
WS2812 B, GP16, 1, RGB(green)


lights up the LED red

phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3374
Posted: 10:56pm 17 Jan 2025      

@Mixtel90 also found some with wrong colours.https://www.thebackshed.com/forum/ViewTopic.php?TID=17173&PID=225831#225831#225831 Though he didn't show his solution it would just require transposing the colours. See if this works
OriginalColour = RGB(red,green,blue)
TransposedColour =((OriginalColour >> 8)And &HFF00)+((OriginalColour<<8)And &HFF0000)+((OriginalColour)And &HFF)
WS2812 B, GP16, 1, TransposedColour

wolfme
Regular Member

Joined: 26/10/2021
Location: Germany
Posts: 43
Posted: 06:27am 18 Jan 2025      

  phil99 said  @Mixtel90 also found some with wrong colours.https://www.thebackshed.com/forum/ViewTopic.php?TID=17173&PID=225831#225831#225831 Though he didn't show his solution it would just require transposing the colours. See if this works
OriginalColour = RGB(red,green,blue)
TransposedColour =((OriginalColour >> 8)And &HFF00)+((OriginalColour<<8)And &HFF0000)+((OriginalColour)And &HFF)
WS2812 B, GP16, 1, TransposedColour


That works, thanks very much!