Skip to content

Commit

Permalink
[ColorControl] Enhanced commands should set EnhancedColorMode to 3 (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
pankore authored and q-thla committed Oct 11, 2022
1 parent eaa1751 commit e880e68
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
41 changes: 37 additions & 4 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t>((newColorMode << 4) + oldColorMode);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
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 e880e68

Please sign in to comment.