Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neopixel examples are problematic #752

Open
ianrrees opened this issue Aug 28, 2024 · 0 comments
Open

Neopixel examples are problematic #752

ianrrees opened this issue Aug 28, 2024 · 0 comments

Comments

@ianrrees
Copy link
Contributor

In #750 I've been working on updating PyGamer to the current HAL, and I'm finding that the WS2812 / neopixel is a tricky problem to solve generically. In the timer-based WS2812 driver, there's a fundamental issue with the time it takes to toggle a GPIO varying between platforms, and also being comparable to the protocol's timing margins. The SPI driver relies on behaviours of the provided SpiBus which aren't described by the trait (nor reliably provided by our current implementation).

So, it's not really clear to me how we should proceed here. A few ideas:

  1. With Spi implementation enhancements #751 point 2 in place, it might be feasible to get the WS2812 SPI driver to work well enough for a demo with a few asterisks like only working on release profile (the status quo). I think we'd need to modify the driver so that it shifts out 3 bytes of WS2812 data (12 SPI bytes, because each bit of WS2812 data is synthesized from 4 bits on SPI) per call to SpiBus::write() - this would minimise the variation in bit timing to any particular WS2812, and hopefully it doesn't matter as much for the data between WS2812s.
  2. When the timer+GPIO driver is updated to use embedded-hal 1.0 DelayNs (in progress), we could possibly introduce a parameter for the time that a GPIO write takes, to allow tuning for the particular board.
  3. At least on the PyGamer, another option is to use the TCC peripheral to generate the WS2812 bit timing. Going this route might provide a good example of driving a peripheral directly, which could help for people who want to use peripherals/features which aren't provided by the HAL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant