pantilt-hat
pantilt-hat copied to clipboard
RGB WS2812 LEDs do not work
A strip of 8 'standard' WS2812b RGB LEDs used as a light on a pan tilt hat just flickers random colours on the first 5 or 6 LEDs. I don't have any RGBW LEDs to use as a comparison test. This has been reported in the pimoroni forums by other users, but I don't think it has been resolved.
Looks like support for RGB is mixed- the ones I tested with (a small NeoPixel ring) still work, but certain variations do not. The WS2812s are driven directly by firmware on the PIC16F1503 which;
- Doesn't have much margin for tweaks
- Can't (easily) be updated in the field
I think it's safer for us to recommend a list of compatible LED products than to risk changing the firmware now, since I don't know what knock-on effect it might have on other WS2812 variants (present & future).
Fixing the code is problematic because the timings are so tight that the code to update the LEDs doesn't have anywhere really to go, briefly it looks like this:
for each colour channel
for each bit in colour channel
if bit is set
write WS2812_DATA HIGH
write WS2812_DATA HIGH
write WS2812_DATA LOW
else
write WS2812_DATA HIGH
write WS2812_DATA LOW
... yes, the only difference between a WS2812 1 pulse and 0 pulse is that the DATA pin is set HIGH twice in a row to increase its duration.
There's actually some loop unrolling, clever instruction ordering and other tricks that can improve this, but it's a delicate balancing act.