From be007796fbd7cf81ec6c13d191190fa3ef2ff811 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 7 Apr 2025 09:45:12 -0300 Subject: [PATCH 01/14] feat(ledc): max resolution review --- cores/esp32/esp32-hal-ledc.c | 47 ++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index 0a3ec5a60c7..9e134902080 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -184,13 +184,6 @@ bool ledcWrite(uint8_t pin, uint32_t duty) { uint8_t group = (bus->channel / 8), channel = (bus->channel % 8); - //Fixing if all bits in resolution is set = LEDC FULL ON - uint32_t max_duty = (1 << bus->channel_resolution) - 1; - - if ((duty == max_duty) && (max_duty != 1)) { - duty = max_duty + 1; - } - ledc_set_duty(group, channel, duty); ledc_update_duty(group, channel); @@ -211,12 +204,6 @@ bool ledcWriteChannel(uint8_t channel, uint32_t duty) { uint32_t resolution = 0; ledc_ll_get_duty_resolution(LEDC_LL_GET_HW(), group, timer, &resolution); - uint32_t max_duty = (1 << resolution) - 1; - - if ((duty == max_duty) && (max_duty != 1)) { - duty = max_duty + 1; - } - ledc_set_duty(group, channel, duty); ledc_update_duty(group, channel); @@ -265,15 +252,16 @@ uint32_t ledcWriteTone(uint8_t pin, uint32_t freq) { bus->channel_resolution = 10; uint32_t res_freq = ledc_get_freq(group, timer); - ledcWrite(pin, 0x1FF); + ledcWrite(pin, 0x200); // LEDC 50% duty is 2^10 / 2 = 0x200 return res_freq; } return 0; } uint32_t ledcWriteNote(uint8_t pin, note_t note, uint8_t octave) { - const uint16_t noteFrequencyBase[12] = {// C C# D Eb E F F# G G# A Bb B - 4186, 4435, 4699, 4978, 5274, 5588, 5920, 6272, 6645, 7040, 7459, 7902 + const uint16_t noteFrequencyBase[12] = { + // C C# D Eb E F F# G G# A Bb B + 4186, 4435, 4699, 4978, 5274, 5588, 5920, 6272, 6645, 7040, 7459, 7902 }; if (octave > 8 || note >= NOTE_MAX) { @@ -391,13 +379,15 @@ static bool ledcFadeConfig(uint8_t pin, uint32_t start_duty, uint32_t target_dut ledc_cbs_t callbacks = {.fade_cb = ledcFnWrapper}; ledc_cb_register(group, channel, &callbacks, (void *)bus); - //Fixing if all bits in resolution is set = LEDC FULL ON - uint32_t max_duty = (1 << bus->channel_resolution) - 1; + uint32_t max_duty = (1 << bus->channel_resolution); // Max LEDC duty - if ((target_duty == max_duty) && (max_duty != 1)) { - target_duty = max_duty + 1; - } else if ((start_duty == max_duty) && (max_duty != 1)) { - start_duty = max_duty + 1; + if (target_duty > max_duty) { + log_w("Target duty %d was adjusted to the maximum duty %d", target_duty, max_duty); + target_duty = max_duty; + } + if (start_duty > max_duty) { + log_w("Starting duty %d was adjusted to the maximum duty %d", start_duty, max_duty); + start_duty = max_duty; } #if SOC_LEDC_SUPPORT_FADE_STOP @@ -411,7 +401,7 @@ static bool ledcFadeConfig(uint8_t pin, uint32_t start_duty, uint32_t target_dut // Wait for LEDCs next PWM cycle to update duty (~ 1-2 ms) while (ledc_get_duty(group, channel) != start_duty); - if (ledc_set_fade_time_and_start(group, channel, target_duty, max_fade_time_ms, LEDC_FADE_NO_WAIT) != ESP_OK) { + if (ledc_set_fade_time_and_start(group, channel, target_duty, _fade_time_ms, LEDC_FADE_NO_WAIT) != ESP_OK) { log_e("ledc_set_fade_time_and_start failed"); return false; } @@ -446,6 +436,17 @@ void analogWrite(uint8_t pin, int value) { return; } } + // Arduino API says that duty goes from 0 to (2^resolution) - 1 + // But LEDC works with duty from 0 to (2^resolution) + // Therefore, it will adjust Arduino MAX Duty to be the LEDC MAx Duty + uint32_t max_duty = (1 << bus->channel_resolution) - 1; + if (value < 0 || value > max_duty) { + log_w("Duty is out of range. Valid duty range for pin d is 0 to %d", pin, max_duty); + return; + } + if ((value == max_duty) && (max_duty != 1)) { + value = max_duty + 1; + } ledcWrite(pin, value); } } From 940cf59b119249adce98df2a649979a3ca92c6bb Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 7 Apr 2025 09:57:47 -0300 Subject: [PATCH 02/14] feat(ledc): check duty limit based on the resolution --- cores/esp32/esp32-hal-ledc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index 9e134902080..72b787bab2c 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -183,7 +183,13 @@ bool ledcWrite(uint8_t pin, uint32_t duty) { if (bus != NULL) { uint8_t group = (bus->channel / 8), channel = (bus->channel % 8); + uint32_t max_duty = (1 << bus->channel_resolution); // Max LEDC duty + if (duty > max_duty) { + log_w("Target duty %d was adjusted to the maximum duty %d", duty, max_duty); + duty = max_duty; + } + ledc_set_duty(group, channel, duty); ledc_update_duty(group, channel); @@ -203,7 +209,12 @@ bool ledcWriteChannel(uint8_t channel, uint32_t duty) { //Fixing if all bits in resolution is set = LEDC FULL ON uint32_t resolution = 0; ledc_ll_get_duty_resolution(LEDC_LL_GET_HW(), group, timer, &resolution); + uint32_t max_duty = (1 << resolution); // Max LEDC duty + if (duty > max_duty) { + log_w("Target duty %d was adjusted to the maximum duty %d", duty, max_duty); + duty = max_duty; + } ledc_set_duty(group, channel, duty); ledc_update_duty(group, channel); From 443f7e10f1d5bc88af426314d9f805bceaff8992 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 7 Apr 2025 09:58:52 -0300 Subject: [PATCH 03/14] fix(ledc): removing white space in code line --- cores/esp32/esp32-hal-ledc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index 72b787bab2c..fdbc4939f1f 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -189,7 +189,6 @@ bool ledcWrite(uint8_t pin, uint32_t duty) { log_w("Target duty %d was adjusted to the maximum duty %d", duty, max_duty); duty = max_duty; } - ledc_set_duty(group, channel, duty); ledc_update_duty(group, channel); From 591a1610ff42581ca0b307bd753b33b933766a61 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 7 Apr 2025 10:14:02 -0300 Subject: [PATCH 04/14] fix(ledc): reverting not necessary change --- cores/esp32/esp32-hal-ledc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index fdbc4939f1f..9b3ec036144 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -411,7 +411,7 @@ static bool ledcFadeConfig(uint8_t pin, uint32_t start_duty, uint32_t target_dut // Wait for LEDCs next PWM cycle to update duty (~ 1-2 ms) while (ledc_get_duty(group, channel) != start_duty); - if (ledc_set_fade_time_and_start(group, channel, target_duty, _fade_time_ms, LEDC_FADE_NO_WAIT) != ESP_OK) { + if (ledc_set_fade_time_and_start(group, channel, target_duty, max_fade_time_ms, LEDC_FADE_NO_WAIT) != ESP_OK) { log_e("ledc_set_fade_time_and_start failed"); return false; } From cdd04b1d406802d27638af7e250f4c6b5d4176c4 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 7 Apr 2025 15:14:43 -0300 Subject: [PATCH 05/14] feat(ledc): testing values that shall be consistent --- cores/esp32/esp32-hal-ledc.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index 9b3ec036144..0b044d7e97d 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -377,6 +377,21 @@ static bool ledcFadeConfig(uint8_t pin, uint32_t start_duty, uint32_t target_dut #endif uint8_t group = (bus->channel / 8), channel = (bus->channel % 8); + uint32_t max_duty = (1 << bus->channel_resolution); // Max LEDC duty + + if (target_duty > max_duty) { + log_w("Final duty %d was adjusted to the maximum duty %d", target_duty, max_duty); + target_duty = max_duty; + } + if (start_duty > max_duty) { + log_w("Starting duty %d was adjusted to the maximum duty %d", start_duty, max_duty); + start_duty = max_duty; + } + if (start_duty >= target_duty) { + log_e("Starting duty must be lower than the final duty"); + return false; + } + // Initialize fade service. if (!fade_initialized) { ledc_fade_func_install(0); @@ -389,17 +404,6 @@ static bool ledcFadeConfig(uint8_t pin, uint32_t start_duty, uint32_t target_dut ledc_cbs_t callbacks = {.fade_cb = ledcFnWrapper}; ledc_cb_register(group, channel, &callbacks, (void *)bus); - uint32_t max_duty = (1 << bus->channel_resolution); // Max LEDC duty - - if (target_duty > max_duty) { - log_w("Target duty %d was adjusted to the maximum duty %d", target_duty, max_duty); - target_duty = max_duty; - } - if (start_duty > max_duty) { - log_w("Starting duty %d was adjusted to the maximum duty %d", start_duty, max_duty); - start_duty = max_duty; - } - #if SOC_LEDC_SUPPORT_FADE_STOP ledc_fade_stop(group, channel); #endif @@ -454,7 +458,7 @@ void analogWrite(uint8_t pin, int value) { log_w("Duty is out of range. Valid duty range for pin d is 0 to %d", pin, max_duty); return; } - if ((value == max_duty) && (max_duty != 1)) { + if (value == max_duty) { value = max_duty + 1; } ledcWrite(pin, value); From 08fea233766c5aebc40fe129ac6acca41773ddd5 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Sat, 3 May 2025 17:18:17 -0300 Subject: [PATCH 06/14] fix(ledc): failing to execute shall issue error log --- cores/esp32/esp32-hal-ledc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index 0b044d7e97d..f3a4e4a2260 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -455,7 +455,7 @@ void analogWrite(uint8_t pin, int value) { // Therefore, it will adjust Arduino MAX Duty to be the LEDC MAx Duty uint32_t max_duty = (1 << bus->channel_resolution) - 1; if (value < 0 || value > max_duty) { - log_w("Duty is out of range. Valid duty range for pin d is 0 to %d", pin, max_duty); + log_e("Duty is out of range. Valid duty range for pin d is 0 to %d", pin, max_duty); return; } if (value == max_duty) { From 174beccd532b62db29d3c54f72481aa73a32f47f Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Sat, 3 May 2025 17:19:28 -0300 Subject: [PATCH 07/14] fix(ledc): missing correct log message format --- cores/esp32/esp32-hal-ledc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index f3a4e4a2260..8a55610cd3b 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -455,7 +455,7 @@ void analogWrite(uint8_t pin, int value) { // Therefore, it will adjust Arduino MAX Duty to be the LEDC MAx Duty uint32_t max_duty = (1 << bus->channel_resolution) - 1; if (value < 0 || value > max_duty) { - log_e("Duty is out of range. Valid duty range for pin d is 0 to %d", pin, max_duty); + log_e("Duty is out of range. Valid duty range for pin %d is 0 to %d", pin, max_duty); return; } if (value == max_duty) { From 71f0a559a238428d5892f1fd5736282fd15f2ccb Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 01:15:00 -0300 Subject: [PATCH 08/14] feat(ledc): Fix target duty value for LEDC to 4096 (maximum) --- libraries/ESP32/examples/AnalogOut/LEDCFade/LEDCFade.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ESP32/examples/AnalogOut/LEDCFade/LEDCFade.ino b/libraries/ESP32/examples/AnalogOut/LEDCFade/LEDCFade.ino index ea190e4f140..c37d9d081a0 100644 --- a/libraries/ESP32/examples/AnalogOut/LEDCFade/LEDCFade.ino +++ b/libraries/ESP32/examples/AnalogOut/LEDCFade/LEDCFade.ino @@ -17,7 +17,7 @@ // define starting duty, target duty and maximum fade time #define LEDC_START_DUTY (0) -#define LEDC_TARGET_DUTY (4095) +#define LEDC_TARGET_DUTY (4096) #define LEDC_FADE_TIME (3000) bool fade_ended = false; // status of LED fade From 49875c399fb0c1a5ac05e23c87654d6b1f82a7b8 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 01:16:19 -0300 Subject: [PATCH 09/14] feat(ledc): Fix target duty value for LEDC to 4096 (maximum) --- .../ESP32/examples/AnalogOut/LEDCGammaFade/LEDCGammaFade.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ESP32/examples/AnalogOut/LEDCGammaFade/LEDCGammaFade.ino b/libraries/ESP32/examples/AnalogOut/LEDCGammaFade/LEDCGammaFade.ino index 4ca6c136ddf..2275bbb4eda 100644 --- a/libraries/ESP32/examples/AnalogOut/LEDCGammaFade/LEDCGammaFade.ino +++ b/libraries/ESP32/examples/AnalogOut/LEDCGammaFade/LEDCGammaFade.ino @@ -21,7 +21,7 @@ // define starting duty, target duty and maximum fade time #define LEDC_START_DUTY (0) -#define LEDC_TARGET_DUTY (4095) +#define LEDC_TARGET_DUTY (4096) #define LEDC_FADE_TIME (2000) // gamma factor for mathematical calculation From 11dcd5c645a692c523fd7df77e8a4d9145f525f8 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 01:17:44 -0300 Subject: [PATCH 10/14] feat(ledc): Change LED fade amount and brightness limits --- .../AnalogOut/LEDCSingleChannel/LEDCSingleChannel.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/ESP32/examples/AnalogOut/LEDCSingleChannel/LEDCSingleChannel.ino b/libraries/ESP32/examples/AnalogOut/LEDCSingleChannel/LEDCSingleChannel.ino index 2317e32a11a..3608a2e641c 100644 --- a/libraries/ESP32/examples/AnalogOut/LEDCSingleChannel/LEDCSingleChannel.ino +++ b/libraries/ESP32/examples/AnalogOut/LEDCSingleChannel/LEDCSingleChannel.ino @@ -26,7 +26,7 @@ #define LEDC_CHANNEL 0 int brightness = 0; // how bright the LED is -int fadeAmount = 5; // how many points to fade the LED by +int fadeAmount = 4; // how many points to fade the LED by void setup() { // Use single LEDC channel 0 for both pins @@ -42,7 +42,7 @@ void loop() { brightness = brightness + fadeAmount; // reverse the direction of the fading at the ends of the fade: - if (brightness <= 0 || brightness >= 255) { + if (brightness <= 0 || brightness >= 256) { fadeAmount = -fadeAmount; } // wait for 30 milliseconds to see the dimming effect From 69baa144445c1d3f58eb2229f443e332ce7c00a2 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 01:19:03 -0300 Subject: [PATCH 11/14] feat(ledc): Adjust LED fade parameters for new maximum values --- .../AnalogOut/LEDCSoftwareFade/LEDCSoftwareFade.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/ESP32/examples/AnalogOut/LEDCSoftwareFade/LEDCSoftwareFade.ino b/libraries/ESP32/examples/AnalogOut/LEDCSoftwareFade/LEDCSoftwareFade.ino index c605a89bc0b..4c88a7f534b 100644 --- a/libraries/ESP32/examples/AnalogOut/LEDCSoftwareFade/LEDCSoftwareFade.ino +++ b/libraries/ESP32/examples/AnalogOut/LEDCSoftwareFade/LEDCSoftwareFade.ino @@ -20,13 +20,13 @@ #define LED_PIN 5 int brightness = 0; // how bright the LED is -int fadeAmount = 5; // how many points to fade the LED by +int fadeAmount = 4; // how many points to fade the LED by // Arduino like analogWrite // value has to be between 0 and valueMax -void ledcAnalogWrite(uint8_t pin, uint32_t value, uint32_t valueMax = 255) { +void ledcAnalogWrite(uint8_t pin, uint32_t value, uint32_t valueMax = 256) { // calculate duty, 4095 from 2 ^ 12 - 1 - uint32_t duty = (4095 / valueMax) * min(value, valueMax); + uint32_t duty = (4096 / valueMax) * min(value, valueMax); // write duty to LEDC ledcWrite(pin, duty); @@ -45,7 +45,7 @@ void loop() { brightness = brightness + fadeAmount; // reverse the direction of the fading at the ends of the fade: - if (brightness <= 0 || brightness >= 255) { + if (brightness <= 0 || brightness >= 256) { fadeAmount = -fadeAmount; } // wait for 30 milliseconds to see the dimming effect From c8d0a9f9c55a978150b7b0b05c55806e10a23ced Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 03:46:49 -0300 Subject: [PATCH 12/14] feat(ledc): Change ledc full brightness to 256 --- .../examples/AnalogOut/ledcWrite_RGB/ledcWrite_RGB.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/ESP32/examples/AnalogOut/ledcWrite_RGB/ledcWrite_RGB.ino b/libraries/ESP32/examples/AnalogOut/ledcWrite_RGB/ledcWrite_RGB.ino index b7ea8943487..4c45b2b3a74 100644 --- a/libraries/ESP32/examples/AnalogOut/ledcWrite_RGB/ledcWrite_RGB.ino +++ b/libraries/ESP32/examples/AnalogOut/ledcWrite_RGB/ledcWrite_RGB.ino @@ -17,7 +17,7 @@ const boolean invert = true; // set true if common anode, false if common catho uint8_t color = 0; // a value from 0 to 255 representing the hue uint32_t R, G, B; // the Red Green and Blue color components -uint8_t brightness = 255; // 255 is maximum brightness, but can be changed. Might need 256 for common anode to fully turn off. +uint16_t brightness = 255; // 255 is maximum brightness, but can be changed. // the setup routine runs once when you press reset: void setup() { @@ -33,12 +33,12 @@ void setup() { // void loop runs over and over again void loop() { - Serial.println("Send all LEDs a 255 and wait 2 seconds."); + Serial.println("Send all LEDs a 256 and wait 2 seconds."); // If your RGB LED turns off instead of on here you should check if the LED is common anode or cathode. // If it doesn't fully turn off and is common anode try using 256. - ledcWrite(ledR, 255); - ledcWrite(ledG, 255); - ledcWrite(ledB, 255); + ledcWrite(ledR, 256); + ledcWrite(ledG, 256); + ledcWrite(ledB, 256); delay(2000); Serial.println("Send all LEDs a 0 and wait 2 seconds."); ledcWrite(ledR, 0); From 5b29c68b81bc098f7f95d62c9a1135b9760818cf Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 03:49:44 -0300 Subject: [PATCH 13/14] fix(ledc): revert back Hue range to 0..255 --- .../ESP32/examples/AnalogOut/ledcWrite_RGB/ledcWrite_RGB.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ESP32/examples/AnalogOut/ledcWrite_RGB/ledcWrite_RGB.ino b/libraries/ESP32/examples/AnalogOut/ledcWrite_RGB/ledcWrite_RGB.ino index 4c45b2b3a74..a3c8c06a5c9 100644 --- a/libraries/ESP32/examples/AnalogOut/ledcWrite_RGB/ledcWrite_RGB.ino +++ b/libraries/ESP32/examples/AnalogOut/ledcWrite_RGB/ledcWrite_RGB.ino @@ -17,7 +17,7 @@ const boolean invert = true; // set true if common anode, false if common catho uint8_t color = 0; // a value from 0 to 255 representing the hue uint32_t R, G, B; // the Red Green and Blue color components -uint16_t brightness = 255; // 255 is maximum brightness, but can be changed. +uint8_t brightness = 255; // 255 is maximum brightness, but can be changed. Might need 256 for common anode to fully turn off. // the setup routine runs once when you press reset: void setup() { From 481d39207d255611634438c2f93b51a611a91436 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 3 Nov 2025 03:59:10 -0300 Subject: [PATCH 14/14] feat(ledc): Specify maximum duty value for LEDC functions Added maximum value constraints for duty parameters in LEDC functions. --- docs/en/api/ledc.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/en/api/ledc.rst b/docs/en/api/ledc.rst index d3d6da1e0f6..a6e9d323d65 100644 --- a/docs/en/api/ledc.rst +++ b/docs/en/api/ledc.rst @@ -100,7 +100,7 @@ This function is used to set duty for the LEDC pin. bool ledcWrite(uint8_t pin, uint32_t duty); * ``pin`` select LEDC pin. -* ``duty`` select duty to be set for selected LEDC pin. +* ``duty`` select duty to be set for selected LEDC pin. Maximum value is 2 ^ ``resolution`` (number of bits). This function will return ``true`` if setting duty is successful. If ``false`` is returned, error occurs and duty was not set. @@ -115,7 +115,7 @@ This function is used to set duty for the LEDC channel. bool ledcWriteChannel(uint8_t channel, uint32_t duty); * ``channel`` select LEDC channel. -* ``duty`` select duty to be set for selected LEDC channel. +* ``duty`` select duty to be set for selected LEDC channel. Maximum value is 2 ^ ``resolution`` (number of bits). This function will return ``true`` if setting duty is successful. If ``false`` is returned, error occurs and duty was not set. @@ -240,8 +240,8 @@ This function is used to setup and start fade for the LEDC pin. bool ledcFade(uint8_t pin, uint32_t start_duty, uint32_t target_duty, int max_fade_time_ms); * ``pin`` select LEDC pin. -* ``start_duty`` select starting duty of fade. -* ``target_duty`` select target duty of fade. +* ``start_duty`` select starting duty of fade. Maximum value is 2 ^ ``resolution`` (number of bits). +* ``target_duty`` select target duty of fade. Maximum value is 2 ^ ``resolution`` (number of bits). * ``max_fade_time_ms`` select maximum time for fade. This function will return ``true`` if configuration is successful. @@ -257,8 +257,8 @@ This function is used to setup and start fade for the LEDC pin with interrupt. bool ledcFadeWithInterrupt(uint8_t pin, uint32_t start_duty, uint32_t target_duty, int max_fade_time_ms, void (*userFunc)(void)); * ``pin`` select LEDC pin. -* ``start_duty`` select starting duty of fade. -* ``target_duty`` select target duty of fade. +* ``start_duty`` select starting duty of fade. Maximum value is 2 ^ ``resolution`` (number of bits). +* ``target_duty`` select target duty of fade. Maximum value is 2 ^ ``resolution`` (number of bits). * ``max_fade_time_ms`` select maximum time for fade. * ``userFunc`` function to be called when interrupt is triggered. @@ -275,8 +275,8 @@ This function is used to setup and start fade for the LEDC pin with interrupt us bool ledcFadeWithInterruptArg(uint8_t pin, uint32_t start_duty, uint32_t target_duty, int max_fade_time_ms, void (*userFunc)(void*), void * arg); * ``pin`` select LEDC pin. -* ``start_duty`` select starting duty of fade. -* ``target_duty`` select target duty of fade. +* ``start_duty`` select starting duty of fade. Maximum value is 2 ^ ``resolution`` (number of bits). +* ``target_duty`` select target duty of fade. Maximum value is 2 ^ ``resolution`` (number of bits). * ``max_fade_time_ms`` select maximum time for fade. * ``userFunc`` function to be called when interrupt is triggered. * ``arg`` pointer to the interrupt arguments.