jgarff / rpi_ws281x

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

Clarify SPI timing issue for Pi 4 #401

Closed Gadgetoid closed 3 years ago

Gadgetoid commented 4 years ago

This commits the findings from #381 to the documentation.

The TLDR is that the Pi 4's idle frequency scaling affects SPI, and this is fundamentally incompatible with the extremely timing sensitive hack method of driving WS281x LEDs used in this library.

Perhaps it would be possible to detect the CPU scaling frequency and dynamically adjust the SPI speed, to avoid needing to clamp it. Though I would not venture this as a priority, since power is likely not an issue when driving strands of LEDs or LED displays.

Xartrick commented 3 years ago

I guess dynamically adjusting SPI speed based on CPU frequency can create offset and provide wrong timing.