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:
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_;


+ 4
- 4
light/light_output.h View File

@ -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<void(light::LightColorValues)> state_callback_{};
friend class YeelightBS2LightState;


Loading…
Cancel
Save