Skip to content

Commit

Permalink
[ColorControl] Enhanced commands should set EnhancedColorMode to 3 (#…
Browse files Browse the repository at this point in the history
…22580)

* [ColorControl] Set EnhancedColorMode to 3 during enhanced-move-to-hue-and-saturation

* [ColorControl] Update handleModeSwitch to set EnhancedColorMode
  • Loading branch information
pankore authored Sep 15, 2022
1 parent 49d7b42 commit 74e171a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
51 changes: 37 additions & 14 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**********************************************************
Expand Down Expand Up @@ -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<uint8_t>((newColorMode << 4) + oldColorMode);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1167,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);
Expand Down
3 changes: 2 additions & 1 deletion src/app/clusters/color-control-server/color-control-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 74e171a

Please sign in to comment.