Optimized JSON buffer usage (pre-serialized color arrays)
This commit is contained in:
parent
0b264176bc
commit
dfdb22f584
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
### Builds after release 0.12.0
|
### Builds after release 0.12.0
|
||||||
|
|
||||||
|
#### Build 2106170
|
||||||
|
|
||||||
|
- Optimized JSON buffer usage (pre-serialized color arrays)
|
||||||
|
|
||||||
#### Build 2106140
|
#### Build 2106140
|
||||||
|
|
||||||
- Updated main logo
|
- Updated main logo
|
||||||
|
@ -330,25 +330,39 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool fo
|
|||||||
|
|
||||||
JsonArray colarr = root.createNestedArray("col");
|
JsonArray colarr = root.createNestedArray("col");
|
||||||
|
|
||||||
|
char colstr[70]; //max len 68 (5 chan, all 255)
|
||||||
|
obuf = colstr; olen = 0;
|
||||||
|
oappend("[");
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 3; i++)
|
for (uint8_t i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
JsonArray colX = colarr.createNestedArray();
|
oappend("[");
|
||||||
|
|
||||||
if (id == strip.getMainSegmentId() && i < 2) //temporary, to make transition work on main segment
|
if (id == strip.getMainSegmentId() && i < 2) //temporary, to make transition work on main segment
|
||||||
{
|
{
|
||||||
if (i == 0) {
|
byte* c = (i == 0)? col:colSec;
|
||||||
colX.add(col[0]); colX.add(col[1]); colX.add(col[2]); if (strip.isRgbw) colX.add(col[3]);
|
|
||||||
} else {
|
oappendi(c[0]); oappend(",");
|
||||||
colX.add(colSec[0]); colX.add(colSec[1]); colX.add(colSec[2]); if (strip.isRgbw) colX.add(colSec[3]);
|
oappendi(c[1]); oappend(",");
|
||||||
|
oappendi(c[2]);
|
||||||
|
if (strip.isRgbw) {
|
||||||
|
oappend(","); oappendi(c[3]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
colX.add((seg.colors[i] >> 16) & 0xFF);
|
oappendi((seg.colors[i] >> 16) & 0xFF); oappend(",");
|
||||||
colX.add((seg.colors[i] >> 8) & 0xFF);
|
oappendi((seg.colors[i] >> 8) & 0xFF); oappend(",");
|
||||||
colX.add((seg.colors[i]) & 0xFF);
|
oappendi((seg.colors[i]) & 0xFF);
|
||||||
if (strip.isRgbw)
|
if (strip.isRgbw) {
|
||||||
colX.add((seg.colors[i] >> 24) & 0xFF);
|
oappend(","); oappendi((seg.colors[i] >> 24) & 0xFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oappend("]");
|
||||||
|
if (i < 2) oappend(",");
|
||||||
|
}
|
||||||
|
oappend("]");
|
||||||
|
root["col"] = serialized(colstr);
|
||||||
|
|
||||||
root[F("fx")] = seg.mode;
|
root[F("fx")] = seg.mode;
|
||||||
root[F("sx")] = seg.speed;
|
root[F("sx")] = seg.speed;
|
||||||
root[F("ix")] = seg.intensity;
|
root[F("ix")] = seg.intensity;
|
||||||
@ -790,6 +804,9 @@ void serveJson(AsyncWebServerRequest* request)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG_PRINT("JSON buffer size: ");
|
||||||
|
DEBUG_PRINTLN(doc.memoryUsage());
|
||||||
|
|
||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2106140
|
#define VERSION 2106170
|
||||||
|
|
||||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||||
//#define WLED_USE_MY_CONFIG
|
//#define WLED_USE_MY_CONFIG
|
||||||
|
Loading…
Reference in New Issue
Block a user