Skip to content

Commit 12f6a43

Browse files
ci(pre-commit): Apply automatic fixes
1 parent b356cef commit 12f6a43

File tree

5 files changed

+64
-60
lines changed

5 files changed

+64
-60
lines changed

Diff for: libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino

+6-6
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void setup() {
115115
Serial.printf("Light Color Temperature changed to %d\r\n", colorTemperature);
116116
// get correspondent Hue and Saturation of the color temperature
117117
HsvColor_t hsvTemperature = espRgbColorToHsvColor(espCTToRgbColor(colorTemperature));
118-
// keep previous the brightness and just change the Hue and Saturation
118+
// keep previous the brightness and just change the Hue and Saturation
119119
currentHSVColor.h = hsvTemperature.h;
120120
currentHSVColor.s = hsvTemperature.s;
121121
return true;
@@ -128,7 +128,7 @@ void setup() {
128128
});
129129
EnhancedColorLight.onChangeColorHSV([](HsvColor_t hsvColor) {
130130
Serial.printf("Light HSV Color changed to (%d,%d,%d)\r\n", hsvColor.h, hsvColor.s, hsvColor.v);
131-
// keep the current brightness and just change Hue and Saturation
131+
// keep the current brightness and just change Hue and Saturation
132132
currentHSVColor.h = hsvColor.h;
133133
currentHSVColor.s = hsvColor.s;
134134
return true;
@@ -140,8 +140,8 @@ void setup() {
140140
if (Matter.isDeviceCommissioned()) {
141141
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
142142
Serial.printf(
143-
"Initial state: %s | RGB Color: (%d,%d,%d) \r\n", EnhancedColorLight ? "ON" : "OFF",
144-
EnhancedColorLight.getColorRGB().r, EnhancedColorLight.getColorRGB().g, EnhancedColorLight.getColorRGB().b
143+
"Initial state: %s | RGB Color: (%d,%d,%d) \r\n", EnhancedColorLight ? "ON" : "OFF", EnhancedColorLight.getColorRGB().r,
144+
EnhancedColorLight.getColorRGB().g, EnhancedColorLight.getColorRGB().b
145145
);
146146
// configure the Light based on initial on-off state and its color
147147
EnhancedColorLight.updateAccessory();
@@ -171,8 +171,8 @@ void loop() {
171171
}
172172
}
173173
Serial.printf(
174-
"Initial state: %s | RGB Color: (%d,%d,%d) \r\n", EnhancedColorLight ? "ON" : "OFF",
175-
EnhancedColorLight.getColorRGB().r, EnhancedColorLight.getColorRGB().g, EnhancedColorLight.getColorRGB().b
174+
"Initial state: %s | RGB Color: (%d,%d,%d) \r\n", EnhancedColorLight ? "ON" : "OFF", EnhancedColorLight.getColorRGB().r,
175+
EnhancedColorLight.getColorRGB().g, EnhancedColorLight.getColorRGB().b
176176
);
177177
// configure the Light based on initial on-off state and its color
178178
EnhancedColorLight.updateAccessory();

Diff for: libraries/Matter/examples/MatterEnhancedColorLight/ci.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
66
]
77
}
8-
8+

Diff for: libraries/Matter/src/MatterEndpoints/MatterColorTemperatureLight.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class MatterColorTemperatureLight : public MatterEndPoint {
5757
void onChangeOnOff(EndPointOnOffCB onChangeCB) {
5858
_onChangeOnOffCB = onChangeCB;
5959
}
60-
60+
6161
// User Callback for whenever the Light brightness value [0..255] is changed by the Matter Controller
6262
using EndPointBrightnessCB = std::function<bool(uint8_t)>;
6363
void onChangeBrightness(EndPointBrightnessCB onChangeCB) {

Diff for: libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.cpp

+51-46
Original file line numberDiff line numberDiff line change
@@ -25,63 +25,65 @@ using namespace chip::app::Clusters;
2525

2626
// endpoint for enhanced color light device
2727
namespace esp_matter {
28-
using namespace cluster;
29-
namespace endpoint {
28+
using namespace cluster;
29+
namespace endpoint {
3030
namespace enhanced_color_light {
3131
typedef struct config {
32-
cluster::descriptor::config_t descriptor;
33-
cluster::identify::config_t identify;
34-
cluster::groups::config_t groups;
35-
cluster::scenes_management::config_t scenes_management;
36-
cluster::on_off::config_t on_off;
37-
cluster::level_control::config_t level_control;
38-
cluster::color_control::config_t color_control;
32+
cluster::descriptor::config_t descriptor;
33+
cluster::identify::config_t identify;
34+
cluster::groups::config_t groups;
35+
cluster::scenes_management::config_t scenes_management;
36+
cluster::on_off::config_t on_off;
37+
cluster::level_control::config_t level_control;
38+
cluster::color_control::config_t color_control;
3939
} config_t;
4040

4141
uint32_t get_device_type_id() {
42-
return ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_ID;
42+
return ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_ID;
4343
}
4444

4545
uint8_t get_device_type_version() {
46-
return ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_VERSION;
46+
return ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_VERSION;
4747
}
4848

4949
esp_err_t add(endpoint_t *endpoint, config_t *config) {
50-
if (!endpoint) {
51-
log_e("Endpoint cannot be NULL");
52-
return ESP_ERR_INVALID_ARG;
53-
}
54-
esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version());
55-
if (err != ESP_OK) {
56-
log_e("Failed to add device type id:%" PRIu32 ",err: %d", get_device_type_id(), err);
57-
return err;
58-
}
50+
if (!endpoint) {
51+
log_e("Endpoint cannot be NULL");
52+
return ESP_ERR_INVALID_ARG;
53+
}
54+
esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version());
55+
if (err != ESP_OK) {
56+
log_e("Failed to add device type id:%" PRIu32 ",err: %d", get_device_type_id(), err);
57+
return err;
58+
}
5959

60-
descriptor::create(endpoint, &(config->descriptor), CLUSTER_FLAG_SERVER);
61-
cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER);
62-
identify::command::create_trigger_effect(identify_cluster);
63-
groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER);
64-
cluster_t *scenes_cluster = scenes_management::create(endpoint, &(config->scenes_management), CLUSTER_FLAG_SERVER);
65-
scenes_management::command::create_copy_scene(scenes_cluster);
66-
scenes_management::command::create_copy_scene_response(scenes_cluster);
67-
68-
on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id());
69-
level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER,
70-
level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id());
71-
color_control::create(endpoint, &(config->color_control), CLUSTER_FLAG_SERVER,
72-
color_control::feature::hue_saturation::get_id() | color_control::feature::color_temperature::get_id());
73-
return ESP_OK;
60+
descriptor::create(endpoint, &(config->descriptor), CLUSTER_FLAG_SERVER);
61+
cluster_t *identify_cluster = identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER);
62+
identify::command::create_trigger_effect(identify_cluster);
63+
groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER);
64+
cluster_t *scenes_cluster = scenes_management::create(endpoint, &(config->scenes_management), CLUSTER_FLAG_SERVER);
65+
scenes_management::command::create_copy_scene(scenes_cluster);
66+
scenes_management::command::create_copy_scene_response(scenes_cluster);
67+
68+
on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id());
69+
level_control::create(
70+
endpoint, &(config->level_control), CLUSTER_FLAG_SERVER, level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id()
71+
);
72+
color_control::create(
73+
endpoint, &(config->color_control), CLUSTER_FLAG_SERVER,
74+
color_control::feature::hue_saturation::get_id() | color_control::feature::color_temperature::get_id()
75+
);
76+
return ESP_OK;
7477
}
7578

