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

Defines

LED_STIRP_BRIGNTNESS

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.

Parameters

strip – Descriptor of LED strip

Returns

ESP_OK on success

esp_err_t led_strip_free(led_strip_t *strip)

Deallocate buffer memory and release RMT channel.

Parameters

strip – Descriptor of LED strip

Returns

ESP_OK on success

esp_err_t led_strip_flush(led_strip_t *strip)

Send strip buffer to LEDs.

Parameters

strip – Descriptor of LED strip

Returns

ESP_OK on success

bool led_strip_busy(led_strip_t *strip)

Check if associated RMT channel is busy.

Parameters

strip – Descriptor of LED strip

Returns

true if RMT peripherals is busy

esp_err_t led_strip_wait(led_strip_t *strip, TickType_t timeout)

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

Parameters
  • strip – Descriptor of LED strip

  • timeout – Timeout in RTOS ticks

Returns

ESP_OK on success

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.

Parameters
  • strip – Descriptor of LED strip

  • numLED number, 0..strip length - 1

  • color – RGB color

Returns

ESP_OK on success

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.

Parameters
  • strip – Descriptor of LED strip

  • start – First LED index, 0-based

  • len – Number of LEDs

  • data – Pointer to RGB data

Returns

ESP_OK on success

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.

Parameters
  • strip – Descriptor of LED strip

  • start – First LED index, 0-based

  • len – Number of LEDs

  • color – RGB color

Returns

ESP_OK on success

struct led_strip_t
#include <led_strip.h>
struct LED