dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
gcscontrolgadget.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 
27 #ifndef GCSControlGADGET_H_
28 #define GCSControlGADGET_H_
29 
30 #include <coreplugin/iuavgadget.h>
32 #include <QTimer>
33 #include <QTime>
34 #include <QHostAddress>
36 
37 #if defined(USE_SDL)
38 #include "sdlgamepad/sdlgamepad.h"
39 #endif
40 
41 // UAVOs
42 #include "manualcontrolcommand.h"
43 
44 namespace Core {
45 class IUAVGadget;
46 }
47 
49 
50 using namespace Core;
51 
53 {
54  Q_OBJECT
55 public:
56  GCSControlGadget(QString classId, GCSControlGadgetWidget *widget, QWidget *parent = nullptr,
57  QObject *plugin = nullptr);
59 
60  QList<int> context() const { return m_context; }
61  QWidget *widget() { return reinterpret_cast<QWidget *>(m_widget); }
62  QString contextHelpId() const { return QString(); }
63 
64  void loadConfiguration(IUAVGadgetConfiguration *config);
65 
66 private:
68  ManualControlCommand *getManualControlCommand();
69 
71  GCSControl *getGcsControl();
72 
73  double constrain(double value);
74 
76  void setGcsReceiver(double leftX, double leftY, double rightX, double rightY, double arming);
77 
78  QTime joystickTime;
79  GCSControlGadgetWidget *m_widget;
80  QList<int> m_context;
81  UAVObject::Metadata mccInitialData;
82 
83  // The channel mappings to the joystick
84  int rollChannel;
85  int pitchChannel;
86  int yawChannel;
87  int throttleChannel;
88 
90  int controlsMode;
91 
93  bool gcsReceiverMode;
94 
96  bool enableSending;
97 
98  buttonSettingsStruct buttonSettings[8];
99  double bound(double input);
100  double wrap(double input);
101  bool channelReverse[8];
102 
103 signals:
104  void sticksChangedRemotely(double leftX, double leftY, double rightX, double rightY);
105 
106 protected slots:
107  void manualControlCommandUpdated(UAVObject *);
108  void sticksChangedLocally(double leftX, double leftY, double rightX, double rightY,
109  double arming);
110  void flightModeChanged(ManualControlSettings::FlightModePositionOptions mode);
112  void enableControl(bool enable);
113 
114  // signals from joystick
115  void gamepads(quint8 count);
116 #if defined(USE_SDL)
117  void buttonState(ButtonNumber number, bool pressed);
118  void axesValues(QListInt16 values);
119 #endif
120 };
121 
122 #endif // GCSControlGADGET_H_
QWidget * widget()
QList< int > context() const
QString contextHelpId() const