|
| 1 | +################ |
| 2 | +MatterColorLight |
| 3 | +################ |
| 4 | + |
| 5 | +About |
| 6 | +----- |
| 7 | + |
| 8 | +The ``MatterColorLight`` class provides a color light endpoint for Matter networks with RGB color control using the HSV color model. This endpoint implements the Matter lighting standard for full-color lighting control. |
| 9 | + |
| 10 | +**Features:** |
| 11 | +* On/off control |
| 12 | +* RGB color control with HSV color model |
| 13 | +* State persistence support |
| 14 | +* Callback support for state and color changes |
| 15 | +* Integration with Apple HomeKit, Amazon Alexa, and Google Home |
| 16 | +* Matter standard compliance |
| 17 | + |
| 18 | +**Use Cases:** |
| 19 | +* RGB smart lights |
| 20 | +* Color-changing lights |
| 21 | +* Mood lighting |
| 22 | +* Entertainment lighting control |
| 23 | +* Smart home color automation |
| 24 | + |
| 25 | +API Reference |
| 26 | +------------- |
| 27 | + |
| 28 | +Constructor |
| 29 | +*********** |
| 30 | + |
| 31 | +MatterColorLight |
| 32 | +^^^^^^^^^^^^^^^^ |
| 33 | + |
| 34 | +Creates a new Matter color light endpoint. |
| 35 | + |
| 36 | +.. code-block:: arduino |
| 37 | +
|
| 38 | + MatterColorLight(); |
| 39 | +
|
| 40 | +Initialization |
| 41 | +************** |
| 42 | + |
| 43 | +begin |
| 44 | +^^^^^ |
| 45 | + |
| 46 | +Initializes the Matter color light endpoint with optional initial state and color. |
| 47 | + |
| 48 | +.. code-block:: arduino |
| 49 | +
|
| 50 | + bool begin(bool initialState = false, espHsvColor_t colorHSV = {0, 254, 31}); |
| 51 | +
|
| 52 | +* ``initialState`` - Initial on/off state (default: ``false`` = off) |
| 53 | +* ``colorHSV`` - Initial HSV color (default: red 12% intensity HSV(0, 254, 31)) |
| 54 | + |
| 55 | +This function will return ``true`` if successful, ``false`` otherwise. |
| 56 | + |
| 57 | +end |
| 58 | +^^^ |
| 59 | + |
| 60 | +Stops processing Matter light events. |
| 61 | + |
| 62 | +.. code-block:: arduino |
| 63 | +
|
| 64 | + void end(); |
| 65 | +
|
| 66 | +On/Off Control |
| 67 | +************** |
| 68 | + |
| 69 | +setOnOff |
| 70 | +^^^^^^^^ |
| 71 | + |
| 72 | +Sets the on/off state of the light. |
| 73 | + |
| 74 | +.. code-block:: arduino |
| 75 | +
|
| 76 | + bool setOnOff(bool newState); |
| 77 | +
|
| 78 | +getOnOff |
| 79 | +^^^^^^^^ |
| 80 | + |
| 81 | +Gets the current on/off state. |
| 82 | + |
| 83 | +.. code-block:: arduino |
| 84 | +
|
| 85 | + bool getOnOff(); |
| 86 | +
|
| 87 | +toggle |
| 88 | +^^^^^^ |
| 89 | + |
| 90 | +Toggles the on/off state. |
| 91 | + |
| 92 | +.. code-block:: arduino |
| 93 | +
|
| 94 | + bool toggle(); |
| 95 | +
|
| 96 | +Color Control |
| 97 | +************* |
| 98 | + |
| 99 | +setColorRGB |
| 100 | +^^^^^^^^^^^ |
| 101 | + |
| 102 | +Sets the color using RGB values. |
| 103 | + |
| 104 | +.. code-block:: arduino |
| 105 | +
|
| 106 | + bool setColorRGB(espRgbColor_t rgbColor); |
| 107 | +
|
| 108 | +* ``rgbColor`` - RGB color structure with red, green, and blue values (0-255 each) |
| 109 | + |
| 110 | +getColorRGB |
| 111 | +^^^^^^^^^^^ |
| 112 | + |
| 113 | +Gets the current color as RGB values. |
| 114 | + |
| 115 | +.. code-block:: arduino |
| 116 | +
|
| 117 | + espRgbColor_t getColorRGB(); |
| 118 | +
|
| 119 | +setColorHSV |
| 120 | +^^^^^^^^^^^ |
| 121 | + |
| 122 | +Sets the color using HSV values. |
| 123 | + |
| 124 | +.. code-block:: arduino |
| 125 | +
|
| 126 | + bool setColorHSV(espHsvColor_t hsvColor); |
| 127 | +
|
| 128 | +* ``hsvColor`` - HSV color structure with hue (0-360), saturation (0-254), and value/brightness (0-254) |
| 129 | + |
| 130 | +getColorHSV |
| 131 | +^^^^^^^^^^^ |
| 132 | + |
| 133 | +Gets the current color as HSV values. |
| 134 | + |
| 135 | +.. code-block:: arduino |
| 136 | +
|
| 137 | + espHsvColor_t getColorHSV(); |
| 138 | +
|
| 139 | +Event Handling |
| 140 | +************** |
| 141 | + |
| 142 | +onChange |
| 143 | +^^^^^^^^ |
| 144 | + |
| 145 | +Sets a callback for when any parameter changes. |
| 146 | + |
| 147 | +.. code-block:: arduino |
| 148 | +
|
| 149 | + void onChange(EndPointCB onChangeCB); |
| 150 | +
|
| 151 | +The callback signature is: |
| 152 | + |
| 153 | +.. code-block:: arduino |
| 154 | +
|
| 155 | + bool onChangeCallback(bool newState, espHsvColor_t newColor); |
| 156 | +
|
| 157 | +onChangeOnOff |
| 158 | +^^^^^^^^^^^^^ |
| 159 | + |
| 160 | +Sets a callback for on/off state changes. |
| 161 | + |
| 162 | +.. code-block:: arduino |
| 163 | +
|
| 164 | + void onChangeOnOff(EndPointOnOffCB onChangeCB); |
| 165 | +
|
| 166 | +onChangeColorHSV |
| 167 | +^^^^^^^^^^^^^^^^ |
| 168 | + |
| 169 | +Sets a callback for color changes. |
| 170 | + |
| 171 | +.. code-block:: arduino |
| 172 | +
|
| 173 | + void onChangeColorHSV(EndPointRGBColorCB onChangeCB); |
| 174 | +
|
| 175 | +updateAccessory |
| 176 | +^^^^^^^^^^^^^^^ |
| 177 | + |
| 178 | +Updates the physical light state using current Matter internal state. |
| 179 | + |
| 180 | +.. code-block:: arduino |
| 181 | +
|
| 182 | + void updateAccessory(); |
| 183 | +
|
| 184 | +Operators |
| 185 | +********* |
| 186 | + |
| 187 | +bool operator |
| 188 | +^^^^^^^^^^^^^ |
| 189 | + |
| 190 | +Returns current on/off state. |
| 191 | + |
| 192 | +.. code-block:: arduino |
| 193 | +
|
| 194 | + operator bool(); |
| 195 | +
|
| 196 | +Assignment operator |
| 197 | +^^^^^^^^^^^^^^^^^^^ |
| 198 | + |
| 199 | +Turns light on or off. |
| 200 | + |
| 201 | +.. code-block:: arduino |
| 202 | +
|
| 203 | + void operator=(bool state); |
| 204 | +
|
| 205 | +Example |
| 206 | +------- |
| 207 | + |
| 208 | +Color Light |
| 209 | +*********** |
| 210 | + |
| 211 | +.. literalinclude:: ../../../libraries/Matter/examples/MatterColorLight/MatterColorLight.ino |
| 212 | + :language: arduino |
0 commit comments