LP-106 Setup Wizard refresh : Add dual servo setup (dual aileron or
[librepilot.git] / ground / gcs / src / plugins / setupwizard / pages / outputcalibrationpage.h
blob13cd2c42734d16491b59ae43b8ebd03e807d3e57
1 /**
2 ******************************************************************************
4 * @file outputcalibrationpage.h
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
6 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
7 * @addtogroup
8 * @{
9 * @addtogroup OutputCalibrationPage
10 * @{
11 * @brief
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
29 #ifndef OUTPUTCALIBRATIONPAGE_H
30 #define OUTPUTCALIBRATIONPAGE_H
32 #include <QtSvg>
33 #include "abstractwizardpage.h"
34 #include "setupwizard.h"
35 #include "outputcalibrationutil.h"
36 #include "vehicleconfigurationhelper.h"
38 namespace Ui {
39 class OutputCalibrationPage;
42 class OutputCalibrationPage : public AbstractWizardPage {
43 Q_OBJECT
45 public:
46 explicit OutputCalibrationPage(SetupWizard *wizard, QWidget *parent = 0);
47 ~OutputCalibrationPage();
48 void initializePage();
49 bool validatePage();
51 bool isFinished()
53 return m_currentWizardIndex >= m_wizardIndexes.size();
56 void loadSVGFile(QString file);
57 void setupActuatorMinMaxAndNeutral(int motorChannelStart, int motorChannelEnd, int totalUsedChannels);
58 protected:
59 void showEvent(QShowEvent *event);
60 void resizeEvent(QResizeEvent *event);
62 public slots:
63 void customBackClicked();
65 private slots:
66 void on_motorNeutralButton_toggled(bool checked);
67 void on_motorNeutralSlider_valueChanged(int value);
69 void on_servoButton_toggled(bool checked);
70 void on_servoCenterAngleSlider_valueChanged(int position);
71 void on_servoMinAngleSlider_valueChanged(int position);
72 void on_servoMaxAngleSlider_valueChanged(int position);
73 void on_reverseCheckbox_toggled(bool checked);
75 void on_dualservoButton_toggled(bool checked);
76 void on_servoCenterAngleSlider1_valueChanged(int position);
77 void on_servoMinAngleSlider1_valueChanged(int position);
78 void on_servoMaxAngleSlider1_valueChanged(int position);
79 void on_reverseCheckbox1_toggled(bool checked);
81 void on_servoCenterAngleSlider2_valueChanged(int position);
82 void on_servoMinAngleSlider2_valueChanged(int position);
83 void on_servoMaxAngleSlider2_valueChanged(int position);
84 void on_reverseCheckbox2_toggled(bool checked);
86 void on_calibrateAllMotors_toggled(bool checked);
88 private:
89 enum ElementType { FULL, FRAME, MOTOR, SERVO };
90 static const int LOW_OUTPUT_RATE_MILLISECONDS = 1000;
91 static const int NEUTRAL_OUTPUT_RATE_MILLISECONDS = 1500;
92 static const int HIGH_OUTPUT_RATE_MILLISECONDS_PWM = 1900;
93 static const int HIGH_OUTPUT_RATE_MILLISECONDS_ONESHOT125 = 2000;
95 void setupVehicle();
96 void startWizard();
97 void setupVehicleItems();
98 void setupVehicleHighlightedPart();
99 void showElementMovement(bool isUp, bool FirstServo, qreal value);
100 void setWizardPage();
101 void enableButtons(bool enable);
102 void enableServoSliders(bool enabled);
103 void onStartButtonToggle(QAbstractButton *button, QList<quint16> &channels,
104 quint16 value, quint16 safeValue, QSlider *slider);
105 void onStartButtonToggleDual(QAbstractButton *button, QList<quint16> &channels,
106 quint16 value1, quint16 value2, quint16 safeValue, QSlider *slider1, QSlider *slider2);
107 void setSliderLimitsAndArrows(quint16 currentChannel, bool showFirst, quint16 value, QCheckBox *revCheckbox, QSlider *minSlider, QSlider *maxSlider);
108 void reverseCheckBoxIsToggled(quint16 currentChannel, QCheckBox *checkBox, QSlider *centerSlider, QSlider *minSlider, QSlider *maxSlider);
110 bool checkAlarms();
111 void debugLogChannelValues(bool showFirst);
113 void getCurrentChannels(QList<quint16> &channels);
114 void enableAllMotorsCheckBox(bool enable);
115 int getHighOutputRate();
116 quint16 getCurrentChannel();
118 Ui::OutputCalibrationPage *ui;
119 QSvgRenderer *m_vehicleRenderer;
120 QGraphicsScene *m_vehicleScene;
121 QGraphicsSvgItem *m_vehicleBoundsItem;
123 qint16 m_currentWizardIndex;
125 QList<QString> m_vehicleElementIds;
126 QList<ElementType> m_vehicleElementTypes;
127 QList<QGraphicsSvgItem *> m_vehicleItems;
128 QList<QGraphicsSvgItem *> m_arrowsItems;
129 QList<quint16> m_vehicleHighlightElementIndexes;
130 QList<quint16> m_channelIndex;
131 QList<qint16> m_wizardIndexes;
133 QList<actuatorChannelSettings> m_actuatorSettings;
135 OutputCalibrationUtil *m_calibrationUtil;
136 void resetOutputCalibrationUtil();
138 static const QString MULTI_SVG_FILE;
139 static const QString FIXEDWING_SVG_FILE;
140 static const QString GROUND_SVG_FILE;
143 #endif // OUTPUTCALIBRATIONPAGE_H