Commit 9dc805dd authored by Don Gagne's avatar Don Gagne

Re-wrote FlightModeConfig

Realized that I had configured my APM:Plane incorrectly since
FlightModeConfig was only set up to work with APM:Copter. Changed code
to respect mode switch channel parameter across all APM frame types.
Also a pile of other changes to make this code much more bullet proof
and correct. Implemented simple mode as well. Changed the style of the
code to be more data driven. This allows for adjusting for new param
values without needed to changing any code.
parent 7e5acad9
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef FLIGHTMODECONFIG_H
#define FLIGHTMODECONFIG_H
#include <QWidget>
#include <QComboBox>
#include "ui_FlightModeConfig.h"
#include "UASInterface.h"
#include "UASManager.h"
#include "AP2ConfigWidget.h"
class FlightModeConfig : public AP2ConfigWidget
......@@ -13,19 +35,55 @@ class FlightModeConfig : public AP2ConfigWidget
public:
explicit FlightModeConfig(QWidget *parent = 0);
~FlightModeConfig();
private slots:
void activeUASSet(UASInterface *uas);
void saveButtonClicked();
void modeChanged(int sysId, QString status, QString description);
// Overrides from AP2ConfigWidget
virtual void activeUASSet(UASInterface *uas);
virtual void parameterChanged(int uas, int component, QString parameterName, QVariant value);
// Signalled from UAS
void remoteControlChannelRawChanged(int chan,float val);
void parameterChanged(int uas, int component, QString parameterName, QVariant value);
// Signalled from FlightModeConfig UI
void saveButtonClicked(void);
private:
QMap<int,int> roverModeIndexToUiIndex;
QMap<int,int> planeModeIndexToUiIndex;
QMap<int,int> roverModeUiIndexToIndex;
QMap<int,int> planeModeUiIndexToIndex;
Ui::FlightModeConfig ui;
typedef struct {
const char* label;
int value;
} FlightModeInfo_t;
static const FlightModeInfo_t _rgModeInfoFixedWing[];
static const FlightModeInfo_t _rgModeInfoRotor[];
static const FlightModeInfo_t _rgModeInfoRover[];
const FlightModeInfo_t* _rgModeInfo;
size_t _cModeInfo;
static const size_t _cModes = 6;
static const char* _rgModeParamFixedWing[_cModes];
static const char* _rgModeParamRotor[_cModes];
static const char* _rgModeParamRover[_cModes];
const char** _rgModeParam;
static const int _rgModePWMBoundary[_cModes];
bool _simpleModeSupported;
static const char* _simpleModeBitMaskParam;
static const char* _modeSwitchRCChannelParamFixedWing;
static const char* _modeSwitchRCChannelParamRover;
const char* _modeSwitchRCChannelParam;
static const int _modeSwitchRCChannelRotor = 4; // ArduCopter harcoded to 0-based channel 4
static const int _modeSwitchRCChannelInvalid = -1;
int _modeSwitchRCChannel;
QLabel* _rgLabel[_cModes];
QComboBox* _rgCombo[_cModes];
QCheckBox* _rgSimpleModeCheckBox[_cModes];
QLabel* _rgPWMLabel[_cModes];
Ui::FlightModeConfig _ui;
};
#endif // FLIGHTMODECONFIG_H
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>818</width>
<height>359</height>
<height>435</height>
</rect>
</property>
<property name="windowTitle">
......@@ -40,15 +40,15 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="labelLayout">
<property name="spacing">
<number>8</number>
<number>-1</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_11">
<widget class="QLabel" name="mode0Label">
<property name="text">
<string>Flight Mode 1</string>
</property>
......@@ -58,7 +58,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="mode1Label">
<property name="text">
<string>Flight Mode 2</string>
</property>
......@@ -68,7 +68,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<widget class="QLabel" name="mode2Label">
<property name="text">
<string>Flight Mode 3</string>
</property>
......@@ -78,7 +78,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="mode3Label">
<property name="text">
<string>Flight Mode 4</string>
</property>
......@@ -88,7 +88,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<widget class="QLabel" name="mode4Label">
<property name="text">
<string>Flight Mode 5</string>
</property>
......@@ -98,7 +98,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_13">
<widget class="QLabel" name="mode5Label">
<property name="text">
<string>Flight Mode 6</string>
</property>
......@@ -110,21 +110,33 @@
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QVBoxLayout" name="comboLayout">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="mode1ComboBox">
<widget class="QComboBox" name="mode0ComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frame">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="mode2ComboBox">
<widget class="QComboBox" name="mode1ComboBox">
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="mode2ComboBox"/>
</item>
<item>
<widget class="QComboBox" name="mode3ComboBox"/>
</item>
......@@ -134,56 +146,53 @@
<item>
<widget class="QComboBox" name="mode5ComboBox"/>
</item>
<item>
<widget class="QComboBox" name="mode6ComboBox"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QVBoxLayout" name="simpleCheckBoxLayout">
<property name="spacing">
<number>8</number>
<number>12</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="mode1SimpleCheckBox">
<widget class="QCheckBox" name="mode0SimpleCheckBox">
<property name="text">
<string>Simple Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mode2SimpleCheckBox">
<widget class="QCheckBox" name="mode1SimpleCheckBox">
<property name="text">
<string>Simple Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mode3SimpleCheckBox">
<widget class="QCheckBox" name="mode2SimpleCheckBox">
<property name="text">
<string>Simple Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mode4SimpleCheckBox">
<widget class="QCheckBox" name="mode3SimpleCheckBox">
<property name="text">
<string>Simple Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mode5SimpleCheckBox">
<widget class="QCheckBox" name="mode4SimpleCheckBox">
<property name="text">
<string>Simple Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mode6SimpleCheckBox">
<widget class="QCheckBox" name="mode5SimpleCheckBox">
<property name="text">
<string>Simple Mode</string>
</property>
......@@ -192,9 +201,12 @@
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="PWMLabelLayout">
<property name="spacing">
<number>-1</number>
</property>
<item>
<widget class="QLabel" name="mode1Label">
<widget class="QLabel" name="mode0PWMLabel">
<property name="styleSheet">
<string notr="true"/>
</property>
......@@ -204,35 +216,35 @@
</widget>
</item>
<item>
<widget class="QLabel" name="mode2Label">
<widget class="QLabel" name="mode1PWMLabel">
<property name="text">
<string>PWM 1231 - 1360</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mode3Label">
<widget class="QLabel" name="mode2PWMLabel">
<property name="text">
<string>PWM 1361 - 1490</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mode4Label">
<widget class="QLabel" name="mode3PWMLabel">
<property name="text">
<string>PWM 1491 - 1620</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mode5Label">
<widget class="QLabel" name="mode4PWMLabel">
<property name="text">
<string>PWM 1621 - 1749</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mode6Label">
<widget class="QLabel" name="mode5PWMLabel">
<property name="styleSheet">
<string notr="true"/>
</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment