@@ -1029,7 +1029,8 @@ Node convert<ModelData>::encode(const ModelData& rhs)
10291029 modelSettingsVersion = SemanticVersion (VERSION);
10301030
10311031 Node node;
1032- auto board = getCurrentBoard ();
1032+ auto firmware = getCurrentFirmware ();
1033+ auto board = firmware->getBoard ();
10331034
10341035 bool hasColorLcd = Boards::getCapability (board, Board::HasColorLcd);
10351036
@@ -1242,8 +1243,8 @@ Node convert<ModelData>::encode(const ModelData& rhs)
12421243 node[" toplcdTimer" ] = rhs.toplcdTimer ;
12431244 }
12441245
1245- if (IS_FAMILY_HORUS_OR_T16 (board)) {
1246- for (int i= 0 ; i< MAX_CUSTOM_SCREENS; i++) {
1246+ if (Boards::getCapability (board, Board::HasColorLcd )) {
1247+ for (int i = 0 ; i < MAX_CUSTOM_SCREENS; i++) {
12471248 const auto & csd = rhs.customScreens .customScreenData [i];
12481249 if (!csd.isEmpty ()) {
12491250 node[" screenData" ][std::to_string (i)] = csd;
@@ -1254,9 +1255,11 @@ Node convert<ModelData>::encode(const ModelData& rhs)
12541255 if (topbarData && topbarData.IsMap ()) {
12551256 node[" topbarData" ] = topbarData;
12561257 }
1257- for (int i = 0 ; i < MAX_TOPBAR_ZONES ; i++)
1258- if (rhs.topbarWidgetWidth [i] > 0 )
1258+ for (int i = 0 ; i < firmware-> getCapability (TopBarZones) ; i++) {
1259+ if (rhs.topbarWidgetWidth [i] > 0 ) {
12591260 node[" topbarWidgetWidth" ][std::to_string (i)][" val" ] = (int )rhs.topbarWidgetWidth [i];
1261+ }
1262+ }
12601263 node[" view" ] = rhs.view ;
12611264 }
12621265
@@ -1311,7 +1314,8 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
13111314{
13121315 if (!node.IsMap ()) return false ;
13131316
1314- Board::Type board = getCurrentBoard ();
1317+ auto firmware = getCurrentFirmware ();
1318+ auto board = firmware->getBoard ();
13151319
13161320 unsigned int modelIds[CPN_MAX_MODULES];
13171321 memset (modelIds, 0 , sizeof (modelIds));
@@ -1663,6 +1667,22 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
16631667 YamlValidateLabelsNames (rhs, board);
16641668 rhs.sortMixes (); // critical for Companion and radio that mix lines are in sequence
16651669
1670+ // TODO move to model conversion so any changes reported
1671+ if (Boards::getCapability (board, Board::HasColorLcd)) {
1672+ // total width of topbar widgets cannot exceed firmware topbar zones
1673+ const int fwzones = firmware->getCapability (TopBarZones);
1674+ int usedzones = 0 ;
1675+
1676+ for (int i = 0 ; i < MAX_TOPBAR_ZONES; i++) {
1677+ usedzones += rhs.topbarWidgetWidth [i];
1678+
1679+ if (usedzones > fwzones) {
1680+ rhs.topbarWidgetWidth [i] = 0 ;
1681+ rhs.topBarData .zones [i].clear ();
1682+ }
1683+ }
1684+ }
1685+
16661686 return true ;
16671687}
16681688
0 commit comments