mirror of https://github.com/arendst/Tasmota.git
Merge pull request #15647 from pcdiem/pwm-dimmer-4
Use adjusted bri for LED's after timeout
This commit is contained in:
commit
9b750f8b70
|
@ -240,6 +240,7 @@ struct TasmotaGlobal_t {
|
||||||
uint8_t discovery_counter; // Delayed discovery counter
|
uint8_t discovery_counter; // Delayed discovery counter
|
||||||
#ifdef USE_PWM_DIMMER
|
#ifdef USE_PWM_DIMMER
|
||||||
uint8_t restore_powered_off_led_counter; // Seconds before powered-off LED (LEDLink) is restored
|
uint8_t restore_powered_off_led_counter; // Seconds before powered-off LED (LEDLink) is restored
|
||||||
|
uint8_t pwm_dimmer_led_bri; // Adjusted brightness LED level
|
||||||
#endif // USE_PWM_DIMMER
|
#endif // USE_PWM_DIMMER
|
||||||
|
|
||||||
#ifndef SUPPORT_IF_STATEMENT
|
#ifndef SUPPORT_IF_STATEMENT
|
||||||
|
|
|
@ -2168,7 +2168,10 @@ void LightSetOutputs(const uint16_t *cur_col_10) {
|
||||||
|
|
||||||
#ifdef USE_PWM_DIMMER
|
#ifdef USE_PWM_DIMMER
|
||||||
// Animate brightness LEDs to follow PWM dimmer brightness
|
// Animate brightness LEDs to follow PWM dimmer brightness
|
||||||
if (PWM_DIMMER == TasmotaGlobal.module_type) PWMDimmerSetBrightnessLeds(change10to8(max_col));
|
if (PWM_DIMMER == TasmotaGlobal.module_type) {
|
||||||
|
TasmotaGlobal.pwm_dimmer_led_bri = change10to8(max_col);
|
||||||
|
PWMDimmerSetBrightnessLeds(-1);
|
||||||
|
}
|
||||||
#endif // USE_PWM_DIMMER
|
#endif // USE_PWM_DIMMER
|
||||||
}
|
}
|
||||||
// char msg[24];
|
// char msg[24];
|
||||||
|
|
|
@ -152,7 +152,7 @@ void PWMModulePreInit(void)
|
||||||
#endif // USE_PWM_DIMMER_REMOTE
|
#endif // USE_PWM_DIMMER_REMOTE
|
||||||
}
|
}
|
||||||
|
|
||||||
// bri: -1 = set to current light bri, -2 = timeout, 0-255 = set to bri
|
// bri: -1 = set to last local light bri, -2 = timeout, 0-255 = set to bri
|
||||||
void PWMDimmerSetBrightnessLeds(int32_t bri)
|
void PWMDimmerSetBrightnessLeds(int32_t bri)
|
||||||
{
|
{
|
||||||
// Find out how many of the LEDs have their ledmask bit set.
|
// Find out how many of the LEDs have their ledmask bit set.
|
||||||
|
@ -169,7 +169,7 @@ void PWMDimmerSetBrightnessLeds(int32_t bri)
|
||||||
if (leds) {
|
if (leds) {
|
||||||
led_timeout_seconds = 5;
|
led_timeout_seconds = 5;
|
||||||
if (bri < 0) {
|
if (bri < 0) {
|
||||||
bri = ((bri == -2 && Settings->flag4.led_timeout) || !Light.power ? 0 : light_state.getBri());
|
bri = ((bri == -2 && Settings->flag4.led_timeout) || !Light.power ? 0 : TasmotaGlobal.pwm_dimmer_led_bri);
|
||||||
if (!bri || !Settings->flag4.led_timeout) led_timeout_seconds = 0;
|
if (!bri || !Settings->flag4.led_timeout) led_timeout_seconds = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,13 +438,13 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
||||||
if (!active_remote_pwm_dimmer) {
|
if (!active_remote_pwm_dimmer) {
|
||||||
#endif // USE_PWM_DIMMER_REMOTE
|
#endif // USE_PWM_DIMMER_REMOTE
|
||||||
|
|
||||||
// Toggle the powered-off LED option.
|
// Toggle the LED timeout.
|
||||||
if (down_button_tapped) {
|
if (down_button_tapped) {
|
||||||
Settings->flag4.led_timeout ^= 1;
|
Settings->flag4.led_timeout ^= 1;
|
||||||
if (Light.power) PWMDimmerSetBrightnessLeds(Settings->flag4.led_timeout ? 0 : -1);
|
if (Light.power) PWMDimmerSetBrightnessLeds(Settings->flag4.led_timeout ? 0 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle the LED timeout.
|
// Toggle the powered-off LED option.
|
||||||
else {
|
else {
|
||||||
Settings->flag4.powered_off_led ^= 1;
|
Settings->flag4.powered_off_led ^= 1;
|
||||||
PWMDimmerSetPoweredOffLed();
|
PWMDimmerSetPoweredOffLed();
|
||||||
|
|
Loading…
Reference in New Issue