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 the blocking RMT API, which is not suitable for use in async code. The SmartLedsWrite trait is implemented for SmartLedsAdapter only if a Blocking RMT channel is passed.
§Example
let rmt = Rmt::new(peripherals.RMT, Rate::from_mhz(80)).unwrap();
let mut led = SmartLedsAdapter::<{ buffer_size(1) }, _, color_order::Rgb, Ws2812Timing>::new(
rmt.channel0, peripherals.GPIO2
);
led.write(brightness([RED], 10)).unwrap();§Usage overview
The SmartLedsAdapter struct implements SmartLedsWrite
and can be used to send color data to connected LEDs.
To initialize a SmartLedsAdapter, use SmartLedsAdapter::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.
SmartLedsAdapter is configured at compile-time to support a variety of LED configurations. See the documentation for SmartLedsAdapter for more info.
§Features
None of the features provided by this crate are for external use, they are only used for testing and examples.
Re-exports§
pub use color_order::ColorOrder;
Modules§
- color_
order - Common
ColorOrderimplementations.
Structs§
- Smart
Leds Adapter 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. Note: it is not verified that this is correct, the datasheet for SK6812 says otherwise. These values have been carried over from an earlier version.
- 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§
- 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 ofSmartLedsAdapter.