Skip to content

Commit 020aedd

Browse files
authored
Use std::min instead of ternary operator
1 parent 73dde09 commit 020aedd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <algorithm>
12
#include "ZigbeeColorDimmableLight.h"
23
#if CONFIG_ZB_ENABLED
34

@@ -127,9 +128,8 @@ bool ZigbeeColorDimmableLight::setLight(bool state, uint8_t level, uint8_t red,
127128

128129
espXyColor_t xy_color = espRgbColorToXYColor(_current_color);
129130
espHsvColor_t hsv_color = espRgbColorToHsvColor(_current_color);
130-
uint8_t hue = (uint8_t)hsv_color.h; // Recast from uint16 to uint8
131-
hue = (hue > 254) ? 254 : hue; // Clamp to 0-254 (per the Zigbee standard)
132-
uint8_t saturation = (hsv_color.s > 254) ? 254 : (uint8_t)hsv_color.s; // Clamp to 0-254 (per the Zigbee standard)
131+
uint8_t hue = std::min((uint8_t)hsv_color.h, (uint8_t)254); // Clamp to 0-254
132+
uint8_t saturation = std::min((uint8_t)hsv_color.s, (uint8_t)254); // Clamp to 0-254
133133

134134
log_v("Updating light state: %d, level: %d, color: %d, %d, %d", state, level, red, green, blue);
135135
/* Update light clusters */

0 commit comments

Comments
 (0)