Skip to content

Commit 4827fb7

Browse files
elecpowerpfeerick
authored andcommitted
fix(cpn): don't assume all lcd customisable switches have colour settings (#5950)
1 parent 2f550c5 commit 4827fb7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

companion/src/firmwares/edgetx/yaml_modeldata.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -1489,16 +1489,20 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
14891489
node["switchNames"] >> rhs.functionSwitchNames;
14901490
if (node["functionSwitchLedONColor"]) {
14911491
for (int i = 0; i < CPN_MAX_SWITCHES_FUNCTION; i += 1) {
1492-
node["functionSwitchLedONColor"][std::to_string(i)]["r"] >> rhs.functionSwitchLedONColor[i].r;
1493-
node["functionSwitchLedONColor"][std::to_string(i)]["g"] >> rhs.functionSwitchLedONColor[i].g;
1494-
node["functionSwitchLedONColor"][std::to_string(i)]["b"] >> rhs.functionSwitchLedONColor[i].b;
1492+
if (node["functionSwitchLedONColor"][std::to_string(i)]) {
1493+
node["functionSwitchLedONColor"][std::to_string(i)]["r"] >> rhs.functionSwitchLedONColor[i].r;
1494+
node["functionSwitchLedONColor"][std::to_string(i)]["g"] >> rhs.functionSwitchLedONColor[i].g;
1495+
node["functionSwitchLedONColor"][std::to_string(i)]["b"] >> rhs.functionSwitchLedONColor[i].b;
1496+
}
14951497
}
14961498
}
14971499
if (node["functionSwitchLedOFFColor"]) {
14981500
for (int i = 0; i < CPN_MAX_SWITCHES_FUNCTION; i += 1) {
1499-
node["functionSwitchLedOFFColor"][std::to_string(i)]["r"] >> rhs.functionSwitchLedOFFColor[i].r;
1500-
node["functionSwitchLedOFFColor"][std::to_string(i)]["g"] >> rhs.functionSwitchLedOFFColor[i].g;
1501-
node["functionSwitchLedOFFColor"][std::to_string(i)]["b"] >> rhs.functionSwitchLedOFFColor[i].b;
1501+
if (node["functionSwitchLedOFFColor"][std::to_string(i)]) {
1502+
node["functionSwitchLedOFFColor"][std::to_string(i)]["r"] >> rhs.functionSwitchLedOFFColor[i].r;
1503+
node["functionSwitchLedOFFColor"][std::to_string(i)]["g"] >> rhs.functionSwitchLedOFFColor[i].g;
1504+
node["functionSwitchLedOFFColor"][std::to_string(i)]["b"] >> rhs.functionSwitchLedOFFColor[i].b;
1505+
}
15021506
}
15031507
}
15041508

0 commit comments

Comments
 (0)