Browse Source

Suppress transitions for night light mode.

Fixes #10
"When changing RGB color settings, while night light mode is active,
transitions don't look good. On many of the transitions, the light
level shows a significant drop."

This commit fully suppresses transitions when the light is in
night light mode.
pull/20/head
Maurice Makaay 3 years ago
parent
commit
197ccfe0d3
1 changed files with 19 additions and 6 deletions
  1. +19
    -6
      light/color_transition_handler.h

+ 19
- 6
light/color_transition_handler.h View File

@ -84,14 +84,27 @@ public:
}
light_mode = end_->light_mode;
progress_ = transformer_->get_progress();
// Determine required GPIO outputs for current transition progress.
progress_ = transformer_->get_progress();
auto smoothed = light::LightTransitionTransformer::smoothed_progress(progress_);
red = esphome::lerp(smoothed, start_->red, end_->red);
green = esphome::lerp(smoothed, start_->green, end_->green);
blue = esphome::lerp(smoothed, start_->blue, end_->blue);
white = esphome::lerp(smoothed, start_->white, end_->white);
// In night light mode, do not use actual transitions. Transitioning
// between colors at the very low LED output levels of the night light,
// results in light drops, which are plain ugly to watch.
if (light_mode == "night") {
red = end_->red;
green = end_->green;
blue = end_->blue;
white = end_->white;
}
// In other light modes, apply smooth transitioning.
else {
auto smoothed = light::LightTransitionTransformer::smoothed_progress(progress_);
red = esphome::lerp(smoothed, start_->red, end_->red);
green = esphome::lerp(smoothed, start_->green, end_->green);
blue = esphome::lerp(smoothed, start_->blue, end_->blue);
white = esphome::lerp(smoothed, start_->white, end_->white);
}
return true;
}


Loading…
Cancel
Save