From 09c6898a2a837eee46199a213347c27d61c9bc7f Mon Sep 17 00:00:00 2001 From: gnxlxnxx Date: Wed, 24 Jan 2024 22:28:24 +0100 Subject: [PATCH] ......................... --- .../monochromatic_light_output.h | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/components/custom_monochromatic/monochromatic_light_output.h b/components/custom_monochromatic/monochromatic_light_output.h index 186f833..eabda9c 100644 --- a/components/custom_monochromatic/monochromatic_light_output.h +++ b/components/custom_monochromatic/monochromatic_light_output.h @@ -19,6 +19,7 @@ public: upper_ = upper; lower_ = lower; state_ = Off; + bright_ = 0.0; } light::LightTraits get_traits() override { auto traits = light::LightTraits(); @@ -27,26 +28,28 @@ public: } void write_state(light::LightState *state) override { this->light_state_ = state; - float bright; - state->current_values_as_brightness(&bright); - this->upper_->set_level(bright); - this->lower_->set_level(bright); + state->current_values_as_brightness(&(this -> bright_)); + this->upper_->set_level(this->bright_); + this->lower_->set_level(this->bright_); } void set_state(State s){ this->state_ = s; switch(s){ case(On): - this -> light_state_->turn_on(); + /* this -> light_state_->turn_on(); */ + this -> upper_ -> set_level(this->bright_); + this -> lower_ -> set_level(this->bright_); break; case(Off): - this -> light_state_->turn_off(); + /* this -> light_state_->turn_off(); */ + this -> upper_ -> set_level(0.0); + this -> lower_ -> set_level(0.0); break; case(Auto): - break; } - this -> write_state(this -> light_state_); + /* this -> write_state(this -> light_state_); */ } void loop(){ @@ -82,6 +85,7 @@ public: protected: State state_; + float bright_; light::LightState *light_state_; output::FloatOutput *upper_; output::FloatOutput *lower_;