Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cpn): ADC switch type hardware definition #5846

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions companion/src/firmwares/boardjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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) <<
Expand Down
1 change: 1 addition & 0 deletions companion/src/firmwares/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ namespace Board {
SWITCH_2POS,
SWITCH_3POS,
SWITCH_FUNC,
SWITCH_ADC,
SWITCH_TYPE_COUNT
};

Expand Down
Loading