mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
Force PWM reapply after frequency change (#13141)
* Force PWM reapply after frequency change * Fix compilation is USE_LIGHT is not defined
This commit is contained in:
parent
f9e1ab1c90
commit
e8b30eadfe
@ -1450,6 +1450,10 @@ void CmndPwmfrequency(void)
|
|||||||
if ((1 == XdrvMailbox.payload) || ((XdrvMailbox.payload >= PWM_MIN) && (XdrvMailbox.payload <= PWM_MAX))) {
|
if ((1 == XdrvMailbox.payload) || ((XdrvMailbox.payload >= PWM_MIN) && (XdrvMailbox.payload <= PWM_MAX))) {
|
||||||
Settings->pwm_frequency = (1 == XdrvMailbox.payload) ? PWM_FREQ : XdrvMailbox.payload;
|
Settings->pwm_frequency = (1 == XdrvMailbox.payload) ? PWM_FREQ : XdrvMailbox.payload;
|
||||||
analogWriteFreq(Settings->pwm_frequency); // Default is 1000 (core_esp8266_wiring_pwm.c)
|
analogWriteFreq(Settings->pwm_frequency); // Default is 1000 (core_esp8266_wiring_pwm.c)
|
||||||
|
#ifdef USE_LIGHT
|
||||||
|
LightReapplyColor();
|
||||||
|
LightAnimate();
|
||||||
|
#endif // USE_LIGHT
|
||||||
}
|
}
|
||||||
ResponseCmndNumber(Settings->pwm_frequency);
|
ResponseCmndNumber(Settings->pwm_frequency);
|
||||||
}
|
}
|
||||||
|
@ -1656,6 +1656,13 @@ uint8_t LightGetSpeedSetting(void) {
|
|||||||
return Settings->light_speed;
|
return Settings->light_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force to reapply color, for example when PWM Frequency changed
|
||||||
|
void LightReapplyColor(void) {
|
||||||
|
for (uint32_t i = 0; i < LST_MAX; i++) {
|
||||||
|
Light.last_color[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// On entry Light.new_color[5] contains the color to be displayed
|
// On entry Light.new_color[5] contains the color to be displayed
|
||||||
// and Light.last_color[5] the color currently displayed
|
// and Light.last_color[5] the color currently displayed
|
||||||
// Light.power tells which lights or channels (SetOption68) are on/off
|
// Light.power tells which lights or channels (SetOption68) are on/off
|
||||||
|
Loading…
x
Reference in New Issue
Block a user