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.- Timing
- Defines the timing for a certain smart LED type.
Enums§
- Adapter
Error - All types of errors that can happen during the conversion and transmission of LED commands.
Constants§
- SK68XX_
TIMING - Timing for the SK68 collection of LEDs.
- WS2811_
LOW_ SPEED_ TIMING - Timing for the WS2811 driver ICs, low-speed mode.
- WS2811_
TIMING - Timing for the WS2811 driver ICs, high-speed mode.
- WS2812B_
TIMING - Timing for the WS2812B LEDs.
- WS2812_
TIMING - Timing for the WS2812 LEDs.
Traits§
- Color
- Utility trait that retrieves metadata about all
smart_leds_traitcolor types.
Functions§
- buffer_
size - Calculate the required buffer size for a certain number of LEDs.
This should be used to create the
BUFFER_SIZEparameter ofRmtSmartLeds.