From 32a2407b19f348b46aae77a97fc22539b02f7efc Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 27 Sep 2020 11:03:29 +0200 Subject: [PATCH] Revert "Revert "Merge pull request #9391 from s-hadinger/fade_256_dev"" This reverts commit 217addc2bb2cf46e7633c93e87954b245cb96556. --- tasmota/CHANGELOG.md | 1 + tasmota/xdrv_04_light.ino | 37 +++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 93e8da613..698888f81 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -19,6 +19,7 @@ - Add new shutter modes (#9244) - Add Zigbee auto-config when pairing - Add support for MLX90640 IR array temperature sensor by Christian Baars +- Change ``WakeUp`` uses 256 steps instead of 100 (#9241) ### 8.5.0 20200907 diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 941659d62..b90d882c8 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -263,8 +263,6 @@ struct LIGHT { uint32_t strip_timer_counter = 0; // Bars and Gradient power_t power = 0; // Power for each channel if SetOption68, or boolean if single light - uint16_t wakeup_counter = 0; - uint8_t entry_color[LST_MAX]; uint8_t current_color[LST_MAX]; uint8_t new_color[LST_MAX]; @@ -276,11 +274,12 @@ struct LIGHT { uint8_t subtype = 0; // LST_ subtype uint8_t device = 0; uint8_t old_power = 1; - uint8_t wakeup_active = 0; - uint8_t wakeup_dimmer = 0; + uint8_t wakeup_active = 0; // 0=inctive, 1=on-going, 2=about to start, 3=will be triggered next cycle uint8_t fixed_color_index = 1; uint8_t pwm_offset = 0; // Offset in color buffer uint8_t max_scheme = LS_MAX -1; + + uint32_t wakeup_start_time = 0; bool update = true; bool pwm_multi_channels = false; // SetOption68, treat each PWM channel as an independant dimmer @@ -1866,25 +1865,27 @@ void LightAnimate(void) light_controller.calcLevels(Light.new_color); break; case LS_WAKEUP: - if (2 == Light.wakeup_active) { - Light.wakeup_active = 1; - for (uint32_t i = 0; i < Light.subtype; i++) { - Light.new_color[i] = 0; + { + if (2 == Light.wakeup_active) { + Light.wakeup_active = 1; + for (uint32_t i = 0; i < Light.subtype; i++) { + Light.new_color[i] = 0; + } + Light.wakeup_start_time = millis(); } - Light.wakeup_counter = 0; - Light.wakeup_dimmer = 0; - } - Light.wakeup_counter++; - if (Light.wakeup_counter > ((Settings.light_wakeup * STATES) / Settings.light_dimmer)) { - Light.wakeup_counter = 0; - Light.wakeup_dimmer++; - if (Light.wakeup_dimmer <= Settings.light_dimmer) { - light_state.setDimmer(Light.wakeup_dimmer); + // which step are we in a range 0..1023 + uint32_t step_10 = ((millis() - Light.wakeup_start_time) * 1023) / (Settings.light_wakeup * 1000); + if (step_10 > 1023) { step_10 = 1023; } // sanity check + uint8_t wakeup_bri = changeUIntScale(step_10, 0, 1023, 0, LightStateClass::DimmerToBri(Settings.light_dimmer)); + + if (wakeup_bri != light_state.getBri()) { + light_state.setBri(wakeup_bri); light_controller.calcLevels(); for (uint32_t i = 0; i < Light.subtype; i++) { Light.new_color[i] = Light.current_color[i]; } - } else { + } + if (1023 == step_10) { Response_P(PSTR("{\"" D_CMND_WAKEUP "\":\"" D_JSON_DONE "\"")); ResponseLightState(1); ResponseJsonEnd();