1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-23 12:13:49 +01:00
This commit is contained in:
J. Nick Koston
2025-10-18 13:15:47 -10:00
parent 80fd51e198
commit cc6b798f2b
2 changed files with 4 additions and 14 deletions

View File

@@ -209,17 +209,16 @@ class ColorModeMask {
/// Build a bitmask of modes that match the given capability requirements
/// @param require_caps Capabilities that must be present in the mode
/// @param exclude_caps Capabilities that must not be present in the mode (for none case)
/// @return Raw bitmask value
static constexpr color_mode_bitmask_t build_mask_matching(uint8_t require_caps, uint8_t exclude_caps = 0) {
static constexpr color_mode_bitmask_t build_mask_matching(uint8_t require_caps) {
color_mode_bitmask_t mask = 0;
// Check each mode to see if it matches the requirements
// Skip UNKNOWN (bit 0), iterate through actual color modes (bits 1-9)
for (int bit = 1; bit < COLOR_MODE_COUNT; ++bit) {
ColorMode mode = bit_to_mode(bit);
uint8_t mode_val = static_cast<uint8_t>(mode);
// Mode matches if it has all required caps and none of the excluded caps
if ((mode_val & require_caps) == require_caps && (mode_val & exclude_caps) == 0) {
// Mode matches if it has all required caps
if ((mode_val & require_caps) == require_caps) {
mask |= (1 << bit);
}
}

View File

@@ -469,16 +469,7 @@ color_mode_bitmask_t LightCall::get_suitable_color_modes_mask_() {
if (has_cwww)
require_caps |= static_cast<uint8_t>(ColorCapability::COLD_WARM_WHITE);
// If no specific color parameters set, exclude modes with color capabilities
uint8_t exclude_caps = 0;
if (!has_rgb && !has_white && !has_ct && !has_cwww) {
// For "none" case, we want all modes but don't exclude anything
// Just require ON_OFF + BRIGHTNESS which all modes have
return ColorModeMask::build_mask_matching(
static_cast<uint8_t>(ColorCapability::ON_OFF | ColorCapability::BRIGHTNESS), exclude_caps);
}
return ColorModeMask::build_mask_matching(require_caps, exclude_caps);
return ColorModeMask::build_mask_matching(require_caps);
}
LightCall &LightCall::set_effect(const std::string &effect) {