Various Companion fixes (#1449)
- Fix (de-)serializing enable param for backlight custom function - Fix OFF backlight - Fix power ON/OFF delay - Fix flight mode trim disabled - Fix trim switch index - Fix deserializing SLIDER[1,2] - Fix shift for logical switches in raw sources
This commit is contained in:
@@ -27,7 +27,8 @@ static bool fnHasEnable(AssignFunc fn)
|
||||
return (fn <= FuncInstantTrim)
|
||||
|| (fn >= FuncReset && fn <= FuncSetTimerLast)
|
||||
|| (fn >= FuncAdjustGV1 && fn <= FuncBindExternalModule)
|
||||
|| (fn == FuncVolume);
|
||||
|| (fn == FuncVolume)
|
||||
|| (fn == FuncBacklight);
|
||||
}
|
||||
|
||||
static bool fnHasRepeat(AssignFunc fn)
|
||||
|
||||
@@ -147,6 +147,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
|
||||
node["gpsFormat"] = rhs.gpsFormat;
|
||||
node["speakerVolume"] = rhs.speakerVolume + 12;
|
||||
node["backlightBright"] = rhs.backlightBright;
|
||||
node["blOffBright"] = rhs.backlightOffBright;
|
||||
node["switchesDelay"] = rhs.switchesDelay;
|
||||
node["globalTimer"] = rhs.globalTimer;
|
||||
node["bluetoothName"] = rhs.bluetoothName;
|
||||
@@ -169,6 +170,8 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
|
||||
node["aux2SerialMode"] = uartModeLut << rhs.aux2SerialMode;
|
||||
node["antennaMode"] = antennaModeLut << rhs.antennaMode;
|
||||
node["backlightColor"] = rhs.backlightColor;
|
||||
node["pwrOnSpeed"] = rhs.pwrOnSpeed;
|
||||
node["pwrOffSpeed"] = rhs.pwrOffSpeed;
|
||||
|
||||
for (int i = 0; i < CPN_MAX_SPECIAL_FUNCTIONS; i++) {
|
||||
const CustomFunctionData& fn = rhs.customFn[i];
|
||||
@@ -304,6 +307,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
||||
node["gpsFormat"] >> rhs.gpsFormat;
|
||||
node["speakerVolume"] >> ioffset_int(rhs.speakerVolume, 12);
|
||||
node["backlightBright"] >> rhs.backlightBright;
|
||||
node["blOffBright"] >> rhs.backlightOffBright;
|
||||
node["switchesDelay"] >> rhs.switchesDelay;
|
||||
node["globalTimer"] >> rhs.globalTimer;
|
||||
node["bluetoothName"] >> rhs.bluetoothName;
|
||||
@@ -326,6 +330,9 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
||||
node["aux2SerialMode"] >> uartModeLut >> rhs.aux2SerialMode;
|
||||
node["antennaMode"] >> antennaModeLut >> rhs.antennaMode;
|
||||
node["backlightColor"] >> rhs.backlightColor;
|
||||
node["pwrOnSpeed"] >> rhs.pwrOnSpeed;
|
||||
node["pwrOffSpeed"] >> rhs.pwrOffSpeed;
|
||||
|
||||
node["customFn"] >> rhs.customFn;
|
||||
|
||||
YamlStickConfig stickConfig;
|
||||
|
||||
@@ -369,7 +369,7 @@ struct convert<YamlTrim> {
|
||||
Node node;
|
||||
node["value"] = rhs.value;
|
||||
if (rhs.mode < 0) {
|
||||
node["mode"] = -1;
|
||||
node["mode"] = (1 << 5) - 1;
|
||||
} else {
|
||||
node["mode"] = 2 * rhs.ref + rhs.mode;
|
||||
}
|
||||
@@ -381,8 +381,8 @@ struct convert<YamlTrim> {
|
||||
|
||||
int trimMode = 0;
|
||||
node["mode"] >> trimMode;
|
||||
if (trimMode < 0) {
|
||||
rhs.mode = trimMode;
|
||||
if (trimMode == (1 << 5) - 1) {
|
||||
rhs.mode = -1;
|
||||
} else {
|
||||
rhs.mode = trimMode % 2;
|
||||
rhs.ref = trimMode / 2;
|
||||
|
||||
@@ -49,7 +49,7 @@ std::string YamlRawSourceEncode(const RawSource& rhs)
|
||||
break;
|
||||
case SOURCE_TYPE_CUSTOM_SWITCH:
|
||||
src_str += "ls(";
|
||||
src_str += std::to_string(rhs.index);
|
||||
src_str += std::to_string(rhs.index + 1);
|
||||
src_str += ")";
|
||||
break;
|
||||
case SOURCE_TYPE_CYC:
|
||||
@@ -108,7 +108,7 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
|
||||
if (idx < CPN_MAX_INPUTS) {
|
||||
rhs = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, idx);
|
||||
}
|
||||
} else if (val_len >= 2
|
||||
} else if (val_len == 2
|
||||
&& val[0] == 'S'
|
||||
&& val[1] >= 'A'
|
||||
&& val[1] <= 'Z') {
|
||||
@@ -139,8 +139,8 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
|
||||
std::stringstream src(src_str.substr(3));
|
||||
int ls = 0;
|
||||
src >> ls;
|
||||
if (ls < CPN_MAX_LOGICAL_SWITCHES)
|
||||
rhs = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, ls);
|
||||
if (ls > 0 && ls < CPN_MAX_LOGICAL_SWITCHES)
|
||||
rhs = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, ls - 1);
|
||||
|
||||
} else if (val_len > 3 &&
|
||||
val[0] == 't' &&
|
||||
|
||||
@@ -50,7 +50,7 @@ std::string YamlRawSwitchEncode(const RawSwitch& rhs)
|
||||
break;
|
||||
|
||||
case SWITCH_TYPE_TRIM:
|
||||
sw_str += getCurrentFirmware()->getTrimSwitchesTag(sval);
|
||||
sw_str += getCurrentFirmware()->getTrimSwitchesTag(sval - 1);
|
||||
break;
|
||||
|
||||
case SWITCH_TYPE_FLIGHT_MODE:
|
||||
@@ -132,7 +132,7 @@ RawSwitch YamlRawSwitchDecode(const std::string& sw_str)
|
||||
int tsw_idx = getCurrentFirmware()->getTrimSwitchesIndex(sw_str_tmp.c_str());
|
||||
if (tsw_idx >= 0) {
|
||||
rhs.type = SWITCH_TYPE_TRIM;
|
||||
rhs.index = tsw_idx;
|
||||
rhs.index = tsw_idx + 1;
|
||||
}
|
||||
|
||||
} else if (val_len >= 3 && val[0] == 'S' &&
|
||||
|
||||
Reference in New Issue
Block a user