mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-21 17:56:31 +00:00
Merge pull request #9770 from pcdiem/dgr1
Set light_dimmer on DGR bri changes, Use DGR direct for PWM dimmer
This commit is contained in:
commit
ab6d08ada0
@ -1954,7 +1954,7 @@ void LightAnimate(void)
|
|||||||
}
|
}
|
||||||
if (Light.update) {
|
if (Light.update) {
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
if (Light.power) LightSendDeviceGroupStatus(false);
|
if (Light.power && !Light.devgrp_no_channels_out) LightSendDeviceGroupStatus(false);
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
|
|
||||||
uint16_t cur_col_10[LST_MAX]; // 10 bits resolution
|
uint16_t cur_col_10[LST_MAX]; // 10 bits resolution
|
||||||
@ -2315,7 +2315,7 @@ void LightSendDeviceGroupStatus(bool status)
|
|||||||
static uint8_t last_bri;
|
static uint8_t last_bri;
|
||||||
uint8_t bri = light_state.getBri();
|
uint8_t bri = light_state.getBri();
|
||||||
bool send_bri_update = (status || bri != last_bri);
|
bool send_bri_update = (status || bri != last_bri);
|
||||||
if (Light.subtype > LST_SINGLE && !Light.devgrp_no_channels_out) {
|
if (Light.subtype > LST_SINGLE) {
|
||||||
static uint8_t channels[LST_MAX + 1] = { 0, 0, 0, 0, 0, 0 };
|
static uint8_t channels[LST_MAX + 1] = { 0, 0, 0, 0, 0, 0 };
|
||||||
if (status) {
|
if (status) {
|
||||||
light_state.getChannels(channels);
|
light_state.getChannels(channels);
|
||||||
@ -2345,13 +2345,17 @@ void LightHandleDevGroupItem(void)
|
|||||||
switch (XdrvMailbox.command_code) {
|
switch (XdrvMailbox.command_code) {
|
||||||
case DGR_ITEM_EOL:
|
case DGR_ITEM_EOL:
|
||||||
more_to_come = (XdrvMailbox.index & DGR_FLAG_MORE_TO_COME);
|
more_to_come = (XdrvMailbox.index & DGR_FLAG_MORE_TO_COME);
|
||||||
if (restore_power && !more_to_come) {
|
if (more_to_come) {
|
||||||
|
TasmotaGlobal.skip_light_fade = true;
|
||||||
|
}
|
||||||
|
else if (restore_power) {
|
||||||
restore_power = false;
|
restore_power = false;
|
||||||
Light.power = Light.old_power;
|
Light.power = Light.old_power;
|
||||||
}
|
}
|
||||||
|
|
||||||
LightAnimate();
|
LightAnimate();
|
||||||
|
|
||||||
|
TasmotaGlobal.skip_light_fade = true;
|
||||||
if (send_state && !more_to_come) {
|
if (send_state && !more_to_come) {
|
||||||
light_controller.saveSettings();
|
light_controller.saveSettings();
|
||||||
if (Settings.flag3.hass_tele_on_power) { // SetOption59 - Send tele/%topic%/STATE in addition to stat/%topic%/RESULT
|
if (Settings.flag3.hass_tele_on_power) { // SetOption59 - Send tele/%topic%/STATE in addition to stat/%topic%/RESULT
|
||||||
@ -2363,6 +2367,7 @@ void LightHandleDevGroupItem(void)
|
|||||||
case DGR_ITEM_LIGHT_BRI:
|
case DGR_ITEM_LIGHT_BRI:
|
||||||
if (light_state.getBri() != value) {
|
if (light_state.getBri() != value) {
|
||||||
light_state.setBri(value);
|
light_state.setBri(value);
|
||||||
|
Settings.light_dimmer = light_state.BriToDimmer(value);
|
||||||
send_state = true;
|
send_state = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2431,7 +2436,6 @@ void LightHandleDevGroupItem(void)
|
|||||||
light_controller.changeChannels(Light.entry_color);
|
light_controller.changeChannels(Light.entry_color);
|
||||||
light_controller.changeBri(old_bri);
|
light_controller.changeBri(old_bri);
|
||||||
Settings.light_scheme = 0;
|
Settings.light_scheme = 0;
|
||||||
Light.devgrp_no_channels_out = false;
|
|
||||||
if (!restore_power && !Light.power) {
|
if (!restore_power && !Light.power) {
|
||||||
Light.old_power = Light.power;
|
Light.old_power = Light.power;
|
||||||
Light.power = 0xff;
|
Light.power = 0xff;
|
||||||
|
@ -91,13 +91,13 @@ void PWMModulePreInit(void)
|
|||||||
if (TasmotaGlobal.module_changed) {
|
if (TasmotaGlobal.module_changed) {
|
||||||
Settings.flag.pwm_control = true; // SetOption15 - Switch between commands PWM or COLOR/DIMMER/CT/CHANNEL
|
Settings.flag.pwm_control = true; // SetOption15 - Switch between commands PWM or COLOR/DIMMER/CT/CHANNEL
|
||||||
Settings.bri_power_on = Settings.bri_preset_low = Settings.bri_preset_high = 0;
|
Settings.bri_power_on = Settings.bri_preset_low = Settings.bri_preset_high = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Previous versions of PWM Dimmer used SetOption32 - Button held for factor times longer as the
|
// Previous versions of PWM Dimmer used SetOption32 - Button held for factor times longer as the
|
||||||
// hold time. The hold time is now fixed and SetOption32 is used as normal including to
|
// hold time. The hold time is now fixed and SetOption32 is used as normal including to
|
||||||
// determine how long a button is held before a reset command is executed. If SetOption32 is
|
// determine how long a button is held before a reset command is executed. If SetOption32 is
|
||||||
// still 5, change it to 40 (the default).
|
// still 5, change it to 40 (the default).
|
||||||
if (Settings.param[P_HOLD_TIME] == 5) Settings.param[P_HOLD_TIME] = 40;
|
if (Settings.param[P_HOLD_TIME] == 5) Settings.param[P_HOLD_TIME] = 40;
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure the brightness level settings are sensible.
|
// Make sure the brightness level settings are sensible.
|
||||||
if (!Settings.bri_power_on) Settings.bri_power_on = 128;
|
if (!Settings.bri_power_on) Settings.bri_power_on = 128;
|
||||||
@ -482,7 +482,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
|||||||
else
|
else
|
||||||
#endif // USE_PWM_DIMMER_REMOTE
|
#endif // USE_PWM_DIMMER_REMOTE
|
||||||
bri = light_state.getBri();
|
bri = light_state.getBri();
|
||||||
int32_t new_bri = bri + bri_offset * ((dgr_item ? 16 : Settings.light_correction ? 4 : bri / 16 + 1));
|
int32_t new_bri = bri + bri_offset * (Settings.light_correction ? 4 : bri / 16 + 1);
|
||||||
|
|
||||||
if (bri_offset > 0) {
|
if (bri_offset > 0) {
|
||||||
if (new_bri > 255) new_bri = 255;
|
if (new_bri > 255) new_bri = 255;
|
||||||
@ -492,7 +492,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
|||||||
}
|
}
|
||||||
if (new_bri != bri) {
|
if (new_bri != bri) {
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
SendDeviceGroupMessage(power_button_index, (dgr_more_to_come ? DGR_MSGTYP_UPDATE_MORE_TO_COME : DGR_MSGTYP_UPDATE), DGR_ITEM_LIGHT_BRI, new_bri);
|
SendDeviceGroupMessage(power_button_index, (dgr_more_to_come ? DGR_MSGTYP_UPDATE_MORE_TO_COME : DGR_MSGTYP_UPDATE_DIRECT), DGR_ITEM_LIGHT_BRI, new_bri);
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
#ifdef USE_PWM_DIMMER_REMOTE
|
#ifdef USE_PWM_DIMMER_REMOTE
|
||||||
if (active_remote_pwm_dimmer) {
|
if (active_remote_pwm_dimmer) {
|
||||||
@ -506,6 +506,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
|||||||
ignore_dgr_sends = true;
|
ignore_dgr_sends = true;
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
light_state.setBri(new_bri);
|
light_state.setBri(new_bri);
|
||||||
|
Settings.light_dimmer = light_state.BriToDimmer(new_bri);
|
||||||
LightAnimate();
|
LightAnimate();
|
||||||
TasmotaGlobal.skip_light_fade = false;
|
TasmotaGlobal.skip_light_fade = false;
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
@ -551,6 +552,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
|||||||
else {
|
else {
|
||||||
#endif // USE_PWM_DIMMER_REMOTE
|
#endif // USE_PWM_DIMMER_REMOTE
|
||||||
light_state.setBri(power_on_bri);
|
light_state.setBri(power_on_bri);
|
||||||
|
Settings.light_dimmer = light_state.BriToDimmer(power_on_bri);
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
Light.devgrp_no_channels_out = true;
|
Light.devgrp_no_channels_out = true;
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user