diff --git a/companion/src/firmwares/edgetx/yaml_generalsettings.h b/companion/src/firmwares/edgetx/yaml_generalsettings.h index 3c76cabb3..19bbc971e 100644 --- a/companion/src/firmwares/edgetx/yaml_generalsettings.h +++ b/companion/src/firmwares/edgetx/yaml_generalsettings.h @@ -83,7 +83,7 @@ namespace YAML { // return node; // } - static bool decode(const YAML::Node& node, GeneralSettings& rhs) { + static bool decode(const Node& node, GeneralSettings& rhs) { node["version"] >> rhs.version; node["versionBla"] >> rhs.version; @@ -93,8 +93,10 @@ namespace YAML { node["contrast"] >> rhs.contrast; node["vBatWarn"] >> rhs.vBatWarn; node["txVoltageCalibration"] >> rhs.txVoltageCalibration; - node["vBatMin"] >> rhs.vBatMin; - node["vBatMax"] >> rhs.vBatMax; + + node["vBatMin"] >> ioffset_int(rhs.vBatMin, 90); + node["vBatMax"] >> ioffset_int(rhs.vBatMax, 120); + node["backlightMode"] >> backlightModeLut >> rhs.backlightMode; node["trainer"] >> rhs.trainer; node["view"] >> rhs.view; diff --git a/companion/src/firmwares/edgetx/yaml_ops.h b/companion/src/firmwares/edgetx/yaml_ops.h index e84adca3d..e2c71a836 100644 --- a/companion/src/firmwares/edgetx/yaml_ops.h +++ b/companion/src/firmwares/edgetx/yaml_ops.h @@ -25,7 +25,24 @@ typedef std::pair YamlLookupTableElmt; typedef std::vector YamlLookupTable; -YAML::Node operator>>(const YAML::Node& node, const YamlLookupTable& lut) +class ioffset_int { + +public: + ioffset_int(int& val, int offset) + : value(val), offset(offset) + {} + + void assign(int newValue) const { + value = newValue - offset; + } + +private: + int& value; + int offset; +}; + + +YAML::Node operator >> (const YAML::Node& node, const YamlLookupTable& lut) { if (node) { std::string str = node.as(); @@ -44,8 +61,15 @@ YAML::Node operator>>(const YAML::Node& node, const YamlLookupTable& lut) return node; } +void operator >> (const YAML::Node& node, const ioffset_int& value) +{ + if (node && node.IsScalar()) { + value.assign(node.as()); + } +} + template -void operator>>(const YAML::Node& node, T& value) +void operator >> (const YAML::Node& node, T& value) { if (node && !node.IsNull()) { value = node.as(); @@ -53,7 +77,7 @@ void operator>>(const YAML::Node& node, T& value) } template <> -void operator>>(const YAML::Node& node, bool& value) +void operator >> (const YAML::Node& node, bool& value) { if (node && node.IsScalar()) { value = node.as(); @@ -61,7 +85,7 @@ void operator>>(const YAML::Node& node, bool& value) } template -void operator>>(const YAML::Node& node, char (&value)[N]) +void operator >> (const YAML::Node& node, char (&value)[N]) { if (node && node.IsScalar()) { auto str = node.as();