From 292fc7839fc38c7eac7845b13ebe51dd2aef7403 Mon Sep 17 00:00:00 2001 From: Stephan Rumswinkel <17520641+srwi@users.noreply.github.com> Date: Thu, 11 Apr 2024 20:50:58 +0200 Subject: [PATCH] Bump ArduinoJson dependency Fixes (#23) --- README.md | 2 +- library.json | 2 +- library.properties | 4 ++-- src/Config.cpp | 18 +++++++++--------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 30ee883..1b83eec 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ FastLEDHub allows you to manage all of your [FastLED]([FastLED](https://github.c ### Library dependencies -- ArduinoJson ≥ 6.0 +- ArduinoJson ≥ 7.0 - ESPEssentials ≥ 2.1 - FastLED - LinkedList diff --git a/library.json b/library.json index 0e17b6b..e285dfd 100644 --- a/library.json +++ b/library.json @@ -18,5 +18,5 @@ "url": "https://github.com/srwi" }, "license": "LGPL-2.1-or-later", - "version": "2.1.3" + "version": "2.2" } diff --git a/library.properties b/library.properties index 2ed7c41..bae7751 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=FastLEDHub -version=2.1.3 +version=2.2 author=Stephan Rumswinkel maintainer=Stephan Rumswinkel sentence=Control multiple FastLED lightstrip animations on the ESP8266 and ESP32 without reuploading. @@ -7,4 +7,4 @@ paragraph=FastLEDHub allows you to manage all of your FastLED sketches on the ES url=https://github.com/srwi/FastLEDHub.git category=Display architectures=esp8266,esp32 -depends=WiFiManager,ESPEssentials,ArduinoJson,LinkedList,FastLED,WebSockets +depends=WiFiManager (>= 2.0.0),ESPEssentials (>= 2.1.0),ArduinoJson (>= 7.0.0),LinkedList,FastLED,WebSockets diff --git a/src/Config.cpp b/src/Config.cpp index 8ce8b9c..3c3d505 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -50,7 +50,7 @@ bool ConfigClass::initialize() bool ConfigClass::parseJson(const char *input) { - StaticJsonDocument<1024> doc; + JsonDocument doc; DeserializationError error = deserializeJson(doc, input); if (doc.containsKey("timeZone")) @@ -128,12 +128,12 @@ void ConfigClass::getUserConfigJson(JsonDocument &doc) doc["sunsetOffset"] = sunsetOffset; doc["sunsetAnimation"] = sunsetAnimation; doc["startupAnimation"] = startupAnimation; - JsonArray sliderValueArray = doc.createNestedArray("sliderValues"); + JsonArray sliderValueArray = doc["sliderValues"].to(); for (uint16_t i = 0; i < sliderValues.size(); i++) { sliderValueArray.add(sliderValues.get(i)); } - JsonArray colorPickerValueArray = doc.createNestedArray("colorPickerValues"); + JsonArray colorPickerValueArray = doc["colorPickerValues"].to(); for (uint16_t i = 0; i < colorPickerValues.size(); i++) { colorPickerValueArray.add(rgb2hex(colorPickerValues.get(i))); @@ -144,15 +144,15 @@ void ConfigClass::getApplicationStateJson(JsonDocument &doc) { doc["status"] = FastLEDHub.getStatus(); doc["currentAnimation"] = FastLEDHub.getCurrentAnimationName(); - JsonArray animations = doc.createNestedArray("animations"); + JsonArray animations = doc["animations"].to(); for (uint8_t i = 0; i < FastLEDHub.animations.size(); i++) { animations.add(FastLEDHub.animations.get(i)->getName()); } - JsonArray sliders = doc.createNestedArray("sliders"); + JsonArray sliders = doc["sliders"].to(); for (uint8_t i = 0; i < FastLEDHub.sliders.size(); i++) { - JsonObject slider = sliders.createNestedObject(); + JsonObject slider = sliders.add(); slider["name"] = FastLEDHub.sliders.get(i)->name; slider["min"] = FastLEDHub.sliders.get(i)->min; slider["max"] = FastLEDHub.sliders.get(i)->max; @@ -160,10 +160,10 @@ void ConfigClass::getApplicationStateJson(JsonDocument &doc) slider["value"] = FastLEDHub.sliders.get(i)->value; slider["icon"] = FastLEDHub.sliders.get(i)->icon; } - JsonArray colorPickers = doc.createNestedArray("colorPickers"); + JsonArray colorPickers = doc["colorPickers"].to(); for (uint8_t i = 0; i < FastLEDHub.colorPickers.size(); i++) { - JsonObject colorPicker = colorPickers.createNestedObject(); + JsonObject colorPicker = colorPickers.add(); colorPicker["name"] = FastLEDHub.colorPickers.get(i)->name; colorPicker["value"] = rgb2hex(FastLEDHub.colorPickers.get(i)->value); colorPicker["icon"] = FastLEDHub.colorPickers.get(i)->icon; @@ -172,7 +172,7 @@ void ConfigClass::getApplicationStateJson(JsonDocument &doc) String ConfigClass::asString(bool includeApplicationState) { - DynamicJsonDocument doc(3072); + JsonDocument doc; getUserConfigJson(doc);