@@ -608,7 +608,7 @@ void ColorControlServer::startColorLoop(EndpointId endpoint, uint8_t startFromSt
608
608
609
609
colorHueTransitionState->initialEnhancedHue = startHue;
610
610
611
- if (direction)
611
+ if (direction == to_underlying (ColorLoopDirection:: kIncrementHue ) )
612
612
{
613
613
colorHueTransitionState->finalEnhancedHue = static_cast <uint16_t >(startHue - 1 );
614
614
}
@@ -617,7 +617,7 @@ void ColorControlServer::startColorLoop(EndpointId endpoint, uint8_t startFromSt
617
617
colorHueTransitionState->finalEnhancedHue = static_cast <uint16_t >(startHue + 1 );
618
618
}
619
619
620
- colorHueTransitionState->up = direction;
620
+ colorHueTransitionState->up = ( direction == to_underlying (ColorLoopDirection:: kIncrementHue )) ;
621
621
colorHueTransitionState->repeat = true ;
622
622
623
623
colorHueTransitionState->stepsRemaining = static_cast <uint16_t >(time * TRANSITION_TIME_1S);
@@ -1496,9 +1496,9 @@ bool ColorControlServer::stepSaturationCommand(app::CommandHandler * commandObj,
1496
1496
bool ColorControlServer::colorLoopCommand (app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
1497
1497
const Commands::ColorLoopSet::DecodableType & commandData)
1498
1498
{
1499
- uint8_t updateFlags = commandData.updateFlags . Raw () ;
1500
- uint8_t action = commandData.action ;
1501
- uint8_t direction = commandData.direction ;
1499
+ auto updateFlags = commandData.updateFlags ;
1500
+ auto action = commandData.action ;
1501
+ auto direction = commandData.direction ;
1502
1502
uint16_t time = commandData.time ;
1503
1503
uint16_t startHue = commandData.startHue ;
1504
1504
uint8_t optionsMask = commandData.optionsMask ;
@@ -1512,10 +1512,7 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
1512
1512
VerifyOrExit (colorHueTransitionState != nullptr , status = Status::UnsupportedEndpoint);
1513
1513
1514
1514
// Validate the action and direction parameters of the command
1515
- if ((action != EMBER_ZCL_COLOR_LOOP_ACTION_DEACTIVATE &&
1516
- action != EMBER_ZCL_COLOR_LOOP_ACTION_ACTIVATE_FROM_COLOR_LOOP_START_ENHANCED_HUE &&
1517
- action != EMBER_ZCL_COLOR_LOOP_ACTION_ACTIVATE_FROM_ENHANCED_CURRENT_HUE) ||
1518
- (direction != DECREMENT_HUE && direction != INCREMENT_HUE))
1515
+ if (action == ColorLoopAction::kUnknownEnumValue || direction == ColorLoopDirection::kUnknownEnumValue )
1519
1516
{
1520
1517
commandObj->AddStatus (commandPath, Status::InvalidCommand);
1521
1518
return true ;
@@ -1529,20 +1526,19 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
1529
1526
1530
1527
Attributes::ColorLoopActive::Get (endpoint, &isColorLoopActive);
1531
1528
1532
- deactiveColorLoop =
1533
- (updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_ACTION) && (action == EMBER_ZCL_COLOR_LOOP_ACTION_DEACTIVATE);
1529
+ deactiveColorLoop = updateFlags.Has (ColorLoopUpdateFlags::kUpdateAction ) && (action == ColorLoopAction::kDeactivate );
1534
1530
1535
- if (updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_DIRECTION )
1531
+ if (updateFlags. Has (ColorLoopUpdateFlags:: kUpdateAction ) )
1536
1532
{
1537
- Attributes::ColorLoopDirection::Set (endpoint, direction);
1533
+ Attributes::ColorLoopDirection::Set (endpoint, to_underlying ( direction) );
1538
1534
1539
1535
// Checks if color loop is active and stays active
1540
1536
if (isColorLoopActive && !deactiveColorLoop)
1541
1537
{
1542
- colorHueTransitionState->up = direction;
1538
+ colorHueTransitionState->up = ( direction == ColorLoopDirection:: kIncrementHue ) ;
1543
1539
colorHueTransitionState->initialEnhancedHue = colorHueTransitionState->currentEnhancedHue ;
1544
1540
1545
- if (direction)
1541
+ if (direction == ColorLoopDirection:: kIncrementHue )
1546
1542
{
1547
1543
colorHueTransitionState->finalEnhancedHue = static_cast <uint16_t >(colorHueTransitionState->initialEnhancedHue - 1 );
1548
1544
}
@@ -1554,7 +1550,7 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
1554
1550
}
1555
1551
}
1556
1552
1557
- if (updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_TIME )
1553
+ if (updateFlags. Has (ColorLoopUpdateFlags:: kUpdateTime ) )
1558
1554
{
1559
1555
Attributes::ColorLoopTime::Set (endpoint, time );
1560
1556
@@ -1576,14 +1572,14 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
1576
1572
}
1577
1573
}
1578
1574
1579
- if (updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_START_HUE )
1575
+ if (updateFlags. Has (ColorLoopUpdateFlags:: kUpdateStartHue ) )
1580
1576
{
1581
1577
Attributes::ColorLoopStartEnhancedHue::Set (endpoint, startHue);
1582
1578
}
1583
1579
1584
- if (updateFlags & EMBER_AF_COLOR_LOOP_UPDATE_FLAGS_UPDATE_ACTION )
1580
+ if (updateFlags. Has (ColorLoopUpdateFlags:: kUpdateAction ) )
1585
1581
{
1586
- if (action == EMBER_ZCL_COLOR_LOOP_ACTION_DEACTIVATE )
1582
+ if (action == ColorLoopAction:: kDeactivate )
1587
1583
{
1588
1584
if (isColorLoopActive)
1589
1585
{
@@ -1600,11 +1596,11 @@ bool ColorControlServer::colorLoopCommand(app::CommandHandler * commandObj, cons
1600
1596
// Do Nothing since it's not on
1601
1597
}
1602
1598
}
1603
- else if (action == EMBER_ZCL_COLOR_LOOP_ACTION_ACTIVATE_FROM_COLOR_LOOP_START_ENHANCED_HUE )
1599
+ else if (action == ColorLoopAction:: kActivateFromColorLoopStartEnhancedHue )
1604
1600
{
1605
1601
startColorLoop (endpoint, true );
1606
1602
}
1607
- else if (action == EMBER_ZCL_COLOR_LOOP_ACTION_ACTIVATE_FROM_ENHANCED_CURRENT_HUE )
1603
+ else if (action == ColorLoopAction:: kActivateFromEnhancedCurrentHue )
1608
1604
{
1609
1605
startColorLoop (endpoint, false );
1610
1606
}
0 commit comments