Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / config / configoutputwidget.h
blobdeacd78abda28e8628676f0834621d49e92482e6
1 /**
2 ******************************************************************************
4 * @file configoutputwidget.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @{
8 * @addtogroup ConfigPlugin Config Plugin
9 * @{
10 * @brief Servo output configuration panel for the config gadget
11 *****************************************************************************/
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.
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.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #ifndef CONFIGOUTPUTWIDGET_H
28 #define CONFIGOUTPUTWIDGET_H
30 #include "cfg_vehicletypes/vehicleconfig.h"
32 #include "../uavobjectwidgetutils/configtaskwidget.h"
33 #include "extensionsystem/pluginmanager.h"
34 #include "uavobjectmanager.h"
35 #include "uavobject.h"
36 #include "uavobjectutilmanager.h"
38 #include "systemalarms.h"
40 #include <QList>
41 #include <QSlider>
43 class Ui_OutputWidget;
44 class OutputChannelForm;
45 class MixerSettings;
47 class QLabel;
48 class QCheckBox;
49 class QWidget;
51 class OutputBankControls {
52 public:
53 OutputBankControls(MixerSettings *mixer, QLabel *label, QColor color, QComboBox *rateCombo, QComboBox *modeCombo);
54 virtual ~OutputBankControls();
56 QLabel *label() const
58 return m_label;
60 QColor color() const
62 return m_color;
64 QComboBox *rateCombo() const
66 return m_rateCombo;
68 QComboBox *modeCombo() const
70 return m_modeCombo;
73 private:
74 MixerSettings *m_mixer;
75 QLabel *m_label;
76 QColor m_color;
77 QComboBox *m_rateCombo;
78 QComboBox *m_modeCombo;
81 class ConfigOutputWidget : public ConfigTaskWidget {
82 Q_OBJECT
84 public:
85 ConfigOutputWidget(QWidget *parent = 0);
86 ~ConfigOutputWidget();
88 public slots:
89 void setInputCalibrationState(bool state);
91 signals:
92 void outputConfigSafeChanged(bool newStatus);
94 protected:
95 void enableControls(bool enable);
96 void setBoardWarning(QString message);
97 void setConfigWarning(QString message);
99 virtual void refreshWidgetsValuesImpl(UAVObject *obj);
100 virtual void updateObjectsFromWidgetsImpl();
102 private:
103 Ui_OutputWidget *m_ui;
104 QList<QSlider> m_sliders;
105 int m_mccDataRate;
106 UAVObject::Metadata m_accInitialData;
107 QList<OutputBankControls> m_banks;
108 int activeBanksCount;
109 void setBanksEnabled(bool state);
111 bool inputCalibrationStarted;
112 bool channelTestsStarted;
114 OutputChannelForm *getOutputChannelForm(const int index) const;
115 void updateChannelInSlider(QSlider *slider, QLabel *min, QLabel *max, QCheckBox *rev, int value);
116 void assignOutputChannel(UAVDataObject *obj, QString &str);
117 void setColor(QWidget *widget, const QColor color);
118 void sendAllChannelTests();
119 enum ChannelConfigWarning { None, CannotDriveServo, IsNormalMotorCheckNeutral, IsReversibleMotorCheckNeutral, BiDirectionalDShotNotSupported };
120 void setChannelLimits(OutputChannelForm *channelForm, OutputBankControls *bankControls);
121 ChannelConfigWarning checkChannelConfig(OutputChannelForm *channelForm, OutputBankControls *bankControls);
122 bool checkOutputConfig();
123 void updateChannelConfigWarning(ChannelConfigWarning warning);
125 private slots:
126 void updateBoardWarnings(UAVObject *);
127 void updateSpinStabilizeCheckComboBoxes();
128 void updateAlwaysStabilizeStatus();
129 void stopTests();
130 void runChannelTests(bool state);
131 void sendChannelTest(int index, int value);
132 void onBankTypeChange();
135 #endif // CONFIGOUTPUTWIDGET_H