mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
parent
43f8f2fd2e
commit
a01fea54a0
1 changed files with 6 additions and 0 deletions
|
@ -8,6 +8,8 @@
|
|||
#endif
|
||||
#include <driver/ledc.h>
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#define CLOCK_FREQUENCY 80e6f
|
||||
|
||||
#ifdef USE_ARDUINO
|
||||
|
@ -120,13 +122,17 @@ void LEDCOutput::write_state(float state) {
|
|||
ledcWrite(this->channel_, duty);
|
||||
#endif
|
||||
#ifdef USE_ESP_IDF
|
||||
#if !defined(USE_ESP32_VARIANT_ESP32C3) || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 1, 0))
|
||||
// ensure that 100% on is not 99.975% on
|
||||
// note: on the C3, this tweak will result in the outputs turning off at 100%, so it has been omitted
|
||||
if ((duty == max_duty) && (max_duty != 1)) {
|
||||
duty = max_duty + 1;
|
||||
}
|
||||
#endif
|
||||
auto speed_mode = get_speed_mode(channel_);
|
||||
auto chan_num = static_cast<ledc_channel_t>(channel_ % 8);
|
||||
int hpoint = ledc_angle_to_htop(this->phase_angle_, this->bit_depth_);
|
||||
ESP_LOGV(TAG, "Setting duty: %" PRIu32 " on channel %u", duty, this->channel_);
|
||||
ledc_set_duty_with_hpoint(speed_mode, chan_num, duty, hpoint);
|
||||
ledc_update_duty(speed_mode, chan_num);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue