mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-03 11:24:10 +01:00
LP-235 Changed the contents and logic of the Failsafe flight mode setting.
Uncrustification.
This commit is contained in:
parent
f4b3b89953
commit
1dd5b3e246
@ -242,6 +242,8 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
|
|||||||
connect(ui->failsafeFlightMode, SIGNAL(currentIndexChanged(int)), this, SLOT(failsafeFlightModeChanged(int)));
|
connect(ui->failsafeFlightMode, SIGNAL(currentIndexChanged(int)), this, SLOT(failsafeFlightModeChanged(int)));
|
||||||
connect(ui->failsafeFlightModeCb, SIGNAL(toggled(bool)), this, SLOT(failsafeFlightModeCbToggled(bool)));
|
connect(ui->failsafeFlightModeCb, SIGNAL(toggled(bool)), this, SLOT(failsafeFlightModeCbToggled(bool)));
|
||||||
|
|
||||||
|
connect(this, SIGNAL(enableControlsChanged(bool)), this, SLOT(enableControlsChanged(bool)));
|
||||||
|
|
||||||
addWidget(ui->configurationWizard);
|
addWidget(ui->configurationWizard);
|
||||||
addWidget(ui->runCalibration);
|
addWidget(ui->runCalibration);
|
||||||
addWidget(ui->failsafeFlightModeCb);
|
addWidget(ui->failsafeFlightModeCb);
|
||||||
@ -440,7 +442,9 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
|
|||||||
void ConfigInputWidget::buildOptionComboBox(QComboBox *combo, UAVObjectField *field, int index, bool applyLimits)
|
void ConfigInputWidget::buildOptionComboBox(QComboBox *combo, UAVObjectField *field, int index, bool applyLimits)
|
||||||
{
|
{
|
||||||
if (combo == ui->failsafeFlightMode) {
|
if (combo == ui->failsafeFlightMode) {
|
||||||
ConfigTaskWidget::buildOptionComboBox(combo, flightModeSettingsObj->getField("FlightModePosition"), index, applyLimits);
|
for (int i = 0; i < 6; i++) {
|
||||||
|
ui->failsafeFlightMode->addItem(QString("Position %1").arg(i + 1), QVariant(i));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ConfigTaskWidget::buildOptionComboBox(combo, field, index, applyLimits);
|
ConfigTaskWidget::buildOptionComboBox(combo, field, index, applyLimits);
|
||||||
}
|
}
|
||||||
@ -1735,6 +1739,11 @@ void ConfigInputWidget::highlightStabilizationMode(int pos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setComboBoxItemEnabled(QComboBox *combo, int index, bool enabled = true)
|
||||||
|
{
|
||||||
|
combo->setItemData(index, enabled ? QVariant(1 | 32) : QVariant(0), Qt::UserRole - 1);
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigInputWidget::updatePositionSlider()
|
void ConfigInputWidget::updatePositionSlider()
|
||||||
{
|
{
|
||||||
ManualControlSettings::DataFields manualSettingsDataPriv = manualSettingsObj->getData();
|
ManualControlSettings::DataFields manualSettingsDataPriv = manualSettingsObj->getData();
|
||||||
@ -1745,31 +1754,37 @@ void ConfigInputWidget::updatePositionSlider()
|
|||||||
ui->fmsModePos6->setEnabled(true);
|
ui->fmsModePos6->setEnabled(true);
|
||||||
ui->pidBankSs1_5->setEnabled(true);
|
ui->pidBankSs1_5->setEnabled(true);
|
||||||
ui->assistControlPos6->setEnabled(true);
|
ui->assistControlPos6->setEnabled(true);
|
||||||
|
setComboBoxItemEnabled(ui->failsafeFlightMode, 5);
|
||||||
// pass through
|
// pass through
|
||||||
case 5:
|
case 5:
|
||||||
ui->fmsModePos5->setEnabled(true);
|
ui->fmsModePos5->setEnabled(true);
|
||||||
ui->pidBankSs1_4->setEnabled(true);
|
ui->pidBankSs1_4->setEnabled(true);
|
||||||
ui->assistControlPos5->setEnabled(true);
|
ui->assistControlPos5->setEnabled(true);
|
||||||
|
setComboBoxItemEnabled(ui->failsafeFlightMode, 4);
|
||||||
// pass through
|
// pass through
|
||||||
case 4:
|
case 4:
|
||||||
ui->fmsModePos4->setEnabled(true);
|
ui->fmsModePos4->setEnabled(true);
|
||||||
ui->pidBankSs1_3->setEnabled(true);
|
ui->pidBankSs1_3->setEnabled(true);
|
||||||
ui->assistControlPos4->setEnabled(true);
|
ui->assistControlPos4->setEnabled(true);
|
||||||
|
setComboBoxItemEnabled(ui->failsafeFlightMode, 3);
|
||||||
// pass through
|
// pass through
|
||||||
case 3:
|
case 3:
|
||||||
ui->fmsModePos3->setEnabled(true);
|
ui->fmsModePos3->setEnabled(true);
|
||||||
ui->pidBankSs1_2->setEnabled(true);
|
ui->pidBankSs1_2->setEnabled(true);
|
||||||
ui->assistControlPos3->setEnabled(true);
|
ui->assistControlPos3->setEnabled(true);
|
||||||
|
setComboBoxItemEnabled(ui->failsafeFlightMode, 2);
|
||||||
// pass through
|
// pass through
|
||||||
case 2:
|
case 2:
|
||||||
ui->fmsModePos2->setEnabled(true);
|
ui->fmsModePos2->setEnabled(true);
|
||||||
ui->pidBankSs1_1->setEnabled(true);
|
ui->pidBankSs1_1->setEnabled(true);
|
||||||
ui->assistControlPos2->setEnabled(true);
|
ui->assistControlPos2->setEnabled(true);
|
||||||
|
setComboBoxItemEnabled(ui->failsafeFlightMode, 1);
|
||||||
// pass through
|
// pass through
|
||||||
case 1:
|
case 1:
|
||||||
ui->fmsModePos1->setEnabled(true);
|
ui->fmsModePos1->setEnabled(true);
|
||||||
ui->pidBankSs1_0->setEnabled(true);
|
ui->pidBankSs1_0->setEnabled(true);
|
||||||
ui->assistControlPos1->setEnabled(true);
|
ui->assistControlPos1->setEnabled(true);
|
||||||
|
setComboBoxItemEnabled(ui->failsafeFlightMode, 0);
|
||||||
// pass through
|
// pass through
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
@ -1780,31 +1795,37 @@ void ConfigInputWidget::updatePositionSlider()
|
|||||||
ui->fmsModePos1->setEnabled(false);
|
ui->fmsModePos1->setEnabled(false);
|
||||||
ui->pidBankSs1_0->setEnabled(false);
|
ui->pidBankSs1_0->setEnabled(false);
|
||||||
ui->assistControlPos1->setEnabled(false);
|
ui->assistControlPos1->setEnabled(false);
|
||||||
|
setComboBoxItemEnabled(ui->failsafeFlightMode, 0, false);
|
||||||
// pass through
|
// pass through
|
||||||
case 1:
|
case 1:
|
||||||
ui->fmsModePos2->setEnabled(false);
|
ui->fmsModePos2->setEnabled(false);
|
||||||
ui->pidBankSs1_1->setEnabled(false);
|
ui->pidBankSs1_1->setEnabled(false);
|
||||||
ui->assistControlPos2->setEnabled(false);
|
ui->assistControlPos2->setEnabled(false);
|
||||||
|
setComboBoxItemEnabled(ui->failsafeFlightMode, 1, false);
|
||||||
// pass through
|
// pass through
|
||||||
case 2:
|
case 2:
|
||||||
ui->fmsModePos3->setEnabled(false);
|
ui->fmsModePos3->setEnabled(false);
|
||||||
ui->pidBankSs1_2->setEnabled(false);
|
ui->pidBankSs1_2->setEnabled(false);
|
||||||
ui->assistControlPos3->setEnabled(false);
|
ui->assistControlPos3->setEnabled(false);
|
||||||
|
setComboBoxItemEnabled(ui->failsafeFlightMode, 2, false);
|
||||||
// pass through
|
// pass through
|
||||||
case 3:
|
case 3:
|
||||||
ui->fmsModePos4->setEnabled(false);
|
ui->fmsModePos4->setEnabled(false);
|
||||||
ui->pidBankSs1_3->setEnabled(false);
|
ui->pidBankSs1_3->setEnabled(false);
|
||||||
ui->assistControlPos4->setEnabled(false);
|
ui->assistControlPos4->setEnabled(false);
|
||||||
|
setComboBoxItemEnabled(ui->failsafeFlightMode, 3, false);
|
||||||
// pass through
|
// pass through
|
||||||
case 4:
|
case 4:
|
||||||
ui->fmsModePos5->setEnabled(false);
|
ui->fmsModePos5->setEnabled(false);
|
||||||
ui->pidBankSs1_4->setEnabled(false);
|
ui->pidBankSs1_4->setEnabled(false);
|
||||||
ui->assistControlPos5->setEnabled(false);
|
ui->assistControlPos5->setEnabled(false);
|
||||||
|
setComboBoxItemEnabled(ui->failsafeFlightMode, 4, false);
|
||||||
// pass through
|
// pass through
|
||||||
case 5:
|
case 5:
|
||||||
ui->fmsModePos6->setEnabled(false);
|
ui->fmsModePos6->setEnabled(false);
|
||||||
ui->pidBankSs1_5->setEnabled(false);
|
ui->pidBankSs1_5->setEnabled(false);
|
||||||
ui->assistControlPos6->setEnabled(false);
|
ui->assistControlPos6->setEnabled(false);
|
||||||
|
setComboBoxItemEnabled(ui->failsafeFlightMode, 5, false);
|
||||||
// pass through
|
// pass through
|
||||||
case 6:
|
case 6:
|
||||||
default:
|
default:
|
||||||
@ -2083,3 +2104,8 @@ void ConfigInputWidget::failsafeFlightModeCbToggled(bool checked)
|
|||||||
{
|
{
|
||||||
ui->failsafeFlightMode->setCurrentIndex(checked ? 0 : -1);
|
ui->failsafeFlightMode->setCurrentIndex(checked ? 0 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigInputWidget::enableControlsChanged(bool enabled)
|
||||||
|
{
|
||||||
|
ui->failsafeFlightMode->setEnabled(enabled && ui->failsafeFlightMode->currentIndex() != -1);
|
||||||
|
}
|
||||||
|
@ -230,6 +230,7 @@ private slots:
|
|||||||
|
|
||||||
void failsafeFlightModeChanged(int index);
|
void failsafeFlightModeChanged(int index);
|
||||||
void failsafeFlightModeCbToggled(bool checked);
|
void failsafeFlightModeCbToggled(bool checked);
|
||||||
|
void enableControlsChanged(bool enabled);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
Loading…
Reference in New Issue
Block a user