Merge pull request #13861 from pcdiem/pwm-dimmer-2

Make sure PWM Dimmer night light stays updated
This commit is contained in:
Theo Arends 2021-11-30 10:08:43 +01:00 committed by GitHub
commit 79191b32be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 11 deletions

View File

@ -491,6 +491,9 @@ void SetLedLink(uint32_t state)
#ifdef USE_BUZZER
BuzzerSetStateToLed(state);
#endif // USE_BUZZER
#ifdef USE_PWM_DIMMER
if (Settings->flag4.powered_off_led) TasmotaGlobal.restore_powered_off_led_counter = 3;
#endif // USE_PWM_DIMMER
}
void SetPulseTimer(uint32_t index, uint32_t time)

View File

@ -184,6 +184,9 @@ struct TasmotaGlobal_t {
uint8_t last_source; // Last command source
uint8_t shutters_present; // Number of actual define shutters
uint8_t discovery_counter; // Delayed discovery counter
#ifdef USE_PWM_DIMMER
uint8_t restore_powered_off_led_counter; // Seconds before powered-off LED (LEDLink) is restored
#endif // USE_PWM_DIMMER
#ifndef SUPPORT_IF_STATEMENT
uint8_t backlog_index; // Command backlog index

View File

@ -63,7 +63,6 @@ struct remote_pwm_dimmer {
uint32_t ignore_any_key_time = 0;
uint32_t button_hold_time[3];
uint8_t led_timeout_seconds = 0;
uint8_t restore_powered_off_led_counter = 0;
uint8_t power_button_index = 0;
uint8_t down_button_index = 1;
uint8_t buttons_pressed = 0;
@ -744,16 +743,10 @@ bool Xdrv35(uint8_t function)
PWMDimmerSetBrightnessLeds(-2);
}
// The powered-off LED is also the LedLink LED. If we lose the WiFi or MQTT server connection,
// the LED will be set to a blinking state and will be turned off when the connection is
// restored. If the state is blinking now, set a flag so we know that we need to restore it
// when it stops blinking.
if (TasmotaGlobal.global_state.data)
restore_powered_off_led_counter = 5;
else if (restore_powered_off_led_counter) {
PWMDimmerSetPoweredOffLed();
restore_powered_off_led_counter--;
}
// The powered-off LED is also the LedLink LED. If the state of it gets changed,
// restore_powered_off_led_counter will get set to the number of seconds
// to wait before restoring it to the proper state.
if (TasmotaGlobal.restore_powered_off_led_counter && !--TasmotaGlobal.restore_powered_off_led_counter) PWMDimmerSetPoweredOffLed();
break;
case FUNC_BUTTON_PRESSED: