dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
configccpmwidget.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 CONFIGccpmWIDGET_H
27 #define CONFIGccpmWIDGET_H
28 
29 #include "ui_ccpm.h"
30 #include "../uavobjectwidgetutils/configtaskwidget.h"
34 #include "uavobjects/uavobject.h"
35 #include <QtSvg/QSvgRenderer>
36 #include <QtSvg/QGraphicsSvgItem>
37 #include <QGraphicsEllipseItem>
38 #include <QWidget>
39 #include <QList>
40 
41 #define CCPM_MAX_SWASH_SERVOS 4
42 
43 class Ui_Widget;
44 
45 typedef struct
46 {
47  int ServoChannels[CCPM_MAX_SWASH_SERVOS];
48  int Used[CCPM_MAX_SWASH_SERVOS];
49  int Max[CCPM_MAX_SWASH_SERVOS];
50  int Neutral[CCPM_MAX_SWASH_SERVOS];
51  int Min[CCPM_MAX_SWASH_SERVOS];
53 
55 {
56  Q_OBJECT
57 
58 public:
59  ConfigCcpmWidget(QWidget *parent = nullptr);
61 
63 
64 private:
65  Ui_CcpmWidget *m_ccpm;
66  QGraphicsSvgItem *SwashplateImg;
67  QGraphicsSvgItem *CurveImg;
68  QGraphicsSvgItem *Servos[CCPM_MAX_SWASH_SERVOS];
69  QGraphicsTextItem *ServosText[CCPM_MAX_SWASH_SERVOS];
70  QGraphicsLineItem *ServoLines[CCPM_MAX_SWASH_SERVOS];
71  QGraphicsEllipseItem *ServosTextCircles[CCPM_MAX_SWASH_SERVOS];
72  QSpinBox *SwashLvlSpinBoxes[CCPM_MAX_SWASH_SERVOS];
73 
74  QString TypeText;
75 
76  bool SwashLvlConfigurationInProgress;
77  UAVObject::Metadata SwashLvlaccInitialData;
78  int SwashLvlState;
79  int SwashLvlServoInterlock;
80 
81  SwashplateServoSettingsStruct oldSwashLvlConfiguration;
82  SwashplateServoSettingsStruct newSwashLvlConfiguration;
83 
84  int MixerChannelData[6];
85  int ShowDisclaimer(int messageID);
86  virtual void enableControls(bool enable){ Q_UNUSED(enable) }; // Not used by this widget
87 
88  bool updatingFromHardware;
89  bool updatingToHardware;
90 
91  virtual void ResetActuators(GUIConfigDataUnion *configData);
92  static QStringList getChannelDescriptions();
93 
94  SystemSettings::AirframeTypeOptions updateConfigObjects();
95 private slots:
96  virtual void setupUI(SystemSettings::AirframeTypeOptions airframeType);
97  void refreshAirframeWidgetsValues(SystemSettings::AirframeTypeOptions frameType);
98  virtual SystemSettings::AirframeTypeOptions updateConfigObjectsFromWidgets();
99  virtual bool throwConfigError(SystemSettings::AirframeTypeOptions airframeType);
100 
101  void ccpmSwashplateUpdate();
102  void ccpmSwashplateRedraw();
103  void UpdateMixer();
104  void UpdateType();
105 
106  void SwashLvlStartButtonPressed();
107  void SwashLvlNextButtonPressed();
108  void SwashLvlCancelButtonPressed();
109  void SwashLvlFinishButtonPressed();
110 
111  // void UpdateCCPMOptionsFromUI();
112  // void UpdateCCPMUIFromOptions();
113 
114  void SetUIComponentVisibilities();
115 
116  void enableSwashplateLevellingControl(bool state);
117  void setSwashplateLevel(int percent);
118  void SwashLvlSpinBoxChanged(int value);
119  virtual void refreshValues(){}; // Not used
120 
121 public slots:
122  void getMixer();
123  void setMixer();
124  void saveccpmUpdate();
125 
126 protected:
127  void showEvent(QShowEvent *event);
128  void resizeEvent(QResizeEvent *event);
129 };
130 
131 #endif // CONFIGccpmWIDGET_H
ConfigCcpmWidget(QWidget *parent=nullptr)
void showEvent(QShowEvent *event)
void resizeEvent(QResizeEvent *event)
virtual void enableControls(bool enable)
static QStringList getChannelDescriptions()