diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 698888f81..93e8da613 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -19,7 +19,6 @@ - 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 b90d882c8..941659d62 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -263,6 +263,8 @@ 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]; @@ -274,12 +276,11 @@ struct LIGHT { uint8_t subtype = 0; // LST_ subtype uint8_t device = 0; uint8_t old_power = 1; - uint8_t wakeup_active = 0; // 0=inctive, 1=on-going, 2=about to start, 3=will be triggered next cycle + uint8_t wakeup_active = 0; + uint8_t wakeup_dimmer = 0; 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 @@ -1865,27 +1866,25 @@ 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; - } - Light.wakeup_start_time = millis(); + if (2 == Light.wakeup_active) { + Light.wakeup_active = 1; + for (uint32_t i = 0; i < Light.subtype; i++) { + Light.new_color[i] = 0; } - // 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.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); light_controller.calcLevels(); for (uint32_t i = 0; i < Light.subtype; i++) { Light.new_color[i] = Light.current_color[i]; } - } - if (1023 == step_10) { + } else { Response_P(PSTR("{\"" D_CMND_WAKEUP "\":\"" D_JSON_DONE "\"")); ResponseLightState(1); ResponseJsonEnd();