1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +01:00

LP-446 - Settings GUI for battery alarm failsafe

This commit is contained in:
Alessio Morale 2016-11-04 01:07:45 +01:00 committed by Philippe Renon
parent 45eb52fcd8
commit e10faa4c42
3 changed files with 120 additions and 5 deletions

View File

@ -177,6 +177,9 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
addWidgetBinding("ManualControlSettings", "FailsafeFlightModeSwitchPosition", ui->failsafeFlightMode, 0, 1, true, new QList<int>(failsafeReloadGroup));
addWidgetBinding("FlightModeSettings", "BatteryFailsafeSwitchPositions", ui->failsafeBatteryWarningFlightMode, 0, 1, true, new QList<int>(failsafeReloadGroup));
addWidgetBinding("FlightModeSettings", "BatteryFailsafeSwitchPositions", ui->failsafeBatteryCriticalFlightMode, 1, 1, true, new QList<int>(failsafeReloadGroup));
// Generate the rows for the failsafe channel form GUI
index = 0;
foreach(QString name, manualSettingsObj->getField("FailsafeChannel")->getElementNames()) {
@ -252,6 +255,13 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
connect(ui->failsafeFlightMode, SIGNAL(currentIndexChanged(int)), this, SLOT(failsafeFlightModeChanged(int)));
connect(ui->failsafeFlightModeCb, SIGNAL(toggled(bool)), this, SLOT(failsafeFlightModeCbToggled(bool)));
connect(ui->failsafeBatteryWarningFlightMode, SIGNAL(currentIndexChanged(int)), this, SLOT(failsafeBatteryWarningFlightModeChanged(int)));
connect(ui->failsafeBatteryWarningFlightModeCb, SIGNAL(toggled(bool)), this, SLOT(failsafeBatteryWarningFlightModeCbToggled(bool)));
connect(ui->failsafeBatteryCriticalFlightMode, SIGNAL(currentIndexChanged(int)), this, SLOT(failsafeBatteryCriticalFlightModeChanged(int)));
connect(ui->failsafeBatteryCriticalFlightModeCb, SIGNAL(toggled(bool)), this, SLOT(failsafeBatteryCriticalFlightModeCbToggled(bool)));
addWidget(ui->configurationWizard);
addWidget(ui->runCalibration);
addWidget(ui->failsafeFlightModeCb);
@ -448,9 +458,9 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
void ConfigInputWidget::buildOptionComboBox(QComboBox *combo, UAVObjectField *field, int index, bool applyLimits)
{
if (combo == ui->failsafeFlightMode) {
if (combo == ui->failsafeFlightMode || combo == ui->failsafeBatteryCriticalFlightMode || combo == ui->failsafeBatteryWarningFlightMode) {
for (quint32 i = 0; i < FlightModeSettings::FLIGHTMODEPOSITION_NUMELEM; i++) {
ui->failsafeFlightMode->addItem(QString("Position %1").arg(i + 1), QVariant(i));
combo->addItem(QString("Position %1").arg(i + 1), QVariant(i));
}
} else {
ConfigTaskWidget::buildOptionComboBox(combo, field, index, applyLimits);
@ -2175,6 +2185,17 @@ void ConfigInputWidget::updateReceiverActivityStatus()
}
}
void ConfigInputWidget::failsafeBatteryWarningFlightModeChanged(int index)
{
ui->failsafeBatteryWarningFlightMode->setEnabled(index != -1);
ui->failsafeBatteryWarningFlightModeCb->setChecked(index != -1);
}
void ConfigInputWidget::failsafeBatteryCriticalFlightModeChanged(int index)
{
ui->failsafeBatteryCriticalFlightMode->setEnabled(index != -1);
ui->failsafeBatteryCriticalFlightModeCb->setChecked(index != -1);
}
void ConfigInputWidget::failsafeFlightModeChanged(int index)
{
ui->failsafeFlightMode->setEnabled(index != -1);
@ -2186,6 +2207,16 @@ void ConfigInputWidget::failsafeFlightModeCbToggled(bool checked)
ui->failsafeFlightMode->setCurrentIndex(checked ? 0 : -1);
}
void ConfigInputWidget::failsafeBatteryWarningFlightModeCbToggled(bool checked)
{
ui->failsafeBatteryWarningFlightMode->setCurrentIndex(checked ? 0 : -1);
}
void ConfigInputWidget::failsafeBatteryCriticalFlightModeCbToggled(bool checked)
{
ui->failsafeBatteryCriticalFlightMode->setCurrentIndex(checked ? 0 : -1);
}
void ConfigInputWidget::enableControlsChanged(bool enabled)
{
ui->failsafeFlightMode->setEnabled(enabled && (ui->failsafeFlightMode->currentIndex() != -1));

View File

@ -232,6 +232,10 @@ private slots:
void failsafeFlightModeChanged(int index);
void failsafeFlightModeCbToggled(bool checked);
void failsafeBatteryWarningFlightModeChanged(int index);
void failsafeBatteryWarningFlightModeCbToggled(bool checked);
void failsafeBatteryCriticalFlightModeChanged(int index);
void failsafeBatteryCriticalFlightModeCbToggled(bool checked);
void enableControlsChanged(bool enabled);
protected:

View File

@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="RCInput">
<attribute name="title">
@ -2358,6 +2358,86 @@ font:bold;</string>
<number>6</number>
</property>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_b2">
<item>
<widget class="QCheckBox" name="failsafeBatteryWarningFlightModeCb">
<property name="text">
<string>On Battery Warning alarm change flight mode to:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="failsafeBatteryWarningFlightMode">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>When triggering battery Warning alarm switch to this flight mode.</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_B28">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_b1">
<item>
<widget class="QCheckBox" name="failsafeBatteryCriticalFlightModeCb">
<property name="text">
<string>On Battery Critical alarm change flight mode to:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="failsafeBatteryCriticalFlightMode">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>When triggering battery Critical alarm switch to this flight mode.</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_B18">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="failsafeFlightModeCb">
@ -2411,14 +2491,14 @@ font:bold;</string>
</item>
</layout>
</item>
<item row="3" column="0">
<item row="5" column="0">
<layout class="QGridLayout" name="failsafeChannelsLayout">
<property name="topMargin">
<number>10</number>
</property>
</layout>
</item>
<item row="2" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Channel input settings on failsafe:</string>