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); 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_()) { } else if (this->has_transition_()) {
// TRANSITION // TRANSITION
if (this->publish_) { if (this->publish_) {
@ -92,7 +92,7 @@ void LightCall::perform() {
this->parent_->stop_effect_(); 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_()) { } else if (this->has_effect_()) {
// EFFECT // EFFECT

View File

@ -228,13 +228,16 @@ void LightState::stop_effect_() {
this->active_effect_index_ = 0; 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_ = this->output_->create_default_transition();
this->transformer_->setup(this->current_values, target, length); this->transformer_->setup(this->current_values, target, length);
if (set_remote_values) {
this->remote_values = target; 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; LightColorValues end_colors = this->remote_values;
// If starting a flash if one is already happening, set end values to end values of current flash // If starting a flash if one is already happening, set end values to end values of current flash
// Hacky but works // 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_ = make_unique<LightFlashTransformer>(*this);
this->transformer_->setup(end_colors, target, length); this->transformer_->setup(end_colors, target, length);
if (set_remote_values) {
this->remote_values = target; this->remote_values = target;
};
} }
void LightState::set_immediately_(const LightColorValues &target, bool set_remote_values) { 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). /// Internal method to stop the current effect (if one is active).
void stop_effect_(); void stop_effect_();
/// Internal method to start a transition to the target color with the given length. /// 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. /// 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). /// Internal method to set the color values to target immediately (with no transition).
void set_immediately_(const LightColorValues &target, bool set_remote_values); void set_immediately_(const LightColorValues &target, bool set_remote_values);