feat(radio): refactor of switch handling to better support customisable switches (#6095)

Co-authored-by: philmoz <phil.a.mitchell@gmail.com>
Co-authored-by: 3djc <3djc@gh.com>
Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
philmoz
2025-07-28 12:59:22 +10:00
committed by GitHub
co-authored by philmoz 3djc elecpower
parent 28833f42e6
commit 0c8c39b134
155 changed files with 4538 additions and 2306 deletions
+5 -12
View File
@@ -765,20 +765,13 @@ QString ModelPrinter::printSwitchWarnings()
uint64_t value;
for (int i = 0; i < Boards::getCapability(board, Board::Switches); i++) {
Board::SwitchInfo switchInfo = Boards::getSwitchInfo(i);
if (switchInfo.type == Board::SWITCH_NOT_AVAILABLE || switchInfo.type == Board::SWITCH_TOGGLE) {
Board::SwitchType type = model.getSwitchType(i, generalSettings);
if (type != Board::SWITCH_2POS && type != Board::SWITCH_3POS) {
continue;
}
if (!(model.switchWarningEnable & (1 << i))) {
if (IS_HORUS_OR_TARANIS(board)) {
value = (switchStates >> (2 * i)) & 0x03;
}
else {
value = (i == 0 ? switchStates & 0x3 : switchStates & 0x1);
switchStates >>= (i == 0 ? 2 : 1);
}
str += RawSwitch(SWITCH_TYPE_SWITCH, 1 + i * 3 + value).toString(board, &generalSettings, &model);
}
value = (switchStates >> (2 * i)) & 0x03;
if (value > 0)
str += RawSwitch(SWITCH_TYPE_SWITCH, i * 3 + value).toString(board, &generalSettings, &model);
}
return (str.isEmpty() ? tr("None") : str.join(" ")) ;
}