From 53ca34914f4a35c0771d2e168ec17e3d0b59d8fd Mon Sep 17 00:00:00 2001 From: tyeth Date: Wed, 11 Dec 2024 21:27:22 +0000 Subject: [PATCH 1/2] Stop blinding status lights --- src/provisioning/littlefs/WipperSnapper_LittleFS.cpp | 9 +++++++++ src/provisioning/tinyusb/Wippersnapper_FS.cpp | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/provisioning/littlefs/WipperSnapper_LittleFS.cpp b/src/provisioning/littlefs/WipperSnapper_LittleFS.cpp index de76fc79f..637c5d25e 100644 --- a/src/provisioning/littlefs/WipperSnapper_LittleFS.cpp +++ b/src/provisioning/littlefs/WipperSnapper_LittleFS.cpp @@ -138,6 +138,15 @@ void WipperSnapper_LittleFS::parseSecrets() { "credentials!\n"); } + if (doc["status_pixel_brightness"]) { + // check it casts to float and support user specifying 0.0f which is + // default, by using the |operator instead of .as + // https://arduinojson.org/v7/api/jsonvariant/or/ + if ((doc["status_pixel_brightness"] | -1.0f) != -1.0f) { + WS.status_pixel_brightness = doc["status_pixel_brightness"].as(); + } + } + // Close the file secretsFile.close(); diff --git a/src/provisioning/tinyusb/Wippersnapper_FS.cpp b/src/provisioning/tinyusb/Wippersnapper_FS.cpp index e4fa0ee72..495fae4d4 100644 --- a/src/provisioning/tinyusb/Wippersnapper_FS.cpp +++ b/src/provisioning/tinyusb/Wippersnapper_FS.cpp @@ -452,6 +452,14 @@ void Wippersnapper_FS::parseSecrets() { "credentials!"); } + if (doc["status_pixel_brightness"]){ + // check it casts to float and support user specifying 0.0f which is default, + // by using the |operator instead of .as https://arduinojson.org/v7/api/jsonvariant/or/ + if ((doc["status_pixel_brightness"] | -1.0f) != -1.0f) { + WS.status_pixel_brightness = doc["status_pixel_brightness"].as(); + } + } + // Close secrets.json file secretsFile.close(); } From 9ddb1206d32650f7bd5a3695adb35edd5f6b5c7e Mon Sep 17 00:00:00 2001 From: tyeth Date: Thu, 19 Dec 2024 17:01:59 +0000 Subject: [PATCH 2/2] Use defined default + rem 2nd check of brightness --- .../littlefs/WipperSnapper_LittleFS.cpp | 13 +++++-------- src/provisioning/tinyusb/Wippersnapper_FS.cpp | 14 ++++++-------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/provisioning/littlefs/WipperSnapper_LittleFS.cpp b/src/provisioning/littlefs/WipperSnapper_LittleFS.cpp index 637c5d25e..f564ef93f 100644 --- a/src/provisioning/littlefs/WipperSnapper_LittleFS.cpp +++ b/src/provisioning/littlefs/WipperSnapper_LittleFS.cpp @@ -138,14 +138,11 @@ void WipperSnapper_LittleFS::parseSecrets() { "credentials!\n"); } - if (doc["status_pixel_brightness"]) { - // check it casts to float and support user specifying 0.0f which is - // default, by using the |operator instead of .as - // https://arduinojson.org/v7/api/jsonvariant/or/ - if ((doc["status_pixel_brightness"] | -1.0f) != -1.0f) { - WS.status_pixel_brightness = doc["status_pixel_brightness"].as(); - } - } + // specify type of value for json key, by using the |operator to include + // a typed default value equivalent of with .as w/ default value + // https://arduinojson.org/v7/api/jsonvariant/or/ + WS._config.status_pixel_brightness = + doc["status_pixel_brightness"] | (float)STATUS_PIXEL_BRIGHTNESS_DEFAULT; // Close the file secretsFile.close(); diff --git a/src/provisioning/tinyusb/Wippersnapper_FS.cpp b/src/provisioning/tinyusb/Wippersnapper_FS.cpp index 495fae4d4..2f1daee98 100644 --- a/src/provisioning/tinyusb/Wippersnapper_FS.cpp +++ b/src/provisioning/tinyusb/Wippersnapper_FS.cpp @@ -325,7 +325,7 @@ void Wippersnapper_FS::createSecretsFile() { strcpy(secretsConfig.aio_key, "YOUR_IO_KEY_HERE"); strcpy(secretsConfig.network.ssid, "YOUR_WIFI_SSID_HERE"); strcpy(secretsConfig.network.pass, "YOUR_WIFI_PASS_HERE"); - secretsConfig.status_pixel_brightness = 0.2; + secretsConfig.status_pixel_brightness = STATUS_PIXEL_BRIGHTNESS_DEFAULT; // Serialize the struct to a JSON document JsonDocument doc; @@ -452,13 +452,11 @@ void Wippersnapper_FS::parseSecrets() { "credentials!"); } - if (doc["status_pixel_brightness"]){ - // check it casts to float and support user specifying 0.0f which is default, - // by using the |operator instead of .as https://arduinojson.org/v7/api/jsonvariant/or/ - if ((doc["status_pixel_brightness"] | -1.0f) != -1.0f) { - WS.status_pixel_brightness = doc["status_pixel_brightness"].as(); - } - } + // specify type of value for json key, by using the |operator to include + // a typed default value equivalent of with .as w/ default value + // https://arduinojson.org/v7/api/jsonvariant/or/ + WS._config.status_pixel_brightness = + doc["status_pixel_brightness"] | (float)STATUS_PIXEL_BRIGHTNESS_DEFAULT; // Close secrets.json file secretsFile.close();