47 rmt_symbol_word_t symbol = {
53 rmt_transmit_config_t config;
54 memset(&config, 0,
sizeof(config));
55 config.loop_count = 0;
56 config.flags.eot_level = value;
57 esp_err_t error = rmt_transmit(this->
channel_, this->
encoder_, &symbol,
sizeof(symbol), &config);
58 if (error != ESP_OK) {
59 ESP_LOGW(TAG,
"rmt_transmit failed: %s", esp_err_to_name(error));
62 error = rmt_tx_wait_all_done(this->
channel_, -1);
63 if (error != ESP_OK) {
64 ESP_LOGW(TAG,
"rmt_tx_wait_all_done failed: %s", esp_err_to_name(error));
71#if ESP_IDF_VERSION_MAJOR >= 5
76 rmt_tx_channel_config_t channel;
77 memset(&channel, 0,
sizeof(channel));
78 channel.clk_src = RMT_CLK_SRC_DEFAULT;
80 channel.gpio_num = gpio_num_t(this->
pin_->
get_pin());
82 channel.trans_queue_depth = 1;
83 channel.flags.io_loop_back = open_drain;
84 channel.flags.io_od_mode = open_drain;
85 channel.flags.invert_out = 0;
87 channel.intr_priority = 0;
88 error = rmt_new_tx_channel(&channel, &this->
channel_);
89 if (error != ESP_OK) {
91 if (error == ESP_ERR_NOT_FOUND) {
102 gpio_pullup_dis(gpio_num_t(this->
pin_->
get_pin()));
105 rmt_copy_encoder_config_t encoder;
106 memset(&encoder, 0,
sizeof(encoder));
107 error = rmt_new_copy_encoder(&encoder, &this->
encoder_);
108 if (error != ESP_OK) {
116 if (error != ESP_OK) {
127 error = rmt_apply_carrier(this->
channel_,
nullptr);
129 rmt_carrier_config_t carrier;
130 memset(&carrier, 0,
sizeof(carrier));
133 carrier.flags.polarity_active_low = this->
inverted_;
134 carrier.flags.always_on = 1;
135 error = rmt_apply_carrier(this->
channel_, &carrier);
137 if (error != ESP_OK) {
147 c.rmt_mode = RMT_MODE_TX;
149 c.tx_config.loop_en =
false;
152 c.tx_config.carrier_en =
false;
154 c.tx_config.carrier_en =
true;
159 c.tx_config.idle_output_en =
true;
161 c.tx_config.carrier_level = RMT_CARRIER_LEVEL_HIGH;
162 c.tx_config.idle_level = RMT_IDLE_LEVEL_LOW;
164 c.tx_config.carrier_level = RMT_CARRIER_LEVEL_LOW;
165 c.tx_config.idle_level = RMT_IDLE_LEVEL_HIGH;
168 esp_err_t error = rmt_config(&c);
169 if (error != ESP_OK) {
177 error = rmt_driver_install(this->
channel_, 0, 0);
178 if (error != ESP_OK) {
180 if (error == ESP_ERR_INVALID_STATE) {
205#if ESP_IDF_VERSION_MAJOR >= 5
206 rmt_symbol_word_t rmt_item;
208 rmt_item32_t rmt_item;
212 bool level =
val >= 0;
218 int32_t item = std::min(
val, int32_t(32767));
221 if (rmt_i % 2 == 0) {
222 rmt_item.level0 =
static_cast<uint32_t
>(level ^ this->
inverted_);
223 rmt_item.duration0 =
static_cast<uint32_t
>(item);
225 rmt_item.level1 =
static_cast<uint32_t
>(level ^ this->
inverted_);
226 rmt_item.duration1 =
static_cast<uint32_t
>(item);
233 if (rmt_i % 2 == 1) {
235 rmt_item.duration1 = 0;
239 if ((this->
rmt_temp_.data() ==
nullptr) || this->rmt_temp_.empty()) {
240 ESP_LOGE(TAG,
"Empty data");
244#if ESP_IDF_VERSION_MAJOR >= 5
245 for (uint32_t i = 0; i < send_times; i++) {
246 rmt_transmit_config_t config;
247 memset(&config, 0,
sizeof(config));
248 config.loop_count = 0;
251 this->rmt_temp_.size() *
sizeof(rmt_symbol_word_t), &config);
252 if (error != ESP_OK) {
253 ESP_LOGW(TAG,
"rmt_transmit failed: %s", esp_err_to_name(error));
258 error = rmt_tx_wait_all_done(this->
channel_, -1);
259 if (error != ESP_OK) {
260 ESP_LOGW(TAG,
"rmt_tx_wait_all_done failed: %s", esp_err_to_name(error));
263 if (i + 1 < send_times)
267 for (uint32_t i = 0; i < send_times; i++) {
268 esp_err_t error = rmt_write_items(this->
channel_, this->
rmt_temp_.data(), this->rmt_temp_.size(),
true);
269 if (error != ESP_OK) {
270 ESP_LOGW(TAG,
"rmt_write_items failed: %s", esp_err_to_name(error));
275 if (i + 1 < send_times)