diff --git a/light/color_transition_handler.h b/light/color_transition_handler.h index 3e386e6..d5fa01b 100644 --- a/light/color_transition_handler.h +++ b/light/color_transition_handler.h @@ -49,7 +49,6 @@ class ColorTransitionHandler : public GPIOOutputs { public: ColorTransitionHandler(LightStateTransformerInspector *inspector) : transformer_(inspector) {} -protected: bool set_light_color_values(light::LightColorValues values) { if (!light_state_has_active_transition_()) { // Remember the last active light color values. When a transition @@ -91,6 +90,11 @@ protected: return true; } + light::LightColorValues get_end_values() { + return end_light_values_; + } + +protected: bool active_ = false; float progress_ = 0.0f; LightStateTransformerInspector *transformer_; diff --git a/light/light_output.h b/light/light_output.h index bdd85da..638921e 100644 --- a/light/light_output.h +++ b/light/light_output.h @@ -57,9 +57,11 @@ public: GPIOOutputs *delegate; if (transition_handler_->set_light_color_values(values)) { delegate = transition_handler_; + state_callback_.call(transition_handler_->get_end_values()); } else { instant_handler_->set_light_color_values(values); delegate = instant_handler_; + state_callback_.call(values); } // Note: one might think that it is more logical to turn on the LED @@ -80,14 +82,12 @@ public: if (values.get_state() == 0) light_->turn_off(); - - state_callback_.call(values); } protected: LightHAL *light_; - GPIOOutputs *transition_handler_; - GPIOOutputs *instant_handler_ = new ColorInstantHandler(); + ColorTransitionHandler *transition_handler_; + ColorInstantHandler *instant_handler_ = new ColorInstantHandler(); CallbackManager state_callback_{}; friend class YeelightBS2LightState;