Browse Source

Make use of smoothed progress for color transitionings.

pull/3/head
Maurice Makaay 3 years ago
parent
commit
1325ef62cf
1 changed files with 7 additions and 4 deletions
  1. +7
    -4
      light.h

+ 7
- 4
light.h View File

@ -48,6 +48,8 @@ namespace bs2 {
return false;
}
// TODO use new starting point when interrupting a transition
// halfway by switching to a new color.
if (is_fresh_transition_()) {
start_->set_light_color_values(start_values);
end_->set_light_color_values(exposer_->get_transformer_end_values());
@ -55,10 +57,11 @@ namespace bs2 {
}
auto progress = exposer_->get_transformer_progress();
red = esphome::lerp(progress, start_->red, end_->red);
green = esphome::lerp(progress, start_->green, end_->green);
blue = esphome::lerp(progress, start_->blue, end_->blue);
white = esphome::lerp(progress, start_->white, end_->white);
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