A few fixes

This commit is contained in:
cschwinne 2020-11-09 00:50:13 +01:00
parent 98e4ac6b27
commit 1f42070104
7 changed files with 760 additions and 747 deletions

View File

@ -1719,12 +1719,6 @@ function updateUI()
updateTrail(d.getElementById('sliderIntensity'));
updateTrail(d.getElementById('sliderW'));
if (isRgbw) d.getElementById('wwrap').style.display = "block";
var btns = d.getElementsByClassName("psts");
for (i = 0; i < btns.length; i++) {
btns[i].className = btns[i].className.replace(" active", "");
}
if (currentPreset > 0 && currentPreset <= btns.length) btns[currentPreset -1].className += " active";
spal = d.getElementById("selectPalette");
spal.style.backgroundColor = (spal.selectedIndex > 0) ? "var(--c-6)":"var(--c-3)";
@ -1876,7 +1870,16 @@ function requestJson(command, rinfo = true, verbose = true) {
e2.value = i.pal;
if (!command) d.getElementById('Effects').scrollTop = d.getElementById('fxb' + selectedFx).offsetTop - d.getElementById('Effects').clientHeight/1.8;
if (s.error) showToast('WLED error ' + s.error, true);
if (s.error && s.error != 0) {
var errstr = "";
switch (s.error) {
case 10: errstr = "Could not mount filesystem!"; break;
case 11: errstr = "Not enough space to save preset!"; break;
case 12: errstr = "The requested preset does not exist."; break;
case 19: errstr = "A filesystem error has occured."; break;
}
showToast('Error ' + s.error + ": " + errstr, true);
}
updateUI();
})
.catch(function (error) {

View File

@ -229,7 +229,8 @@ bool appendObjectToFile(const char* key, JsonDocument* content, uint32_t s, uint
if (pos == 0) //not found
{
DEBUGFS_PRINTLN("not }");
while (bufferedFind("}", false)) //find last closing bracket in JSON if not last char
f.seek(0);
while (bufferedFind("}",false)) //find last closing bracket in JSON if not last char
{
pos = f.position();
}
@ -237,11 +238,11 @@ bool appendObjectToFile(const char* key, JsonDocument* content, uint32_t s, uint
DEBUGFS_PRINT("pos "); DEBUGFS_PRINTLN(pos);
if (pos > 2)
{
f.seek(pos, SeekSet);
f.seek(pos -1, SeekSet);
f.write(',');
} else { //file content is not valid JSON object
f.seek(0, SeekSet);
f.write('{'); //start JSON
f.print('{'); //start JSON
}
f.print(key);
@ -266,7 +267,7 @@ bool writeObjectToFile(const char* file, const char* key, JsonDocument* content)
{
uint32_t s = 0; //timing
#ifdef WLED_DEBUG_FS
DEBUGFS_PRINTF("Write to %s with key %s >>>\n", file, key);
DEBUGFS_PRINTF("Write to %s with key %s >>>\n", file, (key==nullptr)?"nullptr":key);
serializeJson(*content, Serial); DEBUGFS_PRINTLN();
s = millis();
#endif
@ -337,7 +338,7 @@ bool readObjectFromFile(const char* file, const char* key, JsonDocument* dest)
{
if (doCloseFile) closeFile();
#ifdef WLED_DEBUG_FS
DEBUGFS_PRINTF("Read from %s with key %s >>>\n", file, key);
DEBUGFS_PRINTF("Read from %s with key %s >>>\n", file, (key==nullptr)?"nullptr":key);
uint32_t s = millis();
#endif
f = WLED_FS.open(file, "r");

File diff suppressed because it is too large Load Diff

View File

@ -243,7 +243,7 @@ bool deserializeState(JsonObject root)
if (ps > 0) {
deletePreset(ps);
}
ps = root[F("ps")] | -1; //load preset (clears state request!)
ps = root["ps"] | -1; //load preset (clears state request!)
if (ps >= 0) {applyPreset(ps); return stateResponse;}
//HTTP API commands

View File

@ -8,18 +8,22 @@ bool applyPreset(byte index)
{
if (fileDoc) {
errorFlag = readObjectFromFileUsingId("/presets.json", index, fileDoc) ? ERR_NONE : ERR_FS_PLOAD;
JsonObject fdo = fileDoc->as<JsonObject>();
if (fdo["ps"] == index) fdo.remove("ps"); //remove load request for same presets to prevent recursive crash
#ifdef WLED_DEBUG_FS
serializeJson(*fileDoc, Serial);
#endif
deserializeState(fileDoc->as<JsonObject>());
deserializeState(fdo);
} else {
DEBUGFS_PRINTLN(F("Make read buf"));
DynamicJsonDocument fDoc(JSON_BUFFER_SIZE);
errorFlag = readObjectFromFileUsingId("/presets.json", index, &fDoc) ? ERR_NONE : ERR_FS_PLOAD;
JsonObject fdo = fileDoc->as<JsonObject>();
if (fdo["ps"] == index) fdo.remove("ps");
#ifdef WLED_DEBUG_FS
serializeJson(fDoc, Serial);
#endif
deserializeState(fDoc.as<JsonObject>());
deserializeState(fdo);
}
if (!errorFlag) {

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2011080
#define VERSION 2011090
// ESP8266-01 (blue) got too little storage space to work with WLED. 0.10.2 is the last release supporting this unit.

View File

@ -341,7 +341,7 @@ void loadSettingsFromEEPROM()
for (int i=0;i<15;i++) {
DMXFixtureMap[i] = EEPROM.read(2535+i);
} //last used: 2549
EEPROM.read(2550, DMXStartLED);
DMXStartLED = EEPROM.read(2550);
#endif
//Usermod memory