espressif_idf-extra-components/led_strip
suda-morris 2e9e31e8cb led_strip: added change log 2023-01-03 10:51:24 +08:00
..
include led_strip: support invert output 2023-01-03 10:51:24 +08:00
interface led_strip: added led strip driver v2 2022-08-11 15:05:13 +08:00
src led_strip: support invert output 2023-01-03 10:51:24 +08:00
CHANGELOG.md led_strip: added change log 2023-01-03 10:51:24 +08:00
CMakeLists.txt led_strip: added led strip driver v2 2022-08-11 15:05:13 +08:00
LICENSE led_strip: added led strip driver v2 2022-08-11 15:05:13 +08:00
README.md led_strip: support dma feature and various clock source 2022-12-22 13:38:07 +08:00
idf_component.yml led_strip: support dma feature and various clock source 2022-12-22 13:38:07 +08:00

README.md

LED Strip Driver

Component Registry

This driver is designed for addressable LEDs like WS2812, where each LED is controlled by a single data line.

Backend Controllers

The RMT Peripheral

This is the most economical way to drive the LEDs because it only consumes one RMT channel, leaving other channels free to use. However, the memory usage increases dramatically with the number of LEDs. If the RMT hardware can't be assist by DMA, the driver will going into interrupt very frequently, thus result in a high CPU usage. What's worse, if the RMT interrupt is delayed or not serviced in time (e.g. if Wi-Fi interrupt happens on the same CPU core), the RMT transaction will be corrupted and the LEDs will display incorrect colors. If you want to use RMT to drive a large number of LEDs, you'd better to enable the DMA feature if possible. 1

Allocate LED Strip Object with RMT Backend

#define BLINK_GPIO 0

led_strip_handle_t led_strip;

/* LED strip initialization with the GPIO and pixels number*/
led_strip_config_t strip_config = {
    .strip_gpio_num = BLINK_GPIO, // The GPIO that connected to the LED strip's data line
    .max_leds = 1, // The number of LEDs in the strip
};

led_strip_rmt_config_t rmt_config = {
    .clk_src = RMT_CLK_SRC_DEFAULT, // different clock source can lead to different power consumption
    .resolution_hz = 10 * 1000 * 1000, // 10MHz
    .flags.with_dma = false, // wether to enable the DMA feature
};
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));

  1. The DMA feature is not available on all ESP chips. Please check the data sheet before using it. ↩︎