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

Remove WeakEnums for Color Control Cluster (and all weakenum handling as a result) #30524

Merged
merged 15 commits into from
Nov 17, 2023
Merged
14 changes: 7 additions & 7 deletions examples/common/imgui_ui/windows/light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ void Light::Render()
ImGui::Text("Color Control:");
ImGui::Indent();
const char * mode = // based on ColorMode attribute: spec 3.2.7.9
(mColorMode == EMBER_ZCL_COLOR_MODE_CURRENT_HUE_AND_CURRENT_SATURATION) ? "Hue/Saturation"
: (mColorMode == EMBER_ZCL_COLOR_MODE_CURRENT_X_AND_CURRENT_Y) ? "X/Y"
: (mColorMode == EMBER_ZCL_COLOR_MODE_COLOR_TEMPERATURE) ? "Temperature/Mireds"
: "UNKNOWN";
(mColorMode == kColorModeCurrentHueAndCurrentSaturation) ? "Hue/Saturation"
: (mColorMode == kColorModeCurrentXAndCurrentY) ? "X/Y"
: (mColorMode == kColorModeColorTemperature) ? "Temperature/Mireds"
: "UNKNOWN";

ImGui::Text("Mode: %s", mode);

if (mColorMode == EMBER_ZCL_COLOR_MODE_CURRENT_HUE_AND_CURRENT_SATURATION)
if (mColorMode == kColorModeCurrentHueAndCurrentSaturation)
{
const float hueDegrees = (mColorHue * 360.0f) / 254.0f;
const float saturationPercent = 100.0f * (mColorSaturation / 254.0f);
Expand All @@ -173,12 +173,12 @@ void Light::Render()
ImGui::ColorButton("LightColor", HueSaturationToColor(hueDegrees, saturationPercent), 0 /* ImGuiColorEditFlags_* */,
ImVec2(80, 80));
}
else if (mColorMode == EMBER_ZCL_COLOR_MODE_CURRENT_X_AND_CURRENT_Y)
else if (mColorMode == kColorModeCurrentXAndCurrentY)
{
ImGui::Text("Current X: %d", mColorX);
ImGui::Text("Current Y: %d", mColorY);
}
else if (mColorMode == EMBER_ZCL_COLOR_MODE_COLOR_TEMPERATURE)
else if (mColorMode == kColorModeColorTemperature)
{
ImGui::Text("Color Temperature Mireds: %d", mColorTemperatureMireds);
}
Expand Down
7 changes: 6 additions & 1 deletion examples/common/imgui_ui/windows/light.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ class Light : public Window
private:
const chip::EndpointId mEndpointId;

static constexpr uint8_t kColorModeCurrentHueAndCurrentSaturation = 0;
static constexpr uint8_t kColorModeCurrentXAndCurrentY = 1;
static constexpr uint8_t kColorModeColorTemperature = 2;
static constexpr uint8_t kColorModeEnhancedCurrentHueAndCurrentSaturation = 3;

// OnOff
bool mLightIsOn = false;
chip::Optional<bool> mTargetLightIsOn; // allow UI control of this
Expand All @@ -57,7 +62,7 @@ class Light : public Window
uint16_t mLevelRemainingTime10sOfSec = 0;

// Color control
uint8_t mColorMode = EMBER_ZCL_COLOR_MODE_CURRENT_HUE_AND_CURRENT_SATURATION;
uint8_t mColorMode = kColorModeCurrentHueAndCurrentSaturation;
uint8_t mColorHue = 0;
uint8_t mColorSaturation = 0;
uint16_t mColorX = 0;
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/tizen/src/DBusInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ void DBusInterface::SetCurrentLevel(uint8_t value)
void DBusInterface::SetColorMode(chip::app::Clusters::ColorControl::ColorMode colorMode)
{
InternalSetGuard guard(this);
if (light_app_color_control_get_color_mode(mIfaceColorControl) != colorMode)
light_app_color_control_set_color_mode(mIfaceColorControl, colorMode);
if (light_app_color_control_get_color_mode(mIfaceColorControl) != chip::to_underlying(colorMode))
light_app_color_control_set_color_mode(mIfaceColorControl, chip::to_underlying(colorMode));
}

void DBusInterface::SetColorTemperature(uint16_t value)
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/tizen/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/ConcreteAttributePath.h>
#include <app/clusters/color-control-server/color-control-server.h>
#include <app/clusters/network-commissioning/network-commissioning.h>
#include <platform/Tizen/NetworkCommissioningDriver.h>

Expand Down Expand Up @@ -122,8 +123,7 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
void emberAfColorControlClusterInitCallback(EndpointId endpoint)
{
// Set the color mode to color temperature.
Clusters::ColorControl::Attributes::ColorMode::Set(endpoint,
Clusters::ColorControl::ColorMode::EMBER_ZCL_COLOR_MODE_COLOR_TEMPERATURE);
Clusters::ColorControl::Attributes::ColorMode::Set(endpoint, ColorControlServer::EnhancedColorMode::kColorTemperature);
// Preserve the state of the color temperature attribute across reboots.
Clusters::ColorControl::Attributes::StartUpColorTemperatureMireds::SetNull(endpoint);
}
Expand Down
Loading
Loading