30 constexpr operator uint8_t()
const {
return static_cast<uint8_t
>(
val_); }
31 constexpr operator bool()
const {
return static_cast<uint8_t
>(
val_) != 0; }
37 return static_cast<ColorCapability>(
static_cast<uint8_t
>(lhs) &
static_cast<uint8_t
>(rhs));
40 return static_cast<ColorCapability>(
static_cast<uint8_t
>(lhs) &
static_cast<uint8_t
>(rhs));
43 return static_cast<ColorCapability>(
static_cast<uint8_t
>(lhs) |
static_cast<uint8_t
>(rhs));
46 return static_cast<ColorCapability>(
static_cast<uint8_t
>(lhs) |
static_cast<uint8_t
>(rhs));
83 constexpr operator uint8_t()
const {
return static_cast<uint8_t
>(
val_); }
84 constexpr operator bool()
const {
return static_cast<uint8_t
>(
val_) != 0; }
90 return static_cast<ColorMode>(
static_cast<uint8_t
>(lhs) &
static_cast<uint8_t
>(rhs));
93 return static_cast<ColorMode>(
static_cast<uint8_t
>(lhs) &
static_cast<uint8_t
>(rhs));
96 return static_cast<ColorMode>(
static_cast<uint8_t
>(lhs) &
static_cast<uint8_t
>(rhs));
99 return static_cast<ColorMode>(
static_cast<uint8_t
>(lhs) |
static_cast<uint8_t
>(rhs));
102 return static_cast<ColorMode>(
static_cast<uint8_t
>(lhs) |
static_cast<uint8_t
>(rhs));
105 return static_cast<ColorMode>(
static_cast<uint8_t
>(lhs) |
static_cast<uint8_t
>(rhs));
135 for (
int i = 0; i <
MAX_BITS; ++i) {
156 uint8_t cap_bit =
static_cast<uint8_t
>(capability);
160 for (
int bit = 0; bit < color_mode_count; ++bit) {
162 if ((mode_val & cap_bit) != 0) {
191 uint8_t cap_val =
static_cast<uint8_t
>(capability);
192#if defined(__GNUC__) || defined(__clang__)
194 return __builtin_ctz(cap_val);
198 while (cap_val > 1) {
BedjetMode mode
BedJet operating mode.
constexpr bitmask_t get_mask() const
Get the raw bitmask value for optimized operations.
Helper class to allow bitwise operations on ColorCapability.
constexpr ColorCapabilityHelper(ColorCapability val)
Helper class to allow bitwise operations on ColorMode with ColorCapability.
constexpr ColorModeHelper(ColorMode val)
constexpr ColorMode COLOR_MODE_LOOKUP[]
constexpr ColorCapabilityHelper operator|(ColorCapability lhs, ColorCapability rhs)
bool has_capability(const ColorModeMask &mask, ColorCapability capability)
Check if any mode in the bitmask has a specific capability Used for checking if a light supports a ca...
constexpr uint16_t compute_capability_bitmask(ColorCapability capability)
Helper to compute capability bitmask at compile time.
uint16_t color_mode_bitmask_t
constexpr int COLOR_CAPABILITY_COUNT
constexpr ColorCapabilityHelper operator&(ColorCapability lhs, ColorCapability rhs)
ColorMode
Color modes are a combination of color capabilities that can be used at the same time.
@ ON_OFF
Only on/off control.
@ RGB_COLD_WARM_WHITE
RGB color output, and separate cold and warm white outputs.
@ BRIGHTNESS
Dimmable light.
@ UNKNOWN
No color mode configured (cannot be a supported mode, only active when light is off).
@ RGB_WHITE
RGB color output and a separate white output.
@ RGB_COLOR_TEMPERATURE
RGB color output and a separate white output with controllable color temperature.
@ COLOR_TEMPERATURE
Controllable color temperature output.
@ WHITE
White output only (use only if the light also has another color mode such as RGB).
@ COLD_WARM_WHITE
Cold and warm white output with individually controllable brightness.
int capability_to_index(ColorCapability capability)
Helper function to convert a power-of-2 ColorCapability value to an array index for CAPABILITY_BITMAS...
ColorCapability
Color capabilities are the various outputs that a light has and that can be independently controlled ...
@ ON_OFF
Light can be turned on/off.
@ BRIGHTNESS
Master brightness of the light can be controlled.
@ RGB
Color can be controlled using RGB format (includes a brightness control for the color).
@ COLOR_TEMPERATURE
Color temperature can be controlled.
@ WHITE
Brightness of white channel can be controlled separately from other channels.
@ COLD_WARM_WHITE
Brightness of cold and warm white output can be controlled.
constexpr uint16_t CAPABILITY_BITMASKS[]
Compile-time lookup table mapping ColorCapability to bitmask This array is computed at compile time u...
Providing packet encoding functions for exchanging data with a remote host.
Bit mapping policy for ColorMode Uses lookup table for non-contiguous enum values.
static constexpr ColorMode from_bit(unsigned bit)
static constexpr unsigned to_bit(ColorMode mode)
static constexpr int MAX_BITS