11#include "driver/rmt_tx.h"
16#define LED_STRIP_RMT_DEFAULT_RESOLUTION 10000000
17#define LED_STRIP_RMT_DEFAULT_TRANS_QUEUE_SIZE 4
19#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
20#define LED_STRIP_RMT_DEFAULT_MEM_BLOCK_SYMBOLS 64
22#define LED_STRIP_RMT_DEFAULT_MEM_BLOCK_SYMBOLS 48
25static const char *
TAG =
"led_strip_rmt";
39 ESP_RETURN_ON_FALSE(index < rmt_strip->strip_len, ESP_ERR_INVALID_ARG,
TAG,
"index out of maximum number of LEDs");
42 rmt_strip->
pixel_buf[start + 0] = green & 0xFF;
43 rmt_strip->
pixel_buf[start + 1] = red & 0xFF;
44 rmt_strip->
pixel_buf[start + 2] = blue & 0xFF;
54 ESP_RETURN_ON_FALSE(index < rmt_strip->strip_len, ESP_ERR_INVALID_ARG,
TAG,
"index out of maximum number of LEDs");
55 ESP_RETURN_ON_FALSE(rmt_strip->
bytes_per_pixel == 4, ESP_ERR_INVALID_ARG,
TAG,
"wrong LED pixel format, expected 4 bytes per pixel");
56 uint8_t *buf_start = rmt_strip->
pixel_buf + index * 4;
58 *buf_start = green & 0xFF;
59 *++buf_start = red & 0xFF;
60 *++buf_start = blue & 0xFF;
61 *++buf_start = white & 0xFF;
68 rmt_transmit_config_t tx_conf = {
101 ESP_GOTO_ON_FALSE(led_config && rmt_config && ret_strip, ESP_ERR_INVALID_ARG, err,
TAG,
"invalid argument");
103 uint8_t bytes_per_pixel = 3;
112 ESP_GOTO_ON_FALSE(rmt_strip, ESP_ERR_NO_MEM, err,
TAG,
"no mem for rmt strip");
116 rmt_clock_source_t clk_src = RMT_CLK_SRC_DEFAULT;
125 rmt_tx_channel_config_t rmt_chan_config = {
128 .mem_block_symbols = mem_block_symbols,
129 .resolution_hz = resolution,
137 .resolution = resolution,
151 *ret_strip = &rmt_strip->
base;
156 rmt_del_channel(rmt_strip->
rmt_chan);
#define ESP_RETURN_ON_ERROR(x, log_tag, format,...)
#define ESP_GOTO_ON_ERROR(x, goto_tag, log_tag, format,...)
static esp_err_t led_strip_rmt_refresh(led_strip_t *strip)
static esp_err_t led_strip_rmt_set_pixel_rgbw(led_strip_t *strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue, uint32_t white)
#define LED_STRIP_RMT_DEFAULT_TRANS_QUEUE_SIZE
static esp_err_t led_strip_rmt_set_pixel(led_strip_t *strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue)
static esp_err_t led_strip_rmt_clear(led_strip_t *strip)
#define LED_STRIP_RMT_DEFAULT_MEM_BLOCK_SYMBOLS
static esp_err_t led_strip_rmt_del(led_strip_t *strip)
esp_err_t led_strip_new_rmt_device(const led_strip_config_t *led_config, const led_strip_rmt_config_t *rmt_config, led_strip_handle_t *ret_strip)
Create LED strip based on RMT TX channel.
#define LED_STRIP_RMT_DEFAULT_RESOLUTION
esp_err_t rmt_new_led_strip_encoder(const led_strip_encoder_config_t *config, rmt_encoder_handle_t *ret_encoder)
Create RMT encoder for encoding LED strip pixels into RMT symbols.
@ LED_PIXEL_FORMAT_INVALID
struct led_strip_t * led_strip_handle_t
LED strip handle.
led_pixel_format_t led_pixel_format
struct led_strip_config_t::@145177150267040163336221331365072267202117177200 flags
Type of led strip encoder configuration.
LED Strip RMT specific configuration.
rmt_clock_source_t clk_src
struct led_strip_rmt_config_t::@177205126266303010206200207206146127175132325264 flags
rmt_channel_handle_t rmt_chan
rmt_encoder_handle_t strip_encoder
LED strip interface definition.
esp_err_t(* refresh)(led_strip_t *strip)
Refresh memory colors to LEDs.
esp_err_t(* set_pixel)(led_strip_t *strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue)
Set RGB for a specific pixel.
esp_err_t(* del)(led_strip_t *strip)
Free LED strip resources.
esp_err_t(* set_pixel_rgbw)(led_strip_t *strip, uint32_t index, uint32_t red, uint32_t green, uint32_t blue, uint32_t white)
Set RGBW for a specific pixel. Similar to set_pixel but also set the white component.
esp_err_t(* clear)(led_strip_t *strip)
Clear LED strip (turn off all LEDs).