1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-05 04:42:21 +01:00

Change color model to fix white channel issues (#1895)

This commit is contained in:
Oxan van Leeuwen
2021-07-08 11:37:47 +02:00
committed by GitHub
parent fd4b7d4588
commit f9797825ad
13 changed files with 200 additions and 83 deletions

View File

@@ -1263,6 +1263,10 @@ bool LightStateResponse::decode_32bit(uint32_t field_id, Proto32Bit value) {
this->brightness = value.as_float();
return true;
}
case 10: {
this->color_brightness = value.as_float();
return true;
}
case 4: {
this->red = value.as_float();
return true;
@@ -1291,6 +1295,7 @@ void LightStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_fixed32(1, this->key);
buffer.encode_bool(2, this->state);
buffer.encode_float(3, this->brightness);
buffer.encode_float(10, this->color_brightness);
buffer.encode_float(4, this->red);
buffer.encode_float(5, this->green);
buffer.encode_float(6, this->blue);
@@ -1315,6 +1320,11 @@ void LightStateResponse::dump_to(std::string &out) const {
out.append(buffer);
out.append("\n");
out.append(" color_brightness: ");
sprintf(buffer, "%g", this->color_brightness);
out.append(buffer);
out.append("\n");
out.append(" red: ");
sprintf(buffer, "%g", this->red);
out.append(buffer);
@@ -1359,6 +1369,10 @@ bool LightCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
this->has_brightness = value.as_bool();
return true;
}
case 20: {
this->has_color_brightness = value.as_bool();
return true;
}
case 6: {
this->has_rgb = value.as_bool();
return true;
@@ -1415,6 +1429,10 @@ bool LightCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) {
this->brightness = value.as_float();
return true;
}
case 21: {
this->color_brightness = value.as_float();
return true;
}
case 7: {
this->red = value.as_float();
return true;
@@ -1445,6 +1463,8 @@ void LightCommandRequest::encode(ProtoWriteBuffer buffer) const {
buffer.encode_bool(3, this->state);
buffer.encode_bool(4, this->has_brightness);
buffer.encode_float(5, this->brightness);
buffer.encode_bool(20, this->has_color_brightness);
buffer.encode_float(21, this->color_brightness);
buffer.encode_bool(6, this->has_rgb);
buffer.encode_float(7, this->red);
buffer.encode_float(8, this->green);
@@ -1485,6 +1505,15 @@ void LightCommandRequest::dump_to(std::string &out) const {
out.append(buffer);
out.append("\n");
out.append(" has_color_brightness: ");
out.append(YESNO(this->has_color_brightness));
out.append("\n");
out.append(" color_brightness: ");
sprintf(buffer, "%g", this->color_brightness);
out.append(buffer);
out.append("\n");
out.append(" has_rgb: ");
out.append(YESNO(this->has_rgb));
out.append("\n");