Bugfix saving LED config (race condition)
This commit is contained in:
parent
cf3faa1170
commit
569138ac80
@ -132,6 +132,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
uint8_t s = 0; // bus iterator
|
uint8_t s = 0; // bus iterator
|
||||||
if (fromFS) busses.removeAll(); // can't safely manipulate busses directly in network callback
|
if (fromFS) busses.removeAll(); // can't safely manipulate busses directly in network callback
|
||||||
uint32_t mem = 0;
|
uint32_t mem = 0;
|
||||||
|
bool busesChanged = false;
|
||||||
for (JsonObject elm : ins) {
|
for (JsonObject elm : ins) {
|
||||||
if (s >= WLED_MAX_BUSSES) break;
|
if (s >= WLED_MAX_BUSSES) break;
|
||||||
uint8_t pins[5] = {255, 255, 255, 255, 255};
|
uint8_t pins[5] = {255, 255, 255, 255, 255};
|
||||||
@ -161,10 +162,11 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
} else {
|
} else {
|
||||||
if (busConfigs[s] != nullptr) delete busConfigs[s];
|
if (busConfigs[s] != nullptr) delete busConfigs[s];
|
||||||
busConfigs[s] = new BusConfig(ledType, pins, start, length, colorOrder, reversed, skipFirst, AWmode);
|
busConfigs[s] = new BusConfig(ledType, pins, start, length, colorOrder, reversed, skipFirst, AWmode);
|
||||||
doInitBusses = true;
|
busesChanged = true;
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
doInitBusses = busesChanged;
|
||||||
// finalization done in beginStrip()
|
// finalization done in beginStrip()
|
||||||
}
|
}
|
||||||
if (hw_led["rev"]) busses.getBus(0)->reversed = true; //set 0.11 global reversed setting for first bus
|
if (hw_led["rev"]) busses.getBus(0)->reversed = true; //set 0.11 global reversed setting for first bus
|
||||||
|
@ -86,6 +86,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
Bus::setAutoWhiteMode(request->arg(F("AW")).toInt());
|
Bus::setAutoWhiteMode(request->arg(F("AW")).toInt());
|
||||||
strip.setTargetFps(request->arg(F("FR")).toInt());
|
strip.setTargetFps(request->arg(F("FR")).toInt());
|
||||||
|
|
||||||
|
bool busesChanged = false;
|
||||||
for (uint8_t s = 0; s < WLED_MAX_BUSSES; s++) {
|
for (uint8_t s = 0; s < WLED_MAX_BUSSES; s++) {
|
||||||
char lp[4] = "L0"; lp[2] = 48+s; lp[3] = 0; //ascii 0-9 //strip data pin
|
char lp[4] = "L0"; lp[2] = 48+s; lp[3] = 0; //ascii 0-9 //strip data pin
|
||||||
char lc[4] = "LC"; lc[2] = 48+s; lc[3] = 0; //strip length
|
char lc[4] = "LC"; lc[2] = 48+s; lc[3] = 0; //strip length
|
||||||
@ -98,7 +99,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
char aw[4] = "AW"; aw[2] = 48+s; aw[3] = 0; //auto white mode
|
char aw[4] = "AW"; aw[2] = 48+s; aw[3] = 0; //auto white mode
|
||||||
char wo[4] = "WO"; wo[2] = 48+s; wo[3] = 0; //channel swap
|
char wo[4] = "WO"; wo[2] = 48+s; wo[3] = 0; //channel swap
|
||||||
if (!request->hasArg(lp)) {
|
if (!request->hasArg(lp)) {
|
||||||
DEBUG_PRINTLN(F("No data.")); break;
|
DEBUG_PRINT(F("No data for "));
|
||||||
|
DEBUG_PRINTLN(s);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
for (uint8_t i = 0; i < 5; i++) {
|
for (uint8_t i = 0; i < 5; i++) {
|
||||||
lp[1] = 48+i;
|
lp[1] = 48+i;
|
||||||
@ -118,10 +121,12 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
awmode = request->arg(aw).toInt();
|
awmode = request->arg(aw).toInt();
|
||||||
channelSwap = (type == TYPE_SK6812_RGBW || type == TYPE_TM1814) ? request->arg(wo).toInt() : 0;
|
channelSwap = (type == TYPE_SK6812_RGBW || type == TYPE_TM1814) ? request->arg(wo).toInt() : 0;
|
||||||
// actual finalization is done in WLED::loop() (removing old busses and adding new)
|
// actual finalization is done in WLED::loop() (removing old busses and adding new)
|
||||||
|
// this may happen even before this loop is finished so we do "doInitBusses" after the loop
|
||||||
if (busConfigs[s] != nullptr) delete busConfigs[s];
|
if (busConfigs[s] != nullptr) delete busConfigs[s];
|
||||||
busConfigs[s] = new BusConfig(type, pins, start, length, colorOrder | (channelSwap<<4), request->hasArg(cv), skip, awmode);
|
busConfigs[s] = new BusConfig(type, pins, start, length, colorOrder | (channelSwap<<4), request->hasArg(cv), skip, awmode);
|
||||||
doInitBusses = true;
|
busesChanged = true;
|
||||||
}
|
}
|
||||||
|
//doInitBusses = busesChanged; // we will do that below to ensure all input data is processed
|
||||||
|
|
||||||
ColorOrderMap com = {};
|
ColorOrderMap com = {};
|
||||||
for (uint8_t s = 0; s < WLED_MAX_COLOR_ORDER_MAPPINGS; s++) {
|
for (uint8_t s = 0; s < WLED_MAX_COLOR_ORDER_MAPPINGS; s++) {
|
||||||
@ -197,6 +202,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
if (t >= 0 && t < 4) strip.paletteBlend = t;
|
if (t >= 0 && t < 4) strip.paletteBlend = t;
|
||||||
t = request->arg(F("BF")).toInt();
|
t = request->arg(F("BF")).toInt();
|
||||||
if (t > 0) briMultiplier = t;
|
if (t > 0) briMultiplier = t;
|
||||||
|
|
||||||
|
doInitBusses = busesChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
//UI
|
//UI
|
||||||
|
Loading…
Reference in New Issue
Block a user