Skip to content

Commit

Permalink
Stop generating weakly-typed enums for the color loop enum types. (#2…
Browse files Browse the repository at this point in the history
…5790)

* Stop generating weakly-typed enums for the color loop enum types.

* Regenerate generated code.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jul 12, 2023
1 parent a5e267e commit 1214108
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ void ProcessColorControlUnicastBindingCommand(BindingCommandData * data, const E
case Clusters::ColorControl::Commands::ColorLoopSet::Id:
colorLoopSetCommand.updateFlags =
static_cast<chip::BitMask<chip::app::Clusters::ColorControl::ColorLoopUpdateFlags>>(data->args[0]);
colorLoopSetCommand.action = static_cast<EmberAfColorLoopAction>(data->args[1]);
colorLoopSetCommand.direction = static_cast<EmberAfColorLoopDirection>(data->args[2]);
colorLoopSetCommand.action = static_cast<ColorLoopAction>(data->args[1]);
colorLoopSetCommand.direction = static_cast<ColorLoopDirection>(data->args[2]);
colorLoopSetCommand.time = static_cast<uint16_t>(data->args[3]);
colorLoopSetCommand.startHue = static_cast<uint16_t>(data->args[4]);
colorLoopSetCommand.optionsMask = static_cast<uint8_t>(data->args[5]);
Expand Down Expand Up @@ -708,8 +708,8 @@ void ProcessColorControlGroupBindingCommand(BindingCommandData * data, const Emb
case Clusters::ColorControl::Commands::ColorLoopSet::Id:
colorLoopSetCommand.updateFlags =
static_cast<chip::BitMask<chip::app::Clusters::ColorControl::ColorLoopUpdateFlags>>(data->args[0]);
colorLoopSetCommand.action = static_cast<EmberAfColorLoopAction>(data->args[1]);
colorLoopSetCommand.direction = static_cast<EmberAfColorLoopDirection>(data->args[2]);
colorLoopSetCommand.action = static_cast<ColorLoopAction>(data->args[1]);
colorLoopSetCommand.direction = static_cast<ColorLoopDirection>(data->args[2]);
colorLoopSetCommand.time = static_cast<uint16_t>(data->args[3]);
colorLoopSetCommand.startHue = static_cast<uint16_t>(data->args[4]);
colorLoopSetCommand.optionsMask = static_cast<uint8_t>(data->args[5]);
Expand Down
38 changes: 17 additions & 21 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ void ColorControlServer::startColorLoop(EndpointId endpoint, uint8_t startFromSt

colorHueTransitionState->initialEnhancedHue = startHue;

if (direction)
if (direction == to_underlying(ColorLoopDirection::kIncrementHue))
{
colorHueTransitionState->finalEnhancedHue = static_cast<uint16_t>(startHue - 1);
}
Expand All @@ -617,7 +617,7 @@ void ColorControlServer::startColorLoop(EndpointId endpoint, uint8_t startFromSt
colorHueTransitionState->finalEnhancedHue = static_cast<uint16_t>(startHue + 1);
}

colorHueTransitionState->up = direction;
colorHueTransitionState->up = (direction == to_underlying(ColorLoopDirection::kIncrementHue));
colorHueTransitionState->repeat = true;

colorHueTransitionState->stepsRemaining = static_cast<uint16_t>(time * TRANSITION_TIME_1S);
Expand Down Expand Up @@ -1496,9 +1496,9 @@ bool ColorControlServer::stepSaturationCommand(app::CommandHandler * commandObj,
bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
const Commands::ColorLoopSet::DecodableType & commandData)
{
uint8_t updateFlags = commandData.updateFlags.Raw();
uint8_t action = commandData.action;
uint8_t direction = commandData.direction;
auto updateFlags = commandData.updateFlags;
auto action = commandData.action;
auto direction = commandData.direction;
uint16_t time = commandData.time;
uint16_t startHue = commandData.startHue;
uint8_t optionsMask = commandData.optionsMask;
Expand All @@ -1512,10 +1512,7 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
VerifyOrExit(colorHueTransitionState != nullptr, status = Status::UnsupportedEndpoint);

// Validate the action and direction parameters of the command
if ((action != EMBER_ZCL_COLOR_LOOP_ACTION_DEACTIVATE &&
action != EMBER_ZCL_COLOR_LOOP_ACTION_ACTIVATE_FROM_COLOR_LOOP_START_ENHANCED_HUE &&
action != EMBER_ZCL_COLOR_LOOP_ACTION_ACTIVATE_FROM_ENHANCED_CURRENT_HUE) ||
(direction != DECREMENT_HUE && direction != INCREMENT_HUE))
if (action == ColorLoopAction::kUnknownEnumValue || direction == ColorLoopDirection::kUnknownEnumValue)
{
commandObj->AddStatus(commandPath, Status::InvalidCommand);
return true;
Expand All @@ -1529,20 +1526,19 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons

Attributes::ColorLoopActive::Get(endpoint, &isColorLoopActive);

deactiveColorLoop =
(updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_ACTION) && (action == EMBER_ZCL_COLOR_LOOP_ACTION_DEACTIVATE);
deactiveColorLoop = updateFlags.Has(ColorLoopUpdateFlags::kUpdateAction) && (action == ColorLoopAction::kDeactivate);

if (updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_DIRECTION)
if (updateFlags.Has(ColorLoopUpdateFlags::kUpdateAction))
{
Attributes::ColorLoopDirection::Set(endpoint, direction);
Attributes::ColorLoopDirection::Set(endpoint, to_underlying(direction));

// Checks if color loop is active and stays active
if (isColorLoopActive && !deactiveColorLoop)
{
colorHueTransitionState->up = direction;
colorHueTransitionState->up = (direction == ColorLoopDirection::kIncrementHue);
colorHueTransitionState->initialEnhancedHue = colorHueTransitionState->currentEnhancedHue;

if (direction)
if (direction == ColorLoopDirection::kIncrementHue)
{
colorHueTransitionState->finalEnhancedHue = static_cast<uint16_t>(colorHueTransitionState->initialEnhancedHue - 1);
}
Expand All @@ -1554,7 +1550,7 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
}
}

if (updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_TIME)
if (updateFlags.Has(ColorLoopUpdateFlags::kUpdateTime))
{
Attributes::ColorLoopTime::Set(endpoint, time);

Expand All @@ -1576,14 +1572,14 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
}
}

if (updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_START_HUE)
if (updateFlags.Has(ColorLoopUpdateFlags::kUpdateStartHue))
{
Attributes::ColorLoopStartEnhancedHue::Set(endpoint, startHue);
}

if (updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_ACTION)
if (updateFlags.Has(ColorLoopUpdateFlags::kUpdateAction))
{
if (action == EMBER_ZCL_COLOR_LOOP_ACTION_DEACTIVATE)
if (action == ColorLoopAction::kDeactivate)
{
if (isColorLoopActive)
{
Expand All @@ -1600,11 +1596,11 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
// Do Nothing since it's not on
}
}
else if (action == EMBER_ZCL_COLOR_LOOP_ACTION_ACTIVATE_FROM_COLOR_LOOP_START_ENHANCED_HUE)
else if (action == ColorLoopAction::kActivateFromColorLoopStartEnhancedHue)
{
startColorLoop(endpoint, true);
}
else if (action == EMBER_ZCL_COLOR_LOOP_ACTION_ACTIVATE_FROM_ENHANCED_CURRENT_HUE)
else if (action == ColorLoopAction::kActivateFromEnhancedCurrentHue)
{
startColorLoop(endpoint, false);
}
Expand Down
6 changes: 0 additions & 6 deletions src/app/clusters/color-control-server/color-control-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ class ColorControlServer
using HueMoveMode = chip::app::Clusters::ColorControl::HueMoveMode;
using HueDirection = chip::app::Clusters::ColorControl::HueDirection;

enum ColorLoopDirection
{
DECREMENT_HUE = 0x00,
INCREMENT_HUE = 0x01,
};

enum ColorMode
{
COLOR_MODE_HSV = 0x00,
Expand Down
3 changes: 0 additions & 3 deletions src/app/common/templates/config-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ WeakEnums:
- BarrierControlBarrierPosition
- BarrierControlMovingState
- ColorControlOptions
- ColorLoopAction
- ColorLoopDirection
- ColorMode
- EnhancedColorMode
- HardwareFaultEnum
Expand All @@ -25,7 +23,6 @@ DefineBitmaps:
# The goal is to drive this down to 0.
- BarrierControlCapabilities
- BarrierControlSafetyStatus
- ColorLoopUpdateFlags

# We need a more configurable way of deciding which clusters have which init functions....
# See https://github.com/project-chip/connectedhomeip/issues/4369
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions zzz_generated/app-common/app-common/zap-generated/cluster-enums.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 0 additions & 23 deletions zzz_generated/app-common/app-common/zap-generated/enums.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1214108

Please sign in to comment.