7679
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) {
77-
endpoint_t *endpoint = endpoint::create(node, flags, priv_data);
78-
add(endpoint, config);
79-
return endpoint;
80+
endpoint_t *endpoint = endpoint::create(node, flags, priv_data);
81+
add(endpoint, config);
82+
return endpoint;
8083
}
81-
} /* enhanced_color_light */
82-
} /* endpoint */
83-
} /* esp_matter */
84-
84+
} // namespace enhanced_color_light
85+
} // namespace endpoint
86+
} // namespace esp_matter
8587

8688
bool MatterEnhancedColorLight::attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val) {
8789
bool ret = true;
@@ -90,7 +92,10 @@ bool MatterEnhancedColorLight::attributeChangeCB(uint16_t endpoint_id, uint32_t
9092
return false;
9193
}
9294

93-
log_d("Enhanced ColorAttr update callback: endpoint: %u, cluster: %u, attribute: %u, val: %u, type: %u", endpoint_id, cluster_id, attribute_id, val->val.u32, val->type);
95+
log_d(
96+
"Enhanced ColorAttr update callback: endpoint: %u, cluster: %u, attribute: %u, val: %u, type: %u", endpoint_id, cluster_id, attribute_id, val->val.u32,
97+
val->type
98+
);
9499

95100
if (endpoint_id == getEndPointId()) {
96101
switch (cluster_id) {
@@ -101,7 +106,7 @@ bool MatterEnhancedColorLight::attributeChangeCB(uint16_t endpoint_id, uint32_t
101106
ret &= _onChangeOnOffCB(val->val.b);
102107
}
103108
if (_onChangeCB != NULL) {
104-
ret &= _onChangeCB(val->val.b, colorHSV, brightnessLevel, colorTemperatureLevel);
109+
ret &= _onChangeCB(val->val.b, colorHSV, brightnessLevel, colorTemperatureLevel);
105110
}
106111
if (ret == true) {
107112
onOffState = val->val.b;
@@ -145,13 +150,13 @@ bool MatterEnhancedColorLight::attributeChangeCB(uint16_t endpoint_id, uint32_t
145150
if (attribute_id == ColorControl::Attributes::CurrentHue::Id) {
146151
log_d("Enhanced ColorLight Hue changed to %d", val->val.u8);
147152
hsvColor.h = val->val.u8;
148-
} else { // attribute_id == ColorControl::Attributes::CurrentSaturation::Id)
153+
} else { // attribute_id == ColorControl::Attributes::CurrentSaturation::Id)
149154
log_d("Enhanced ColorLight Saturation changed to %d", val->val.u8);
150155
hsvColor.s = val->val.u8;
151156
}
152157
if (_onChangeColorCB != NULL) {
153158
ret &= _onChangeColorCB(hsvColor);
154-
}
159+
}
155160
if (_onChangeCB != NULL) {
156161
ret &= _onChangeCB(onOffState, hsvColor, brightnessLevel, colorTemperatureLevel);
157162
}
@@ -338,7 +343,7 @@ bool MatterEnhancedColorLight::setColorHSV(espHsvColor_t _hsvColor) {
338343
return true;
339344
}
340345

341-
colorHSV = { _hsvColor.h, _hsvColor.s, _hsvColor.v };
346+
colorHSV = {_hsvColor.h, _hsvColor.s, _hsvColor.v};
342347

343348
endpoint_t *endpoint = endpoint::get(node::get(), endpoint_id);
344349
cluster_t *cluster = cluster::get(endpoint, ColorControl::Id);

Diff for: libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class MatterEnhancedColorLight : public MatterEndPoint {
2828
MatterEnhancedColorLight();
2929
~MatterEnhancedColorLight();
3030
// default initial state is off, brigthness = 25 (10%), HSV(21, 216, 25), color temperature is 454 (Warm White)
31-
virtual bool begin(bool initialState = false, espHsvColor_t colorHSV = { 21, 216, 25}, uint8_t newBrightness = 25, uint16_t colorTemperature = 454);
31+
virtual bool begin(bool initialState = false, espHsvColor_t colorHSV = {21, 216, 25}, uint8_t newBrightness = 25, uint16_t colorTemperature = 454);
3232
// this will just stop processing Light Matter events
3333
void end();
3434

@@ -47,7 +47,6 @@ class MatterEnhancedColorLight : public MatterEndPoint {
4747
bool setColorHSV(espHsvColor_t hsvColor); // returns true if successful
4848
espHsvColor_t getColorHSV(); // returns current HSV Color
4949

50-
5150
// used to update the state of the light using the current Matter Light internal state
5251
// It is necessary to set a user callback function using onChange() to handle the physical light state
5352
void updateAccessory();
@@ -90,10 +89,10 @@ class MatterEnhancedColorLight : public MatterEndPoint {
9089

9190
protected:
9291
bool started = false;
93-
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)
94-
uint8_t brightnessLevel = 0; // default initial brightness is 0, but it can be changed by begin(bool, uint8_t)
95-
espHsvColor_t colorHSV = { 0 }; // default initial color HSV is black, but it can be changed by begin(bool, uint8_t, espHsvColor_t)
96-
uint16_t colorTemperatureLevel = 0; // default initial color temperature is 0, but it can be changed by begin(bool, uint8_t, espHsvColor_t, uint16_t)
92+
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)
93+
uint8_t brightnessLevel = 0; // default initial brightness is 0, but it can be changed by begin(bool, uint8_t)
94+
espHsvColor_t colorHSV = {0}; // default initial color HSV is black, but it can be changed by begin(bool, uint8_t, espHsvColor_t)
95+
uint16_t colorTemperatureLevel = 0; // default initial color temperature is 0, but it can be changed by begin(bool, uint8_t, espHsvColor_t, uint16_t)
9796
EndPointOnOffCB _onChangeOnOffCB = NULL;
9897
EndPointBrightnessCB _onChangeBrightnessCB = NULL;
9998
EndPointRGBColorCB _onChangeColorCB = NULL;

0 commit comments

Comments
 (0)