Browse Source

pass target brightness to on_brightness handlers, instead of actual brightness, during transitions.

pull/4/head
Maurice Makaay 3 years ago
parent
commit
0ea3651056
2 changed files with 9 additions and 5 deletions
  1. +5
    -1
      light/color_transition_handler.h
  2. +4
    -4
      light/light_output.h

+ 5
- 1
light/color_transition_handler.h View File

@ -49,7 +49,6 @@ class ColorTransitionHandler : public GPIOOutputs {
public: public:
ColorTransitionHandler(LightStateTransformerInspector *inspector) : transformer_(inspector) {} ColorTransitionHandler(LightStateTransformerInspector *inspector) : transformer_(inspector) {}
protected:
bool set_light_color_values(light::LightColorValues values) { bool set_light_color_values(light::LightColorValues values) {
if (!light_state_has_active_transition_()) { if (!light_state_has_active_transition_()) {
// Remember the last active light color values. When a transition // Remember the last active light color values. When a transition
@ -91,6 +90,11 @@ protected:
return true; return true;
} }
light::LightColorValues get_end_values() {
return end_light_values_;
}
protected:
bool active_ = false; bool active_ = false;
float progress_ = 0.0f; float progress_ = 0.0f;
LightStateTransformerInspector *transformer_; LightStateTransformerInspector *transformer_;


+ 4
- 4
light/light_output.h View File

@ -57,9 +57,11 @@ public:
GPIOOutputs *delegate; GPIOOutputs *delegate;
if (transition_handler_->set_light_color_values(values)) { if (transition_handler_->set_light_color_values(values)) {
delegate = transition_handler_; delegate = transition_handler_;
state_callback_.call(transition_handler_->get_end_values());
} else { } else {
instant_handler_->set_light_color_values(values); instant_handler_->set_light_color_values(values);
delegate = instant_handler_; delegate = instant_handler_;
state_callback_.call(values);
} }
// Note: one might think that it is more logical to turn on the LED // Note: one might think that it is more logical to turn on the LED
@ -80,14 +82,12 @@ public:
if (values.get_state() == 0) if (values.get_state() == 0)
light_->turn_off(); light_->turn_off();
state_callback_.call(values);
} }
protected: protected:
LightHAL *light_; LightHAL *light_;
GPIOOutputs *transition_handler_;
GPIOOutputs *instant_handler_ = new ColorInstantHandler();
ColorTransitionHandler *transition_handler_;
ColorInstantHandler *instant_handler_ = new ColorInstantHandler();
CallbackManager<void(light::LightColorValues)> state_callback_{}; CallbackManager<void(light::LightColorValues)> state_callback_{};
friend class YeelightBS2LightState; friend class YeelightBS2LightState;


Loading…
Cancel
Save