Skip to content

Use ws2812 on rust with embedded-hal spi

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

mlamoore/ws2812-spi-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ws2812 driver for embedded-hal spi traits

For usage with the smart-leds crate.

An embedded-hal driver for ws2812 leds using spi as the timing provider.

It provides two variants:

  • The normal usage

    Your spi peripheral has to run betwee 2MHz and 3.8MHz & the SPI data is created on-the-fly. This means that your core has to be reasonably fast (~48 MHz).

  • Prerendered

    If your core is too slow or your SPI peripheral has a different frequency, you may want to use this. It creates all the data beforehand & then sends it. This means that you have to provide a data array that's large enough for all the spi data.

It doesn't work!!!

  • Do you use the normal variant? Does your spi run at the right frequency?

    Lots of embeded devices don't support this, so you may need to look at your hal implementation and at your data sheet. If you use the prerendered version, you should also verify that the spi frequency matches the requirements.

  • If the first led is always on, no matter what data you put in, your spi is probably not setting the mosi line to low on idle (You can check with a multimeter). It may also be a timing issue with the first bit being sent, this is the case on the stm32f030 with 2MHz.

    You could try using the mosi_idle_high feature, it might help.

  • Is your device fast enough? Is your iterator fast enough? Taking too long may completely screw up the timings for the normal version. Try the prerendered variant.

  • Is everything white? This may stem from an spi peripheral that's too slow or one that takes too much time in-between bytes

When opening an issue about wrong/strange data, it would help if you include your code (of course) and a capture of MOSI & SCK from an oscilloscope/a logic analyzer.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Use ws2812 on rust with embedded-hal spi

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%