@@ -46,16 +46,11 @@ const uint8_t MAX_LIGHT_NUMBER = 6;
4646MatterOnOffLight OnOffLight[MAX_LIGHT_NUMBER];
4747
4848// all pins, one for each on-off light
49- uint8_t lightPins[MAX_LIGHT_NUMBER] = { 2 , 4 , 6 , 8 , 10 , 12 }; // must replace it by the real pin for the target SoC and application
49+ uint8_t lightPins[MAX_LIGHT_NUMBER] = {2 , 4 , 6 , 8 , 10 , 12 }; // must replace it by the real pin for the target SoC and application
5050
5151// friendly OnOffLights names used for printing a message in the callback
5252const char *lightName[MAX_LIGHT_NUMBER] = {
53- " Room 1" ,
54- " Room 2" ,
55- " Room 3" ,
56- " Room 4" ,
57- " Room 5" ,
58- " Room 6" ,
53+ " Room 1" , " Room 2" , " Room 3" , " Room 4" , " Room 5" , " Room 6" ,
5954};
6055
6156// simple setup() function
@@ -79,18 +74,19 @@ void setup() {
7974 Serial.println (WiFi.localIP ());
8075 delay (500 );
8176#endif
82-
77+
8378 // setup all the OnOff Light endpoint and their lambda callback functions
8479 for (uint8_t i = 0 ; i < MAX_LIGHT_NUMBER; i++) {
8580 pinMode (lightPins[i], OUTPUT); // set the GPIO function
86- OnOffLight[i].begin (false ); // off
81+ OnOffLight[i].begin (false ); // off
8782
8883 // inline lambda function using capture array index -> it will just print a message in the console
8984 OnOffLight[i].onChangeOnOff ([i](bool state) -> bool {
9085 // Display message with the specific light name and details
91- Serial.printf (" Matter App Control: '%s' (OnOffLight[%d], Endpoint %d, GPIO %d) changed to: %s\r\n " ,
92- lightName[i], i, OnOffLight[i].getEndPointId (),
93- lightPins[i], state ? " ON" : " OFF" );
86+ Serial.printf (
87+ " Matter App Control: '%s' (OnOffLight[%d], Endpoint %d, GPIO %d) changed to: %s\r\n " , lightName[i], i, OnOffLight[i].getEndPointId (), lightPins[i],
88+ state ? " ON" : " OFF"
89+ );
9490
9591 return true ;
9692 });
@@ -126,5 +122,5 @@ void loop() {
126122 delay (3000 );
127123 }
128124
129- delay (100 );
125+ delay (100 );
130126}
0 commit comments