led_strip - RMT-based driver for WS2812B/SK6812/APA106 LED strips

Warning

This component does not support ESP8266 RTOS SDK!

group led_strip

RMT-based ESP-IDF driver for WS2812B/SK6812/APA106 LED strips.

Copyright (C) 2020 Ruslan V. Uss https://github.com/UncleRus

MIT Licensed as described in the file LICENSE

Enums

enum led_strip_type_t

LED type.

Values:

enumerator LED_STRIP_WS2812
enumerator LED_STRIP_SK6812
enumerator LED_STRIP_APA106

Functions

void led_strip_install()

Setup library This method must be called before any other led_strip methods.

esp_err_t led_strip_init(led_strip_t *strip)

Initialize LED strip and allocate buffer memory.

Return

ESP_OK on success

Parameters
  • strip: Descriptor of LED strip

esp_err_t led_strip_free(led_strip_t *strip)

Deallocate buffer memory and release RMT channel.

Return

ESP_OK on success

Parameters
  • strip: Descriptor of LED strip

esp_err_t led_strip_flush(led_strip_t *strip)

Send strip buffer to LEDs.

Return

ESP_OK on success

Parameters
  • strip: Descriptor of LED strip

bool led_strip_busy(led_strip_t *strip)

Check if associated RMT channel is busy.

Return

true if RMT peripherals is busy

Parameters
  • strip: Descriptor of LED strip

esp_err_t led_strip_wait(led_strip_t *strip, TickType_t timeout)

Wait until RMT peripherals is free to send buffer to LEDs.

Return

ESP_OK on success

Parameters
  • strip: Descriptor of LED strip

  • timeout: Timeout in RTOS ticks

esp_err_t led_strip_set_pixel(led_strip_t *strip, size_t num, rgb_t color)

Set color of single LED in strip This function does not actually change colors of the LEDs.

Call led_strip_flush() to send buffer to the LEDs.

Return

ESP_OK on success

Parameters
  • strip: Descriptor of LED strip

  • num: LED number, 0..strip length - 1

  • color: RGB color

esp_err_t led_strip_set_pixels(led_strip_t *strip, size_t start, size_t len, rgb_t *data)

Set colors of multiple LEDs This function does not actually change colors of the LEDs.

Call led_strip_flush() to send buffer to the LEDs.

Return

ESP_OK on success

Parameters
  • strip: Descriptor of LED strip

  • start: First LED index, 0-based

  • len: Number of LEDs

  • data: Pointer to RGB data

esp_err_t led_strip_fill(led_strip_t *strip, size_t start, size_t len, rgb_t color)

Set multiple LEDs to the one color This function does not actually change colors of the LEDs.

Call led_strip_flush() to send buffer to the LEDs.

Return

ESP_OK on success

Parameters
  • strip: Descriptor of LED strip

  • start: First LED index, 0-based

  • len: Number of LEDs

  • color: RGB color

struct rgb_t
#include <led_strip.h>

RGB color representation.

struct led_strip_t
#include <led_strip.h>

LED strip descriptor.