From a220ea36c686ebf6aa70b0ce14d324861efee769 Mon Sep 17 00:00:00 2001 From: Neil Horne <15316949+elecpower@users.noreply.github.com> Date: Fri, 28 Feb 2025 10:16:16 +1100 Subject: [PATCH] fix(cpn): don't assume all lcd customisable switches have colour settings (#5950) --- .../src/firmwares/edgetx/yaml_modeldata.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index f0ceeeb18..617df48b3 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -1489,16 +1489,20 @@ bool convert::decode(const Node& node, ModelData& rhs) node["switchNames"] >> rhs.functionSwitchNames; if (node["functionSwitchLedONColor"]) { for (int i = 0; i < CPN_MAX_SWITCHES_FUNCTION; i += 1) { - node["functionSwitchLedONColor"][std::to_string(i)]["r"] >> rhs.functionSwitchLedONColor[i].r; - node["functionSwitchLedONColor"][std::to_string(i)]["g"] >> rhs.functionSwitchLedONColor[i].g; - node["functionSwitchLedONColor"][std::to_string(i)]["b"] >> rhs.functionSwitchLedONColor[i].b; + if (node["functionSwitchLedONColor"][std::to_string(i)]) { + node["functionSwitchLedONColor"][std::to_string(i)]["r"] >> rhs.functionSwitchLedONColor[i].r; + node["functionSwitchLedONColor"][std::to_string(i)]["g"] >> rhs.functionSwitchLedONColor[i].g; + node["functionSwitchLedONColor"][std::to_string(i)]["b"] >> rhs.functionSwitchLedONColor[i].b; + } } } if (node["functionSwitchLedOFFColor"]) { for (int i = 0; i < CPN_MAX_SWITCHES_FUNCTION; i += 1) { - node["functionSwitchLedOFFColor"][std::to_string(i)]["r"] >> rhs.functionSwitchLedOFFColor[i].r; - node["functionSwitchLedOFFColor"][std::to_string(i)]["g"] >> rhs.functionSwitchLedOFFColor[i].g; - node["functionSwitchLedOFFColor"][std::to_string(i)]["b"] >> rhs.functionSwitchLedOFFColor[i].b; + if (node["functionSwitchLedOFFColor"][std::to_string(i)]) { + node["functionSwitchLedOFFColor"][std::to_string(i)]["r"] >> rhs.functionSwitchLedOFFColor[i].r; + node["functionSwitchLedOFFColor"][std::to_string(i)]["g"] >> rhs.functionSwitchLedOFFColor[i].g; + node["functionSwitchLedOFFColor"][std::to_string(i)]["b"] >> rhs.functionSwitchLedOFFColor[i].b; + } } }