Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ColorControl] Enhanced commands should set EnhancedColorMode to 3 #22580

Merged
merged 2 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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