dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
configinputwidget.h
Go to the documentation of this file.
1 
12 /*
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  * for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, see <http://www.gnu.org/licenses/>
25  */
26 #ifndef CONFIGINPUTWIDGET_H
27 #define CONFIGINPUTWIDGET_H
28 
29 #include <QGraphicsView>
30 #include <QList>
31 #include <QPointer>
32 #include <QRadioButton>
33 #include <QWidget>
34 #include <QSvgRenderer>
35 #include <QGraphicsSvgItem>
36 
37 #include "ui_input.h"
38 #include "ui_inputchannelform.h"
39 
43 #include "uavobjects/uavobject.h"
44 #include <QWidget>
45 #include <QList>
46 #include "inputchannelform.h"
47 
48 #include "flightstatus.h"
49 #include "manualcontrolcommand.h"
50 #include "manualcontrolsettings.h"
51 #include "receiveractivity.h"
52 
53 class TelemetryManager;
54 class Ui_InputWidget;
55 
57 {
58  Q_OBJECT
59 public:
60  ConfigInputWidget(QWidget *parent = nullptr);
62  enum wizardSteps {
73  };
74  enum txMode { mode1, mode2 };
75  enum txMovements {
88  };
90  enum txType { acro, heli };
92  void startInputWizard() { goToWizard(); }
93 
94 protected:
95  // Note: must match armingNames
105  };
106 
108  {
110  QString name;
111  QString armName;
112  QString disarmName;
113  QString uavoOption;
114  bool isSwitch;
115  bool isStick;
116  bool isFixed;
117  };
118 
119  static const QVector<ArmingMethod> armingMethods;
120 
121 private:
122  // This was set through trial and error. Extensive testing
123  // will have to be done before changing it. At a minimum,
124  // this should include Turnigy9x, FrSky, S.BUS, and Spektrum
125  // transmitters.
126  static const int DEBOUNCE_THRESHOLD_COUNT = 1;
127  // This was set through trial and error. Extensive testing
128  // will have to be done before changing it. At a minimum,
129  // this should include Turnigy9x, FrSky, S.BUS, and Spektrum
130  // transmitters.
131  static const int CHANNEL_IDENTIFICATION_WAIT_TIME_MS = 2500;
132 
133  bool growing;
134  bool reverse[ManualControlSettings::CHANNELNEUTRAL_NUMELEM];
135 
136  int minSeen[ManualControlSettings::CHANNELNEUTRAL_NUMELEM];
137  int maxSeen[ManualControlSettings::CHANNELNEUTRAL_NUMELEM];
138 
139  txMovements currentMovement;
140  int movePos;
141  void setTxMovement(txMovements movement);
142  Ui_InputWidget *m_config;
143  wizardSteps wizardStep;
144  QList<QPointer<QWidget>> extraWidgets;
145  txMode transmitterMode;
146  txType transmitterType;
147 
149  struct channelsStruct
150  {
151  bool operator==(const channelsStruct &rhs) const
152  {
153  return ((group == rhs.group) && (number == rhs.number));
154  }
155  int group;
156  int number;
157  } lastChannel;
158  channelsStruct currentChannel;
159  QList<channelsStruct> usedChannels;
160  bool channelDetected;
161  QEventLoop *loop;
162  bool skipflag;
163 
164  int currentChannelNum;
165  QList<int> heliChannelOrder;
166  QList<int> acroChannelOrder;
167 
168  ManualControlCommand *manualCommandObj;
169  ManualControlCommand::DataFields manualCommandData;
170  FlightStatus *flightStatusObj;
171  UAVObject::Metadata manualControlMdata;
172  ManualControlSettings *manualSettingsObj;
173  ManualControlSettings::DataFields manualSettingsData;
174  ManualControlSettings::DataFields previousManualSettingsData;
175  ReceiverActivity *receiverActivityObj;
176  ReceiverActivity::DataFields receiverActivityData;
177  QMap<QString, UAVObject::Metadata> originalMetaData;
178 
179  QSvgRenderer *m_renderer;
180 
181  // Background: background
182  QGraphicsSvgItem *m_txMainBody;
183  QGraphicsSvgItem *m_txLeftStick;
184  QGraphicsSvgItem *m_txRightStick;
185  QGraphicsSvgItem *m_txAccess0;
186  QGraphicsSvgItem *m_txAccess1;
187  QGraphicsSvgItem *m_txAccess2;
188  QGraphicsSvgItem *m_txFlightMode;
189  QGraphicsSvgItem *m_txArming;
190  QGraphicsSvgItem *m_txBackground;
191  QGraphicsSvgItem *m_txArrows;
192  QTransform m_txLeftStickOrig;
193  QTransform m_txRightStickOrig;
194  QTransform m_txAccess0Orig;
195  QTransform m_txAccess1Orig;
196  QTransform m_txAccess2Orig;
197  QTransform m_txFlightModeCOrig;
198  QTransform m_txFlightModeLOrig;
199  QTransform m_txFlightModeROrig;
200  QTransform m_txArmingSwitchOrigL;
201  QTransform m_txArmingSwitchOrigR;
202  QTransform m_txMainBodyOrig;
203  QTransform m_txArrowsOrig;
204  QTimer *animate;
205 
206  QComboBox *cbArmingOption;
207  ArmingMethodType lastArmingMethod;
208  bool armingConfigUpdating;
209 
210  void resetTxControls();
211  void setMoveFromCommand(int command);
212 
213  void fastMdata();
214  void restoreMdata();
215 
216  void setChannel(int);
217  void nextChannel();
218  void prevChannel();
219 
220  void wizardSetUpStep(enum wizardSteps);
221  void wizardTearDownStep(enum wizardSteps);
222 
224  TelemetryManager *telMngr;
225  quint8 scaleSwitchChannel(quint8 channelNumber, quint8 switchPositions);
226 
227  const ArmingMethod armingMethodFromArmName(const QString &name);
228  const ArmingMethod armingMethodFromUavoOption(const QString &option);
229  void fillArmingComboBox();
230 
231 private slots:
232  void wzNext();
233  void wzBack();
234  void wzCancel();
235  void goToWizard();
236  void identifyControls();
237  void identifyLimits();
238  void moveTxControls();
239  void moveSticks();
240  void detectFailsafe();
241  void dimOtherControls(bool value);
242  void moveFMSlider();
243  void updatePositionSlider();
244  void invertControls();
245  void simpleCalibration(bool state);
246  void updateCalibration();
247  void checkArmingConfig();
248  void checkReprojection();
249  void updateArmingConfig(UAVObject *manualControlSettings);
250  void timeoutCheckboxChanged();
251  void checkCollective();
252 
253 protected:
254  void resizeEvent(QResizeEvent *event);
255  virtual void enableControls(bool enable);
256  void addMessage(QWidget *target, const QString type, const QString msg);
257  void addWarning(QWidget *target, QWidget *cause, const QString msg);
258  void clearMessages(QWidget *widget, const QString type);
259  void clearWarnings(QWidget *target, QWidget *causesParent);
260 };
261 
262 #endif
void clearMessages(QWidget *widget, const QString type)
void resizeEvent(QResizeEvent *event)
bool operator==(const channelsStruct &rhs) const
void clearWarnings(QWidget *target, QWidget *causesParent)
void addMessage(QWidget *target, const QString type, const QString msg)
void addWarning(QWidget *target, QWidget *cause, const QString msg)
virtual void enableControls(bool enable)
static const QVector< ArmingMethod > armingMethods
Definition: icore.h:39
ConfigInputWidget(QWidget *parent=nullptr)