4 releases (breaking)

0.4.0 Dec 2, 2020
0.3.0 Feb 9, 2020
0.2.0 May 3, 2019
0.1.0 Mar 5, 2019

#427 in Embedded development

Download history 67/week @ 2021-08-16 57/week @ 2021-08-23 26/week @ 2021-08-30 258/week @ 2021-09-06 211/week @ 2021-09-13 298/week @ 2021-09-20 293/week @ 2021-09-27 416/week @ 2021-10-04 366/week @ 2021-10-11 451/week @ 2021-10-18 541/week @ 2021-10-25 57/week @ 2021-11-01 670/week @ 2021-11-08 743/week @ 2021-11-15 329/week @ 2021-11-22 206/week @ 2021-11-29

1,954 downloads per month
Used in 4 crates

MIT/Apache

5MB
243 lines

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.

rainbow on stm32f0

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 should suffice).

  • Prerendered

    If your core is too slow (for example, the AVR family), 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?

    Your CPU might be too slow, but this can also depend on the HAL implementation & your Iterator chain. Using the prerendered variant might help. For many SPI peripherals, the clock generations is way less sophisticated than e.g. the UART peripheral. You should verify it runs at an acceptable frequency, by either studying the datasheet & the hal code or using a logic analyzer. An fx2 based one, commonly available under $10 works great for this.

  • 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.

Dependencies