## Features - Segmented dimming

### Function introduction
- Traditional ceiling lamp products can achieve changes in brightness and color temperature through wall switches (power on and off). The hardware detects the power off time. For example, if the power is turned on again within 5 seconds after the power off, the brightness and color temperature are adjusted to the next preset value. If the power off time exceeds 5 seconds, the state before the light is turned off is maintained, and this cycle continues. Generally, there are 3 to 4 preset values ​​for brightness and color temperature. Commonly used segmented dimming hardware solutions include Mingwei SM2213EK. This function is widely used in the domestic market. In order to cater to customer usage habits, smart ceiling lamps add this function.

### DP protocol

|DPID_wifi | DPID_zigbee| DPID_sigmesh| Function name |code |Transmission type |Type |Function point attribute|
|---|---|---|---|---|---|---|---|
|52 |||Segment dimming| segment_dimming| rw| raw |{ "type": "raw", "maxlen": 255 }|

- Protocol format

|Version number | Segment dimming switch |Number of segments |Hue H |Saturation S |Brightness V |Brightness B |Color temperature T|
|---|---|---|---|---|---|---|---|
|1byte| 1byte |1byte |2byte |2byte| 2byte |2byte |2byte|

- Protocol field description:

|Serial number |Field |Length (Byte)| Data representative description|
|---|---|---|---|
|1| Version number| 1| 0x00: Initial version|
|2| Segment dimming switch| 1 |0x00: Off, 0x01: On|
|3| Number of segments| 1| Number of segments, range: 2~5 segments|
|4| Hue H |2 | HEX format, range 0x0000 ~ 0x0168 (i.e. 0~360)|
|5| Saturation S| 2 | HEX format, range 0x0000 ~ 0x03E8 (i.e. 0~1000)|
|6| Brightness V |2| HEX format, range 0x0000 ~ 0x03E8 (i.e. 0~1000)|
|7| Brightness B| 2 | HEX format, range 0x0000 ~ 0x03E8 (i.e. 0~1000) |
|8| Color temperature T| 2 |HEX format, range 0x0000 ~ 0x03E8 (i.e. 0~1000) |

**Note: If the dimming is divided into 3 sections, the sequence number 4~8 fields are repeated 3 times, and so on. **

### How to develop

- Monitor and report DP according to UI interaction
  - [Specific monitoring and sending examples](/en/miniapp/solution-panel/ability#device-function-point-management)

### Notes
- Pay attention to the impact of power-on reaction/power-off memory
  - The segmented dimming function and power-on reaction are essentially defining the state of the device powering on. Only one of the power-on reaction state and segmented dimming state can be effective. When the user only selects the segment dimming dp point and does not select the power-off memory dp point at the same time, the APP control panel provides the option to turn on/off the segment dimming function, which is turned off by default.

### Related materials
- [Function page]: 
  - None
- [Component]:  
  - None
- [Tutorial]:  
  - None
- [SDK]:  
  - None
- [API]:  
  - None