From 087ca18a9a994d8752a01b2fc30df7becfb193cb Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Tue, 18 Feb 2025 12:49:36 -0500 Subject: [PATCH] Add use_dma option --- esphome/components/esp32_rmt_led_strip/led_strip.cpp | 2 +- esphome/components/esp32_rmt_led_strip/led_strip.h | 2 ++ esphome/components/esp32_rmt_led_strip/light.py | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/esphome/components/esp32_rmt_led_strip/led_strip.cpp b/esphome/components/esp32_rmt_led_strip/led_strip.cpp index 4e8c862c23..355f60ef05 100644 --- a/esphome/components/esp32_rmt_led_strip/led_strip.cpp +++ b/esphome/components/esp32_rmt_led_strip/led_strip.cpp @@ -58,7 +58,7 @@ void ESP32RMTLEDStripLightOutput::setup() { channel.flags.io_loop_back = 0; channel.flags.io_od_mode = 0; channel.flags.invert_out = 0; - channel.flags.with_dma = 0; + channel.flags.with_dma = this->use_dma_; channel.intr_priority = 0; if (rmt_new_tx_channel(&channel, &this->channel_) != ESP_OK) { ESP_LOGE(TAG, "Channel creation failed"); diff --git a/esphome/components/esp32_rmt_led_strip/led_strip.h b/esphome/components/esp32_rmt_led_strip/led_strip.h index fe49b9a2f3..40bb8a857e 100644 --- a/esphome/components/esp32_rmt_led_strip/led_strip.h +++ b/esphome/components/esp32_rmt_led_strip/led_strip.h @@ -51,6 +51,7 @@ class ESP32RMTLEDStripLightOutput : public light::AddressableLight { void set_num_leds(uint16_t num_leds) { this->num_leds_ = num_leds; } void set_is_rgbw(bool is_rgbw) { this->is_rgbw_ = is_rgbw; } void set_is_wrgb(bool is_wrgb) { this->is_wrgb_ = is_wrgb; } + void set_use_dma(bool use_dma) { this->use_dma_ = use_dma; } void set_use_psram(bool use_psram) { this->use_psram_ = use_psram; } /// Set a maximum refresh rate in µs as some lights do not like being updated too often. @@ -96,6 +97,7 @@ class ESP32RMTLEDStripLightOutput : public light::AddressableLight { uint16_t num_leds_; bool is_rgbw_; bool is_wrgb_; + bool use_dma_; bool use_psram_; RGBOrder rgb_order_; diff --git a/esphome/components/esp32_rmt_led_strip/light.py b/esphome/components/esp32_rmt_led_strip/light.py index e2c9f7e64a..dd01546d1c 100644 --- a/esphome/components/esp32_rmt_led_strip/light.py +++ b/esphome/components/esp32_rmt_led_strip/light.py @@ -15,6 +15,7 @@ from esphome.const import ( CONF_RGB_ORDER, CONF_RMT_CHANNEL, CONF_RMT_SYMBOLS, + CONF_USE_DMA, ) from esphome.core import CORE @@ -138,6 +139,7 @@ CONFIG_SCHEMA = cv.All( cv.Optional(CONF_CHIPSET): cv.one_of(*CHIPSETS, upper=True), cv.Optional(CONF_IS_RGBW, default=False): cv.boolean, cv.Optional(CONF_IS_WRGB, default=False): cv.boolean, + cv.Optional(CONF_USE_DMA): cv.All(cv.only_with_esp_idf, cv.boolean), cv.Optional(CONF_USE_PSRAM, default=True): cv.boolean, cv.Inclusive( CONF_BIT0_HIGH, @@ -211,6 +213,10 @@ async def to_code(config): if esp32_rmt.use_new_rmt_driver(): cg.add(var.set_rmt_symbols(config[CONF_RMT_SYMBOLS])) + if CONF_USE_DMA in config: + cg.add(var.set_use_dma(config[CONF_USE_DMA])) + else: + cg.add(var.set_use_dma(False)) else: rmt_channel_t = cg.global_ns.enum("rmt_channel_t") cg.add(