Skip first and apply preset fixes

This commit is contained in:
cschwinne 2021-12-11 19:30:11 +01:00
parent 3f0258e215
commit 2ce8f1ee5d
2 changed files with 11 additions and 3 deletions

View File

@ -91,7 +91,7 @@ class Bus {
virtual void setBrightness(uint8_t b) {} virtual void setBrightness(uint8_t b) {}
virtual void cleanup() {} virtual void cleanup() {}
virtual uint8_t getPins(uint8_t* pinArray) { return 0; } virtual uint8_t getPins(uint8_t* pinArray) { return 0; }
inline uint16_t getLength() { return _len; } virtual uint16_t getLength() { return _len; }
virtual void setColorOrder() {} virtual void setColorOrder() {}
virtual uint8_t getColorOrder() { return COL_ORDER_RGB; } virtual uint8_t getColorOrder() { return COL_ORDER_RGB; }
virtual uint8_t skippedLeds() { return 0; } virtual uint8_t skippedLeds() { return 0; }
@ -220,7 +220,7 @@ class BusDigital : public Bus {
return _colorOrder; return _colorOrder;
} }
inline uint16_t getLength() { uint16_t getLength() {
return _len - _skip; return _len - _skip;
} }

View File

@ -10,7 +10,15 @@ bool applyPreset(byte index, byte callMode)
const char *filename = index < 255 ? "/presets.json" : "/tmp.json"; const char *filename = index < 255 ? "/presets.json" : "/tmp.json";
if (fileDoc) { uint8_t core = 1;
//crude way to determine if this was called by a network request
#ifdef ARDUINO_ARCH_ESP32
core = xPortGetCoreID();
#endif
//only allow use of fileDoc from the core responsible for network requests
//do not use active network request doc from preset called by main loop (playlist, schedule, ...)
if (fileDoc && core) {
errorFlag = readObjectFromFileUsingId(filename, index, fileDoc) ? ERR_NONE : ERR_FS_PLOAD; errorFlag = readObjectFromFileUsingId(filename, index, fileDoc) ? ERR_NONE : ERR_FS_PLOAD;
JsonObject fdo = fileDoc->as<JsonObject>(); JsonObject fdo = fileDoc->as<JsonObject>();
if (fdo["ps"] == index) fdo.remove("ps"); //remove load request for same presets to prevent recursive crash if (fdo["ps"] == index) fdo.remove("ps"); //remove load request for same presets to prevent recursive crash