Companion save serial port settings even if OFF
This commit is contained in:
@@ -214,7 +214,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
|
||||
|
||||
Node serialPort;
|
||||
for (int i = 0; i < GeneralSettings::SP_COUNT; i++) {
|
||||
if (rhs.serialPort[i] != GeneralSettings::AUX_SERIAL_OFF) {
|
||||
if (rhs.serialPort[i] != GeneralSettings::AUX_SERIAL_OFF || rhs.serialPower[i]) {
|
||||
Node mode = uartModeLut << rhs.serialPort[i];
|
||||
serialPort[LookupValue(serialPortLut, i)]["mode"] = mode;
|
||||
serialPort[LookupValue(serialPortLut, i)]["power"] = (int)rhs.serialPower[i];
|
||||
@@ -405,11 +405,13 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
||||
node["varioRepeat"] >> rhs.varioRepeat;
|
||||
node["backgroundVolume"] >> ioffset_int(rhs.backgroundVolume, 2);
|
||||
|
||||
// depreciated v2.7 replaced by serialPort
|
||||
if (node["auxSerialMode"]) {
|
||||
node["auxSerialMode"] >> oldUartModeLut >>
|
||||
rhs.serialPort[GeneralSettings::SP_AUX1];
|
||||
}
|
||||
|
||||
// depreciated v2.7 replaced by serialPort
|
||||
if (node["aux2SerialMode"]) {
|
||||
node["aux2SerialMode"] >> oldUartModeLut >>
|
||||
rhs.serialPort[GeneralSettings::SP_AUX2];
|
||||
@@ -424,9 +426,15 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
||||
int p = port_nr.as<int>();
|
||||
if (p >= 0 && p < GeneralSettings::SP_COUNT && port.second.IsMap()) {
|
||||
port.second["mode"] >> uartModeLut >> rhs.serialPort[p];
|
||||
int pwr = port.second["power"].as<int>();
|
||||
if (pwr >= 0 && pwr <= 1)
|
||||
port.second["power"] >> rhs.serialPower[p];
|
||||
// introduced v2.8
|
||||
Node port_pwr = port.second["power"];
|
||||
if (port_pwr && port_pwr.IsScalar()) {
|
||||
try {
|
||||
int pwr = port_pwr.as<int>();
|
||||
if (pwr == 0 || pwr == 1)
|
||||
rhs.serialPower[p] = pwr;
|
||||
} catch(...) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user