From fe45ed8010cf4eb2e3de9f36efd4ef80d0b82fe6 Mon Sep 17 00:00:00 2001 From: Lukas Bachschwell Date: Fri, 27 Dec 2019 16:27:42 +0100 Subject: [PATCH] #63 Add variables for jsonDynamicDocument Sizes --- README.md | 2 +- src/ESPUI.cpp | 6 +++--- src/ESPUI.h | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1bc53f9..b3abc1a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ESPUI +# ESPUI 2.0 ![ESPUI](https://github.com/s00500/ESPUI/blob/master/docs/ui_complete.png) // TODO: Update Logo diff --git a/src/ESPUI.cpp b/src/ESPUI.cpp index 09b2b16..c859342 100644 --- a/src/ESPUI.cpp +++ b/src/ESPUI.cpp @@ -480,7 +480,7 @@ void ESPUIClass::updateControl(Control *control, int clientId) { } String json; - DynamicJsonDocument document(2000); + DynamicJsonDocument document(jsonUpdateDocumentSize); JsonObject root = document.to(); root["type"] = (int)control->type + ControlType::UpdateOffset; @@ -578,7 +578,7 @@ void ESPUIClass::addGraphPoint(uint16_t id, int nValue, int clientId) { } String json; - DynamicJsonDocument document(2000); + DynamicJsonDocument document(jsonUpdateDocumentSize); JsonObject root = document.to(); root["type"] = (int)ControlType::GraphPoint; @@ -622,7 +622,7 @@ sent as one blob at the beginning. Therefore a new type is used as well */ void ESPUIClass::jsonDom(AsyncWebSocketClient *client) { String json; - DynamicJsonDocument document(4000); + DynamicJsonDocument document(jsonInitialDocumentSize); document["type"] = (int)UI_INITIAL_GUI; JsonArray items = document.createNestedArray("controls"); diff --git a/src/ESPUI.h b/src/ESPUI.h index 1095593..944f56e 100644 --- a/src/ESPUI.h +++ b/src/ESPUI.h @@ -166,7 +166,11 @@ enum Verbosity : uint8_t { Quiet = 0, Verbose, VerboseJSON }; class ESPUIClass { public: - ESPUIClass() { verbosity = Verbosity::Quiet; } + ESPUIClass() { + verbosity = Verbosity::Quiet; + jsonUpdateDocumentSize = 2000; + jsonInitialDocumentSize = 8000; + } void setVerbosity(Verbosity verbosity); void begin(const char *_title, const char *username = nullptr, const char *password = nullptr); // Setup server and page in Memorymode void beginSPIFFS(const char *_title, const char *username = nullptr, const char *password = nullptr); // Setup server and page in SPIFFSmode