Small improvements to fx data extraction functions
- Un-F() most segment JSON keys, decreases JSON doc usage by 47 B (increases static RAM usage by 32 B), makes `extractModeDefaults` work without strstr_P - Removed String from serializeModeData and serializeModeNames - Set 0.14 version name "Hoshi"
This commit is contained in:
parent
5b51ce9840
commit
2ada88a266
@ -264,6 +264,7 @@ board_build.ldscript = ${common.ldscript_4m1m}
|
||||
build_unflags = ${common.build_unflags}
|
||||
build_flags = ${common.build_flags_esp8266} -D WLED_RELEASE_NAME=ESP8266
|
||||
lib_deps = ${esp8266.lib_deps}
|
||||
monitor_filters = esp8266_exception_decoder
|
||||
|
||||
[env:esp8266_2m]
|
||||
board = esp_wroom_02
|
||||
|
@ -653,7 +653,7 @@ function populateInfo(i)
|
||||
}
|
||||
}
|
||||
var vcn = "Kuuhaku";
|
||||
if (i.ver.startsWith("0.13.")) vcn = "Toki";
|
||||
if (i.ver.startsWith("0.14.")) vcn = "Hoshi";
|
||||
if (i.ver.includes("-bl")) vcn = "Ryujin";
|
||||
if (i.cn) vcn = i.cn;
|
||||
|
||||
|
@ -505,7 +505,7 @@ function populateInfo(i)
|
||||
}
|
||||
}
|
||||
var vcn = "Kuuhaku";
|
||||
if (i.ver.startsWith("0.13.")) vcn = "Toki";
|
||||
if (i.ver.startsWith("0.14.")) vcn = "Hoshi";
|
||||
if (i.ver.includes("-bl")) vcn = "Ryujin";
|
||||
if (i.cn) vcn = i.cn;
|
||||
|
||||
|
101
wled00/json.cpp
101
wled00/json.cpp
@ -79,8 +79,8 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
uint16_t grp = elem["grp"] | seg.grouping;
|
||||
uint16_t spc = elem[F("spc")] | seg.spacing;
|
||||
uint16_t of = seg.offset;
|
||||
uint8_t soundSim = elem[F("ssim")] | seg.soundSim;
|
||||
uint8_t map1D2D = elem[F("mp12")] | seg.map1D2D;
|
||||
uint8_t soundSim = elem["ssim"] | seg.soundSim;
|
||||
uint8_t map1D2D = elem["mp12"] | seg.map1D2D;
|
||||
|
||||
if ((spc>0 && spc!=seg.spacing) || seg.map1D2D!=map1D2D) seg.fill(BLACK); // clear spacing gaps
|
||||
|
||||
@ -164,10 +164,10 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
|
||||
seg.selected = elem["sel"] | seg.selected;
|
||||
seg.reverse = elem["rev"] | seg.reverse;
|
||||
seg.mirror = elem[F("mi")] | seg.mirror;
|
||||
seg.mirror = elem["mi"] | seg.mirror;
|
||||
#ifndef WLED_DISABLE_2D
|
||||
seg.reverse_y = elem[F("rY")] | seg.reverse_y;
|
||||
seg.mirror_y = elem[F("mY")] | seg.mirror_y;
|
||||
seg.reverse_y = elem["rY"] | seg.reverse_y;
|
||||
seg.mirror_y = elem["mY"] | seg.mirror_y;
|
||||
seg.transpose = elem[F("tp")] | seg.transpose;
|
||||
#endif
|
||||
|
||||
@ -185,17 +185,17 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
if (elem[F("fxdef")])
|
||||
{
|
||||
int16_t sOpt;
|
||||
sOpt = extractModeDefaults(fx, SET_F("sx")); if (sOpt >= 0) seg.speed = sOpt;
|
||||
sOpt = extractModeDefaults(fx, SET_F("ix")); if (sOpt >= 0) seg.intensity = sOpt;
|
||||
sOpt = extractModeDefaults(fx, SET_F("c1")); if (sOpt >= 0) seg.custom1 = sOpt;
|
||||
sOpt = extractModeDefaults(fx, SET_F("c2")); if (sOpt >= 0) seg.custom2 = sOpt;
|
||||
sOpt = extractModeDefaults(fx, SET_F("c3")); if (sOpt >= 0) seg.custom3 = sOpt;
|
||||
sOpt = extractModeDefaults(fx, SET_F("mp12")); if (sOpt >= 0) seg.map1D2D = sOpt & 0x07;
|
||||
sOpt = extractModeDefaults(fx, SET_F("ssim")); if (sOpt >= 0) seg.soundSim = sOpt & 0x03;
|
||||
sOpt = extractModeDefaults(fx, "rev"); if (sOpt >= 0) seg.reverse = (bool)sOpt;
|
||||
sOpt = extractModeDefaults(fx, SET_F("mi")); if (sOpt >= 0) seg.mirror = (bool)sOpt; // NOTE: setting this option is a risky business
|
||||
sOpt = extractModeDefaults(fx, SET_F("rY")); if (sOpt >= 0) seg.reverse_y = (bool)sOpt;
|
||||
sOpt = extractModeDefaults(fx, SET_F("mY")); if (sOpt >= 0) seg.mirror_y = (bool)sOpt; // NOTE: setting this option is a risky business
|
||||
sOpt = extractModeDefaults(fx, "sx"); if (sOpt >= 0) seg.speed = sOpt;
|
||||
sOpt = extractModeDefaults(fx, "ix"); if (sOpt >= 0) seg.intensity = sOpt;
|
||||
sOpt = extractModeDefaults(fx, "c1"); if (sOpt >= 0) seg.custom1 = sOpt;
|
||||
sOpt = extractModeDefaults(fx, "c2"); if (sOpt >= 0) seg.custom2 = sOpt;
|
||||
sOpt = extractModeDefaults(fx, "c3"); if (sOpt >= 0) seg.custom3 = sOpt;
|
||||
sOpt = extractModeDefaults(fx, "mp12"); if (sOpt >= 0) seg.map1D2D = sOpt & 0x07;
|
||||
sOpt = extractModeDefaults(fx, "ssim"); if (sOpt >= 0) seg.soundSim = sOpt & 0x03;
|
||||
sOpt = extractModeDefaults(fx, "rev"); if (sOpt >= 0) seg.reverse = (bool)sOpt;
|
||||
sOpt = extractModeDefaults(fx, "mi"); if (sOpt >= 0) seg.mirror = (bool)sOpt; // NOTE: setting this option is a risky business
|
||||
sOpt = extractModeDefaults(fx, "rY"); if (sOpt >= 0) seg.reverse_y = (bool)sOpt;
|
||||
sOpt = extractModeDefaults(fx, "mY"); if (sOpt >= 0) seg.mirror_y = (bool)sOpt; // NOTE: setting this option is a risky business
|
||||
sOpt = extractModeDefaults(fx, "pal");
|
||||
if (sOpt >= 0 && sOpt < strip.getPaletteCount() + strip.customPalettes.size()) {
|
||||
if (sOpt != seg.palette) {
|
||||
@ -206,8 +206,8 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
}
|
||||
|
||||
//getVal also supports inc/decrementing and random
|
||||
getVal(elem[F("sx")], &seg.speed);
|
||||
getVal(elem[F("ix")], &seg.intensity);
|
||||
getVal(elem["sx"], &seg.speed);
|
||||
getVal(elem["ix"], &seg.intensity);
|
||||
uint8_t pal = seg.palette;
|
||||
if (getVal(elem["pal"], &pal, 1, strip.getPaletteCount())) {
|
||||
if (pal != seg.palette) {
|
||||
@ -215,15 +215,15 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
seg.palette = pal;
|
||||
}
|
||||
}
|
||||
getVal(elem[F("c1")], &seg.custom1);
|
||||
getVal(elem[F("c2")], &seg.custom2);
|
||||
getVal(elem["c1"], &seg.custom1);
|
||||
getVal(elem["c2"], &seg.custom2);
|
||||
uint8_t cust3 = seg.custom3;
|
||||
getVal(elem[F("c3")], &cust3); // we can't pass reference to bifield
|
||||
getVal(elem["c3"], &cust3); // we can't pass reference to bifield
|
||||
seg.custom3 = cust3;
|
||||
|
||||
seg.check1 = elem[F("o1")] | seg.check1;
|
||||
seg.check2 = elem[F("o2")] | seg.check2;
|
||||
seg.check3 = elem[F("o3")] | seg.check3;
|
||||
seg.check1 = elem["o1"] | seg.check1;
|
||||
seg.check2 = elem["o2"] | seg.check2;
|
||||
seg.check3 = elem["o3"] | seg.check3;
|
||||
|
||||
JsonArray iarr = elem[F("i")]; //set individual LEDs
|
||||
if (!iarr.isNull()) {
|
||||
@ -497,25 +497,25 @@ void serializeSegment(JsonObject& root, Segment& seg, byte id, bool forPreset, b
|
||||
root["col"] = serialized(colstr);
|
||||
|
||||
root["fx"] = seg.mode;
|
||||
root[F("sx")] = seg.speed;
|
||||
root[F("ix")] = seg.intensity;
|
||||
root["sx"] = seg.speed;
|
||||
root["ix"] = seg.intensity;
|
||||
root["pal"] = seg.palette;
|
||||
root[F("c1")] = seg.custom1;
|
||||
root[F("c2")] = seg.custom2;
|
||||
root[F("c3")] = seg.custom3;
|
||||
root[F("sel")] = seg.isSelected();
|
||||
root["c1"] = seg.custom1;
|
||||
root["c2"] = seg.custom2;
|
||||
root["c3"] = seg.custom3;
|
||||
root["sel"] = seg.isSelected();
|
||||
root["rev"] = seg.reverse;
|
||||
root[F("mi")] = seg.mirror;
|
||||
root["mi"] = seg.mirror;
|
||||
if (strip.isMatrix) {
|
||||
root[F("rY")] = seg.reverse_y;
|
||||
root[F("mY")] = seg.mirror_y;
|
||||
root["rY"] = seg.reverse_y;
|
||||
root["mY"] = seg.mirror_y;
|
||||
root[F("tp")] = seg.transpose;
|
||||
}
|
||||
root[F("o1")] = seg.check1;
|
||||
root[F("o2")] = seg.check2;
|
||||
root[F("o3")] = seg.check3;
|
||||
root[F("ssim")] = seg.soundSim;
|
||||
root[F("mp12")] = seg.map1D2D;
|
||||
root["o1"] = seg.check1;
|
||||
root["o2"] = seg.check2;
|
||||
root["o3"] = seg.check3;
|
||||
root["ssim"] = seg.soundSim;
|
||||
root["mp12"] = seg.map1D2D;
|
||||
}
|
||||
|
||||
void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segmentBounds)
|
||||
@ -920,12 +920,13 @@ void serializeNodes(JsonObject root)
|
||||
|
||||
void serializeModeData(JsonArray fxdata)
|
||||
{
|
||||
char lineBuffer[128];
|
||||
for (size_t i = 0; i < strip.getModeCount(); i++) {
|
||||
String lineBuffer = FPSTR(strip.getModeData(i));
|
||||
if (lineBuffer.length() > 0) {
|
||||
uint8_t endPos = lineBuffer.indexOf('@');
|
||||
if (endPos>0) fxdata.add(lineBuffer.substring(endPos));
|
||||
else fxdata.add("");
|
||||
strncpy_P(lineBuffer, strip.getModeData(i), 127);
|
||||
if (lineBuffer[0] != 0) {
|
||||
char* dataPtr = strchr(lineBuffer,'@');
|
||||
if (dataPtr) fxdata.add(dataPtr);
|
||||
else fxdata.add("");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -933,12 +934,13 @@ void serializeModeData(JsonArray fxdata)
|
||||
// deserializes mode names string into JsonArray
|
||||
// also removes WLED-SR extensions (@...) from deserialised names
|
||||
void serializeModeNames(JsonArray arr) {
|
||||
char lineBuffer[128];
|
||||
for (size_t i = 0; i < strip.getModeCount(); i++) {
|
||||
String lineBuffer = FPSTR(strip.getModeData(i));
|
||||
if (lineBuffer.length() > 0) {
|
||||
uint8_t endPos = lineBuffer.indexOf('@');
|
||||
if (endPos>0) arr.add(lineBuffer.substring(0, endPos));
|
||||
else arr.add(lineBuffer);
|
||||
strncpy_P(lineBuffer, strip.getModeData(i), 127);
|
||||
if (lineBuffer[0] != 0) {
|
||||
char* dataPtr = strchr(lineBuffer,'@');
|
||||
if (dataPtr) *dataPtr = 0; // terminate mode data after name
|
||||
arr.add(lineBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -969,7 +971,6 @@ void serveJson(AsyncWebServerRequest* request)
|
||||
request->send(response);
|
||||
releaseJSONBufferLock();
|
||||
} else {
|
||||
//request->send_P(200, "application/json", JSON_mode_names);
|
||||
request->send(503, "application/json", F("{\"error\":3}"));
|
||||
}
|
||||
return;
|
||||
@ -1013,11 +1014,11 @@ void serveJson(AsyncWebServerRequest* request)
|
||||
serializeInfo(info);
|
||||
if (subJson != 3)
|
||||
{
|
||||
//lDoc[F("effects")] = serialized((const __FlashStringHelper*)JSON_mode_names);
|
||||
JsonArray effects = lDoc.createNestedArray(F("effects"));
|
||||
serializeModeNames(effects); // remove WLED-SR extensions from effect names
|
||||
lDoc[F("palettes")] = serialized((const __FlashStringHelper*)JSON_palette_names);
|
||||
}
|
||||
//lDoc["m"] = lDoc.memoryUsage(); // JSON buffer usage, for remote debugging
|
||||
}
|
||||
|
||||
DEBUG_PRINTF("JSON buffer size: %u for request: %d\n", lDoc.memoryUsage(), subJson);
|
||||
|
@ -360,14 +360,16 @@ int16_t extractModeDefaults(uint8_t mode, const char *segVar)
|
||||
{
|
||||
if (mode < strip.getModeCount()) {
|
||||
char lineBuffer[128] = "";
|
||||
strncpy_P(lineBuffer, PSTR(strip.getModeData(mode)), 127);
|
||||
if (strlen(lineBuffer) > 0) {
|
||||
strncpy_P(lineBuffer, strip.getModeData(mode), 127);
|
||||
lineBuffer[127] = '\0'; // terminate string
|
||||
if (lineBuffer[0] != 0) {
|
||||
char* startPtr = strrchr(lineBuffer, ';'); // last ";" in FX data
|
||||
if (!startPtr) return -1;
|
||||
|
||||
char* stopPtr = strstr(startPtr, segVar);
|
||||
if (!stopPtr) return -1;
|
||||
|
||||
stopPtr += strlen(segVar) +1; // skip "="
|
||||
return atoi(stopPtr);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2208251
|
||||
#define VERSION 2208310
|
||||
|
||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||
//#define WLED_USE_MY_CONFIG
|
||||
@ -222,7 +222,7 @@ using PSRAMDynamicJsonDocument = BasicJsonDocument<PSRAM_Allocator>;
|
||||
|
||||
// Global Variable definitions
|
||||
WLED_GLOBAL char versionString[] _INIT(TOSTRING(WLED_VERSION));
|
||||
#define WLED_CODENAME "Toki"
|
||||
#define WLED_CODENAME "Hoshi"
|
||||
|
||||
// AP and OTA default passwords (for maximum security change them!)
|
||||
WLED_GLOBAL char apPass[65] _INIT(DEFAULT_AP_PASS);
|
||||
|
@ -415,8 +415,8 @@ void deEEP() {
|
||||
}
|
||||
|
||||
segObj["fx"] = EEPROM.read(i+10);
|
||||
segObj[F("sx")] = EEPROM.read(i+11);
|
||||
segObj[F("ix")] = EEPROM.read(i+16);
|
||||
segObj["sx"] = EEPROM.read(i+11);
|
||||
segObj["ix"] = EEPROM.read(i+16);
|
||||
segObj["pal"] = EEPROM.read(i+17);
|
||||
} else {
|
||||
Segment* seg = strip.getSegments();
|
||||
|
Loading…
Reference in New Issue
Block a user