File tree 1 file changed +5
-5
lines changed
libraries/Matter/examples/MatterOnOffLight
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 22
22
MatterOnOffLight OnOffLight;
23
23
24
24
// it will keep last OnOff state stored, using Preferences
25
- Preferences lastStatePref ;
26
- # define ON_OFF_PREF_KEY " lastOnOffState "
25
+ Preferences statePref ;
26
+ const char *OnOffPrefKey = " OnOffState " ;
27
27
28
28
// set your board LED pin here
29
29
#ifdef LED_BUILTIN
@@ -49,7 +49,7 @@ bool setLightOnOff(bool state) {
49
49
digitalWrite (ledPin, LOW);
50
50
}
51
51
// store last OnOff state for when the Light is restarted / power goes off
52
- lastStatePref .putBool (ON_OFF_PREF_KEY , state);
52
+ statePref .putBool (OnOffPrefKey , state);
53
53
// This callback must return the success state to Matter core
54
54
return true ;
55
55
}
@@ -83,8 +83,8 @@ void setup() {
83
83
delay (500 );
84
84
85
85
// Initialize Matter EndPoint
86
- lastStatePref .begin (" matterLight" , false );
87
- bool lastOnOffState = lastStatePref .getBool (ON_OFF_PREF_KEY , true );
86
+ statePref .begin (" matterLight" , false );
87
+ bool lastOnOffState = statePref .getBool (OnOffPrefKey , true );
88
88
OnOffLight.begin (lastOnOffState);
89
89
OnOffLight.onChange (setLightOnOff);
90
90
You can’t perform that action at this time.
0 commit comments