Bonus: Bit-Banging WS2812 LEDs
Video demonstration is WIP
WS2812 LEDs are serially-addressable RGB leds – you send 24 bits of RGB color data per LED, and they show the color!
They have a quirky RZ-encoded, timing-precise protocol. Instead of a high voltage meaning 1 and low voltage meaning 0, every symbol starts high and ends low – the value of that bit depends on the duty cycle – how much of the time the bit was high instead of low.
We can simulate this 800khz RZ-encoded signal with SPI running at 2.4Mhz – every bit we want to send out, we pad with a High and Low bit, resulting in 3 times as many bits being interpreted as our WS2812 compatible signal.
PyFtdi includes a spi interface; now we just need to write the glue code that will take our 24 bit color choice and pad it into the right format… but wait…
Double Bonus! My ‘lazy engineer’ instinct saved the day again – before setting out to prototype this code, a bit of searching found that there’s already a circuitpython library from adafruit that does this! This should work just like the other circuitpython examples shown in the previous I2C demos – I’ll test and post a video shortly.
