mirror of
https://github.com/esphome/esphome.git
synced 2025-07-28 14:16:40 +00:00
[esp32_rmt_led_strip] Add use_dma option (#8270)
This commit is contained in:
parent
2fd5f9ac58
commit
a7b676231a
@ -58,7 +58,7 @@ void ESP32RMTLEDStripLightOutput::setup() {
|
|||||||
channel.flags.io_loop_back = 0;
|
channel.flags.io_loop_back = 0;
|
||||||
channel.flags.io_od_mode = 0;
|
channel.flags.io_od_mode = 0;
|
||||||
channel.flags.invert_out = 0;
|
channel.flags.invert_out = 0;
|
||||||
channel.flags.with_dma = 0;
|
channel.flags.with_dma = this->use_dma_;
|
||||||
channel.intr_priority = 0;
|
channel.intr_priority = 0;
|
||||||
if (rmt_new_tx_channel(&channel, &this->channel_) != ESP_OK) {
|
if (rmt_new_tx_channel(&channel, &this->channel_) != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Channel creation failed");
|
ESP_LOGE(TAG, "Channel creation failed");
|
||||||
|
@ -51,6 +51,7 @@ class ESP32RMTLEDStripLightOutput : public light::AddressableLight {
|
|||||||
void set_num_leds(uint16_t num_leds) { this->num_leds_ = num_leds; }
|
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_rgbw(bool is_rgbw) { this->is_rgbw_ = is_rgbw; }
|
||||||
void set_is_wrgb(bool is_wrgb) { this->is_wrgb_ = is_wrgb; }
|
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; }
|
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.
|
/// Set a maximum refresh rate in µs as some lights do not like being updated too often.
|
||||||
@ -85,7 +86,7 @@ class ESP32RMTLEDStripLightOutput : public light::AddressableLight {
|
|||||||
rmt_encoder_handle_t encoder_{nullptr};
|
rmt_encoder_handle_t encoder_{nullptr};
|
||||||
rmt_symbol_word_t *rmt_buf_{nullptr};
|
rmt_symbol_word_t *rmt_buf_{nullptr};
|
||||||
rmt_symbol_word_t bit0_, bit1_, reset_;
|
rmt_symbol_word_t bit0_, bit1_, reset_;
|
||||||
uint32_t rmt_symbols_;
|
uint32_t rmt_symbols_{48};
|
||||||
#else
|
#else
|
||||||
rmt_item32_t *rmt_buf_{nullptr};
|
rmt_item32_t *rmt_buf_{nullptr};
|
||||||
rmt_item32_t bit0_, bit1_, reset_;
|
rmt_item32_t bit0_, bit1_, reset_;
|
||||||
@ -94,11 +95,12 @@ class ESP32RMTLEDStripLightOutput : public light::AddressableLight {
|
|||||||
|
|
||||||
uint8_t pin_;
|
uint8_t pin_;
|
||||||
uint16_t num_leds_;
|
uint16_t num_leds_;
|
||||||
bool is_rgbw_;
|
bool is_rgbw_{false};
|
||||||
bool is_wrgb_;
|
bool is_wrgb_{false};
|
||||||
bool use_psram_;
|
bool use_dma_{false};
|
||||||
|
bool use_psram_{false};
|
||||||
|
|
||||||
RGBOrder rgb_order_;
|
RGBOrder rgb_order_{ORDER_RGB};
|
||||||
|
|
||||||
uint32_t last_refresh_{0};
|
uint32_t last_refresh_{0};
|
||||||
optional<uint32_t> max_refresh_rate_{};
|
optional<uint32_t> max_refresh_rate_{};
|
||||||
|
@ -3,7 +3,7 @@ import logging
|
|||||||
|
|
||||||
from esphome import pins
|
from esphome import pins
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
from esphome.components import esp32_rmt, light
|
from esphome.components import esp32, esp32_rmt, light
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
CONF_CHIPSET,
|
CONF_CHIPSET,
|
||||||
@ -15,6 +15,7 @@ from esphome.const import (
|
|||||||
CONF_RGB_ORDER,
|
CONF_RGB_ORDER,
|
||||||
CONF_RMT_CHANNEL,
|
CONF_RMT_CHANNEL,
|
||||||
CONF_RMT_SYMBOLS,
|
CONF_RMT_SYMBOLS,
|
||||||
|
CONF_USE_DMA,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
|
|
||||||
@ -138,6 +139,11 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
cv.Optional(CONF_CHIPSET): cv.one_of(*CHIPSETS, upper=True),
|
cv.Optional(CONF_CHIPSET): cv.one_of(*CHIPSETS, upper=True),
|
||||||
cv.Optional(CONF_IS_RGBW, default=False): cv.boolean,
|
cv.Optional(CONF_IS_RGBW, default=False): cv.boolean,
|
||||||
cv.Optional(CONF_IS_WRGB, default=False): cv.boolean,
|
cv.Optional(CONF_IS_WRGB, default=False): cv.boolean,
|
||||||
|
cv.Optional(CONF_USE_DMA): cv.All(
|
||||||
|
esp32.only_on_variant(supported=[esp32.const.VARIANT_ESP32S3]),
|
||||||
|
cv.only_with_esp_idf,
|
||||||
|
cv.boolean,
|
||||||
|
),
|
||||||
cv.Optional(CONF_USE_PSRAM, default=True): cv.boolean,
|
cv.Optional(CONF_USE_PSRAM, default=True): cv.boolean,
|
||||||
cv.Inclusive(
|
cv.Inclusive(
|
||||||
CONF_BIT0_HIGH,
|
CONF_BIT0_HIGH,
|
||||||
@ -211,6 +217,8 @@ async def to_code(config):
|
|||||||
|
|
||||||
if esp32_rmt.use_new_rmt_driver():
|
if esp32_rmt.use_new_rmt_driver():
|
||||||
cg.add(var.set_rmt_symbols(config[CONF_RMT_SYMBOLS]))
|
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:
|
else:
|
||||||
rmt_channel_t = cg.global_ns.enum("rmt_channel_t")
|
rmt_channel_t = cg.global_ns.enum("rmt_channel_t")
|
||||||
cg.add(
|
cg.add(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user