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/output 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"
32 #include "extensionsystem/pluginmanager.h"
33 #include "uavobjectmanager.h"
34 #include "uavobject.h"
36 #include "manualcontrolcommand.h"
37 #include "manualcontrolsettings.h"
38 #include "actuatorsettings.h"
39 #include "mixersettings.h"
40 #include "flightmodesettings.h"
41 #include "receiveractivity.h"
42 #include "flightstatus.h"
43 #include "accessorydesired.h"
44 #include "systemsettings.h"
52 class Ui_InputWizardWidget
;
56 class QGraphicsSvgItem
;
57 class QGraphicsSimpleTextItem
;
59 class ConfigInputWidget
: public ConfigTaskWidget
{
62 ConfigInputWidget(QWidget
*parent
= 0);
64 enum wizardSteps
{ wizardWelcome
, wizardChooseMode
, wizardChooseType
, wizardIdentifySticks
, wizardIdentifyCenter
, wizardIdentifyLimits
, wizardIdentifyInverted
, wizardFinish
, wizardNone
};
65 enum txMode
{ mode1
, mode2
, mode3
, mode4
};
66 enum txMovements
{ moveLeftVerticalStick
, moveRightVerticalStick
, moveLeftHorizontalStick
, moveRightHorizontalStick
, moveAccess0
, moveAccess1
, moveAccess2
, moveAccess3
, moveFlightMode
, centerAll
, moveAll
, nothing
};
67 enum txMovementType
{ vertical
, horizontal
, jump
, mix
};
68 enum txType
{ acro
, heli
, ground
};
69 void startInputWizard()
73 void enableControls(bool enable
);
74 bool shouldObjectBeSaved(UAVObject
*object
);
79 bool reverse
[ManualControlSettings::CHANNELNEUTRAL_NUMELEM
];
80 txMovements currentMovement
;
82 void setTxMovement(txMovements movement
);
84 Ui_InputWizardWidget
*wizardUi
;
86 wizardSteps wizardStep
;
87 QList
<QPointer
<QWidget
> > extraWidgets
;
88 txMode transmitterMode
;
89 txType transmitterType
;
90 struct channelsStruct
{
91 bool operator ==(const channelsStruct
& rhs
) const
93 return (group
== rhs
.group
) && (number
== rhs
.number
);
95 bool operator !=(const channelsStruct
& rhs
) const
97 return !operator==(rhs
);
103 channelsStruct currentChannel
;
104 QList
<channelsStruct
> usedChannels
;
105 bool channelDetected
;
109 // Variables to support delayed transitions when detecting input controls.
110 QTimer nextDelayedTimer
;
112 int nextDelayedLatestActivityTick
;
114 int currentChannelNum
;
115 QList
<int> heliChannelOrder
;
116 QList
<int> acroChannelOrder
;
117 QList
<int> groundChannelOrder
;
119 uint16_t flightModeSignalValue
[FlightModeSettings::FLIGHTMODEPOSITION_NUMELEM
];
121 UAVObject::Metadata manualControlMdata
;
122 ManualControlCommand
*manualCommandObj
;
123 ManualControlCommand::DataFields manualCommandData
;
125 FlightStatus
*flightStatusObj
;
126 FlightStatus::DataFields flightStatusData
;
128 UAVObject::Metadata accessoryDesiredMdata0
;
129 AccessoryDesired
*accessoryDesiredObj0
;
130 AccessoryDesired
*accessoryDesiredObj1
;
131 AccessoryDesired
*accessoryDesiredObj2
;
132 AccessoryDesired
*accessoryDesiredObj3
;
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
;
149 ManualControlSettings::DataFields manualSettingsData
;
150 ActuatorSettings::DataFields actuatorSettingsData
;
151 FlightModeSettings::DataFields flightModeSettingsData
;
152 SystemSettings::DataFields systemSettingsData
;
156 QSvgRenderer
*m_renderer
;
158 // Background: background
159 QGraphicsSvgItem
*m_txMainBody
;
160 QGraphicsSvgItem
*m_txLeftStick
;
161 QGraphicsSvgItem
*m_txRightStick
;
162 QGraphicsSvgItem
*m_txAccess0
;
163 QGraphicsSvgItem
*m_txAccess1
;
164 QGraphicsSvgItem
*m_txAccess2
;
165 QGraphicsSvgItem
*m_txAccess3
;
166 QGraphicsSvgItem
*m_txFlightMode
;
167 QGraphicsSvgItem
*m_txFlightModeCountBG
;
168 QGraphicsSimpleTextItem
*m_txFlightModeCountText
;
169 QGraphicsSvgItem
*m_txBackground
;
170 QGraphicsSvgItem
*m_txArrows
;
171 QTransform m_txLeftStickOrig
;
172 QTransform m_txRightStickOrig
;
173 QTransform m_txAccess0Orig
;
174 QTransform m_txAccess1Orig
;
175 QTransform m_txAccess2Orig
;
176 QTransform m_txAccess3Orig
;
177 QTransform m_txFlightModeCOrig
;
178 QTransform m_txFlightModeLOrig
;
179 QTransform m_txFlightModeROrig
;
180 QTransform m_txFlightModeCountBGOrig
;
181 QTransform m_txFlightModeCountTextOrig
;
182 QTransform m_txMainBodyOrig
;
183 QTransform m_txArrowsOrig
;
185 void resetTxControls();
186 void setMoveFromCommand(int command
);
191 void setChannel(int);
195 void wizardSetUpStep(enum wizardSteps
);
196 void wizardTearDownStep(enum wizardSteps
);
198 void registerControlActivity();
200 void wzNextDelayedStart();
201 void wzNextDelayedCancel();
203 AccessoryDesired
*getAccessoryDesiredInstance(int instance
);
204 float getAccessoryDesiredValue(int instance
);
206 void highlightStabilizationMode(int pos
);
210 void wzNextDelayed();
214 void disableWizardButton(int);
216 void identifyControls();
217 void identifyLimits();
218 void moveTxControls();
220 void dimOtherControls(bool value
);
222 void updatePositionSlider();
223 void updateConfigAlarmStatus();
224 void invertControls();
225 void simpleCalibration(bool state
);
226 void adjustSpecialNeutrals();
227 void checkThrottleRange();
228 void updateCalibration();
229 void resetChannelSettings();
230 void resetFlightModeSettings();
231 void resetActuatorSettings();
232 void forceOneFlightMode();
234 void failsafeFlightModeChanged(int index
);
235 void failsafeFlightModeCbToggled(bool checked
);
236 void enableControlsChanged(bool enabled
);
239 void resizeEvent(QResizeEvent
*event
);
240 void buildOptionComboBox(QComboBox
*combo
, UAVObjectField
*field
, int index
, bool applyLimits
);
243 #endif // ifndef CONFIGINPUTWIDGET_H