## Features - Light Strip Painting

### Function Introduction

- The light strip painting capability is mainly used for light strip categories, allowing users to customize the coloring of the light strip to enrich the playability of the light strip.
- The DP color value of the graffiti color light adopts the [HSV color model](https://baike.baidu.com/item/HSV%E9%A2%9C%E8%89%B2%E6%A8%A1%E5%9E%8B/21501482), and the string value corresponding to the HSV model color is sent through the panel.

1. Hue (H)
   Hue adjustment range: 0-360, the range of the value sent by the panel is 0-360, and the color ring adjustment range and the value sent by the panel are in a linear correspondence.
2. Saturation (S)
   Saturation adjustment range: 0%-100%, the range of the value sent by the panel is 0-1000, and the color ring adjustment range and the value sent by the panel are in a linear correspondence.
3. Brightness (V)
   Brightness adjustment range: 1%-100%, the value range sent by the panel is 10-1000, and the color wheel adjustment range and the value sent by the panel are linearly corresponding.

- Color light supports display:
  1. [Three channels](/en/miniapp/solution-ai/ability/lamp-solution/lamp#number-of-channels)
  2. [Four channels](/en/miniapp/solution-ai/ability/lamp-solution/lamp#number-of-channels)
  3. [Five channels](/en/miniapp/solution-ai/ability/lamp-solution/lamp#number-of-channels)

### DP protocol

---

| DP code           | DP meaning           | DP type                          | Remarks |
| ----------------- | -------------------- | -------------------------------- | ------- |
| paint_colour_data | Color light smear DP | { "type": "raw", "maxlen": 255 } |         |

---

- paint_colour_data DP details

| Version number | Adjustment mode                                                                            | Adjustment effect                                                                              | Segment number                 | Data                |
| -------------- | ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- | ------------------------------ | ------------------- |
| 1byte          | 1byte                                                                                      | 1byte                                                                                          | 1byte                          | See the table below |
| 0x00           | 0x00: White light mode 0x01: Color light mode 0x02: Color card mode 0x03: Combination mode | 0x00: No effect 0x01: Transition between segments 0x02: Flashing 0x03: Breathing 0x04: Shining | Number of light strip segments | See the table below |

- White light mode:

| Adjustment action  | B brightness | T color temperature |
| ------------------ | ------------ | ------------------- |
| 1byte              | 2byte        | 2byte               |
| 0x00: Paint bucket | 0-1000       | 0-1000              |

- Color light, color card mode:

| Adjustment action                                           | HSV                                 | Segment selection                                                                                                                              | Data 1                                                 | Data 2                                               | Data x... |
| ----------------------------------------------------------- | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | ---------------------------------------------------- | --------- |
| 1byte                                                       | 6byte                               | 1byte                                                                                                                                          | 1byte                                                  | 1byte                                                | ...       |
| 0x00: Paint bucket 0X01: Pencil (click) 0X02: Eraser (erase | Color light HSV color value (2+2+2) | 7bit: (0: continuous; 1: discontinuous) 0bit-6bit: (when continuous, meaningless; when discontinuous, represents the total number of segments) | Continuous: start number Discontinuous: segment number | Continuous: end number Discontinuous: segment number | ...       |

- Combination mode

| Combination mode (reserved) | Color 1                             | Color 2                             | ... |
| --------------------------- | ----------------------------------- | ----------------------------------- | --- |
| 1byte                       | 6byte                               | 6byte                               | ... |
| 0x00: Uniform               | Color light HSV color value (2+2+2) | Color light HSV color value (2+2+2) | ... |

### How to develop

- [Lamp strip component implementation reference](https://developer.tuya.com/material/library_oHEKLjj0/component?code=LampStripLightSmear)
  - After installation, the specific implementation logic is described in `node_module/@ray-js/lamp-strip-light-smear/src/README.md`
- Monitor and report DP according to UI interaction
  - [Specific monitoring and sending examples](/en/miniapp/solution-panel/ability#device-function-point-management)

### Notes

- Apply the UI implementation of the light strip:
  1. Canvas/SVG + collision detection can be used in the applet to achieve this.
  2. In RN, the corresponding image is used to dynamically modify the color and its gradient color.
- Problems with synchronizing the status of the light strip and the device
  1. Because the DP point only saves the data of the most recent application, the data of white light and color light needs to be stored in the cloud (separate storage is recommended) to synchronize the status of the panel and the device
  2. When the button or remote control operates the lamp, listen to the DP status synchronization

### Related materials

- [Function page]:
  - None
- [Component]:
  1. [Light strip component](https://developer.tuya.com/material/library_oHEKLjj0/component?code=LampStripLightSmear)
- [Tutorial]:
  1. [Light strip template tutorial](https://developer.tuya.com/en/miniapp-codelabs/codelabs/panel-lamp-strip/index.html#0)
- [SDK]:
  - None
- [API]:
  - None
