Crate esp_hal_smartled

Crate esp_hal_smartled 

Source
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

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 ColorOrder implementations.

Structs§

RmtSmartLeds
SmartLedsWrite driver implementation using the ESP32’s “remote control” (RMT) peripheral for hardware-offloaded, fast control of smart LEDs.

Enums§

AdapterError
All types of errors that can happen during the conversion and transmission of LED commands.
Sk68xxTiming
Timing for the SK68 collection of LEDs.
Ws2811LowSpeedTiming
Timing for the WS2811 driver ICs, low-speed mode.
Ws2811Timing
Timing for the WS2811 driver ICs, high-speed mode.
Ws2812Timing
Timing for the WS2812 LEDs.
Ws2812bTiming
Timing for the WS2812B LEDs.

Traits§

Color
Utility trait that retrieves metadata about all smart_leds_trait color 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_SIZE parameter of RmtSmartLeds.

Type Aliases§

Rgb8RmtSmartLeds
A RmtSmartLeds for 8-bit RGB colors, which is what most smart LEDs use.
Sk68xxRgbwSmartLeds
A RmtSmartLeds for integrated SK8612 (etc.) smart LEDs with RGBW.
WhiteSmartLeds
A RmtSmartLeds for smart LEDs with a single (white) channel.
Ws2812SmartLeds
A RmtSmartLeds for the common WS2812 integrated smart LEDs.