From cc99b49c0a85d7d187e3e1b1fde9412131aadc5c Mon Sep 17 00:00:00 2001 From: pankore <86098180+pankore@users.noreply.github.com> Date: Tue, 13 Sep 2022 16:24:39 +0800 Subject: [PATCH 1/2] [ColorControl] Set EnhancedColorMode to 3 during enhanced-move-to-hue-and-saturation --- src/app/clusters/color-control-server/color-control-server.cpp | 3 +++ 1 file changed, 3 insertions(+) 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 b0b033753dd66e..1f96d0ba851e46 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -1087,6 +1087,9 @@ bool ColorControlServer::moveToHueAndSaturationCommand(EndpointId endpoint, uint { colorHueTransitionState->initialEnhancedHue = currentHue; colorHueTransitionState->currentEnhancedHue = currentHue; + Attributes::ColorMode::Set(endpoint, CurrentHueandCurrentSaturation); + Attributes::EnhancedColorMode::Set(endpoint, EnhancedCurrentHueandCurrentSaturation); + colorHueTransitionState->finalEnhancedHue = hue; } else From 2eabd91341dc8577865fa675d8804ffa61b21fc2 Mon Sep 17 00:00:00 2001 From: pankore <86098180+pankore@users.noreply.github.com> Date: Wed, 14 Sep 2022 16:13:49 +0800 Subject: [PATCH 2/2] [ColorControl] Update handleModeSwitch to set EnhancedColorMode --- .../color-control-server.cpp | 54 +++++++++++++------ .../color-control-server.h | 3 +- 2 files changed, 39 insertions(+), 18 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 1f96d0ba851e46..799eeb87781af2 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -49,14 +49,6 @@ using namespace chip::app::Clusters::ColorControl; * Attributes Definition *********************************************************/ -enum EnhancedColorModeType -{ - CurrentHueandCurrentSaturation = 0, - CurrentXandCurrentY = 1, - ColorTemperatureMireds = 2, - EnhancedCurrentHueandCurrentSaturation = 3, -}; - ColorControlServer ColorControlServer::instance; /********************************************************** @@ -184,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); @@ -796,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); @@ -963,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); @@ -973,8 +984,6 @@ bool ColorControlServer::moveToHueCommand(EndpointId endpoint, uint16_t hue, uin { Attributes::EnhancedCurrentHue::Get(endpoint, &(colorHueTransitionState->initialEnhancedHue)); Attributes::EnhancedCurrentHue::Get(endpoint, &(colorHueTransitionState->currentEnhancedHue)); - Attributes::ColorMode::Set(endpoint, CurrentHueandCurrentSaturation); - Attributes::EnhancedColorMode::Set(endpoint, EnhancedCurrentHueandCurrentSaturation); colorHueTransitionState->finalEnhancedHue = hue; } @@ -1077,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); @@ -1087,9 +1103,6 @@ bool ColorControlServer::moveToHueAndSaturationCommand(EndpointId endpoint, uint { colorHueTransitionState->initialEnhancedHue = currentHue; colorHueTransitionState->currentEnhancedHue = currentHue; - Attributes::ColorMode::Set(endpoint, CurrentHueandCurrentSaturation); - Attributes::EnhancedColorMode::Set(endpoint, EnhancedCurrentHueandCurrentSaturation); - colorHueTransitionState->finalEnhancedHue = hue; } else @@ -1170,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