Expand description
Allows for the use of an RMT output channel on the ESP32 family to easily drive smart RGB LEDs. This is a driver for the smart-leds framework and allows using the utility functions from this crate as well as higher-level libraries based on smart-leds.
Different from ws2812-esp32-rmt-driver, which is based on the unofficial esp-idf SDK, this crate is based on the official no-std esp-hal.
This driver uses either the blocking RMT API, or the async one, depending on the given RMT channel.
The SmartLedsWrite trait (or SmartLedsWriteAsync) is implemented for RmtSmartLeds with the corresponding channel mode.
§Example
let rmt = Rmt::new(peripherals.RMT, Rate::from_mhz(80)).unwrap();
let mut led = RmtSmartLeds::<{ buffer_size::<RGB8>(1) }, _, RGB8, color_order::Rgb, Ws2812Timing>::new(
rmt.channel0, peripherals.GPIO2
);
led.write(brightness([RED], 10)).unwrap();§Usage overview
The RmtSmartLeds struct implements SmartLedsWrite or SmartLedsWriteAsync
and can be used to send color data to connected LEDs.
To initialize a RmtSmartLeds, use RmtSmartLeds::new,
which takes an RMT channel and a PeripheralOutput.
If you want to reuse the channel afterwards, you can use esp_hal::rmt::ChannelCreator::reborrow to create a shorter-lived derived channel.
RmtSmartLeds is configured at compile-time to support a variety of LED configurations. See the documentation for RmtSmartLeds for more info.
§Features
defmt: Derivedefmt::Formaton some types.
Other features provided by this crate are not for external use, they are only used for testing and examples.
Re-exports§
pub use color_order::ColorOrder;
Modules§
- color_
order - Common
ColorOrderimplementations.
Structs§
- RmtSmart
Leds SmartLedsWritedriver implementation using the ESP32’s “remote control” (RMT) peripheral for hardware-offloaded, fast control of smart LEDs.
Enums§
- Adapter
Error - All types of errors that can happen during the conversion and transmission of LED commands.
- Sk68xx
Timing - Timing for the SK68 collection of LEDs.
- Ws2811
LowSpeed Timing - Timing for the WS2811 driver ICs, low-speed mode.
- Ws2811
Timing - Timing for the WS2811 driver ICs, high-speed mode.
- Ws2812
Timing - Timing for the WS2812 LEDs.
- Ws2812b
Timing - Timing for the WS2812B LEDs.
Traits§
- Color
- Utility trait that retrieves metadata about all
smart_leds_traitcolor types. - Timing
- Common trait for all different smart LED dependent timings.
Functions§
- buffer_
size - Calculate the required buffer size for a certain number of LEDs.
This should be used to create the
BUFFER_SIZEparameter ofRmtSmartLeds.
Type Aliases§
- Rgb8
RmtSmart Leds - A
RmtSmartLedsfor 8-bit RGB colors, which is what most smart LEDs use. - Sk68xx
Rgbw Smart Leds - A
RmtSmartLedsfor integrated SK8612 (etc.) smart LEDs with RGBW. - White
Smart Leds - A
RmtSmartLedsfor smart LEDs with a single (white) channel. - Ws2812
Smart Leds - A
RmtSmartLedsfor the common WS2812 integrated smart LEDs.