2 ******************************************************************************
4 * @file configservowidget.h
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
6 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
7 * @addtogroup GCSPlugins GCS Plugins
9 * @addtogroup ConfigPlugin Config Plugin
11 * @brief Servo input configuration panel for the config gadget
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
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
28 #ifndef CONFIGINPUTWIDGET_H
29 #define CONFIGINPUTWIDGET_H
31 #include "uavobjectwidgetutils/configtaskwidget.h"
33 #include "uavobject.h"
35 #include "manualcontrolcommand.h"
36 #include "manualcontrolsettings.h"
37 #include "actuatorsettings.h"
38 #include "mixersettings.h"
39 #include "flightmodesettings.h"
40 #include "receiveractivity.h"
41 #include "flightstatus.h"
42 #include "accessorydesired.h"
43 #include "systemsettings.h"
44 #include "hwsettings.h"
51 class Ui_InputWizardWidget
;
55 class QGraphicsSvgItem
;
56 class QGraphicsSimpleTextItem
;
58 class ConfigInputWidget
: public ConfigTaskWidget
{
61 ConfigInputWidget(QWidget
*parent
= 0);
63 enum wizardSteps
{ wizardWelcome
, wizardChooseMode
, wizardChooseType
, wizardIdentifySticks
, wizardIdentifyCenter
, wizardIdentifyLimits
, wizardIdentifyInverted
, wizardFinish
, wizardNone
};
64 enum txMode
{ mode1
, mode2
, mode3
, mode4
};
65 enum txMovements
{ moveLeftVerticalStick
, moveRightVerticalStick
, moveLeftHorizontalStick
, moveRightHorizontalStick
, moveAccess0
, moveAccess1
, moveAccess2
, moveAccess3
, moveFlightMode
, centerAll
, moveAll
, nothing
};
66 enum txMovementType
{ vertical
, horizontal
, jump
, mix
};
67 enum txType
{ acro
, heli
, ground
};
68 void startInputWizard()
72 void enableControls(bool enable
);
73 bool shouldObjectBeSaved(UAVObject
*object
);
78 bool reverse
[ManualControlSettings::CHANNELNEUTRAL_NUMELEM
];
79 txMovements currentMovement
;
81 void setTxMovement(txMovements movement
);
83 Ui_InputWizardWidget
*wizardUi
;
85 wizardSteps wizardStep
;
86 QList
<QPointer
<QWidget
> > extraWidgets
;
87 txMode transmitterMode
;
88 txType transmitterType
;
89 struct channelsStruct
{
90 bool operator ==(const channelsStruct
& rhs
) const
92 return (group
== rhs
.group
) && (number
== rhs
.number
);
94 bool operator !=(const channelsStruct
& rhs
) const
96 return !operator==(rhs
);
102 channelsStruct currentChannel
;
103 QList
<channelsStruct
> usedChannels
;
104 bool channelDetected
;
108 // Variables to support delayed transitions when detecting input controls.
109 QTimer nextDelayedTimer
;
111 int nextDelayedLatestActivityTick
;
113 int currentChannelNum
;
114 QList
<int> heliChannelOrder
;
115 QList
<int> acroChannelOrder
;
116 QList
<int> groundChannelOrder
;
118 uint16_t flightModeSignalValue
[FlightModeSettings::FLIGHTMODEPOSITION_NUMELEM
];
120 UAVObject::Metadata manualControlMdata
;
121 ManualControlCommand
*manualCommandObj
;
122 ManualControlCommand::DataFields manualCommandData
;
124 FlightStatus
*flightStatusObj
;
125 FlightStatus::DataFields flightStatusData
;
127 UAVObject::Metadata accessoryDesiredMdata0
;
128 AccessoryDesired
*accessoryDesiredObj0
;
129 AccessoryDesired
*accessoryDesiredObj1
;
130 AccessoryDesired
*accessoryDesiredObj2
;
131 AccessoryDesired
*accessoryDesiredObj3
;
132 AccessoryDesired
*rssiDesiredObj4
;
134 ManualControlSettings
*manualSettingsObj
;
135 ManualControlSettings::DataFields manualSettingsData
;
137 ActuatorSettings
*actuatorSettingsObj
;
138 ActuatorSettings::DataFields actuatorSettingsData
;
140 FlightModeSettings
*flightModeSettingsObj
;
141 FlightModeSettings::DataFields flightModeSettingsData
;
142 ReceiverActivity
*receiverActivityObj
;
143 ReceiverActivity::DataFields receiverActivityData
;
145 SystemSettings
*systemSettingsObj
;
146 SystemSettings::DataFields systemSettingsData
;
148 HwSettings
*hwSettingsObj
;
151 ManualControlSettings::DataFields manualSettingsData
;
152 ActuatorSettings::DataFields actuatorSettingsData
;
153 FlightModeSettings::DataFields flightModeSettingsData
;
154 SystemSettings::DataFields systemSettingsData
;
158 QSvgRenderer
*m_renderer
;
160 // Background: background
161 QGraphicsSvgItem
*m_txMainBody
;
162 QGraphicsSvgItem
*m_txLeftStick
;
163 QGraphicsSvgItem
*m_txRightStick
;
164 QGraphicsSvgItem
*m_txAccess0
;
165 QGraphicsSvgItem
*m_txAccess1
;
166 QGraphicsSvgItem
*m_txAccess2
;
167 QGraphicsSvgItem
*m_txAccess3
;
168 QGraphicsSvgItem
*m_txFlightMode
;
169 QGraphicsSvgItem
*m_txFlightModeCountBG
;
170 QGraphicsSimpleTextItem
*m_txFlightModeCountText
;
171 QGraphicsSvgItem
*m_txBackground
;
172 QGraphicsSvgItem
*m_txArrows
;
173 QTransform m_txLeftStickOrig
;
174 QTransform m_txRightStickOrig
;
175 QTransform m_txAccess0Orig
;
176 QTransform m_txAccess1Orig
;
177 QTransform m_txAccess2Orig
;
178 QTransform m_txAccess3Orig
;
179 QTransform m_txFlightModeCOrig
;
180 QTransform m_txFlightModeLOrig
;
181 QTransform m_txFlightModeROrig
;
182 QTransform m_txFlightModeCountBGOrig
;
183 QTransform m_txFlightModeCountTextOrig
;
184 QTransform m_txMainBodyOrig
;
185 QTransform m_txArrowsOrig
;
187 void resetTxControls();
188 void setMoveFromCommand(int command
);
193 void setChannel(int);
197 void wizardSetUpStep(enum wizardSteps
);
198 void wizardTearDownStep(enum wizardSteps
);
200 void registerControlActivity();
202 void wzNextDelayedStart();
203 void wzNextDelayedCancel();
205 AccessoryDesired
*getAccessoryDesiredInstance(int instance
);
206 float getAccessoryDesiredValue(int instance
);
208 void highlightStabilizationMode(int pos
);
212 void wzNextDelayed();
216 void disableWizardButton(int);
217 void identifyControls();
218 void identifyLimits();
219 void moveTxControls();
221 void dimOtherControls(bool value
);
223 void updatePositionSlider();
224 void updateConfigAlarmStatus();
225 void invertControls();
226 void simpleCalibration(bool state
);
227 void adjustSpecialNeutrals();
228 void checkThrottleRange();
229 void updateCalibration();
230 void resetChannelSettings();
231 void resetFlightModeSettings();
232 void resetActuatorSettings();
233 void updateReceiverActivityStatus();
235 void failsafeFlightModeChanged(int index
);
236 void failsafeFlightModeCbToggled(bool checked
);
237 void failsafeBatteryWarningFlightModeChanged(int index
);
238 void failsafeBatteryWarningFlightModeCbToggled(bool checked
);
239 void failsafeBatteryCriticalFlightModeChanged(int index
);
240 void failsafeBatteryCriticalFlightModeCbToggled(bool checked
);
241 void enableControlsChanged(bool enabled
);
244 void resizeEvent(QResizeEvent
*event
);
245 void buildOptionComboBox(QComboBox
*combo
, UAVObjectField
*field
, int index
, bool applyLimits
);
248 #endif // ifndef CONFIGINPUTWIDGET_H