Some fixes
This commit is contained in:
@@ -129,7 +129,8 @@ bool convert<LogicalSwitchData>::decode(const Node& node,
|
||||
std::string sw_str;
|
||||
getline(def, sw_str, ',');
|
||||
rhs.val1 = YamlRawSwitchDecode(sw_str).toValue();
|
||||
rhs.val2 = YamlRawSwitchDecode(def.str()).toValue();
|
||||
getline(def, sw_str);
|
||||
rhs.val2 = YamlRawSwitchDecode(sw_str).toValue();
|
||||
} break;
|
||||
|
||||
case LS_FAMILY_EDGE: {
|
||||
@@ -154,7 +155,8 @@ bool convert<LogicalSwitchData>::decode(const Node& node,
|
||||
std::string src_str;
|
||||
getline(def, src_str, ',');
|
||||
rhs.val1 = YamlRawSourceDecode(src_str).toValue();
|
||||
rhs.val2 = YamlRawSourceDecode(def.str()).toValue();
|
||||
getline(def, src_str);
|
||||
rhs.val2 = YamlRawSourceDecode(src_str).toValue();
|
||||
} break;
|
||||
|
||||
case LS_FAMILY_TIMER: {
|
||||
|
||||
@@ -405,7 +405,7 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
|
||||
YamlReadCurvePoints(node["points"], rhs.curves);
|
||||
|
||||
node["logicalSw"] >> rhs.logicalSw;
|
||||
node["customFn"] >> rhs.customFn;
|
||||
//node["customFn"] >> rhs.customFn;
|
||||
|
||||
// swashRingData
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ std::string YamlRawSourceEncode(const RawSource& rhs)
|
||||
src_str = getCurrentFirmware()->getAnalogInputTag(rhs.index);
|
||||
break;
|
||||
case SOURCE_TYPE_TRIM:
|
||||
src_str = LookupValue(trimSourceLut, rhs.index);
|
||||
src_str = YAML::LookupValue(trimSourceLut, rhs.index);
|
||||
break;
|
||||
case SOURCE_TYPE_MAX:
|
||||
src_str += "MAX";
|
||||
@@ -84,7 +84,7 @@ std::string YamlRawSourceEncode(const RawSource& rhs)
|
||||
src_str += ")";
|
||||
break;
|
||||
case SOURCE_TYPE_CYC:
|
||||
src_str = LookupValue(cycSourceLut, rhs.index);
|
||||
src_str = YAML::LookupValue(cycSourceLut, rhs.index);
|
||||
break;
|
||||
case SOURCE_TYPE_PPM:
|
||||
src_str += "tr(";
|
||||
@@ -102,7 +102,7 @@ std::string YamlRawSourceEncode(const RawSource& rhs)
|
||||
src_str += ")";
|
||||
break;
|
||||
case SOURCE_TYPE_SPECIAL:
|
||||
src_str = LookupValue(specialSourceLut, rhs.index);
|
||||
src_str = YAML::LookupValue(specialSourceLut, rhs.index);
|
||||
break;
|
||||
case SOURCE_TYPE_TELEMETRY:
|
||||
src_str = "tele(";
|
||||
@@ -148,15 +148,11 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
|
||||
val[2] == 'a' &&
|
||||
val[3] == '(') {
|
||||
|
||||
src_str = src_str.substr(4);
|
||||
|
||||
size_t next_pos = 0;
|
||||
int script = std::stoi(src_str, &next_pos);
|
||||
|
||||
if (next_pos >= src_str.size()) return false;
|
||||
src_str = src_str.substr(next_pos + 1);
|
||||
|
||||
int output = std::stoi(src_str);
|
||||
std::stringstream src(src_str.substr(4));
|
||||
int script = 0, output = 0;
|
||||
src >> script;
|
||||
src.ignore();
|
||||
src >> output;
|
||||
rhs = RawSource(SOURCE_TYPE_LUA_OUTPUT, script * 16 + output);
|
||||
|
||||
} else if (val_len > 3 &&
|
||||
@@ -164,8 +160,9 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
|
||||
val[1] == 's' &&
|
||||
val[2] == '(') {
|
||||
|
||||
src_str = src_str.substr(3);
|
||||
int ls = std::stoi(src_str);
|
||||
std::stringstream src(src_str.substr(3));
|
||||
int ls = 0;
|
||||
src >> ls;
|
||||
rhs = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, ls);
|
||||
|
||||
} else if (val_len > 3 &&
|
||||
@@ -173,8 +170,9 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
|
||||
val[1] == 'r' &&
|
||||
val[2] == '(') {
|
||||
|
||||
src_str = src_str.substr(3);
|
||||
int tr = std::stoi(src_str);
|
||||
std::stringstream src(src_str.substr(3));
|
||||
int tr = 0;
|
||||
src >> tr;
|
||||
rhs = RawSource(SOURCE_TYPE_PPM, tr);
|
||||
|
||||
} else if (val_len > 3 &&
|
||||
@@ -182,8 +180,9 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
|
||||
val[1] == 'h' &&
|
||||
val[2] == '(') {
|
||||
|
||||
src_str = src_str.substr(3);
|
||||
int ch = std::stoi(src_str);
|
||||
std::stringstream src(src_str.substr(3));
|
||||
int ch = 0;
|
||||
src >> ch;
|
||||
rhs = RawSource(SOURCE_TYPE_CH, ch);
|
||||
|
||||
} else if (val_len > 3 &&
|
||||
@@ -191,8 +190,9 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
|
||||
val[1] == 'v' &&
|
||||
val[2] == '(') {
|
||||
|
||||
src_str = src_str.substr(3);
|
||||
int gv = std::stoi(src_str);
|
||||
std::stringstream src(src_str.substr(3));
|
||||
int gv = 0;
|
||||
src >> gv;
|
||||
rhs = RawSource(SOURCE_TYPE_GVAR, gv);
|
||||
|
||||
} else if (val_len > 5 &&
|
||||
@@ -202,23 +202,26 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
|
||||
val[3] == 'e' &&
|
||||
val[4] == '(') {
|
||||
|
||||
src_str = src_str.substr(5);
|
||||
std::stringstream src(src_str.substr(5));
|
||||
|
||||
// parse sign
|
||||
uint8_t sign = 0;
|
||||
if (src_str[0] == '-') {
|
||||
char c = src.peek();
|
||||
if (c == '-') {
|
||||
sign = 1;
|
||||
src_str = src_str.substr(1);
|
||||
} else if (src_str[0] == '+') {
|
||||
src.ignore();
|
||||
} else if (c == '+') {
|
||||
sign = 2;
|
||||
src_str = src_str.substr(1);
|
||||
src.ignore();
|
||||
}
|
||||
|
||||
int sensor = std::stoi(src_str);
|
||||
int sensor = 0;
|
||||
src >> sensor;
|
||||
rhs = RawSource(SOURCE_TYPE_TELEMETRY, sensor * 3 + sign);
|
||||
|
||||
} else {
|
||||
|
||||
YAML::Node node(src_str);
|
||||
std::string ana_str;
|
||||
node >> ana_str;
|
||||
int ana_idx = getCurrentFirmware()->getAnalogInputIndex(ana_str.c_str());
|
||||
|
||||
@@ -74,7 +74,7 @@ std::string YamlRawSwitchEncode(const RawSwitch& rhs)
|
||||
break;
|
||||
|
||||
case SWITCH_TYPE_TRIM:
|
||||
sw_str += LookupValue(trimSwitchLut, sval);
|
||||
sw_str += YAML::LookupValue(trimSwitchLut, sval);
|
||||
break;
|
||||
|
||||
case SWITCH_TYPE_FLIGHT_MODE:
|
||||
@@ -88,7 +88,7 @@ std::string YamlRawSwitchEncode(const RawSwitch& rhs)
|
||||
break;
|
||||
|
||||
default:
|
||||
sw_str += LookupValue(switchTypeLut, rhs.type);
|
||||
sw_str += YAML::LookupValue(switchTypeLut, rhs.type);
|
||||
break;
|
||||
}
|
||||
return sw_str;
|
||||
@@ -125,7 +125,7 @@ RawSwitch YamlRawSwitchDecode(const std::string& sw_str)
|
||||
} else if (sw_str.substr(0, 3) == std::string("Trim")) { // "Trim"
|
||||
|
||||
rhs.type = SWITCH_TYPE_TRIM;
|
||||
node >> trimSwitchLut >> rhs.index;
|
||||
YAML::Node(sw_str) >> trimSwitchLut >> rhs.index;
|
||||
} else if (val_len >= 3 && val[0] == 'S' &&
|
||||
(val[1] >= 'A' && val[1] <= 'Z') &&
|
||||
(val[2] >= '0' && val[2] <= '2')) {
|
||||
@@ -134,7 +134,7 @@ RawSwitch YamlRawSwitchDecode(const std::string& sw_str)
|
||||
// TODO: check if we have a match?
|
||||
// or does RawSwitch default to NONE anyway?
|
||||
//
|
||||
node >> rhs.type;
|
||||
YAML::Node(sw_str) >> rhs.type;
|
||||
rhs.index = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user