All of our Pan Tilt HATs are actually tested on a jig with a 24 pixel NeoPixel ring installed. However I tried a 12 pixel ring I found in a box, and it just wouldn’t work.
It appears like APA102s, not all WS2812s are created equal. And certain brands/variants are more forgiving of deviation from the protocol.
It’s really finickity to get an accurate representation of the protocol on an 8bit PIC at 16Mhz - but there’s a fair amount of leeway
I’ve hooked up my oscilloscope, unrolled the loop (which I shared above) and made some very minor timing tweaks to the off bits.
It now seems to work with my test 12 pixel NeoPixel ring, while still working with the RGBW sticks and the 24 pixel ring on the test jig.
It is really close to the limit though. Assuming a definite logic HIGH level of 0.7*VCC, the HIGH pulse for a 0 bit is now just scraping 250us, which is the lower limit of acceptable timing.
At this point, I wouldn’t be surprised if the clock accuracy on the PIC itself caused some bits to be misidentified.
I could push this as a new firmware for all Pan Tilt HAT boards from this point- but since there’s clearly a fair deal of variance in WS2812 LEDs I can’t make any guarantee that it will work with all possible variants. Even boards we’ve tested and list on the product page could change their part supplier and suddenly not work.
This is one of those things that’s just complicated- a PIC15F1503 is ill-suited to driving WS2812s. I added it in as a bonus feature to avoid the pain and inconvenience of using the Pi itself to drive LEDs. It will never be perfect.
@skypi - you could tap a wire off BCM18 (marked as PWM on the Pan Tilt HAT) and try your luck running the NeoPixels using the rpi-ws281x library. (just run the Unicorn HAT library to test, and then go from there)