ESPHome  2024.5.5
color_mode.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 
5 namespace esphome {
6 namespace light {
7 
9 enum class ColorCapability : uint8_t {
11  ON_OFF = 1 << 0,
13  BRIGHTNESS = 1 << 1,
15  WHITE = 1 << 2,
17  COLOR_TEMPERATURE = 1 << 3,
19  COLD_WARM_WHITE = 1 << 4,
21  RGB = 1 << 5
22 };
23 
26  public:
27  constexpr ColorCapabilityHelper(ColorCapability val) : val_(val) {}
28  constexpr operator ColorCapability() const { return val_; }
29  constexpr operator uint8_t() const { return static_cast<uint8_t>(val_); }
30  constexpr operator bool() const { return static_cast<uint8_t>(val_) != 0; }
31 
32  protected:
34 };
36  return static_cast<ColorCapability>(static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs));
37 }
39  return static_cast<ColorCapability>(static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs));
40 }
42  return static_cast<ColorCapability>(static_cast<uint8_t>(lhs) | static_cast<uint8_t>(rhs));
43 }
45  return static_cast<ColorCapability>(static_cast<uint8_t>(lhs) | static_cast<uint8_t>(rhs));
46 }
47 
49 enum class ColorMode : uint8_t {
51  UNKNOWN = 0,
53  ON_OFF = (uint8_t) ColorCapability::ON_OFF,
67  RGB_WHITE =
75 };
76 
79  public:
80  constexpr ColorModeHelper(ColorMode val) : val_(val) {}
81  constexpr operator ColorMode() const { return val_; }
82  constexpr operator uint8_t() const { return static_cast<uint8_t>(val_); }
83  constexpr operator bool() const { return static_cast<uint8_t>(val_) != 0; }
84 
85  protected:
87 };
89  return static_cast<ColorMode>(static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs));
90 }
92  return static_cast<ColorMode>(static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs));
93 }
95  return static_cast<ColorMode>(static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs));
96 }
98  return static_cast<ColorMode>(static_cast<uint8_t>(lhs) | static_cast<uint8_t>(rhs));
99 }
101  return static_cast<ColorMode>(static_cast<uint8_t>(lhs) | static_cast<uint8_t>(rhs));
102 }
104  return static_cast<ColorMode>(static_cast<uint8_t>(lhs) | static_cast<uint8_t>(rhs));
105 }
106 
107 } // namespace light
108 } // namespace esphome
ColorMode
Color modes are a combination of color capabilities that can be used at the same time.
Definition: color_mode.h:49
RGB color output and a separate white output.
Helper class to allow bitwise operations on ColorMode with ColorCapability.
Definition: color_mode.h:78
Color temperature can be controlled.
mopeka_std_values val[4]
constexpr ColorCapabilityHelper operator|(ColorCapability lhs, ColorCapability rhs)
Definition: color_mode.h:41
constexpr ColorCapabilityHelper(ColorCapability val)
Definition: color_mode.h:27
RGB color output, and separate cold and warm white outputs.
Brightness of cold and warm white output can be controlled.
Brightness of white channel can be controlled separately from other channels.
Light can be turned on/off.
RGB color output and a separate white output with controllable color temperature. ...
Helper class to allow bitwise operations on ColorCapability.
Definition: color_mode.h:25
constexpr ColorCapabilityHelper operator &(ColorCapability lhs, ColorCapability rhs)
Definition: color_mode.h:35
Master brightness of the light can be controlled.
No color mode configured (cannot be a supported mode, only active when light is off).
ColorCapability
Color capabilities are the various outputs that a light has and that can be independently controlled ...
Definition: color_mode.h:9
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
Color can be controlled using RGB format (includes a brightness control for the color).
constexpr ColorModeHelper(ColorMode val)
Definition: color_mode.h:80