24 esp_clk_tree_src_get_freq_hz((soc_module_clk_t) RMT_CLK_SRC_DEFAULT, ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &freq);
70 if (this->
buf_ ==
nullptr) {
71 ESP_LOGE(TAG,
"Cannot allocate LED buffer!");
75 memset(this->
buf_, 0, buffer_size);
79 ESP_LOGE(TAG,
"Cannot allocate effect data!");
84#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
94 rmt_tx_channel_config_t channel;
95 memset(&channel, 0,
sizeof(channel));
96 channel.clk_src = RMT_CLK_SRC_DEFAULT;
97 channel.resolution_hz = rmt_resolution_hz();
98 channel.gpio_num = gpio_num_t(this->
pin_);
100 channel.trans_queue_depth = 1;
102 channel.flags.with_dma = this->
use_dma_;
103 channel.intr_priority = 0;
104 if (rmt_new_tx_channel(&channel, &this->
channel_) != ESP_OK) {
105 ESP_LOGE(TAG,
"Channel creation failed");
110#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
111 rmt_simple_encoder_config_t encoder;
112 memset(&encoder, 0,
sizeof(encoder));
113 encoder.callback = encoder_callback;
115 encoder.min_chunk_size = RMT_SYMBOLS_PER_BYTE;
116 if (rmt_new_simple_encoder(&encoder, &this->
encoder_) != ESP_OK) {
117 ESP_LOGE(TAG,
"Encoder creation failed");
122 rmt_copy_encoder_config_t encoder;
123 memset(&encoder, 0,
sizeof(encoder));
124 if (rmt_new_copy_encoder(&encoder, &this->
encoder_) != ESP_OK) {
125 ESP_LOGE(TAG,
"Encoder creation failed");
131 if (rmt_enable(this->
channel_) != ESP_OK) {
132 ESP_LOGE(TAG,
"Enabling channel failed");
171 ESP_LOGVV(TAG,
"Writing RGB values to bus");
173 esp_err_t error = rmt_tx_wait_all_done(this->
channel_, 1000);
174 if (error != ESP_OK) {
175 ESP_LOGE(TAG,
"RMT TX timeout");
181#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
188 uint8_t *psrc = this->
buf_;
189 rmt_symbol_word_t *pdest = this->
rmt_buf_;
190 while (size < buffer_size) {
192 for (
int i = 0; i < 8; i++) {
201 if (this->
params_.
reset.duration0 > 0 || this->params_.reset.duration1 > 0) {
208 rmt_transmit_config_t config;
209 memset(&config, 0,
sizeof(config));
210#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
215 if (error != ESP_OK) {
216 ESP_LOGE(TAG,
"RMT TX error");
224 int32_t r = 0, g = 0, b = 0;
258 uint8_t white = this->
is_wrgb_ ? 0 : 3;
260 return {this->
buf_ + (index * multiplier) + r + this->
is_wrgb_,
262 this->
buf_ + (index * multiplier) + b + this->is_wrgb_,
263 this->
is_rgbw_ || this->is_wrgb_ ? this->
buf_ + (index * multiplier) + white :
nullptr,