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