1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

LP-446 - fixes from review

This commit is contained in:
Alessio Morale 2016-12-06 01:00:02 +01:00 committed by Philippe Renon
parent e10faa4c42
commit dbbc0f0ed0
6 changed files with 166 additions and 172 deletions

View File

@ -568,6 +568,7 @@ void HandleBatteryFailsafe(uint8_t *position, FlightModeSettingsData *modeSettin
break;
default:
failsafeStatus = BATTERYFAILSAFE_NONE;
break;
}
uint32_t debounceTimerms = PIOS_DELAY_DiffuS(changeTimestamp) / 1000;

View File

@ -100,7 +100,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
rssiDesiredObj4 = AccessoryDesired::GetInstance(getObjectManager(), 4);
actuatorSettingsObj = ActuatorSettings::GetInstance(getObjectManager());
systemSettingsObj = SystemSettings::GetInstance(getObjectManager());
hwSettingsObj = HwSettings::GetInstance(getObjectManager());
// Only instance 0 is present if the board is not connected.
// The other instances are populated lazily.
Q_ASSERT(accessoryDesiredObj0);
@ -265,6 +265,8 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
addWidget(ui->configurationWizard);
addWidget(ui->runCalibration);
addWidget(ui->failsafeFlightModeCb);
addWidget(ui->failsafeBatteryWarningFlightModeCb);
addWidget(ui->failsafeBatteryCriticalFlightModeCb);
// Wizard
wizardUi = new Ui_InputWizardWidget();
@ -1797,88 +1799,40 @@ void ConfigInputWidget::updatePositionSlider()
{
ManualControlSettings::DataFields manualSettingsDataPriv = manualSettingsObj->getData();
switch (manualSettingsDataPriv.FlightModeNumber) {
default:
case 6:
ui->fmsModePos6->setEnabled(true);
ui->pidBankSs1_5->setEnabled(true);
ui->assistControlPos6->setEnabled(true);
setComboBoxItemEnabled(ui->failsafeFlightMode, 5);
// pass through
case 5:
ui->fmsModePos5->setEnabled(true);
ui->pidBankSs1_4->setEnabled(true);
ui->assistControlPos5->setEnabled(true);
setComboBoxItemEnabled(ui->failsafeFlightMode, 4);
// pass through
case 4:
ui->fmsModePos4->setEnabled(true);
ui->pidBankSs1_3->setEnabled(true);
ui->assistControlPos4->setEnabled(true);
setComboBoxItemEnabled(ui->failsafeFlightMode, 3);
// pass through
case 3:
ui->fmsModePos3->setEnabled(true);
ui->pidBankSs1_2->setEnabled(true);
ui->assistControlPos3->setEnabled(true);
setComboBoxItemEnabled(ui->failsafeFlightMode, 2);
// pass through
case 2:
ui->fmsModePos2->setEnabled(true);
ui->pidBankSs1_1->setEnabled(true);
ui->assistControlPos2->setEnabled(true);
setComboBoxItemEnabled(ui->failsafeFlightMode, 1);
// pass through
case 1:
ui->fmsModePos1->setEnabled(true);
ui->pidBankSs1_0->setEnabled(true);
ui->assistControlPos1->setEnabled(true);
setComboBoxItemEnabled(ui->failsafeFlightMode, 0);
// pass through
case 0:
break;
}
QWidget *fmodes[] = {
ui->fmsModePos1,
ui->fmsModePos2,
ui->fmsModePos3,
ui->fmsModePos4,
ui->fmsModePos5,
ui->fmsModePos6
};
QWidget *pidbanks[] = {
ui->pidBankSs1_0,
ui->pidBankSs1_1,
ui->pidBankSs1_2,
ui->pidBankSs1_3,
ui->pidBankSs1_4,
ui->pidBankSs1_5
};
QWidget *assisstecontrols[] = {
ui->assistControlPos1,
ui->assistControlPos2,
ui->assistControlPos3,
ui->assistControlPos4,
ui->assistControlPos5,
ui->assistControlPos6
};
switch (manualSettingsDataPriv.FlightModeNumber) {
case 0:
ui->fmsModePos1->setEnabled(false);
ui->pidBankSs1_0->setEnabled(false);
ui->assistControlPos1->setEnabled(false);
setComboBoxItemEnabled(ui->failsafeFlightMode, 0, false);
// pass through
case 1:
ui->fmsModePos2->setEnabled(false);
ui->pidBankSs1_1->setEnabled(false);
ui->assistControlPos2->setEnabled(false);
setComboBoxItemEnabled(ui->failsafeFlightMode, 1, false);
// pass through
case 2:
ui->fmsModePos3->setEnabled(false);
ui->pidBankSs1_2->setEnabled(false);
ui->assistControlPos3->setEnabled(false);
setComboBoxItemEnabled(ui->failsafeFlightMode, 2, false);
// pass through
case 3:
ui->fmsModePos4->setEnabled(false);
ui->pidBankSs1_3->setEnabled(false);
ui->assistControlPos4->setEnabled(false);
setComboBoxItemEnabled(ui->failsafeFlightMode, 3, false);
// pass through
case 4:
ui->fmsModePos5->setEnabled(false);
ui->pidBankSs1_4->setEnabled(false);
ui->assistControlPos5->setEnabled(false);
setComboBoxItemEnabled(ui->failsafeFlightMode, 4, false);
// pass through
case 5:
ui->fmsModePos6->setEnabled(false);
ui->pidBankSs1_5->setEnabled(false);
ui->assistControlPos6->setEnabled(false);
setComboBoxItemEnabled(ui->failsafeFlightMode, 5, false);
// pass through
case 6:
default:
break;
for (quint32 i = 0; i < FlightModeSettings::FLIGHTMODEPOSITION_NUMELEM; i++) {
bool enabled = i < manualSettingsDataPriv.FlightModeNumber;
fmodes[i]->setEnabled(enabled);
pidbanks[i]->setEnabled(enabled);
assisstecontrols[i]->setEnabled(enabled);
setComboBoxItemEnabled(ui->failsafeFlightMode, i, enabled);
setComboBoxItemEnabled(ui->failsafeBatteryCriticalFlightMode, i, enabled);
setComboBoxItemEnabled(ui->failsafeBatteryWarningFlightMode, i, enabled);
}
QString fmNumber = QString().setNum(manualSettingsDataPriv.FlightModeNumber);
@ -2187,12 +2141,19 @@ void ConfigInputWidget::updateReceiverActivityStatus()
void ConfigInputWidget::failsafeBatteryWarningFlightModeChanged(int index)
{
ui->failsafeBatteryWarningFlightMode->setEnabled(index != -1);
hwSettingsData = hwSettingsObj->getData();
bool batteryModuleEnabled = (hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_BATTERY] == HwSettings::OPTIONALMODULES_ENABLED);
ui->failsafeBatteryWarningFlightMode->setEnabled(batteryModuleEnabled && index != -1);
ui->failsafeBatteryWarningFlightModeCb->setChecked(index != -1);
}
void ConfigInputWidget::failsafeBatteryCriticalFlightModeChanged(int index)
{
ui->failsafeBatteryCriticalFlightMode->setEnabled(index != -1);
hwSettingsData = hwSettingsObj->getData();
bool batteryModuleEnabled = (hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_BATTERY] == HwSettings::OPTIONALMODULES_ENABLED);
ui->failsafeBatteryCriticalFlightMode->setEnabled(batteryModuleEnabled && index != -1);
ui->failsafeBatteryCriticalFlightModeCb->setChecked(index != -1);
}
@ -2219,5 +2180,12 @@ void ConfigInputWidget::failsafeBatteryCriticalFlightModeCbToggled(bool checked)
void ConfigInputWidget::enableControlsChanged(bool enabled)
{
ui->failsafeFlightMode->setEnabled(enabled && (ui->failsafeFlightMode->currentIndex() != -1));
ui->failsafeFlightMode->setEnabled(enabled && ui->failsafeFlightMode->currentIndex() != -1);
hwSettingsData = hwSettingsObj->getData();
bool batteryModuleEnabled = (hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_BATTERY] == HwSettings::OPTIONALMODULES_ENABLED);
ui->failsafeBatteryWarningFlightMode->setEnabled(batteryModuleEnabled && enabled && ui->failsafeBatteryWarningFlightMode->currentIndex() != -1);
ui->failsafeBatteryCriticalFlightMode->setEnabled(batteryModuleEnabled && enabled && ui->failsafeBatteryCriticalFlightMode->currentIndex() != -1);
ui->failsafeBatteryWarningFlightModeCb->setEnabled(enabled && batteryModuleEnabled);
ui->failsafeBatteryCriticalFlightModeCb->setEnabled(enabled && batteryModuleEnabled);
}

