Revert "Revert "Merge pull request #9391 from s-hadinger/fade_256_dev""

This reverts commit 217addc2bb.
This commit is contained in:
Theo Arends 2020-09-27 11:03:29 +02:00
parent a6250ec552
commit 32a2407b19
2 changed files with 20 additions and 18 deletions

View File

@ -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

View File

@ -263,8 +263,6 @@ struct LIGHT {
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
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();