From 02a8024e9499ae5404f6c34ce95fc025822ec7c7 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 22 Oct 2025 08:54:21 -1000 Subject: [PATCH] Update esphome/components/light/color_mode.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- esphome/components/light/color_mode.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/esphome/components/light/color_mode.h b/esphome/components/light/color_mode.h index 71b79ea506..1f64b22e82 100644 --- a/esphome/components/light/color_mode.h +++ b/esphome/components/light/color_mode.h @@ -159,8 +159,15 @@ constexpr uint16_t CAPABILITY_BITMASKS[] = { compute_capability_bitmask(ColorCapability::RGB), // 1 << 5 }; -/// Convert a power-of-2 ColorCapability value to an array index -/// ColorCapability values: 1, 2, 4, 8, 16, 32 -> array indices: 0, 1, 2, 3, 4, 5 +/** + * @brief Helper function to convert a power-of-2 ColorCapability value to an array index for CAPABILITY_BITMASKS lookup. + * + * This function maps ColorCapability values (1, 2, 4, 8, 16, 32) to array indices (0, 1, 2, 3, 4, 5). + * Used to index into the CAPABILITY_BITMASKS lookup table. + * + * @param capability A ColorCapability enum value (must be a power of 2). + * @return The corresponding array index (0-based). + */ inline int capability_to_index(ColorCapability capability) { uint8_t cap_val = static_cast(capability); #if defined(__GNUC__) || defined(__clang__)