Allow transforms and flashes to not update remote_values (#2313)

This commit is contained in:
Matthew Mazzanti 2021-09-15 13:59:58 -04:00 committed by GitHub
parent aed140d802
commit 8f3a739da7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 8 deletions

View file

@ -77,7 +77,7 @@ void LightCall::perform() {
ESP_LOGD(TAG, " Flash length: %.1fs", *this->flash_length_ / 1e3f);
}
this->parent_->start_flash_(v, *this->flash_length_);
this->parent_->start_flash_(v, *this->flash_length_, this->publish_);
} else if (this->has_transition_()) {
// TRANSITION
if (this->publish_) {
@ -92,7 +92,7 @@ void LightCall::perform() {
this->parent_->stop_effect_();
}
this->parent_->start_transition_(v, *this->transition_length_);
this->parent_->start_transition_(v, *this->transition_length_, this->publish_);
} else if (this->has_effect_()) {
// EFFECT

View file

@ -228,13 +228,16 @@ void LightState::stop_effect_() {
this->active_effect_index_ = 0;
}
void LightState::start_transition_(const LightColorValues &target, uint32_t length) {
void LightState::start_transition_(const LightColorValues &target, uint32_t length, bool set_remote_values) {
this->transformer_ = this->output_->create_default_transition();
this->transformer_->setup(this->current_values, target, length);
this->remote_values = target;
if (set_remote_values) {
this->remote_values = target;
}
}
void LightState::start_flash_(const LightColorValues &target, uint32_t length) {
void LightState::start_flash_(const LightColorValues &target, uint32_t length, bool set_remote_values) {
LightColorValues end_colors = this->remote_values;
// If starting a flash if one is already happening, set end values to end values of current flash
// Hacky but works
@ -243,7 +246,10 @@ void LightState::start_flash_(const LightColorValues &target, uint32_t length) {
this->transformer_ = make_unique<LightFlashTransformer>(*this);
this->transformer_->setup(end_colors, target, length);
this->remote_values = target;
if (set_remote_values) {
this->remote_values = target;
};
}
void LightState::set_immediately_(const LightColorValues &target, bool set_remote_values) {

View file

@ -154,10 +154,10 @@ class LightState : public Nameable, public Component {
/// Internal method to stop the current effect (if one is active).
void stop_effect_();
/// Internal method to start a transition to the target color with the given length.
void start_transition_(const LightColorValues &target, uint32_t length);
void start_transition_(const LightColorValues &target, uint32_t length, bool set_remote_values);
/// Internal method to start a flash for the specified amount of time.
void start_flash_(const LightColorValues &target, uint32_t length);
void start_flash_(const LightColorValues &target, uint32_t length, bool set_remote_values);
/// Internal method to set the color values to target immediately (with no transition).
void set_immediately_(const LightColorValues &target, bool set_remote_values);