From 3e42ed3385cfd296c464f6fe7bc470d420b8d32d Mon Sep 17 00:00:00 2001 From: Neil Horne <15316949+elecpower@users.noreply.github.com> Date: Tue, 28 Jan 2025 11:10:57 +1100 Subject: [PATCH] fix(cpn): ADC switch type hardware definition (#5846) --- companion/src/firmwares/boardjson.cpp | 12 ++++++++++++ companion/src/firmwares/boards.h | 1 + 2 files changed, 13 insertions(+) diff --git a/companion/src/firmwares/boardjson.cpp b/companion/src/firmwares/boardjson.cpp index e74d20eae..10d520327 100644 --- a/companion/src/firmwares/boardjson.cpp +++ b/companion/src/firmwares/boardjson.cpp @@ -51,6 +51,7 @@ static const StringTagMappingTable switchTypesLookupTable = { {std::to_string(Board::SWITCH_2POS), "2POS"}, {std::to_string(Board::SWITCH_3POS), "3POS"}, {std::to_string(Board::SWITCH_FUNC), "FSWITCH"}, + {std::to_string(Board::SWITCH_ADC), "ADC"}, }; static const StringTagMappingTable stickNamesLookupTable = { @@ -995,6 +996,17 @@ bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs sw.display.y = (unsigned int)d.at(1).toInt(0); } + // special handing for ADC + if (sw.type == Board::SWITCH_ADC) { + if (sw.dflt == Board::SWITCH_TOGGLE) { + // this could be 2 or 3 position toggle so play safe + // it therefore has an impact on configuring hardware, available switches, simulator widget, yaml encode and decode + sw.dflt = Board::SWITCH_3POS; + } + // make the same + sw.type = sw.dflt; + } + switches->insert(switches->end(), sw); // qDebug() << "tag:" << sw.tag.c_str() << "name:" << sw.name.c_str() << "type:" << sw.type << ">" << Boards::switchTypeToString(sw.type) << diff --git a/companion/src/firmwares/boards.h b/companion/src/firmwares/boards.h index a6765dbb3..b019e5a1d 100644 --- a/companion/src/firmwares/boards.h +++ b/companion/src/firmwares/boards.h @@ -119,6 +119,7 @@ namespace Board { SWITCH_2POS, SWITCH_3POS, SWITCH_FUNC, + SWITCH_ADC, SWITCH_TYPE_COUNT };