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

examples(pygamer): Restore neopixel examples using SPI driver #802

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

jbeaurivage
Copy link
Contributor

Summary

Reinstate the neopixel examples in the pygamer BSP. The examples now use the ws2812-spi driver instead of bitbanging the protocol. Note that the neopixel_tilt example could not be restored, because creating an Spi struct requires a clock pin, even though it's not used by the LEDs. For the pygamer, that pin can be one of SDA or SCL, both of which are required to talk to the accelerometer over I2C.

Checklist

  • All new or modified code is well documented, especially public items
  • No new warnings or clippy suggestions have been introduced

Closes #752.

@jbeaurivage
Copy link
Contributor Author

@kyp44, I'd like to solicit your help testing these examples on a pygamer if you don't mind.

@jbeaurivage jbeaurivage force-pushed the pygamer-neopixel-examples branch from f65fe5b to 1bc3e5b Compare December 7, 2024 18:07
@kyp44
Copy link
Contributor

kyp44 commented Dec 8, 2024

@jbeaurivage I'll definitely test these when I get a chance. Do we not need to wait for this PR to be merged though?

@jbeaurivage
Copy link
Contributor Author

Thanks! And nope, these examples work with the mainstream release of ws2812-spi. That PR is to help with DMA SPI transactions, whereas these examples don't need DMA to work. Just compiling with optimizations enabled.

@ianrrees
Copy link
Contributor

ianrrees commented Dec 8, 2024

I've just had a play with this branch on my pygamer and can confirm all the neopixel examples work (except the battery one, as I don't have a battery handy).

My memory is fuzzy but think I found the ehal SPI traits don't provide strong enough guarantees to meet the neopixel timing requirements. Since we control the SPI implementation here too, maybe that's not a problem, but longer term it might be good to use neopixels as an example of how to write a peripheral driver outside of atsamd-rs - using the TC/TCC or similar to control the timing.

@jbeaurivage jbeaurivage force-pushed the pygamer-neopixel-examples branch from 1bc3e5b to 275d0e8 Compare December 9, 2024 14:41
@jbeaurivage
Copy link
Contributor Author

Since hardware tests are conclusive, this is ready to be merged.

@kyp44
Copy link
Contributor

kyp44 commented Dec 9, 2024

@jbeaurivage Sorry, I was busy with life/kids stuff all weekend, but I just tested all the examples. As @ianrrees found, they all work really well, including the battery example. My PyGamer battery happened to be low so I watched the NeoPixels meter go up as I let it charge. The button example was especially neat!

Once the PR over at ws2812-spi-rs is merged, I think it would be great to add or convert an example to use DMA. I re-incorporated neopixels into my stress test example and, interestingly, even without using DMA, the neopixels now seem to work much better even when there are a lot of interrupts going on, though I still observed the colors glitching from time to time, presumably when the SPI write gets interrupted. I am hoping using DMA will help with this. In any case, this is generally a big improvement over what we had before so kudos!

@sajattack sajattack merged commit d655b38 into atsamd-rs:master Dec 11, 2024
108 checks passed
@jbeaurivage jbeaurivage deleted the pygamer-neopixel-examples branch December 11, 2024 13:59
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

Successfully merging this pull request may close these issues.

Neopixel examples are problematic
4 participants