View File

@ -41,7 +41,7 @@
#include "flightstatus.h"
#include "accessorydesired.h"
#include "systemsettings.h"
#include "hwsettings.h"
#include <QPointer>
#include <QWidget>
#include <QList>
@ -145,6 +145,9 @@ private:
SystemSettings *systemSettingsObj;
SystemSettings::DataFields systemSettingsData;
HwSettings *hwSettingsObj;
HwSettings::DataFields hwSettingsData;
typedef struct {
ManualControlSettings::DataFields manualSettingsData;
ActuatorSettings::DataFields actuatorSettingsData;

View File

@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="RCInput">
<attribute name="title">
@ -2336,6 +2336,106 @@ font:bold;</string>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_b8">
<property name="title">
<string>Battery Failsafe Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_b12">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="1" column="0">
<layout class="QGridLayout" name="horizontalLayout_b2">
<item row="1" column="0">
<widget class="QCheckBox" name="failsafeBatteryWarningFlightModeCb">
<property name="text">
<string>On battery warning alarm change flight mode to:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<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 row="1" column="2">
<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>
<item row="2" column="0">
<widget class="QCheckBox" name="failsafeBatteryCriticalFlightModeCb">
<property name="text">
<string>On battery critical alarm change flight mode to:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<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 row="2" column="2">
<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>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
@ -2358,86 +2458,6 @@ 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">
@ -2491,14 +2511,14 @@ font:bold;</string>
</item>
</layout>
</item>
<item row="5" column="0">
<item row="3" column="0">
<layout class="QGridLayout" name="failsafeChannelsLayout">
<property name="topMargin">
<number>10</number>
</property>
</layout>
</item>
<item row="4" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Channel input settings on failsafe:</string>
@ -2548,7 +2568,9 @@ font:bold;</string>
</property>
<property name="plainText">
<string>Failsafe is a function that is triggered when the connection between the transmitter and receiver is lost. Failsafe gives the user a chance to configure some basic behaviour and specify what input the flight controller should get even if no control signals from the transmitter is present.
The failsafe is triggered differently for different receivers. Failsafe should always be tested before every flight.</string>
The failsafe is triggered differently for different receivers. Failsafe should always be tested before every flight.
Battery Failsafe triggers the selected flight modes as soon as the related alarm is raised. It needs Battery module enabled and configured. It is not available on CC3D.</string>
</property>
<property name="backgroundVisible">
<bool>false</bool>

View File

@ -5,7 +5,7 @@
<field name="Type" units="" type="enum" elements="1" options="LiPo,A123,LiCo,LiFeSO4,None" defaultvalue="LiPo"/>
<field name="NbCells" units="" type="uint8" elements="1" defaultvalue="0"/>
<field name="Capacity" units="mAh" type="uint32" elements="1" defaultvalue="0"/>
<field name="CellVoltageThresholds" units="V" type="float" elementnames="Warning, Critical" defaultvalue="3.8,3.5"/>
<field name="CellVoltageThresholds" units="V" type="float" elementnames="Warning, Critical" defaultvalue="3.4,3.1"/>
<field name="SensorCalibrations" units="" type="float" elementnames="VoltageFactor, CurrentFactor, VoltageZero, CurrentZero" defaultvalue="1.0, 1.0, 0.0, 0.0"/>
<field name="ResetConsumedEnergy" units="bool" type="enum" elements="1" options="False,True" defaultvalue="False"/>
<access gcs="readwrite" flight="readwrite"/>

View File

@ -95,7 +95,7 @@
<field name="AutoTakeOffHeight" units="m" type="float" elements="1" defaultvalue="2.5" description="height in meters above arming altitude to climb to during autotakeoff"/>
<field name="PositionHoldOffset" units="m" type="float" elementnames="Horizontal,Vertical" defaultvalue="30,15" description="stick sensitivity for position roam modes"/>
<field name="VarioControlLowPassAlpha" units="" type="float" elements="1" defaultvalue="0.98" description="stick low pass filter for position roam modes"/>
<field name="BatteryFailsafeSwitchPositions" units="" type="int8" elementnames="Warning,Critical" defaultvalue="-1" />
<field name="BatteryFailsafeSwitchPositions" units="" type="int8" elementnames="Warning,Critical" defaultvalue="-1" />
<field name="FlightModeChangeRestartsPathPlan" units="bool" type="enum" elements="1" options="False,True" defaultvalue="True" description="wether a path plan should continue when interrupted by flight mode change (False), or restart from waypoint 0 (True)"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>