I have a callback-routine which is called when the led switches ON or OFF or a new brightness (a slider in the Alexa-App is moved around. The
bool ledcFade(uint8_t pin, uint32_t start_duty, uint32_t target_duty, int max_fade_time_ms);
stucks if it is called again before the fade ends.
Code: Select all
callback(newbrightness)
{
ledcFade(port_LED_l1, ledcRead(port_LED_l1), newbrightness, FADETIME_MS); // fade 3 secs
}
Code: Select all
callback(newbrightness)
{
ledcWrite(port_LED_l1, ledcRead(port_LED_l1)); // init, if a fade is running it helps not to get stuck
ledcFade(port_LED_l1, ledcRead(port_LED_l1), newbrightness, FADETIME_MS); // fade 3 secs
}