From 08f23dbdd2a952dc36217da20123a8868e361061 Mon Sep 17 00:00:00 2001 From: pankore <86098180+pankore@users.noreply.github.com> Date: Fri, 16 Sep 2022 02:37:19 +0800 Subject: [PATCH] [ColorControl] Enhanced commands should set EnhancedColorMode to 3 (#22580) * [ColorControl] Set EnhancedColorMode to 3 during enhanced-move-to-hue-and-saturation * [ColorControl] Update handleModeSwitch to set EnhancedColorMode --- .../color-control-server.cpp | 41 +++++++++++++++++-- .../color-control-server.h | 3 +- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/app/clusters/color-control-server/color-control-server.cpp b/src/app/clusters/color-control-server/color-control-server.cpp index e48fdf07713f49..8d2ab865b247a6 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -176,6 +176,11 @@ void ColorControlServer::handleModeSwitch(EndpointId endpoint, uint8_t newColorM } Attributes::EnhancedColorMode::Set(endpoint, newColorMode); + if (newColorMode == ColorControlServer::ColorMode::COLOR_MODE_EHSV) + { + // Transpose COLOR_MODE_EHSV to COLOR_MODE_HSV after setting EnhancedColorMode + newColorMode = ColorControlServer::ColorMode::COLOR_MODE_HSV; + } Attributes::ColorMode::Set(endpoint, newColorMode); colorModeTransition = static_cast((newColorMode << 4) + oldColorMode); @@ -788,7 +793,14 @@ bool ColorControlServer::moveHueCommand(EndpointId endpoint, uint8_t moveMode, u } // Handle color mode transition, if necessary. - handleModeSwitch(endpoint, ColorControlServer::ColorMode::COLOR_MODE_HSV); + if (isEnhanced) + { + handleModeSwitch(endpoint, ColorControlServer::ColorMode::COLOR_MODE_EHSV); + } + else + { + handleModeSwitch(endpoint, ColorControlServer::ColorMode::COLOR_MODE_HSV); + } // now, kick off the state machine. initHueSat(endpoint, colorHueTransitionState, colorSaturationTransitionState); @@ -955,7 +967,14 @@ bool ColorControlServer::moveToHueCommand(EndpointId endpoint, uint16_t hue, uin stopAllColorTransitions(endpoint); // Handle color mode transition, if necessary. - handleModeSwitch(endpoint, ColorControlServer::ColorMode::COLOR_MODE_HSV); + if (isEnhanced) + { + handleModeSwitch(endpoint, ColorControlServer::ColorMode::COLOR_MODE_EHSV); + } + else + { + handleModeSwitch(endpoint, ColorControlServer::ColorMode::COLOR_MODE_HSV); + } // now, kick off the state machine. initHueSat(endpoint, colorHueTransitionState, colorSaturationTransitionState); @@ -1067,7 +1086,14 @@ bool ColorControlServer::moveToHueAndSaturationCommand(EndpointId endpoint, uint stopAllColorTransitions(endpoint); // Handle color mode transition, if necessary. - handleModeSwitch(endpoint, ColorControlServer::ColorMode::COLOR_MODE_HSV); + if (isEnhanced) + { + handleModeSwitch(endpoint, ColorControlServer::ColorMode::COLOR_MODE_EHSV); + } + else + { + handleModeSwitch(endpoint, ColorControlServer::ColorMode::COLOR_MODE_HSV); + } // now, kick off the state machine. initHueSat(endpoint, colorHueTransitionState, colorSaturationTransitionState); @@ -1157,7 +1183,14 @@ bool ColorControlServer::stepHueCommand(EndpointId endpoint, uint8_t stepMode, u } // Handle color mode transition, if necessary. - handleModeSwitch(endpoint, COLOR_MODE_HSV); + if (isEnhanced) + { + handleModeSwitch(endpoint, ColorControlServer::ColorMode::COLOR_MODE_EHSV); + } + else + { + handleModeSwitch(endpoint, ColorControlServer::ColorMode::COLOR_MODE_HSV); + } // now, kick off the state machine. initHueSat(endpoint, colorHueTransitionState, colorSaturationTransitionState); diff --git a/src/app/clusters/color-control-server/color-control-server.h b/src/app/clusters/color-control-server/color-control-server.h index 8723ea77db5e03..536ad22d3e3ce0 100644 --- a/src/app/clusters/color-control-server/color-control-server.h +++ b/src/app/clusters/color-control-server/color-control-server.h @@ -91,7 +91,8 @@ class ColorControlServer { COLOR_MODE_HSV = 0x00, COLOR_MODE_CIE_XY = 0x01, - COLOR_MODE_TEMPERATURE = 0x02 + COLOR_MODE_TEMPERATURE = 0x02, + COLOR_MODE_EHSV = 0x03 }; enum Conversion