Prevent selection of impossible switch type in radio hardware (#8083)
* Prevent selection of impossible switch type in radio hardware
This commit is contained in:
@@ -231,7 +231,23 @@ SwitchInfo Boards::getSwitchInfo(Board::Type board, int index)
|
||||
if (index < DIM(switches))
|
||||
return switches[index];
|
||||
}
|
||||
else if (IS_HORUS_OR_TARANIS(board)) {
|
||||
else if (IS_FAMILY_HORUS_OR_T16(board)) {
|
||||
const Board::SwitchInfo switches[] = {
|
||||
{SWITCH_3POS, "SA"},
|
||||
{SWITCH_3POS, "SB"},
|
||||
{SWITCH_3POS, "SC"},
|
||||
{SWITCH_3POS, "SD"},
|
||||
{SWITCH_3POS, "SE"},
|
||||
{SWITCH_2POS, "SF"},
|
||||
{SWITCH_3POS, "SG"},
|
||||
{SWITCH_TOGGLE, "SH"},
|
||||
{SWITCH_2POS, "SI"},
|
||||
{SWITCH_2POS, "SJ"}
|
||||
};
|
||||
if (index < DIM(switches))
|
||||
return switches[index];
|
||||
}
|
||||
else if (IS_TARANIS(board)) {
|
||||
const Board::SwitchInfo switches[] = {
|
||||
{SWITCH_3POS, "SA"},
|
||||
{SWITCH_3POS, "SB"},
|
||||
|
||||
@@ -109,6 +109,15 @@ void HardwarePanel::setupSliderType(int index, QLabel *label, AutoLineEdit *name
|
||||
}
|
||||
}
|
||||
|
||||
bool HardwarePanel::isSwitch3Pos(int idx)
|
||||
{
|
||||
Board::Type board = firmware->getBoard();
|
||||
Board::SwitchInfo switchInfo = Boards::getSwitchInfo(board, idx);
|
||||
|
||||
switchInfo.config = Board::SwitchType(generalSettings.switchConfig[idx]);
|
||||
return switchInfo.config == Board::SWITCH_3POS;
|
||||
};
|
||||
|
||||
HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
GeneralPanel(parent, generalSettings, firmware),
|
||||
ui(new Ui::Hardware)
|
||||
@@ -155,17 +164,17 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
|
||||
setupSliderType(2, ui->ls2Label, ui->ls2Name, ui->ls2Type);
|
||||
setupSliderType(3, ui->rs2Label, ui->rs2Name, ui->rs2Type);
|
||||
|
||||
setupSwitchType(0, ui->saLabel, ui->saName, ui->saType);
|
||||
setupSwitchType(1, ui->sbLabel, ui->sbName, ui->sbType);
|
||||
setupSwitchType(2, ui->scLabel, ui->scName, ui->scType);
|
||||
setupSwitchType(3, ui->sdLabel, ui->sdName, ui->sdType);
|
||||
setupSwitchType(4, ui->seLabel, ui->seName, ui->seType);
|
||||
setupSwitchType(5, ui->sfLabel, ui->sfName, ui->sfType);
|
||||
setupSwitchType(6, ui->sgLabel, ui->sgName, ui->sgType);
|
||||
setupSwitchType(7, ui->shLabel, ui->shName, ui->shType, false); //switch does not support 3POS
|
||||
setupSwitchType(8, ui->siLabel, ui->siName, ui->siType);
|
||||
setupSwitchType(9, ui->sjLabel, ui->sjName, ui->sjType);
|
||||
setupSwitchType(10, ui->skLabel, ui->skName, ui->skType);
|
||||
setupSwitchType(0, ui->saLabel, ui->saName, ui->saType, isSwitch3Pos(0));
|
||||
setupSwitchType(1, ui->sbLabel, ui->sbName, ui->sbType, isSwitch3Pos(1));
|
||||
setupSwitchType(2, ui->scLabel, ui->scName, ui->scType, isSwitch3Pos(2));
|
||||
setupSwitchType(3, ui->sdLabel, ui->sdName, ui->sdType, isSwitch3Pos(3));
|
||||
setupSwitchType(4, ui->seLabel, ui->seName, ui->seType, isSwitch3Pos(4));
|
||||
setupSwitchType(5, ui->sfLabel, ui->sfName, ui->sfType, isSwitch3Pos(5));
|
||||
setupSwitchType(6, ui->sgLabel, ui->sgName, ui->sgType, isSwitch3Pos(6));
|
||||
setupSwitchType(7, ui->shLabel, ui->shName, ui->shType, isSwitch3Pos(7));
|
||||
setupSwitchType(8, ui->siLabel, ui->siName, ui->siType, isSwitch3Pos(8));
|
||||
setupSwitchType(9, ui->sjLabel, ui->sjName, ui->sjType, isSwitch3Pos(9));
|
||||
setupSwitchType(10, ui->skLabel, ui->skName, ui->skType); // Here starts X9E, only 3 switches
|
||||
setupSwitchType(11, ui->slLabel, ui->slName, ui->slType);
|
||||
setupSwitchType(12, ui->smLabel, ui->smName, ui->smType);
|
||||
setupSwitchType(13, ui->snLabel, ui->snName, ui->snType);
|
||||
|
||||
@@ -63,6 +63,7 @@ class HardwarePanel : public GeneralPanel
|
||||
Ui::Hardware *ui;
|
||||
|
||||
void setValues();
|
||||
bool isSwitch3Pos(int idx);
|
||||
};
|
||||
|
||||
#endif // _HARDWARE_H_
|
||||
|
||||
Reference in New Issue
Block a user