Added conditional compile for dynamic JSON buffer.
- WLED_USE_DYNAMIC_JSON Minor fixes.
This commit is contained in:
parent
f7de055f67
commit
f8da8f6929
@ -55,6 +55,7 @@ class St7789DisplayUsermod : public Usermod {
|
|||||||
private:
|
private:
|
||||||
//Private class members. You can declare variables and functions only accessible to your usermod here
|
//Private class members. You can declare variables and functions only accessible to your usermod here
|
||||||
unsigned long lastTime = 0;
|
unsigned long lastTime = 0;
|
||||||
|
bool enabled = true;
|
||||||
|
|
||||||
bool displayTurnedOff = false;
|
bool displayTurnedOff = false;
|
||||||
long lastRedraw = 0;
|
long lastRedraw = 0;
|
||||||
@ -140,7 +141,7 @@ class St7789DisplayUsermod : public Usermod {
|
|||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
PinManagerPinType pins[] = { { TFT_MOSI, true }, { TFT_MISO, false}, { TFT_SCLK, true }, { TFT_CS, true}, { TFT_DC, true}, { TFT_RST, true }, { TFT_BL, true } };
|
PinManagerPinType pins[] = { { TFT_MOSI, true }, { TFT_MISO, false}, { TFT_SCLK, true }, { TFT_CS, true}, { TFT_DC, true}, { TFT_RST, true }, { TFT_BL, true } };
|
||||||
if (!pinManager.allocateMultiplePins(pins, 7, PinOwner::UM_FourLineDisplay)) { return; }
|
if (!pinManager.allocateMultiplePins(pins, 7, PinOwner::UM_FourLineDisplay)) { enabled = false; return; }
|
||||||
|
|
||||||
tft.init();
|
tft.init();
|
||||||
tft.setRotation(0); //Rotation here is set up for the text to be readable with the port on the left. Use 1 to flip.
|
tft.setRotation(0); //Rotation here is set up for the text to be readable with the port on the left. Use 1 to flip.
|
||||||
@ -321,7 +322,7 @@ class St7789DisplayUsermod : public Usermod {
|
|||||||
if (user.isNull()) user = root.createNestedObject("u");
|
if (user.isNull()) user = root.createNestedObject("u");
|
||||||
|
|
||||||
JsonArray lightArr = user.createNestedArray("ST7789"); //name
|
JsonArray lightArr = user.createNestedArray("ST7789"); //name
|
||||||
lightArr.add(F("installed")); //unit
|
lightArr.add(enabled?F("installed"):F("disabled")); //unit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -362,7 +363,15 @@ class St7789DisplayUsermod : public Usermod {
|
|||||||
*/
|
*/
|
||||||
void addToConfig(JsonObject& root)
|
void addToConfig(JsonObject& root)
|
||||||
{
|
{
|
||||||
//JsonObject top = root.createNestedObject("exampleUsermod");
|
JsonObject top = root.createNestedObject("ST7789");
|
||||||
|
JsonArray pins = top.createNestedArray("pin");
|
||||||
|
pins.add(TFT_MOSI);
|
||||||
|
pins.add(TFT_MISO);
|
||||||
|
pins.add(TFT_SCLK);
|
||||||
|
pins.add(TFT_CS);
|
||||||
|
pins.add(TFT_DC);
|
||||||
|
pins.add(TFT_RST);
|
||||||
|
pins.add(TFT_BL);
|
||||||
//top["great"] = userVar0; //save this var persistently whenever settings are saved
|
//top["great"] = userVar0; //save this var persistently whenever settings are saved
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,8 +657,9 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
top[FPSTR(_enabled)] = enabled;
|
top[FPSTR(_enabled)] = enabled;
|
||||||
JsonArray io_pin = top.createNestedArray("pin");
|
JsonArray io_pin = top.createNestedArray("pin");
|
||||||
for (byte i=0; i<5; i++) io_pin.add(ioPin[i]);
|
for (byte i=0; i<5; i++) io_pin.add(ioPin[i]);
|
||||||
top["help4PinTypes"] = F("Clk,Data,CS,DC,RST"); // help for Settings page
|
top["help4Pins"] = F("Clk,Data,CS,DC,RST"); // help for Settings page
|
||||||
top["type"] = type;
|
top["type"] = type;
|
||||||
|
top["help4Type"] = F("1=SSD1306,2=SH1106,3=SSD1306_128x64,4=SSD1305,5=SSD1305_128x64,6=SSD1306_SPI,7=SSD1306_SPI_128x64"); // help for Settings page
|
||||||
top[FPSTR(_flip)] = (bool) flip;
|
top[FPSTR(_flip)] = (bool) flip;
|
||||||
top[FPSTR(_contrast)] = contrast;
|
top[FPSTR(_contrast)] = contrast;
|
||||||
top[FPSTR(_refreshRate)] = refreshRate/1000;
|
top[FPSTR(_refreshRate)] = refreshRate/1000;
|
||||||
|
@ -1089,10 +1089,13 @@ void WS2812FX::deserializeMap(uint8_t n) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE); // full sized buffer for larger maps
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
DEBUG_PRINT(F("Reading LED map from "));
|
DEBUG_PRINT(F("Reading LED map from "));
|
||||||
DEBUG_PRINTLN(fileName);
|
DEBUG_PRINTLN(fileName);
|
||||||
|
@ -427,10 +427,13 @@ void deserializeConfigFromFS() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
DEBUG_PRINTLN(F("Reading settings from /cfg.json..."));
|
DEBUG_PRINTLN(F("Reading settings from /cfg.json..."));
|
||||||
|
|
||||||
@ -454,10 +457,13 @@ void serializeConfig() {
|
|||||||
|
|
||||||
DEBUG_PRINTLN(F("Writing settings to /cfg.json..."));
|
DEBUG_PRINTLN(F("Writing settings to /cfg.json..."));
|
||||||
|
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
JsonArray rev = doc.createNestedArray("rev");
|
JsonArray rev = doc.createNestedArray("rev");
|
||||||
rev.add(1); //major settings revision
|
rev.add(1); //major settings revision
|
||||||
@ -771,10 +777,13 @@ void serializeConfig() {
|
|||||||
bool deserializeConfigSec() {
|
bool deserializeConfigSec() {
|
||||||
DEBUG_PRINTLN(F("Reading settings from /wsec.json..."));
|
DEBUG_PRINTLN(F("Reading settings from /wsec.json..."));
|
||||||
|
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
bool success = readObjectFromFile("/wsec.json", nullptr, &doc);
|
bool success = readObjectFromFile("/wsec.json", nullptr, &doc);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
@ -819,10 +828,13 @@ bool deserializeConfigSec() {
|
|||||||
void serializeConfigSec() {
|
void serializeConfigSec() {
|
||||||
DEBUG_PRINTLN(F("Writing settings to /wsec.json..."));
|
DEBUG_PRINTLN(F("Writing settings to /wsec.json..."));
|
||||||
|
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
JsonObject nw = doc.createNestedObject("nw");
|
JsonObject nw = doc.createNestedObject("nw");
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ function sCol(na, col) {d.documentElement.style.setProperty(na, col);}
|
|||||||
function gId(c) {return d.getElementById(c);}
|
function gId(c) {return d.getElementById(c);}
|
||||||
function gEBCN(c) {return d.getElementsByClassName(c);}
|
function gEBCN(c) {return d.getElementsByClassName(c);}
|
||||||
function isEmpty(o) {return Object.keys(o).length === 0;}
|
function isEmpty(o) {return Object.keys(o).length === 0;}
|
||||||
function isO(i) {return (i && typeof i === 'object' && !Array.isArray(i));}
|
function isObj(i) {return (i && typeof i === 'object' && !Array.isArray(i));}
|
||||||
|
|
||||||
function applyCfg()
|
function applyCfg()
|
||||||
{
|
{
|
||||||
@ -253,7 +253,7 @@ function onLoad()
|
|||||||
loadPalettesData(redrawPalPrev);
|
loadPalettesData(redrawPalPrev);
|
||||||
loadFX(()=>{
|
loadFX(()=>{
|
||||||
loadPresets(()=>{
|
loadPresets(()=>{
|
||||||
if (isO(lastinfo) && isEmpty(lastinfo)) loadInfo(requestJson); // if not filled by WS
|
if (isObj(lastinfo) && isEmpty(lastinfo)) loadInfo(requestJson); // if not filled by WS
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -533,7 +533,7 @@ function populatePresets(fromls)
|
|||||||
pNum = 0;
|
pNum = 0;
|
||||||
for (var key of (arr||[]))
|
for (var key of (arr||[]))
|
||||||
{
|
{
|
||||||
if (!isO(key[1])) continue;
|
if (!isObj(key[1])) continue;
|
||||||
let i = parseInt(key[0]);
|
let i = parseInt(key[0]);
|
||||||
var qll = key[1].ql;
|
var qll = key[1].ql;
|
||||||
if (qll) pQL.push([i, qll, pName(i)]);
|
if (qll) pQL.push([i, qll, pName(i)]);
|
||||||
@ -2297,9 +2297,9 @@ function mergeDeep(target, ...sources)
|
|||||||
if (!sources.length) return target;
|
if (!sources.length) return target;
|
||||||
const source = sources.shift();
|
const source = sources.shift();
|
||||||
|
|
||||||
if (isO(target) && isO(source)) {
|
if (isObj(target) && isObj(source)) {
|
||||||
for (const key in source) {
|
for (const key in source) {
|
||||||
if (isO(source[key])) {
|
if (isObj(source[key])) {
|
||||||
if (!target[key]) Object.assign(target, { [key]: {} });
|
if (!target[key]) Object.assign(target, { [key]: {} });
|
||||||
mergeDeep(target[key], source[key]);
|
mergeDeep(target[key], source[key]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,7 +62,7 @@ function sCol(na, col) {d.documentElement.style.setProperty(na, col);}
|
|||||||
function gId(c) {return d.getElementById(c);}
|
function gId(c) {return d.getElementById(c);}
|
||||||
function gEBCN(c) {return d.getElementsByClassName(c);}
|
function gEBCN(c) {return d.getElementsByClassName(c);}
|
||||||
function isEmpty(o) {return Object.keys(o).length === 0;}
|
function isEmpty(o) {return Object.keys(o).length === 0;}
|
||||||
function isO(i) { return (i && typeof i === 'object' && !Array.isArray(i)); }
|
function isObj(i) { return (i && typeof i === 'object' && !Array.isArray(i)); }
|
||||||
|
|
||||||
function applyCfg()
|
function applyCfg()
|
||||||
{
|
{
|
||||||
@ -238,7 +238,7 @@ async function onLoad()
|
|||||||
loadPalettesData(redrawPalPrev);
|
loadPalettesData(redrawPalPrev);
|
||||||
loadFX(()=>{
|
loadFX(()=>{
|
||||||
loadPresets(()=>{
|
loadPresets(()=>{
|
||||||
if (isO(lastinfo) && isEmpty(lastinfo)) loadInfo(requestJson); // if not filled by WS
|
if (isObj(lastinfo) && isEmpty(lastinfo)) loadInfo(requestJson); // if not filled by WS
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -449,7 +449,7 @@ function populatePresets()
|
|||||||
pNum = 0;
|
pNum = 0;
|
||||||
for (var key of (arr||[]))
|
for (var key of (arr||[]))
|
||||||
{
|
{
|
||||||
if (!isO(key[1])) continue;
|
if (!isObj(key[1])) continue;
|
||||||
let i = parseInt(key[0]);
|
let i = parseInt(key[0]);
|
||||||
var qll = key[1].ql;
|
var qll = key[1].ql;
|
||||||
if (qll) pQL.push([i, qll, pName(i)]);
|
if (qll) pQL.push([i, qll, pName(i)]);
|
||||||
@ -1404,9 +1404,9 @@ function mergeDeep(target, ...sources)
|
|||||||
if (!sources.length) return target;
|
if (!sources.length) return target;
|
||||||
const source = sources.shift();
|
const source = sources.shift();
|
||||||
|
|
||||||
if (isO(target) && isO(source)) {
|
if (isObj(target) && isObj(source)) {
|
||||||
for (const key in source) {
|
for (const key in source) {
|
||||||
if (isO(source[key])) {
|
if (isObj(source[key])) {
|
||||||
if (!target[key]) Object.assign(target, { [key]: {} });
|
if (!target[key]) Object.assign(target, { [key]: {} });
|
||||||
mergeDeep(target[key], source[key]);
|
mergeDeep(target[key], source[key]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -575,10 +575,13 @@ void decodeIRJson(uint32_t code)
|
|||||||
JsonObject fdo;
|
JsonObject fdo;
|
||||||
JsonObject jsonCmdObj;
|
JsonObject jsonCmdObj;
|
||||||
|
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
sprintf_P(objKey, PSTR("\"0x%lX\":"), (unsigned long)code);
|
sprintf_P(objKey, PSTR("\"0x%lX\":"), (unsigned long)code);
|
||||||
|
|
||||||
|
@ -913,12 +913,15 @@ void serveJson(AsyncWebServerRequest* request)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//AsyncJsonResponse* response = new AsyncJsonResponse(JSON_BUFFER_SIZE);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
AsyncJsonResponse* response = new AsyncJsonResponse(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
|
||||||
AsyncJsonResponse *response = new AsyncJsonResponse(&doc);
|
AsyncJsonResponse *response = new AsyncJsonResponse(&doc);
|
||||||
|
#endif
|
||||||
|
|
||||||
JsonObject lDoc = response->getRoot();
|
JsonObject lDoc = response->getRoot();
|
||||||
|
|
||||||
switch (subJson)
|
switch (subJson)
|
||||||
|
@ -91,14 +91,19 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
|
|||||||
colorUpdated(CALL_MODE_DIRECT_CHANGE);
|
colorUpdated(CALL_MODE_DIRECT_CHANGE);
|
||||||
} else if (strcmp_P(topic, PSTR("/api")) == 0) {
|
} else if (strcmp_P(topic, PSTR("/api")) == 0) {
|
||||||
if (payload[0] == '{') { //JSON API
|
if (payload[0] == '{') { //JSON API
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
deserializeJson(doc, payloadStr);
|
deserializeJson(doc, payloadStr);
|
||||||
fileDoc = &doc;
|
fileDoc = &doc;
|
||||||
deserializeState(doc.as<JsonObject>());
|
deserializeState(doc.as<JsonObject>());
|
||||||
fileDoc = nullptr;
|
fileDoc = nullptr;
|
||||||
|
|
||||||
jsonBufferLock = false;
|
jsonBufferLock = false;
|
||||||
} else { //HTTP API
|
} else { //HTTP API
|
||||||
String apireq = "win&";
|
String apireq = "win&";
|
||||||
|
@ -20,10 +20,14 @@ bool applyPreset(byte index, byte callMode)
|
|||||||
deserializeState(fdo, callMode, index);
|
deserializeState(fdo, callMode, index);
|
||||||
} else {
|
} else {
|
||||||
DEBUGFS_PRINTLN(F("Make read buf"));
|
DEBUGFS_PRINTLN(F("Make read buf"));
|
||||||
//DynamicJsonDocument fDoc(JSON_BUFFER_SIZE);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
errorFlag = readObjectFromFileUsingId(filename, index, &doc) ? ERR_NONE : ERR_FS_PLOAD;
|
errorFlag = readObjectFromFileUsingId(filename, index, &doc) ? ERR_NONE : ERR_FS_PLOAD;
|
||||||
JsonObject fdo = doc.as<JsonObject>();
|
JsonObject fdo = doc.as<JsonObject>();
|
||||||
if (fdo["ps"] == index) fdo.remove("ps");
|
if (fdo["ps"] == index) fdo.remove("ps");
|
||||||
@ -50,10 +54,14 @@ void savePreset(byte index, bool persist, const char* pname, JsonObject saveobj)
|
|||||||
|
|
||||||
if (!fileDoc) {
|
if (!fileDoc) {
|
||||||
DEBUGFS_PRINTLN(F("Allocating saving buffer"));
|
DEBUGFS_PRINTLN(F("Allocating saving buffer"));
|
||||||
//DynamicJsonDocument lDoc(JSON_BUFFER_SIZE);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
sObj = doc.to<JsonObject>();
|
sObj = doc.to<JsonObject>();
|
||||||
if (pname) sObj["n"] = pname;
|
if (pname) sObj["n"] = pname;
|
||||||
|
|
||||||
|
@ -415,10 +415,13 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
//USERMODS
|
//USERMODS
|
||||||
if (subPage == 8)
|
if (subPage == 8)
|
||||||
{
|
{
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
JsonObject um = doc.createNestedObject("um");
|
JsonObject um = doc.createNestedObject("um");
|
||||||
|
|
||||||
|
@ -603,7 +603,9 @@ WLED_GLOBAL int8_t loadLedmap _INIT(-1);
|
|||||||
WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
|
WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
|
||||||
|
|
||||||
// global ArduinoJson buffer
|
// global ArduinoJson buffer
|
||||||
|
#ifndef WLED_USE_DYNAMIC_JSON
|
||||||
WLED_GLOBAL StaticJsonDocument<JSON_BUFFER_SIZE> doc;
|
WLED_GLOBAL StaticJsonDocument<JSON_BUFFER_SIZE> doc;
|
||||||
|
#endif
|
||||||
WLED_GLOBAL volatile bool jsonBufferLock _INIT(false);
|
WLED_GLOBAL volatile bool jsonBufferLock _INIT(false);
|
||||||
|
|
||||||
// enable additional debug output
|
// enable additional debug output
|
||||||
|
@ -382,10 +382,13 @@ void deEEP() {
|
|||||||
|
|
||||||
DEBUG_PRINTLN(F("Preset file not found, attempting to load from EEPROM"));
|
DEBUG_PRINTLN(F("Preset file not found, attempting to load from EEPROM"));
|
||||||
DEBUGFS_PRINTLN(F("Allocating saving buffer for dEEP"));
|
DEBUGFS_PRINTLN(F("Allocating saving buffer for dEEP"));
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE *2);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
JsonObject sObj = doc.to<JsonObject>();
|
JsonObject sObj = doc.to<JsonObject>();
|
||||||
sObj.createNestedObject("0");
|
sObj.createNestedObject("0");
|
||||||
|
@ -43,11 +43,13 @@ void handleSerial()
|
|||||||
}
|
}
|
||||||
else if (next == '{') { //JSON API
|
else if (next == '{') { //JSON API
|
||||||
bool verboseResponse = false;
|
bool verboseResponse = false;
|
||||||
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
{
|
#endif
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
|
||||||
Serial.setTimeout(100);
|
Serial.setTimeout(100);
|
||||||
DeserializationError error = deserializeJson(doc, Serial);
|
DeserializationError error = deserializeJson(doc, Serial);
|
||||||
if (error) {
|
if (error) {
|
||||||
@ -57,10 +59,9 @@ void handleSerial()
|
|||||||
fileDoc = &doc;
|
fileDoc = &doc;
|
||||||
verboseResponse = deserializeState(doc.as<JsonObject>());
|
verboseResponse = deserializeState(doc.as<JsonObject>());
|
||||||
fileDoc = nullptr;
|
fileDoc = nullptr;
|
||||||
}
|
|
||||||
//only send response if TX pin is unused for other purposes
|
//only send response if TX pin is unused for other purposes
|
||||||
if (verboseResponse && !pinManager.isPinAllocated(1)) {
|
if (verboseResponse && !pinManager.isPinAllocated(1)) {
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
|
||||||
doc.clear();
|
doc.clear();
|
||||||
JsonObject state = doc.createNestedObject("state");
|
JsonObject state = doc.createNestedObject("state");
|
||||||
serializeState(state);
|
serializeState(state);
|
||||||
|
@ -110,10 +110,13 @@ void initServer()
|
|||||||
bool verboseResponse = false;
|
bool verboseResponse = false;
|
||||||
bool isConfig = false;
|
bool isConfig = false;
|
||||||
{ //scope JsonDocument so it releases its buffer
|
{ //scope JsonDocument so it releases its buffer
|
||||||
//DynamicJsonDocument jsonBuffer(JSON_BUFFER_SIZE);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
DeserializationError error = deserializeJson(doc, (uint8_t*)(request->_tempObject));
|
DeserializationError error = deserializeJson(doc, (uint8_t*)(request->_tempObject));
|
||||||
JsonObject root = doc.as<JsonObject>();
|
JsonObject root = doc.as<JsonObject>();
|
||||||
|
@ -36,10 +36,13 @@ void wsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventTyp
|
|||||||
}
|
}
|
||||||
bool verboseResponse = false;
|
bool verboseResponse = false;
|
||||||
{ //scope JsonDocument so it releases its buffer
|
{ //scope JsonDocument so it releases its buffer
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
DeserializationError error = deserializeJson(doc, data, len);
|
DeserializationError error = deserializeJson(doc, data, len);
|
||||||
JsonObject root = doc.as<JsonObject>();
|
JsonObject root = doc.as<JsonObject>();
|
||||||
@ -111,10 +114,14 @@ void sendDataWs(AsyncWebSocketClient * client)
|
|||||||
AsyncWebSocketMessageBuffer * buffer;
|
AsyncWebSocketMessageBuffer * buffer;
|
||||||
|
|
||||||
{ //scope JsonDocument so it releases its buffer
|
{ //scope JsonDocument so it releases its buffer
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
JsonObject state = doc.createNestedObject("state");
|
JsonObject state = doc.createNestedObject("state");
|
||||||
serializeState(state);
|
serializeState(state);
|
||||||
JsonObject info = doc.createNestedObject("info");
|
JsonObject info = doc.createNestedObject("info");
|
||||||
|
@ -253,10 +253,14 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
// add reserved and usermod pins as d.um_p array
|
// add reserved and usermod pins as d.um_p array
|
||||||
oappend(SET_F("d.um_p=[6,7,8,9,10,11"));
|
oappend(SET_F("d.um_p=[6,7,8,9,10,11"));
|
||||||
|
|
||||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE/2);
|
#ifdef WLED_USE_DYNAMIC_JSON
|
||||||
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
|
#else
|
||||||
while (jsonBufferLock) delay(1);
|
while (jsonBufferLock) delay(1);
|
||||||
jsonBufferLock = true;
|
jsonBufferLock = true;
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
JsonObject mods = doc.createNestedObject(F("um"));
|
JsonObject mods = doc.createNestedObject(F("um"));
|
||||||
usermods.addToConfig(mods);
|
usermods.addToConfig(mods);
|
||||||
if (!mods.isNull()) fillUMPins(mods);
|
if (!mods.isNull()) fillUMPins(mods);
|
||||||
|
Loading…
Reference in New Issue
Block a user