mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 17:05:21 +01:00
Correctly invert esp32 RMT TX (#2022)
This commit is contained in:
parent
9fbb3659a6
commit
7828f48b9a
2 changed files with 4 additions and 2 deletions
|
@ -41,6 +41,7 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase,
|
|||
bool initialized_{false};
|
||||
std::vector<rmt_item32_t> rmt_temp_;
|
||||
esp_err_t error_code_{ESP_OK};
|
||||
bool inverted_{false};
|
||||
#endif
|
||||
uint8_t carrier_duty_percent_{50};
|
||||
};
|
||||
|
|
|
@ -50,6 +50,7 @@ void RemoteTransmitterComponent::configure_rmt() {
|
|||
} else {
|
||||
c.tx_config.carrier_level = RMT_CARRIER_LEVEL_LOW;
|
||||
c.tx_config.idle_level = RMT_IDLE_LEVEL_HIGH;
|
||||
this->inverted_ = true;
|
||||
}
|
||||
|
||||
esp_err_t error = rmt_config(&c);
|
||||
|
@ -95,10 +96,10 @@ void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t sen
|
|||
val -= item;
|
||||
|
||||
if (rmt_i % 2 == 0) {
|
||||
rmt_item.level0 = static_cast<uint32_t>(level);
|
||||
rmt_item.level0 = static_cast<uint32_t>(level ^ this->inverted_);
|
||||
rmt_item.duration0 = static_cast<uint32_t>(item);
|
||||
} else {
|
||||
rmt_item.level1 = static_cast<uint32_t>(level);
|
||||
rmt_item.level1 = static_cast<uint32_t>(level ^ this->inverted_);
|
||||
rmt_item.duration1 = static_cast<uint32_t>(item);
|
||||
this->rmt_temp_.push_back(rmt_item);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue