@@ -65,16 +65,14 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
65
65
return ;
66
66
}
67
67
68
- if ((attributeId != ColorControl::Attributes::CurrentX::Id) && (attributeId != ColorControl::Attributes::CurrentY::Id) &&
69
- (attributeId != ColorControl::Attributes::CurrentHue::Id) &&
70
- (attributeId != ColorControl::Attributes::CurrentSaturation::Id))
71
- {
72
- ChipLogProgress (Zcl, " Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI (attributeId));
73
- return ;
74
- }
75
-
76
- if (size == sizeof (uint16_t ))
68
+ /* XY color space */
69
+ if (attributeId == ColorControl::Attributes::CurrentX::Id || attributeId == ColorControl::Attributes::CurrentY::Id)
77
70
{
71
+ if (size != sizeof (uint16_t ))
72
+ {
73
+ ChipLogError (Zcl, " Wrong length for ColorControl value: %d" , size);
74
+ return ;
75
+ }
78
76
XyColor_t xy;
79
77
if (attributeId == ColorControl::Attributes::CurrentX::Id)
80
78
{
@@ -90,20 +88,37 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
90
88
EmberAfStatus status = ColorControl::Attributes::CurrentX::Get (endpoint, &xy.x );
91
89
assert (status == EMBER_ZCL_STATUS_SUCCESS);
92
90
}
91
+
93
92
ChipLogProgress (Zcl, " New XY color: %u|%u" , xy.x , xy.y );
94
93
LightingMgr ().InitiateAction (LightingManager::COLOR_ACTION_XY, 0 , sizeof (xy), (uint8_t *) &xy);
95
94
}
96
- else if (size == sizeof (uint8_t ))
95
+ /* HSV color space */
96
+ else if (attributeId == ColorControl::Attributes::CurrentHue::Id ||
97
+ attributeId == ColorControl::Attributes::CurrentSaturation::Id ||
98
+ attributeId == ColorControl::Attributes::EnhancedCurrentHue::Id)
97
99
{
100
+ if (size != sizeof (uint8_t ))
101
+ {
102
+ ChipLogError (Zcl, " Wrong length for ColorControl value: %d" , size);
103
+ return ;
104
+ }
98
105
HsvColor_t hsv;
99
- if (attributeId == ColorControl::Attributes::CurrentHue::Id)
106
+ if (attributeId == ColorControl::Attributes::EnhancedCurrentHue::Id)
107
+ {
108
+ // We only support 8-bit hue. Assuming hue is linear, normalize 16-bit to 8-bit.
109
+ hsv.h = (uint8_t )((*reinterpret_cast <uint16_t *>(value)) >> 8 );
110
+ // get saturation from cluster value storage
111
+ EmberAfStatus status = ColorControl::Attributes::CurrentSaturation::Get (endpoint, &hsv.s );
112
+ assert (status == EMBER_ZCL_STATUS_SUCCESS);
113
+ }
114
+ else if (attributeId == ColorControl::Attributes::CurrentHue::Id)
100
115
{
101
116
hsv.h = *value;
102
117
// get saturation from cluster value storage
103
118
EmberAfStatus status = ColorControl::Attributes::CurrentSaturation::Get (endpoint, &hsv.s );
104
119
assert (status == EMBER_ZCL_STATUS_SUCCESS);
105
120
}
106
- if (attributeId == ColorControl::Attributes::CurrentSaturation::Id)
121
+ else if (attributeId == ColorControl::Attributes::CurrentSaturation::Id)
107
122
{
108
123
hsv.s = *value;
109
124
// get hue from cluster value storage
@@ -113,16 +128,19 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
113
128
ChipLogProgress (Zcl, " New HSV color: %u|%u" , hsv.h , hsv.s );
114
129
LightingMgr ().InitiateAction (LightingManager::COLOR_ACTION_HSV, 0 , sizeof (hsv), (uint8_t *) &hsv);
115
130
}
131
+ else if (attributeId == ColorControl::Attributes::ColorTemperatureMireds::Id)
132
+ {
133
+ CtColor_t ct;
134
+ ct.ctMireds = *reinterpret_cast <uint16_t *>(value);
135
+ ChipLogProgress (Zcl, " New CT color: %u" , ct.ctMireds );
136
+ LightingMgr ().InitiateAction (LightingManager::COLOR_ACTION_CT, 0 , sizeof (ct), (uint8_t *) &ct.ctMireds );
137
+ }
116
138
else
117
139
{
118
- ChipLogError (Zcl, " Wrong length for ColorControl value: %d" , size);
140
+ ChipLogProgress (Zcl, " Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI (attributeId));
141
+ return ;
119
142
}
120
143
}
121
- else
122
- {
123
- ChipLogProgress (Zcl, " Unknown cluster ID: " ChipLogFormatMEI, ChipLogValueMEI (clusterId));
124
- return ;
125
- }
126
144
}
127
145
128
146
/* * @brief OnOff Cluster Init
0 commit comments