Backup RFP Infinity controller state before Resolume changes
This commit is contained in:
@@ -87,6 +87,52 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
||||
|
||||
JsonObject hw = doc[F("hw")];
|
||||
|
||||
#if defined(WLED_ENABLE_INFINITY_CONTROLLER) && defined(WLED_INFINITY_MASTER)
|
||||
auto normalizeRfpMasterLedBusConfig = [](JsonObject root) -> bool {
|
||||
JsonObject hwObj = root[F("hw")];
|
||||
if (hwObj.isNull()) hwObj = root.createNestedObject(F("hw"));
|
||||
JsonObject hwLedObj = hwObj[F("led")];
|
||||
if (hwLedObj.isNull()) hwLedObj = hwObj.createNestedObject(F("led"));
|
||||
|
||||
const uint8_t dummyPins[] = {DATA_PINS};
|
||||
const uint8_t dummyPin = dummyPins[0];
|
||||
JsonArray insArray = hwLedObj["ins"];
|
||||
bool needsMigration = insArray.isNull() || insArray.size() != 1;
|
||||
|
||||
if (!needsMigration) {
|
||||
JsonObject onlyBus = insArray[0].as<JsonObject>();
|
||||
JsonArray pins = onlyBus["pin"];
|
||||
needsMigration = pins.isNull()
|
||||
|| pins.size() != 1
|
||||
|| pins[0].as<int>() != dummyPin
|
||||
|| (onlyBus["start"] | 0) != 0
|
||||
|| (onlyBus["len"] | 0) != 1;
|
||||
}
|
||||
|
||||
if (!needsMigration) return false;
|
||||
|
||||
USER_PRINTLN(F("RFP master: repairing LED bus config, keeping status pixel GPIO free."));
|
||||
hwLedObj.remove("ins");
|
||||
JsonArray fixedIns = hwLedObj.createNestedArray("ins");
|
||||
JsonObject bus = fixedIns.createNestedObject();
|
||||
bus["start"] = 0;
|
||||
bus["len"] = 1;
|
||||
JsonArray pin = bus.createNestedArray("pin");
|
||||
pin.add(dummyPin);
|
||||
bus[F("order")] = COL_ORDER_GRB;
|
||||
bus["rev"] = false;
|
||||
bus[F("skip")] = 0;
|
||||
bus["type"] = TYPE_WS2812_RGB;
|
||||
bus["ref"] = false;
|
||||
bus[F("rgbwm")] = RGBW_MODE_MANUAL_ONLY;
|
||||
bus[F("freq")] = 0;
|
||||
return true;
|
||||
};
|
||||
|
||||
if (fromFS && normalizeRfpMasterLedBusConfig(doc)) needsSave = true;
|
||||
hw = doc[F("hw")];
|
||||
#endif
|
||||
|
||||
// initialize LED pins and lengths prior to other HW (except for ethernet)
|
||||
JsonObject hw_led = hw["led"];
|
||||
|
||||
@@ -446,6 +492,10 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
||||
CJSON(nodeListEnabled, if_nodes[F("list")]);
|
||||
CJSON(nodeBroadcastEnabled, if_nodes[F("bcast")]);
|
||||
|
||||
#ifdef WLED_ENABLE_INFINITY_CONTROLLER
|
||||
infinityDeserializeConfig(interfaces);
|
||||
#endif
|
||||
|
||||
JsonObject if_live = interfaces["live"];
|
||||
CJSON(receiveDirect, if_live["en"]);
|
||||
CJSON(useMainSegmentOnly, if_live[F("mso")]);
|
||||
@@ -948,6 +998,10 @@ void serializeConfig() {
|
||||
if_nodes[F("list")] = nodeListEnabled;
|
||||
if_nodes[F("bcast")] = nodeBroadcastEnabled;
|
||||
|
||||
#ifdef WLED_ENABLE_INFINITY_CONTROLLER
|
||||
infinitySerializeConfig(interfaces);
|
||||
#endif
|
||||
|
||||
JsonObject if_live = interfaces.createNestedObject("live");
|
||||
if_live["en"] = receiveDirect;
|
||||
if_live[F("mso")] = useMainSegmentOnly;
|
||||
|
||||
Reference in New Issue
Block a user