1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Merged in m_thread/librepilot/thread/LP-235_Failsafe_Settings_GUI (pull request #187)

LP-235 Failsafe settings GUI
This commit is contained in:
Fredrik Arvidsson 2016-03-03 08:53:51 +01:00
commit 044c357be8
11 changed files with 729 additions and 53 deletions

View File

@ -58,7 +58,8 @@ HEADERS += \
calibration/gyrobiascalibrationmodel.h \
calibration/calibrationuiutils.h \
configoplinkwidget.h \
configrevonanohwwidget.h
configrevonanohwwidget.h \
failsafechannelform.h
SOURCES += \
configplugin.cpp \
@ -99,7 +100,8 @@ SOURCES += \
calibration/levelcalibrationmodel.cpp \
calibration/gyrobiascalibrationmodel.cpp \
configoplinkwidget.cpp \
configrevonanohwwidget.cpp
configrevonanohwwidget.cpp \
failsafechannelform.cpp
FORMS += \
airframe.ui \
@ -124,6 +126,7 @@ FORMS += \
mixercurve.ui \
configrevohwwidget.ui \
oplink.ui \
configrevonanohwwidget.ui
configrevonanohwwidget.ui \
failsafechannelform.ui
RESOURCES += configgadget.qrc

View File

@ -42,6 +42,10 @@
#include <QMessageBox>
#include <utils/stylehelper.h>
#include <QMessageBox>
#include "inputchannelform.h"
#include "ui_inputchannelform.h"
#include "failsafechannelform.h"
#include "ui_failsafechannelform.h"
#define ACCESS_MIN_MOVE -3
#define ACCESS_MAX_MOVE 3
@ -101,37 +105,39 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
addApplySaveButtons(ui->saveRCInputToRAM, ui->saveRCInputToSD);
// Generate the rows of buttons in the input channel form GUI
unsigned int index = 0;
unsigned int indexRT = 0;
quint32 index = 0;
quint32 indexRT = 0;
foreach(QString name, manualSettingsObj->getField("ChannelNumber")->getElementNames()) {
Q_ASSERT(index < ManualControlSettings::CHANNELGROUPS_NUMELEM);
InputChannelForm *form = new InputChannelForm(index, this);
form->setName(name);
form->moveTo(*(ui->channelLayout));
// Input channel setup
InputChannelForm *inputChannelForm = new InputChannelForm(index, this);
inputChannelForm->setName(name);
inputChannelForm->moveTo(*(ui->channelLayout));
// The order of the following binding calls is important. Since the values will be populated
// in reverse order of the binding order otherwise the 'Reversed' logic will floor the neutral value
// to the max value ( which is smaller than the neutral value when reversed ) and the channel number
// will not be set correctly.
addWidgetBinding("ManualControlSettings", "ChannelNumber", form->ui->channelNumber, index);
addWidgetBinding("ManualControlSettings", "ChannelGroups", form->ui->channelGroup, index);
addWidgetBinding("ManualControlSettings", "ChannelNumber", inputChannelForm->ui->channelNumber, index);
addWidgetBinding("ManualControlSettings", "ChannelGroups", inputChannelForm->ui->channelGroup, index);
// Slider position based on real time Rcinput (allow monitoring)
addWidgetBinding("ManualControlCommand", "Channel", form->ui->channelNeutral, index);
addWidgetBinding("ManualControlCommand", "Channel", inputChannelForm->ui->channelNeutral, index);
// Neutral value stored on board (SpinBox)
addWidgetBinding("ManualControlSettings", "ChannelNeutral", form->ui->neutralValue, index);
addWidgetBinding("ManualControlSettings", "ChannelMax", form->ui->channelMax, index);
addWidgetBinding("ManualControlSettings", "ChannelMin", form->ui->channelMin, index);
addWidgetBinding("ManualControlSettings", "ChannelMax", form->ui->channelMax, index);
addWidgetBinding("ManualControlSettings", "ChannelNeutral", inputChannelForm->ui->neutralValue, index);
addWidgetBinding("ManualControlSettings", "ChannelMax", inputChannelForm->ui->channelMax, index);
addWidgetBinding("ManualControlSettings", "ChannelMin", inputChannelForm->ui->channelMin, index);
addWidgetBinding("ManualControlSettings", "ChannelMax", inputChannelForm->ui->channelMax, index);
addWidget(form->ui->channelRev);
addWidget(inputChannelForm->ui->channelRev);
// Reversing supported for some channels only
bool reversable = ((index == ManualControlSettings::CHANNELGROUPS_THROTTLE) ||
(index == ManualControlSettings::CHANNELGROUPS_ROLL) ||
(index == ManualControlSettings::CHANNELGROUPS_PITCH) ||
(index == ManualControlSettings::CHANNELGROUPS_YAW));
form->ui->channelRev->setVisible(reversable);
inputChannelForm->ui->channelRev->setVisible(reversable);
// Input filter response time fields supported for some channels only
switch (index) {
@ -143,21 +149,40 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
case ManualControlSettings::CHANNELGROUPS_ACCESSORY1:
case ManualControlSettings::CHANNELGROUPS_ACCESSORY2:
case ManualControlSettings::CHANNELGROUPS_ACCESSORY3:
addWidgetBinding("ManualControlSettings", "ResponseTime", form->ui->channelResponseTime, indexRT);
addWidgetBinding("ManualControlSettings", "ResponseTime", inputChannelForm->ui->channelResponseTime, indexRT);
++indexRT;
break;
case ManualControlSettings::CHANNELGROUPS_THROTTLE:
case ManualControlSettings::CHANNELGROUPS_FLIGHTMODE:
form->ui->channelResponseTime->setVisible(false);
inputChannelForm->ui->channelResponseTime->setVisible(false);
break;
default:
Q_ASSERT(0);
break;
}
++index;
}
QList<int> failsafeReloadGroup;
failsafeReloadGroup.append(555);
addWidgetBinding("ManualControlSettings", "FailsafeFlightModeSwitchPosition", ui->failsafeFlightMode, 0, 1, true, new QList<int>(failsafeReloadGroup));
// Generate the rows for the failsafe channel form GUI
index = 0;
foreach(QString name, manualSettingsObj->getField("FailsafeChannel")->getElementNames()) {
Q_ASSERT(index < ManualControlSettings::FAILSAFECHANNEL_NUMELEM);
// Failsafe channels setup
FailsafeChannelForm *failsafeChannelForm = new FailsafeChannelForm(index, this);
addWidget(failsafeChannelForm->ui->channelValueSpinner);
failsafeChannelForm->setName(name);
failsafeChannelForm->moveTo(*(ui->failsafeChannelsLayout));
addWidgetBinding("ManualControlSettings", "FailsafeChannel", failsafeChannelForm->ui->channelValue, index, 0.01, true, new QList<int>(failsafeReloadGroup));
++index;
}
addWidget(ui->failsafeDefault);
addWidgetBinding("ManualControlSettings", "Deadband", ui->deadband, 0, 1);
addWidgetBinding("ManualControlSettings", "DeadbandAssistedControl", ui->assistedControlDeadband, 0, 1);
@ -170,13 +195,11 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
connect(wizardUi->wzBack, SIGNAL(clicked()), this, SLOT(wzBack()));
ui->stackedWidget->setCurrentIndex(0);
addWidgetBinding("FlightModeSettings", "FlightModePosition", ui->fmsModePos1, 0, 1, true);
addWidgetBinding("FlightModeSettings", "FlightModePosition", ui->fmsModePos2, 1, 1, true);
addWidgetBinding("FlightModeSettings", "FlightModePosition", ui->fmsModePos3, 2, 1, true);
addWidgetBinding("FlightModeSettings", "FlightModePosition", ui->fmsModePos4, 3, 1, true);
addWidgetBinding("FlightModeSettings", "FlightModePosition", ui->fmsModePos5, 4, 1, true);
addWidgetBinding("FlightModeSettings", "FlightModePosition", ui->fmsModePos6, 5, 1, true);
addWidgetBinding("ManualControlSettings", "FlightModeNumber", ui->fmsPosNum);
QList<QWidget*> widgets = QList<QWidget*>() << ui->fmsModePos1 << ui->fmsModePos2 << ui->fmsModePos3 <<
ui->fmsModePos4 << ui->fmsModePos5 << ui->fmsModePos6;
foreach(QWidget* widget, widgets) {
addWidgetBinding("FlightModeSettings", "FlightModePosition", widget, 0, 1, true);
}
addWidgetBinding("FlightModeSettings", "Stabilization1Settings", ui->fmsSsPos1Roll, "Roll", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization2Settings", ui->fmsSsPos2Roll, "Roll", 1, true);
@ -184,18 +207,21 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
addWidgetBinding("FlightModeSettings", "Stabilization4Settings", ui->fmsSsPos4Roll, "Roll", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization5Settings", ui->fmsSsPos5Roll, "Roll", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization6Settings", ui->fmsSsPos6Roll, "Roll", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization1Settings", ui->fmsSsPos1Pitch, "Pitch", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization2Settings", ui->fmsSsPos2Pitch, "Pitch", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization3Settings", ui->fmsSsPos3Pitch, "Pitch", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization4Settings", ui->fmsSsPos4Pitch, "Pitch", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization5Settings", ui->fmsSsPos5Pitch, "Pitch", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization6Settings", ui->fmsSsPos6Pitch, "Pitch", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization1Settings", ui->fmsSsPos1Yaw, "Yaw", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization2Settings", ui->fmsSsPos2Yaw, "Yaw", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization3Settings", ui->fmsSsPos3Yaw, "Yaw", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization4Settings", ui->fmsSsPos4Yaw, "Yaw", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization5Settings", ui->fmsSsPos5Yaw, "Yaw", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization6Settings", ui->fmsSsPos6Yaw, "Yaw", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization1Settings", ui->fmsSsPos1Thrust, "Thrust", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization2Settings", ui->fmsSsPos2Thrust, "Thrust", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization3Settings", ui->fmsSsPos3Thrust, "Thrust", 1, true);
@ -203,18 +229,25 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
addWidgetBinding("FlightModeSettings", "Stabilization5Settings", ui->fmsSsPos5Thrust, "Thrust", 1, true);
addWidgetBinding("FlightModeSettings", "Stabilization6Settings", ui->fmsSsPos6Thrust, "Thrust", 1, true);
addWidgetBinding("ManualControlSettings", "FlightModeNumber", ui->fmsPosNum);
addWidgetBinding("FlightModeSettings", "Arming", ui->armControl);
addWidgetBinding("FlightModeSettings", "ArmedTimeout", ui->armTimeout, 0, 1000);
connect(ManualControlCommand::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(moveFMSlider()));
connect(ManualControlSettings::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updatePositionSlider()));
connect(ui->failsafeFlightMode, SIGNAL(currentIndexChanged(int)), this, SLOT(failsafeFlightModeChanged(int)));
connect(ui->failsafeFlightModeCb, SIGNAL(toggled(bool)), this, SLOT(failsafeFlightModeCbToggled(bool)));
addWidget(ui->configurationWizard);
addWidget(ui->runCalibration);
addWidget(ui->failsafeFlightModeCb);
autoLoadWidgets();
populateWidgets();
refreshWidgetsValues();
// Connect the help button
connect(ui->inputHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
@ -401,6 +434,15 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
updateEnableControls();
}
void ConfigInputWidget::buildOptionComboBox(QComboBox *combo, UAVObjectField *field, int index, bool applyLimits)
{
if (combo == ui->failsafeFlightMode) {
ConfigTaskWidget::buildOptionComboBox(combo, flightModeSettingsObj->getField("FlightModePosition"), index, applyLimits);
} else {
ConfigTaskWidget::buildOptionComboBox(combo, field, index, applyLimits);
}
}
void ConfigInputWidget::resetTxControls()
{
m_txLeftStick->setTransform(m_txLeftStickOrig, false);
@ -1998,3 +2040,14 @@ void ConfigInputWidget::forceOneFlightMode()
manualSettingsData.FlightModeNumber = 1;
manualSettingsObj->setData(manualSettingsData);
}
void ConfigInputWidget::failsafeFlightModeChanged(int index)
{
ui->failsafeFlightMode->setEnabled(index != -1);
ui->failsafeFlightModeCb->setChecked(index != -1);
}
void ConfigInputWidget::failsafeFlightModeCbToggled(bool checked)
{
ui->failsafeFlightMode->setCurrentIndex(checked ? 0 : -1);
}

View File

@ -36,8 +36,6 @@
#include "uavobject.h"
#include <QWidget>
#include <QList>
#include "inputchannelform.h"
#include "ui_inputchannelform.h"
#include <QRadioButton>
#include "manualcontrolcommand.h"
#include "manualcontrolsettings.h"
@ -229,8 +227,12 @@ private slots:
void resetActuatorSettings();
void forceOneFlightMode();
void failsafeFlightModeChanged(int index);
void failsafeFlightModeCbToggled(bool checked);
protected:
void resizeEvent(QResizeEvent *event);
void buildOptionComboBox(QComboBox *combo, UAVObjectField *field, int index, bool applyLimits);
};
#endif // ifndef CONFIGINPUTWIDGET_H

View File

@ -107,6 +107,9 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa
addWidget(ui->pushButton_9);
addWidget(ui->pushButton_10);
addWidget(ui->pushButton_11);
addWidget(ui->pushButton_12);
addWidget(ui->pushButton_13);
addWidget(ui->pushButton_14);
addWidget(ui->pushButton_20);
addWidget(ui->pushButton_22);
addWidget(ui->pushButton_23);

View File

@ -0,0 +1,24 @@
#include "failsafechannelform.h"
#include "ui_failsafechannelform.h"
FailsafeChannelForm::FailsafeChannelForm(const int index, QWidget *parent) :
ChannelForm(index, parent), ui(new Ui::FailsafeChannelForm)
{
ui->setupUi(this);
disableMouseWheelEvents();
}
FailsafeChannelForm::~FailsafeChannelForm()
{
delete ui;
}
QString FailsafeChannelForm::name()
{
return ui->channelName->text();
}
void FailsafeChannelForm::setName(const QString &name)
{
ui->channelName->setText(name);
}

View File

@ -0,0 +1,29 @@
#ifndef FAILSAFECHANNELFORM_H
#define FAILSAFECHANNELFORM_H
#include "channelform.h"
#include "configinputwidget.h"
#include <QWidget>
namespace Ui {
class FailsafeChannelForm;
}
class FailsafeChannelForm : public ChannelForm {
Q_OBJECT
public:
explicit FailsafeChannelForm(const int index, QWidget *parent = NULL);
~FailsafeChannelForm();
friend class ConfigInputWidget;
virtual QString name();
virtual void setName(const QString &name);
private:
Ui::FailsafeChannelForm *ui;
};
#endif // FAILSAFECHANNELFORM_H

View File

@ -0,0 +1,284 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FailsafeChannelForm</class>
<widget class="QWidget" name="FailsafeChannelForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>993</width>
<height>57</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>12</number>
</property>
<item row="0" column="1">
<widget class="QLabel" name="legend4">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>Channel value</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
color: rgb(255, 255, 255);
border-radius: 5;
font: bold 12px;
margin:1px;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="text">
<string>Channel Value relative to channel Neutral</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="legend5">
<property name="toolTip">
<string>Channel value</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
color: rgb(255, 255, 255);
border-radius: 5;
font: bold 12px;
margin:1px;</string>
</property>
<property name="text">
<string>Value</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="TextBubbleSlider" name="channelValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Channel value in %</string>
</property>
<property name="accessibleName">
<string/>
</property>
<property name="accessibleDescription">
<string/>
</property>
<property name="inputMethodHints">
<set>Qt::ImhNone</set>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="channelValueSpinner">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="suffix">
<string>%</string>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="legend0">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>Channel function</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
color: rgb(255, 255, 255);
border-radius: 5;
font: bold 12px;
margin:1px;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="text">
<string>Function</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="channelName">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Text</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>TextBubbleSlider</class>
<extends>QSlider</extends>
<header>utils/textbubbleslider.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>channelValue</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>channelValue</sender>
<signal>valueChanged(int)</signal>
<receiver>channelValueSpinner</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>530</x>
<y>43</y>
</hint>
<hint type="destinationlabel">
<x>965</x>
<y>43</y>
</hint>
</hints>
</connection>
<connection>
<sender>channelValueSpinner</sender>
<signal>valueChanged(int)</signal>
<receiver>channelValue</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>965</x>
<y>43</y>
</hint>
<hint type="destinationlabel">
<x>530</x>
<y>43</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -21,7 +21,7 @@
</property>
<widget class="QWidget" name="RCInput">
<attribute name="title">
<string>RC Input</string>
<string>Remote Control Input</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_11">
<property name="spacing">
@ -2125,6 +2125,278 @@ font:bold;</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_failsafe">
<attribute name="title">
<string>Failsafe Settings</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea_4">
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="0">
<red>232</red>
<green>232</green>
<blue>232</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="0">
<red>232</red>
<green>232</green>
<blue>232</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="0">
<red>232</red>
<green>232</green>
<blue>232</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="0">
<red>232</red>
<green>232</green>
<blue>232</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_4">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1220</width>
<height>655</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>Failsafe Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_12">
<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="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="failsafeFlightModeCb">
<property name="text">
<string>On failsafe change flight mode to:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="failsafeFlightMode">
<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 failsafe switch to this flight mode.</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<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>
<widget class="QPushButton" name="failsafeDefault">
<property name="text">
<string>Default</string>
</property>
<property name="objrelation" stdset="0">
<stringlist>
<string>objname:ManualControlSettings</string>
<string>button:default</string>
<string>buttongroup:555</string>
</stringlist>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QGridLayout" name="failsafeChannelsLayout">
<property name="topMargin">
<number>10</number>
</property>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Channel input settings on failsafe:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Failsafe Information</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</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>
</property>
<property name="backgroundVisible">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Arming Settings</string>

View File

@ -135,9 +135,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-104</y>
<width>866</width>
<height>767</height>
<y>0</y>
<width>877</width>
<height>764</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
@ -7773,8 +7773,8 @@ border-radius: 5;</string>
<rect>
<x>0</x>
<y>0</y>
<width>866</width>
<height>697</height>
<width>877</width>
<height>765</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_29">
@ -17192,8 +17192,8 @@ border-radius: 5;</string>
<rect>
<x>0</x>
<y>0</y>
<width>879</width>
<height>663</height>
<width>877</width>
<height>671</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8" stretch="0,0,0,0,0,0">
@ -23038,8 +23038,8 @@ font:bold;</string>
<rect>
<x>0</x>
<y>0</y>
<width>879</width>
<height>663</height>
<width>877</width>
<height>671</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_18">

View File

@ -1041,26 +1041,16 @@ void ConfigTaskWidget::checkWidgetsLimits(QWidget *widget, UAVObjectField *field
}
}
void ConfigTaskWidget::loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double scale)
void ConfigTaskWidget::loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool applyLimits, double scale)
{
if (!widget || !field) {
return;
}
if (QComboBox * cb = qobject_cast<QComboBox *>(widget)) {
cb->clear();
QStringList options = field->getOptions();
for (int optionIndex = 0; optionIndex < options.count(); optionIndex++) {
if (hasLimits) {
if (m_currentBoardId > -1 && field->isWithinLimits(options.at(optionIndex), index, m_currentBoardId)) {
cb->addItem(options.at(optionIndex), QVariant(optionIndex));
}
} else {
cb->addItem(options.at(optionIndex), QVariant(optionIndex));
}
}
buildOptionComboBox(cb, field, index, applyLimits);
}
if (!hasLimits) {
if (!applyLimits) {
return;
} else if (QDoubleSpinBox * cb = qobject_cast<QDoubleSpinBox *>(widget)) {
if (field->getMaxLimit(index).isValid()) {
@ -1105,6 +1095,21 @@ void ConfigTaskWidget::updateEnableControls()
enableControls(telMngr->isConnected());
}
void ConfigTaskWidget::buildOptionComboBox(QComboBox *combo, UAVObjectField *field, int index, bool applyLimits)
{
QStringList options = field->getOptions();
for (int optionIndex = 0; optionIndex < options.count(); optionIndex++) {
if (applyLimits) {
if (m_currentBoardId > -1 && field->isWithinLimits(options.at(optionIndex), index, m_currentBoardId)) {
combo->addItem(options.at(optionIndex), QVariant(optionIndex));
}
} else {
combo->addItem(options.at(optionIndex), QVariant(optionIndex));
}
}
}
void ConfigTaskWidget::disableMouseWheelEvents()
{
// Disable mouse wheel events

View File

@ -241,7 +241,7 @@ private:
void connectWidgetUpdatesToSlot(QWidget *widget, const char *function);
void disconnectWidgetUpdatesToSlot(QWidget *widget, const char *function);
void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double sclale);
void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool applyLimits, double scale);
int fieldIndexFromElementName(QString objectName, QString fieldName, QString elementName);
@ -262,6 +262,7 @@ protected:
virtual void enableControls(bool enable);
virtual QString mapObjectName(const QString objectName);
virtual UAVObject *getObject(const QString name, quint32 instId = 0);
virtual void buildOptionComboBox(QComboBox *combo, UAVObjectField *field, int index, bool applyLimits);
void checkWidgetsLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, QVariant value, double scale);
void updateEnableControls();
};