LP-514 Add DShot150/600/1200 and OneShot42/MultiShot Esc support to Wizard
[librepilot.git] / ground / gcs / src / plugins / setupwizard / pages / outputcalibrationpage.h
blob09c33310ffc3d32119f6c9728dd8e0b100215960
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_DSHOT = 0;
91 static const int HIGH_OUTPUT_RATE_DSHOT = 2000;
92 static const int LOW_OUTPUT_RATE_MILLISECONDS = 1000;
93 static const int LOW_OUTPUT_RATE_MILLISECONDS_PWM = 1000;
94 static const int HIGH_OUTPUT_RATE_MILLISECONDS_PWM = 1900;
95 static const int NEUTRAL_OUTPUT_RATE_RANGE = 500;
96 static const int NEUTRAL_OUTPUT_RATE_MILLISECONDS = 1500;
97 static const int HIGH_OUTPUT_RATE_MILLISECONDS_ONESHOT_MULTISHOT = 2000;
99 void setupVehicle();
100 void startWizard();
101 void setupVehicleItems();
102 void setupVehicleHighlightedPart();
103 void showElementMovement(bool isUp, bool FirstServo, qreal value);
104 void setWizardPage();
105 void enableButtons(bool enable);
106 void enableServoSliders(bool enabled);
107 void onStartButtonToggle(QAbstractButton *button, QList<quint16> &channels,
108 quint16 value, quint16 safeValue, QSlider *slider);
109 void onStartButtonToggleDual(QAbstractButton *button, QList<quint16> &channels,
110 quint16 value1, quint16 value2, quint16 safeValue, QSlider *slider1, QSlider *slider2);
111 void setSliderLimitsAndArrows(quint16 currentChannel, bool showFirst, quint16 value, QCheckBox *revCheckbox, QSlider *minSlider, QSlider *maxSlider);
112 void reverseCheckBoxIsToggled(quint16 currentChannel, QCheckBox *checkBox, QSlider *centerSlider, QSlider *minSlider, QSlider *maxSlider);
114 bool checkAlarms();
115 void debugLogChannelValues(bool showFirst);
117 void getCurrentChannels(QList<quint16> &channels);
118 void enableAllMotorsCheckBox(bool enable);
119 int getLowOutputRate();
120 int getHighOutputRate();
121 quint16 getCurrentChannel();
123 Ui::OutputCalibrationPage *ui;
124 QSvgRenderer *m_vehicleRenderer;
125 QGraphicsScene *m_vehicleScene;
126 QGraphicsSvgItem *m_vehicleBoundsItem;
128 qint16 m_currentWizardIndex;
130 QList<QString> m_vehicleElementIds;
131 QList<ElementType> m_vehicleElementTypes;
132 QList<QGraphicsSvgItem *> m_vehicleItems;
133 QList<QGraphicsSvgItem *> m_arrowsItems;
134 QList<quint16> m_vehicleHighlightElementIndexes;
135 QList<quint16> m_channelIndex;
136 QList<qint16> m_wizardIndexes;
138 QList<actuatorChannelSettings> m_actuatorSettings;
140 OutputCalibrationUtil *m_calibrationUtil;
141 void resetOutputCalibrationUtil();
143 static const QString MULTI_SVG_FILE;
144 static const QString FIXEDWING_SVG_FILE;
145 static const QString GROUND_SVG_FILE;
148 #endif // OUTPUTCALIBRATIONPAGE_H