Skip to content

Commit

Permalink
Remove WeakEnums for Color Control Cluster (and all weakenum handli…
Browse files Browse the repository at this point in the history
…ng as a result) (#30524)

* Remove color control types as they are not spec defined currently. Remove them from weak enums

* zap regen

* make it compile

* Restyle

* Fix imgui compilation. Had to have separate constants unfortunately

* Fix compilation

* Fix tizen compilation

* Restyle

* fix another tizen build error

* Remove include of enums.h

* Remove WeakEnumHandling

* Zap regen all

* Restyle

* Remove one more reference

---------

Co-authored-by: Andrei Litvin <andreilitvin@google.com>
  • Loading branch information
andy31415 and andreilitvin committed Nov 17, 2023
1 parent 83e2492 commit 4b515e8
Show file tree
Hide file tree
Showing 46 changed files with 91 additions and 243 deletions.
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
1 change: 0 additions & 1 deletion examples/thermostat/silabs/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/callback.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/enums.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
Expand Down
1 change: 0 additions & 1 deletion examples/tv-app/android/java/AppImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#pragma once

#include <app-common/zap-generated/enums.h>
#include <app/app-platform/ContentApp.h>
#include <app/app-platform/ContentAppPlatform.h>
#include <app/util/attribute-storage.h>
Expand Down
1 change: 0 additions & 1 deletion examples/tv-app/tv-common/include/AppTv.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#pragma once

#include <app-common/zap-generated/enums.h>
#include <app/app-platform/ContentApp.h>
#include <app/app-platform/ContentAppPlatform.h>
#include <app/util/attribute-storage.h>
Expand Down
3 changes: 0 additions & 3 deletions examples/window-app/silabs/include/LcdPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@

#pragma once

// clang-format off
#include "app-common/zap-generated/enums.h"
#include "app-common/zap-generated/cluster-enums.h"
// clang-format on

#include <lcd.h>

Expand Down
1 change: 0 additions & 1 deletion src/app/app-platform/ContentApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#pragma once

#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/enums.h>
#include <app/clusters/account-login-server/account-login-delegate.h>
#include <app/clusters/application-basic-server/application-basic-delegate.h>
#include <app/clusters/application-launcher-server/application-launcher-delegate.h>
Expand Down
1 change: 0 additions & 1 deletion src/app/app-platform/ContentAppPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#pragma once

#include <app-common/zap-generated/enums.h>
#include <app/OperationalSessionSetup.h>
#include <app/app-platform/ContentApp.h>
#include <app/util/attribute-storage.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <access/AccessControl.h>

#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/enums.h>

#include <app/AttributeAccessInterface.h>
#include <app/CommandHandler.h>
Expand Down
Loading

0 comments on commit 4b515e8

Please sign in to comment.