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
);
76 void setOutputConfigSafe(bool status
);
79 void inputCalibrationStateChanged(bool newState
);
84 bool reverse
[ManualControlSettings::CHANNELNEUTRAL_NUMELEM
];
85 bool outputConfigIsSafe
;
86 txMovements currentMovement
;
88 void setTxMovement(txMovements movement
);
90 Ui_InputWizardWidget
*wizardUi
;
92 wizardSteps wizardStep
;
93 QList
<QPointer
<QWidget
> > extraWidgets
;
94 txMode transmitterMode
;
95 txType transmitterType
;
96 struct channelsStruct
{
97 bool operator ==(const channelsStruct
& rhs
) const
99 return (group
== rhs
.group
) && (number
== rhs
.number
);
101 bool operator !=(const channelsStruct
& rhs
) const
103 return !operator==(rhs
);
109 channelsStruct currentChannel
;
110 QList
<channelsStruct
> usedChannels
;
111 bool channelDetected
;
115 // Variables to support delayed transitions when detecting input controls.
116 QTimer nextDelayedTimer
;
118 int nextDelayedLatestActivityTick
;
120 int currentChannelNum
;
121 QList
<int> heliChannelOrder
;
122 QList
<int> acroChannelOrder
;
123 QList
<int> groundChannelOrder
;
125 uint16_t flightModeSignalValue
[FlightModeSettings::FLIGHTMODEPOSITION_NUMELEM
];
127 UAVObject::Metadata manualControlMdata
;
128 ManualControlCommand
*manualCommandObj
;
129 ManualControlCommand::DataFields manualCommandData
;
131 FlightStatus
*flightStatusObj
;
132 FlightStatus::DataFields flightStatusData
;
134 UAVObject::Metadata accessoryDesiredMdata0
;
135 AccessoryDesired
*accessoryDesiredObj0
;
136 AccessoryDesired
*accessoryDesiredObj1
;
137 AccessoryDesired
*accessoryDesiredObj2
;
138 AccessoryDesired
*accessoryDesiredObj3
;
139 AccessoryDesired
*rssiDesiredObj4
;
141 ManualControlSettings
*manualSettingsObj
;
142 ManualControlSettings::DataFields manualSettingsData
;
144 ActuatorSettings
*actuatorSettingsObj
;
145 ActuatorSettings::DataFields actuatorSettingsData
;
147 FlightModeSettings
*flightModeSettingsObj
;
148 FlightModeSettings::DataFields flightModeSettingsData
;
149 ReceiverActivity
*receiverActivityObj
;
150 ReceiverActivity::DataFields receiverActivityData
;
152 SystemSettings
*systemSettingsObj
;
153 SystemSettings::DataFields systemSettingsData
;
155 HwSettings
*hwSettingsObj
;
158 ManualControlSettings::DataFields manualSettingsData
;
159 ActuatorSettings::DataFields actuatorSettingsData
;
160 FlightModeSettings::DataFields flightModeSettingsData
;
161 SystemSettings::DataFields systemSettingsData
;
165 QSvgRenderer
*m_renderer
;
167 // Background: background
168 QGraphicsSvgItem
*m_txMainBody
;
169 QGraphicsSvgItem
*m_txLeftStick
;
170 QGraphicsSvgItem
*m_txRightStick
;
171 QGraphicsSvgItem
*m_txAccess0
;
172 QGraphicsSvgItem
*m_txAccess1
;
173 QGraphicsSvgItem
*m_txAccess2
;
174 QGraphicsSvgItem
*m_txAccess3
;
175 QGraphicsSvgItem
*m_txFlightMode
;
176 QGraphicsSvgItem
*m_txFlightModeCountBG
;
177 QGraphicsSimpleTextItem
*m_txFlightModeCountText
;
178 QGraphicsSvgItem
*m_txBackground
;
179 QGraphicsSvgItem
*m_txArrows
;
180 QTransform m_txLeftStickOrig
;
181 QTransform m_txRightStickOrig
;
182 QTransform m_txAccess0Orig
;
183 QTransform m_txAccess1Orig
;
184 QTransform m_txAccess2Orig
;
185 QTransform m_txAccess3Orig
;
186 QTransform m_txFlightModeCOrig
;
187 QTransform m_txFlightModeLOrig
;
188 QTransform m_txFlightModeROrig
;
189 QTransform m_txFlightModeCountBGOrig
;
190 QTransform m_txFlightModeCountTextOrig
;
191 QTransform m_txMainBodyOrig
;
192 QTransform m_txArrowsOrig
;
194 void resetTxControls();
195 void setMoveFromCommand(int command
);
200 void setChannel(int);
204 void wizardSetUpStep(enum wizardSteps
);
205 void wizardTearDownStep(enum wizardSteps
);
207 void registerControlActivity();
209 void wzNextDelayedStart();
210 void wzNextDelayedCancel();
212 AccessoryDesired
*getAccessoryDesiredInstance(int instance
);
213 float getAccessoryDesiredValue(int instance
);
215 void highlightStabilizationMode(int pos
);
219 void wzNextDelayed();
223 void disableWizardButton(int);
224 void identifyControls();
225 void identifyLimits();
226 void moveTxControls();
228 void dimOtherControls(bool value
);
230 void updatePositionSlider();
231 void updateConfigAlarmStatus();
232 void invertControls();
233 void simpleCalibration(bool state
);
234 void adjustSpecialNeutrals();
235 void checkThrottleRange();
236 void updateCalibration();
237 void resetChannelSettings();
238 void resetFlightModeSettings();
239 void resetActuatorSettings();
240 void updateReceiverActivityStatus();
242 void failsafeFlightModeChanged(int index
);
243 void failsafeFlightModeCbToggled(bool checked
);
244 void failsafeBatteryWarningFlightModeChanged(int index
);
245 void failsafeBatteryWarningFlightModeCbToggled(bool checked
);
246 void failsafeBatteryCriticalFlightModeChanged(int index
);
247 void failsafeBatteryCriticalFlightModeCbToggled(bool checked
);
248 void enableControlsChanged(bool enabled
);
251 void resizeEvent(QResizeEvent
*event
);
252 void buildOptionComboBox(QComboBox
*combo
, UAVObjectField
*field
, int index
, bool applyLimits
);
255 #endif // ifndef CONFIGINPUTWIDGET_H