Change `WakeUp` uses 256 steps instead of 100 (#9241)

This commit is contained in:
Stephan Hadinger 2020-09-26 11:44:05 +02:00
parent 8a849ffb05
commit 1a9f0bfa33
2 changed files with 20 additions and 18 deletions

View File

@ -19,6 +19,7 @@
- Add new shutter modes (#9244) - Add new shutter modes (#9244)
- Add Zigbee auto-config when pairing - Add Zigbee auto-config when pairing
- Add support for MLX90640 IR array temperature sensor by Christian Baars - Add support for MLX90640 IR array temperature sensor by Christian Baars
- Change ``WakeUp`` uses 256 steps instead of 100 (#9241)
### 8.5.0 20200907 ### 8.5.0 20200907

View File

@ -263,8 +263,6 @@ struct LIGHT {
uint32_t strip_timer_counter = 0; // Bars and Gradient uint32_t strip_timer_counter = 0; // Bars and Gradient
power_t power = 0; // Power<x> for each channel if SetOption68, or boolean if single light power_t power = 0; // Power<x> for each channel if SetOption68, or boolean if single light
uint16_t wakeup_counter = 0;
uint8_t entry_color[LST_MAX]; uint8_t entry_color[LST_MAX];
uint8_t current_color[LST_MAX]; uint8_t current_color[LST_MAX];
uint8_t new_color[LST_MAX]; uint8_t new_color[LST_MAX];
@ -276,12 +274,13 @@ struct LIGHT {
uint8_t subtype = 0; // LST_ subtype uint8_t subtype = 0; // LST_ subtype
uint8_t device = 0; uint8_t device = 0;
uint8_t old_power = 1; uint8_t old_power = 1;
uint8_t wakeup_active = 0; uint8_t wakeup_active = 0; // 0=inctive, 1=on-going, 2=about to start, 3=will be triggered next cycle
uint8_t wakeup_dimmer = 0;
uint8_t fixed_color_index = 1; uint8_t fixed_color_index = 1;
uint8_t pwm_offset = 0; // Offset in color buffer uint8_t pwm_offset = 0; // Offset in color buffer
uint8_t max_scheme = LS_MAX -1; uint8_t max_scheme = LS_MAX -1;
uint32_t wakeup_start_time = 0;
bool update = true; bool update = true;
bool pwm_multi_channels = false; // SetOption68, treat each PWM channel as an independant dimmer bool pwm_multi_channels = false; // SetOption68, treat each PWM channel as an independant dimmer
bool virtual_ct = false; // SetOption106, add a 5th virtual channel, only if SO106 = 1, SO68 = 0, Light is RGBW (4 channels), SO37 < 128 bool virtual_ct = false; // SetOption106, add a 5th virtual channel, only if SO106 = 1, SO68 = 0, Light is RGBW (4 channels), SO37 < 128
@ -1866,25 +1865,27 @@ void LightAnimate(void)
light_controller.calcLevels(Light.new_color); light_controller.calcLevels(Light.new_color);
break; break;
case LS_WAKEUP: case LS_WAKEUP:
{
if (2 == Light.wakeup_active) { if (2 == Light.wakeup_active) {
Light.wakeup_active = 1; Light.wakeup_active = 1;
for (uint32_t i = 0; i < Light.subtype; i++) { for (uint32_t i = 0; i < Light.subtype; i++) {
Light.new_color[i] = 0; Light.new_color[i] = 0;
} }
Light.wakeup_counter = 0; Light.wakeup_start_time = millis();
Light.wakeup_dimmer = 0;
} }
Light.wakeup_counter++; // which step are we in a range 0..1023
if (Light.wakeup_counter > ((Settings.light_wakeup * STATES) / Settings.light_dimmer)) { uint32_t step_10 = ((millis() - Light.wakeup_start_time) * 1023) / (Settings.light_wakeup * 1000);
Light.wakeup_counter = 0; if (step_10 > 1023) { step_10 = 1023; } // sanity check
Light.wakeup_dimmer++; uint8_t wakeup_bri = changeUIntScale(step_10, 0, 1023, 0, LightStateClass::DimmerToBri(Settings.light_dimmer));
if (Light.wakeup_dimmer <= Settings.light_dimmer) {
light_state.setDimmer(Light.wakeup_dimmer); if (wakeup_bri != light_state.getBri()) {
light_state.setBri(wakeup_bri);
light_controller.calcLevels(); light_controller.calcLevels();
for (uint32_t i = 0; i < Light.subtype; i++) { for (uint32_t i = 0; i < Light.subtype; i++) {
Light.new_color[i] = Light.current_color[i]; Light.new_color[i] = Light.current_color[i];
} }
} else { }
if (1023 == step_10) {
Response_P(PSTR("{\"" D_CMND_WAKEUP "\":\"" D_JSON_DONE "\"")); Response_P(PSTR("{\"" D_CMND_WAKEUP "\":\"" D_JSON_DONE "\""));
ResponseLightState(1); ResponseLightState(1);
ResponseJsonEnd(); ResponseJsonEnd();