Correctly invert esp32 RMT TX (#2022)

This commit is contained in:
WeekendWarrior1 2021-07-26 17:20:02 +10:00 committed by GitHub
parent 1f5cbca509
commit 1dd43a75f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -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};
};

View file

@ -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);
}