Removed unused arguments from rgbww code (#2137)

This commit is contained in:
Jesse Hills 2021-08-09 16:44:52 +12:00 committed by GitHub
parent b3ae3e1feb
commit ea4a458214
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 17 deletions

View file

@ -157,16 +157,14 @@ class LightColorValues {
} }
/// Convert these light color values to an RGBWW representation with the given parameters. /// Convert these light color values to an RGBWW representation with the given parameters.
void as_rgbww(float color_temperature_cw, float color_temperature_ww, float *red, float *green, float *blue, void as_rgbww(float *red, float *green, float *blue, float *cold_white, float *warm_white, float gamma = 0,
float *cold_white, float *warm_white, float gamma = 0, bool constant_brightness = false, bool constant_brightness = false) const {
bool color_interlock = false) const {
this->as_rgb(red, green, blue, gamma); this->as_rgb(red, green, blue, gamma);
this->as_cwww(0, 0, cold_white, warm_white, gamma, constant_brightness); this->as_cwww(cold_white, warm_white, gamma, constant_brightness);
} }
/// Convert these light color values to an CWWW representation with the given parameters. /// Convert these light color values to an CWWW representation with the given parameters.
void as_cwww(float color_temperature_cw, float color_temperature_ww, float *cold_white, float *warm_white, void as_cwww(float *cold_white, float *warm_white, float gamma = 0, bool constant_brightness = false) const {
float gamma = 0, bool constant_brightness = false) const {
if (this->color_mode_ & ColorCapability::COLD_WARM_WHITE) { if (this->color_mode_ & ColorCapability::COLD_WARM_WHITE) {
const float cw_level = gamma_correct(this->cold_white_, gamma); const float cw_level = gamma_correct(this->cold_white_, gamma);
const float ww_level = gamma_correct(this->warm_white_, gamma); const float ww_level = gamma_correct(this->warm_white_, gamma);

View file

@ -1,6 +1,6 @@
#include "light_state.h" #include "light_state.h"
#include "light_output.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "light_output.h"
namespace esphome { namespace esphome {
namespace light { namespace light {
@ -174,15 +174,13 @@ void LightState::current_values_as_rgbw(float *red, float *green, float *blue, f
this->current_values.as_rgbw(red, green, blue, white, this->gamma_correct_, false); this->current_values.as_rgbw(red, green, blue, white, this->gamma_correct_, false);
} }
void LightState::current_values_as_rgbww(float *red, float *green, float *blue, float *cold_white, float *warm_white, void LightState::current_values_as_rgbww(float *red, float *green, float *blue, float *cold_white, float *warm_white,
bool constant_brightness, bool color_interlock) { bool constant_brightness) {
auto traits = this->get_traits(); auto traits = this->get_traits();
this->current_values.as_rgbww(traits.get_min_mireds(), traits.get_max_mireds(), red, green, blue, cold_white, this->current_values.as_rgbww(red, green, blue, cold_white, warm_white, this->gamma_correct_, constant_brightness);
warm_white, this->gamma_correct_, constant_brightness, false);
} }
void LightState::current_values_as_cwww(float *cold_white, float *warm_white, bool constant_brightness) { void LightState::current_values_as_cwww(float *cold_white, float *warm_white, bool constant_brightness) {
auto traits = this->get_traits(); auto traits = this->get_traits();
this->current_values.as_cwww(traits.get_min_mireds(), traits.get_max_mireds(), cold_white, warm_white, this->current_values.as_cwww(cold_white, warm_white, this->gamma_correct_, constant_brightness);
this->gamma_correct_, constant_brightness);
} }
void LightState::start_effect_(uint32_t effect_index) { void LightState::start_effect_(uint32_t effect_index) {

View file

@ -3,9 +3,9 @@
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include "esphome/core/optional.h" #include "esphome/core/optional.h"
#include "esphome/core/preferences.h" #include "esphome/core/preferences.h"
#include "light_effect.h"
#include "light_color_values.h"
#include "light_call.h" #include "light_call.h"
#include "light_color_values.h"
#include "light_effect.h"
#include "light_traits.h" #include "light_traits.h"
#include "light_transformer.h" #include "light_transformer.h"
@ -126,7 +126,7 @@ class LightState : public Nameable, public Component {
void current_values_as_rgbw(float *red, float *green, float *blue, float *white, bool color_interlock = false); void current_values_as_rgbw(float *red, float *green, float *blue, float *white, bool color_interlock = false);
void current_values_as_rgbww(float *red, float *green, float *blue, float *cold_white, float *warm_white, void current_values_as_rgbww(float *red, float *green, float *blue, float *cold_white, float *warm_white,
bool constant_brightness = false, bool color_interlock = false); bool constant_brightness = false);
void current_values_as_cwww(float *cold_white, float *warm_white, bool constant_brightness = false); void current_values_as_cwww(float *cold_white, float *warm_white, bool constant_brightness = false);

View file

@ -30,8 +30,7 @@ class RGBWWLightOutput : public light::LightOutput {
} }
void write_state(light::LightState *state) override { void write_state(light::LightState *state) override {
float red, green, blue, cwhite, wwhite; float red, green, blue, cwhite, wwhite;
state->current_values_as_rgbww(&red, &green, &blue, &cwhite, &wwhite, this->constant_brightness_, state->current_values_as_rgbww(&red, &green, &blue, &cwhite, &wwhite, this->constant_brightness_);
this->color_interlock_);
this->red_->set_level(red); this->red_->set_level(red);
this->green_->set_level(green); this->green_->set_level(green);
this->blue_->set_level(blue); this->blue_->set_level(blue);