1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-25 14:10:54 +00:00

#63 Add variables for jsonDynamicDocument Sizes

This commit is contained in:
Lukas Bachschwell 2019-12-27 16:27:42 +01:00
parent 0323920a0d
commit fe45ed8010
Signed by: lbsadmin
GPG Key ID: CCC6AA87CC8DF425
3 changed files with 9 additions and 5 deletions

View File

@ -1,4 +1,4 @@
# ESPUI # ESPUI 2.0
![ESPUI](https://github.com/s00500/ESPUI/blob/master/docs/ui_complete.png) // ![ESPUI](https://github.com/s00500/ESPUI/blob/master/docs/ui_complete.png) //
TODO: Update Logo TODO: Update Logo

View File

@ -480,7 +480,7 @@ void ESPUIClass::updateControl(Control *control, int clientId) {
} }
String json; String json;
DynamicJsonDocument document(2000); DynamicJsonDocument document(jsonUpdateDocumentSize);
JsonObject root = document.to<JsonObject>(); JsonObject root = document.to<JsonObject>();
root["type"] = (int)control->type + ControlType::UpdateOffset; root["type"] = (int)control->type + ControlType::UpdateOffset;
@ -578,7 +578,7 @@ void ESPUIClass::addGraphPoint(uint16_t id, int nValue, int clientId) {
} }
String json; String json;
DynamicJsonDocument document(2000); DynamicJsonDocument document(jsonUpdateDocumentSize);
JsonObject root = document.to<JsonObject>(); JsonObject root = document.to<JsonObject>();
root["type"] = (int)ControlType::GraphPoint; 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) { void ESPUIClass::jsonDom(AsyncWebSocketClient *client) {
String json; String json;
DynamicJsonDocument document(4000); DynamicJsonDocument document(jsonInitialDocumentSize);
document["type"] = (int)UI_INITIAL_GUI; document["type"] = (int)UI_INITIAL_GUI;
JsonArray items = document.createNestedArray("controls"); JsonArray items = document.createNestedArray("controls");

View File

@ -166,7 +166,11 @@ enum Verbosity : uint8_t { Quiet = 0, Verbose, VerboseJSON };
class ESPUIClass { class ESPUIClass {
public: public:
ESPUIClass() { verbosity = Verbosity::Quiet; } ESPUIClass() {
verbosity = Verbosity::Quiet;
jsonUpdateDocumentSize = 2000;
jsonInitialDocumentSize = 8000;
}
void setVerbosity(Verbosity verbosity); void setVerbosity(Verbosity verbosity);
void begin(const char *_title, const char *username = nullptr, const char *password = nullptr); // Setup server and page in Memorymode 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 void beginSPIFFS(const char *_title, const char *username = nullptr, const char *password = nullptr); // Setup server and page in SPIFFSmode