File tree Expand file tree Collapse file tree 2 files changed +11
-16
lines changed Expand file tree Collapse file tree 2 files changed +11
-16
lines changed Original file line number Diff line number Diff line change @@ -138,14 +138,11 @@ void WipperSnapper_LittleFS::parseSecrets() {
138
138
" credentials!\n " );
139
139
}
140
140
141
- if (doc[" status_pixel_brightness" ]) {
142
- // check it casts to float and support user specifying 0.0f which is
143
- // default, by using the |operator instead of .as
144
- // https://arduinojson.org/v7/api/jsonvariant/or/
145
- if ((doc[" status_pixel_brightness" ] | -1 .0f ) != -1 .0f ) {
146
- WS.status_pixel_brightness = doc[" status_pixel_brightness" ].as <float >();
147
- }
148
- }
141
+ // specify type of value for json key, by using the |operator to include
142
+ // a typed default value equivalent of with .as<float> w/ default value
143
+ // https://arduinojson.org/v7/api/jsonvariant/or/
144
+ WS._config .status_pixel_brightness =
145
+ doc[" status_pixel_brightness" ] | (float )STATUS_PIXEL_BRIGHTNESS_DEFAULT;
149
146
150
147
// Close the file
151
148
secretsFile.close ();
Original file line number Diff line number Diff line change @@ -325,7 +325,7 @@ void Wippersnapper_FS::createSecretsFile() {
325
325
strcpy (secretsConfig.aio_key , " YOUR_IO_KEY_HERE" );
326
326
strcpy (secretsConfig.network .ssid , " YOUR_WIFI_SSID_HERE" );
327
327
strcpy (secretsConfig.network .pass , " YOUR_WIFI_PASS_HERE" );
328
- secretsConfig.status_pixel_brightness = 0.2 ;
328
+ secretsConfig.status_pixel_brightness = STATUS_PIXEL_BRIGHTNESS_DEFAULT ;
329
329
330
330
// Serialize the struct to a JSON document
331
331
JsonDocument doc;
@@ -452,13 +452,11 @@ void Wippersnapper_FS::parseSecrets() {
452
452
" credentials!" );
453
453
}
454
454
455
- if (doc[" status_pixel_brightness" ]){
456
- // check it casts to float and support user specifying 0.0f which is default,
457
- // by using the |operator instead of .as https://arduinojson.org/v7/api/jsonvariant/or/
458
- if ((doc[" status_pixel_brightness" ] | -1 .0f ) != -1 .0f ) {
459
- WS.status_pixel_brightness = doc[" status_pixel_brightness" ].as <float >();
460
- }
461
- }
455
+ // specify type of value for json key, by using the |operator to include
456
+ // a typed default value equivalent of with .as<float> w/ default value
457
+ // https://arduinojson.org/v7/api/jsonvariant/or/
458
+ WS._config .status_pixel_brightness =
459
+ doc[" status_pixel_brightness" ] | (float )STATUS_PIXEL_BRIGHTNESS_DEFAULT;
462
460
463
461
// Close secrets.json file
464
462
secretsFile.close ();
You can’t perform that action at this time.
0 commit comments