From 33b1a853b9afa55c4f26cacbda1133f3bc36fdb6 Mon Sep 17 00:00:00 2001 From: Martin Flasskamp Date: Thu, 22 Dec 2022 08:21:44 +0100 Subject: [PATCH] calc LEDC PWM Resolution with LEDC_TIMER_BIT_MAX (#3820) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> fixes https://github.com/esphome/issues/issues/3128 --- esphome/components/ledc/ledc_output.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/esphome/components/ledc/ledc_output.cpp b/esphome/components/ledc/ledc_output.cpp index a56dccfd72..34cf4cd1f6 100644 --- a/esphome/components/ledc/ledc_output.cpp +++ b/esphome/components/ledc/ledc_output.cpp @@ -6,17 +6,15 @@ #ifdef USE_ARDUINO #include #endif -#ifdef USE_ESP_IDF #include -#endif namespace esphome { namespace ledc { static const char *const TAG = "ledc.output"; -#ifdef USE_ESP_IDF static const int MAX_RES_BITS = LEDC_TIMER_BIT_MAX - 1; +#ifdef USE_ESP_IDF #if SOC_LEDC_SUPPORT_HS_MODE // Only ESP32 has LEDC_HIGH_SPEED_MODE inline ledc_mode_t get_speed_mode(uint8_t channel) { return channel < 8 ? LEDC_HIGH_SPEED_MODE : LEDC_LOW_SPEED_MODE; } @@ -26,8 +24,6 @@ inline ledc_mode_t get_speed_mode(uint8_t channel) { return channel < 8 ? LEDC_H // https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/api-reference/peripherals/ledc.html#functionality-overview inline ledc_mode_t get_speed_mode(uint8_t) { return LEDC_LOW_SPEED_MODE; } #endif -#else -static const int MAX_RES_BITS = 20; #endif float ledc_max_frequency_for_bit_depth(uint8_t bit_depth) { return 80e6f / float(1 << bit_depth); }