jgarff / rpi_ws281x

Userspace Raspberry Pi PWM library for WS281X LEDs
BSD 2-Clause "Simplified" License
1.78k stars 622 forks source link

Conversion table for ws2812b #382

Open rikvermeer opened 4 years ago

rikvermeer commented 4 years ago

Hi, pardon me for putting this here in an issue.

According to your application there is a bit conversion where 0 becomes 000 and 1 becomes 110 while the frequency is set to 2.4Mhz instead of 800kHz for a valid output signal.

I've used this information to create a conversion table with all values from 0 to 255 as index and their 3 bit counterparts. Please feel free to help others with this gist.

https://gist.github.com/rikvermeer/6739cab4d9dba89a08f46fad6ccae343#file-ws281x-conv

It can be used as a lookup table, don't forget to flatten:

[...table[255], ...table[155], ...table[0]]
[219, 109, 182, 192, 108, 54, 0, 0, 0]
Gadgetoid commented 2 years ago

Thank you,

Possibly a foreshadowing of https://github.com/jgarff/rpi_ws281x/pull/468

Marking as notice for now, in case anyone finds this useful.