Smart LEDs Animations
This crate complements the smart_leds collection of crates for interacting with individually addressable
LEDs using Rust. It endeavors to provide a declarative interface
to a library of ready-made animations usable in low-memory, no_std environments, as well as a framework for
creating custom animations.
This crate has been tested only with a WS2812B strip driven by an Arduino Uno R3 but should work with any hardware
supported by smart_leds.
[!IMPORTANT] A Note About API Stability: Expect some volatility across versions.
This crate was developed by a newcomer to both Rust and embedded programming as a learning project. I learned a lot in getting it to this point, and I think it provides value as-is, but I'm sure there's a lot of room for improvement. If folks open issues to suggest better implementations, request missing features,etc.—and I hope they do so I can keep learning!—I suspect the public interfaces of the library to change to accommodate the same.
Features
- Makes zero heap allocations—no need for an allocator crate.
- Wraps and re-exports
smart_ledsso you don't have to explicitly include it in your dependencies. Abstractssmart_leds'sGammaandBrightnessiterators—for those smart LED chips which support them—intoDriverconfigurations, ensuring correct usage. - Provides several ready-made
animationsto use in your projects as well as a framework for creating custom ones. - Supports running different animations on different sections of the LED strip as well as composing individual animations into a compound animation.
Example

Pictured here is the the Halloween project that led to the creation of this library. A single, unbroken LED strip borders the marquee, so in many cases the visual effects are realized across noncontiguous pixels. The two main animations are implemented as follows:
- Broken arrow: The main building block of this animation is the
Snake; there are four of them in play. Each side of the arrow above the lettering is aSnake. These are grouped together in aParallelanimation because they need to be treated as a single unit in theSeriesanimation that represents the broken arrow as a whole. The other component in theSeriesis anArrow, which is little more than two convergingSnakes with a little extra logic to handle some edge cases. - Glitch: I have taken to calling the rectangle of pixels around the lettering a
Glitcheffect. Because I thought it too bespoke for a general-purpose library, it is implemented as a custom animation in the aforementioned project. Hopefully it's a useful example of how downstream users might use theAnimateFramestrait.
Basic Usage
Add this crate to your project:
…then:
// This is simplified code from a project which uses an Arduino Uno R3 to drive WS2812B strip.
// Much has been omitted to highlight use of this library. A complete example is available
// at https://github.com/universalhandle/beetlejuice_marquee.
!
For more detail, see the documentation. For a real-world example which makes use of most of the features of this crate, see the Halloween project that started it all.
License
smart_leds_animations is distributed under the terms of both the MIT license
and the Apache License (Version 2.0).
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.
Contributing
Issues, pull requests, feature requests, and constructive criticism are welcome.