LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / plugins / config / configinputwidget.h
bloba9bfaeca919471c340660a3acd689342b85dbc8c
1 /**
2 ******************************************************************************
4 * @file configservowidget.h
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
6 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
7 * @addtogroup GCSPlugins GCS Plugins
8 * @{
9 * @addtogroup ConfigPlugin Config Plugin
10 * @{
11 * @brief Servo input/output configuration panel for the config gadget
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef CONFIGINPUTWIDGET_H
29 #define CONFIGINPUTWIDGET_H
31 #include "uavobjectwidgetutils/configtaskwidget.h"
32 #include "extensionsystem/pluginmanager.h"
33 #include "uavobjectmanager.h"
34 #include "uavobject.h"
36 #include "manualcontrolcommand.h"
37 #include "manualcontrolsettings.h"
38 #include "actuatorsettings.h"
39 #include "mixersettings.h"
40 #include "flightmodesettings.h"
41 #include "receiveractivity.h"
42 #include "flightstatus.h"
43 #include "accessorydesired.h"
44 #include "systemsettings.h"
46 #include <QPointer>
47 #include <QWidget>
48 #include <QList>
49 #include <QTimer>
51 class Ui_InputWidget;
52 class Ui_InputWizardWidget;
54 class QEventLoop;
55 class QSvgRenderer;
56 class QGraphicsSvgItem;
57 class QGraphicsSimpleTextItem;
59 class ConfigInputWidget : public ConfigTaskWidget {
60 Q_OBJECT
61 public:
62 ConfigInputWidget(QWidget *parent = 0);
63 ~ConfigInputWidget();
64 enum wizardSteps { wizardWelcome, wizardChooseMode, wizardChooseType, wizardIdentifySticks, wizardIdentifyCenter, wizardIdentifyLimits, wizardIdentifyInverted, wizardFinish, wizardNone };
65 enum txMode { mode1, mode2, mode3, mode4 };
66 enum txMovements { moveLeftVerticalStick, moveRightVerticalStick, moveLeftHorizontalStick, moveRightHorizontalStick, moveAccess0, moveAccess1, moveAccess2, moveAccess3, moveFlightMode, centerAll, moveAll, nothing };
67 enum txMovementType { vertical, horizontal, jump, mix };
68 enum txType { acro, heli, ground };
69 void startInputWizard()
71 goToWizard();
73 void enableControls(bool enable);
74 bool shouldObjectBeSaved(UAVObject *object);
76 private:
77 bool throttleError;
78 bool growing;
79 bool reverse[ManualControlSettings::CHANNELNEUTRAL_NUMELEM];
80 txMovements currentMovement;
81 int movePos;
82 void setTxMovement(txMovements movement);
83 Ui_InputWidget *ui;
84 Ui_InputWizardWidget *wizardUi;
86 wizardSteps wizardStep;
87 QList<QPointer<QWidget> > extraWidgets;
88 txMode transmitterMode;
89 txType transmitterType;
90 struct channelsStruct {
91 bool operator ==(const channelsStruct & rhs) const
93 return (group == rhs.group) && (number == rhs.number);
95 bool operator !=(const channelsStruct & rhs) const
97 return !operator==(rhs);
99 int group;
100 int number;
101 int channelIndex;
102 } lastChannel;
103 channelsStruct currentChannel;
104 QList<channelsStruct> usedChannels;
105 bool channelDetected;
106 QEventLoop *loop;
107 bool skipflag;
109 // Variables to support delayed transitions when detecting input controls.
110 QTimer nextDelayedTimer;
111 int nextDelayedTick;
112 int nextDelayedLatestActivityTick;
114 int currentChannelNum;
115 QList<int> heliChannelOrder;
116 QList<int> acroChannelOrder;
117 QList<int> groundChannelOrder;
119 uint16_t flightModeSignalValue[FlightModeSettings::FLIGHTMODEPOSITION_NUMELEM];
121 UAVObject::Metadata manualControlMdata;
122 ManualControlCommand *manualCommandObj;
123 ManualControlCommand::DataFields manualCommandData;
125 FlightStatus *flightStatusObj;
126 FlightStatus::DataFields flightStatusData;
128 UAVObject::Metadata accessoryDesiredMdata0;
129 AccessoryDesired *accessoryDesiredObj0;
130 AccessoryDesired *accessoryDesiredObj1;
131 AccessoryDesired *accessoryDesiredObj2;
132 AccessoryDesired *accessoryDesiredObj3;
134 ManualControlSettings *manualSettingsObj;
135 ManualControlSettings::DataFields manualSettingsData;
137 ActuatorSettings *actuatorSettingsObj;
138 ActuatorSettings::DataFields actuatorSettingsData;
140 FlightModeSettings *flightModeSettingsObj;
141 FlightModeSettings::DataFields flightModeSettingsData;
142 ReceiverActivity *receiverActivityObj;
143 ReceiverActivity::DataFields receiverActivityData;
145 SystemSettings *systemSettingsObj;
146 SystemSettings::DataFields systemSettingsData;
148 typedef struct {
149 ManualControlSettings::DataFields manualSettingsData;
150 ActuatorSettings::DataFields actuatorSettingsData;
151 FlightModeSettings::DataFields flightModeSettingsData;
152 SystemSettings::DataFields systemSettingsData;
153 } Memento;
154 Memento memento;
156 QSvgRenderer *m_renderer;
158 // Background: background
159 QGraphicsSvgItem *m_txMainBody;
160 QGraphicsSvgItem *m_txLeftStick;
161 QGraphicsSvgItem *m_txRightStick;
162 QGraphicsSvgItem *m_txAccess0;
163 QGraphicsSvgItem *m_txAccess1;
164 QGraphicsSvgItem *m_txAccess2;
165 QGraphicsSvgItem *m_txAccess3;
166 QGraphicsSvgItem *m_txFlightMode;
167 QGraphicsSvgItem *m_txFlightModeCountBG;
168 QGraphicsSimpleTextItem *m_txFlightModeCountText;
169 QGraphicsSvgItem *m_txBackground;
170 QGraphicsSvgItem *m_txArrows;
171 QTransform m_txLeftStickOrig;
172 QTransform m_txRightStickOrig;
173 QTransform m_txAccess0Orig;
174 QTransform m_txAccess1Orig;
175 QTransform m_txAccess2Orig;
176 QTransform m_txAccess3Orig;
177 QTransform m_txFlightModeCOrig;
178 QTransform m_txFlightModeLOrig;
179 QTransform m_txFlightModeROrig;
180 QTransform m_txFlightModeCountBGOrig;
181 QTransform m_txFlightModeCountTextOrig;
182 QTransform m_txMainBodyOrig;
183 QTransform m_txArrowsOrig;
184 QTimer *animate;
185 void resetTxControls();
186 void setMoveFromCommand(int command);
188 void fastMdata();
189 void restoreMdata();
191 void setChannel(int);
192 void nextChannel();
193 void prevChannel();
195 void wizardSetUpStep(enum wizardSteps);
196 void wizardTearDownStep(enum wizardSteps);
198 void registerControlActivity();
200 void wzNextDelayedStart();
201 void wzNextDelayedCancel();
203 AccessoryDesired *getAccessoryDesiredInstance(int instance);
204 float getAccessoryDesiredValue(int instance);
206 void highlightStabilizationMode(int pos);
208 private slots:
209 void wzNext();
210 void wzNextDelayed();
211 void wzBack();
212 void wzCancel();
213 void goToWizard();
214 void disableWizardButton(int);
215 void openHelp();
216 void identifyControls();
217 void identifyLimits();
218 void moveTxControls();
219 void moveSticks();
220 void dimOtherControls(bool value);
221 void moveFMSlider();
222 void updatePositionSlider();
223 void updateConfigAlarmStatus();
224 void invertControls();
225 void simpleCalibration(bool state);
226 void adjustSpecialNeutrals();
227 void checkThrottleRange();
228 void updateCalibration();
229 void resetChannelSettings();
230 void resetFlightModeSettings();
231 void resetActuatorSettings();
232 void forceOneFlightMode();
234 void failsafeFlightModeChanged(int index);
235 void failsafeFlightModeCbToggled(bool checked);
236 void enableControlsChanged(bool enabled);
238 protected:
239 void resizeEvent(QResizeEvent *event);
240 void buildOptionComboBox(QComboBox *combo, UAVObjectField *field, int index, bool applyLimits);
243 #endif // ifndef CONFIGINPUTWIDGET_H