19 Q_PROPERTY(QQuickItem* statusText MEMBER _statusText REQUIRED)
20 Q_PROPERTY(QQuickItem* cancelButton MEMBER _cancelButton REQUIRED)
21 Q_PROPERTY(QQuickItem* nextButton MEMBER _nextButton REQUIRED)
23 Q_PROPERTY(
int minChannelCount MEMBER _chanMinimum CONSTANT)
24 Q_PROPERTY(
int channelCount READ channelCount NOTIFY channelCountChanged)
25 Q_PROPERTY(
int channelValueMin MEMBER _calDefaultMinValue CONSTANT)
26 Q_PROPERTY(
int channelValueMax MEMBER _calDefaultMaxValue CONSTANT)
27 Q_PROPERTY(QList<int> stickDisplayPositions READ stickDisplayPositions NOTIFY stickDisplayPositionsChanged)
28 Q_PROPERTY(
bool centeredThrottle READ centeredThrottle WRITE setCenteredThrottle NOTIFY centeredThrottleChanged)
29 Q_PROPERTY(
int transmitterMode READ transmitterMode WRITE setTransmitterMode NOTIFY transmitterModeChanged)
30 Q_PROPERTY(
bool joystickMode READ joystickMode WRITE setJoystickMode NOTIFY joystickModeChanged REQUIRED)
31 Q_PROPERTY(
bool calibrating READ calibrating NOTIFY calibratingChanged)
32 Q_PROPERTY(
bool singleStickDisplay READ singleStickDisplay NOTIFY singleStickDisplayChanged)
34 Q_PROPERTY(
bool rollChannelMapped READ rollChannelMapped NOTIFY rollChannelMappedChanged)
35 Q_PROPERTY(
bool pitchChannelMapped READ pitchChannelMapped NOTIFY pitchChannelMappedChanged)
36 Q_PROPERTY(
bool yawChannelMapped READ yawChannelMapped NOTIFY yawChannelMappedChanged)
37 Q_PROPERTY(
bool throttleChannelMapped READ throttleChannelMapped NOTIFY throttleChannelMappedChanged)
38 Q_PROPERTY(
bool rollExtensionChannelMapped READ rollExtensionChannelMapped NOTIFY rollExtensionChannelMappedChanged)
39 Q_PROPERTY(
bool pitchExtensionChannelMapped READ pitchExtensionChannelMapped NOTIFY pitchExtensionChannelMappedChanged)
40 Q_PROPERTY(
bool aux1ExtensionChannelMapped READ aux1ExtensionChannelMapped NOTIFY aux1ExtensionChannelMappedChanged)
41 Q_PROPERTY(
bool aux2ExtensionChannelMapped READ aux2ExtensionChannelMapped NOTIFY aux2ExtensionChannelMappedChanged)
42 Q_PROPERTY(
bool aux3ExtensionChannelMapped READ aux3ExtensionChannelMapped NOTIFY aux3ExtensionChannelMappedChanged)
43 Q_PROPERTY(
bool aux4ExtensionChannelMapped READ aux4ExtensionChannelMapped NOTIFY aux4ExtensionChannelMappedChanged)
44 Q_PROPERTY(
bool aux5ExtensionChannelMapped READ aux5ExtensionChannelMapped NOTIFY aux5ExtensionChannelMappedChanged)
45 Q_PROPERTY(
bool aux6ExtensionChannelMapped READ aux6ExtensionChannelMapped NOTIFY aux6ExtensionChannelMappedChanged)
47 Q_PROPERTY(
bool pitchExtensionEnabled READ pitchExtensionEnabled NOTIFY pitchExtensionEnabledChanged)
48 Q_PROPERTY(
bool rollExtensionEnabled READ rollExtensionEnabled NOTIFY rollExtensionEnabledChanged)
49 Q_PROPERTY(
bool aux1ExtensionEnabled READ aux1ExtensionEnabled NOTIFY aux1ExtensionEnabledChanged)
50 Q_PROPERTY(
bool aux2ExtensionEnabled READ aux2ExtensionEnabled NOTIFY aux2ExtensionEnabledChanged)
51 Q_PROPERTY(
bool aux3ExtensionEnabled READ aux3ExtensionEnabled NOTIFY aux3ExtensionEnabledChanged)
52 Q_PROPERTY(
bool aux4ExtensionEnabled READ aux4ExtensionEnabled NOTIFY aux4ExtensionEnabledChanged)
53 Q_PROPERTY(
bool aux5ExtensionEnabled READ aux5ExtensionEnabled NOTIFY aux5ExtensionEnabledChanged)
54 Q_PROPERTY(
bool aux6ExtensionEnabled READ aux6ExtensionEnabled NOTIFY aux6ExtensionEnabledChanged)
55 Q_PROPERTY(
bool anyExtensionEnabled READ anyExtensionEnabled NOTIFY anyExtensionEnabledChanged)
57 Q_PROPERTY(
int adjustedRollChannelValue READ adjustedRollChannelValue NOTIFY adjustedRollChannelValueChanged)
58 Q_PROPERTY(
int adjustedPitchChannelValue READ adjustedPitchChannelValue NOTIFY adjustedPitchChannelValueChanged)
59 Q_PROPERTY(
int adjustedYawChannelValue READ adjustedYawChannelValue NOTIFY adjustedYawChannelValueChanged)
60 Q_PROPERTY(
int adjustedThrottleChannelValue READ adjustedThrottleChannelValue NOTIFY adjustedThrottleChannelValueChanged)
61 Q_PROPERTY(
int adjustedRollExtensionChannelValue READ adjustedRollExtensionChannelValue NOTIFY adjustedRollExtensionChannelValueChanged)
62 Q_PROPERTY(
int adjustedPitchExtensionChannelValue READ adjustedPitchExtensionChannelValue NOTIFY adjustedPitchExtensionChannelValueChanged)
63 Q_PROPERTY(
int adjustedAux1ExtensionChannelValue READ adjustedAux1ExtensionChannelValue NOTIFY adjustedAux1ExtensionChannelValueChanged)
64 Q_PROPERTY(
int adjustedAux2ExtensionChannelValue READ adjustedAux2ExtensionChannelValue NOTIFY adjustedAux2ExtensionChannelValueChanged)
65 Q_PROPERTY(
int adjustedAux3ExtensionChannelValue READ adjustedAux3ExtensionChannelValue NOTIFY adjustedAux3ExtensionChannelValueChanged)
66 Q_PROPERTY(
int adjustedAux4ExtensionChannelValue READ adjustedAux4ExtensionChannelValue NOTIFY adjustedAux4ExtensionChannelValueChanged)
67 Q_PROPERTY(
int adjustedAux5ExtensionChannelValue READ adjustedAux5ExtensionChannelValue NOTIFY adjustedAux5ExtensionChannelValueChanged)
68 Q_PROPERTY(
int adjustedAux6ExtensionChannelValue READ adjustedAux6ExtensionChannelValue NOTIFY adjustedAux6ExtensionChannelValueChanged)
70 Q_PROPERTY(
int rollChannelReversed READ rollChannelReversed NOTIFY rollChannelReversedChanged)
71 Q_PROPERTY(
int pitchChannelReversed READ pitchChannelReversed NOTIFY pitchChannelReversedChanged)
72 Q_PROPERTY(
int yawChannelReversed READ yawChannelReversed NOTIFY yawChannelReversedChanged)
73 Q_PROPERTY(
int throttleChannelReversed READ throttleChannelReversed NOTIFY throttleChannelReversedChanged)
74 Q_PROPERTY(
int rollExtensionChannelReversed READ rollExtensionChannelReversed NOTIFY rollExtensionChannelReversedChanged)
75 Q_PROPERTY(
int pitchExtensionChannelReversed READ pitchExtensionChannelReversed NOTIFY pitchExtensionChannelReversedChanged)
76 Q_PROPERTY(
int aux1ExtensionChannelReversed READ aux1ExtensionChannelReversed NOTIFY aux1ExtensionChannelReversedChanged)
77 Q_PROPERTY(
int aux2ExtensionChannelReversed READ aux2ExtensionChannelReversed NOTIFY aux2ExtensionChannelReversedChanged)
78 Q_PROPERTY(
int aux3ExtensionChannelReversed READ aux3ExtensionChannelReversed NOTIFY aux3ExtensionChannelReversedChanged)
79 Q_PROPERTY(
int aux4ExtensionChannelReversed READ aux4ExtensionChannelReversed NOTIFY aux4ExtensionChannelReversedChanged)
80 Q_PROPERTY(
int aux5ExtensionChannelReversed READ aux5ExtensionChannelReversed NOTIFY aux5ExtensionChannelReversedChanged)
81 Q_PROPERTY(
int aux6ExtensionChannelReversed READ aux6ExtensionChannelReversed NOTIFY aux6ExtensionChannelReversedChanged)
83 Q_PROPERTY(
int rollDeadband READ rollDeadband NOTIFY rollDeadbandChanged)
84 Q_PROPERTY(
int pitchDeadband READ pitchDeadband NOTIFY pitchDeadbandChanged)
85 Q_PROPERTY(
int rollExtensionDeadband READ rollExtensionDeadband NOTIFY rollExtensionDeadbandChanged)
86 Q_PROPERTY(
int yawDeadband READ yawDeadband NOTIFY yawDeadbandChanged)
87 Q_PROPERTY(
int throttleDeadband READ throttleDeadband NOTIFY throttleDeadbandChanged)
88 Q_PROPERTY(
int pitchExtensionDeadband READ pitchExtensionDeadband NOTIFY pitchExtensionDeadbandChanged)
89 Q_PROPERTY(
int aux1ExtensionDeadband READ aux1ExtensionDeadband NOTIFY aux1ExtensionDeadbandChanged)
90 Q_PROPERTY(
int aux2ExtensionDeadband READ aux2ExtensionDeadband NOTIFY aux2ExtensionDeadbandChanged)
91 Q_PROPERTY(
int aux3ExtensionDeadband READ aux3ExtensionDeadband NOTIFY aux3ExtensionDeadbandChanged)
92 Q_PROPERTY(
int aux4ExtensionDeadband READ aux4ExtensionDeadband NOTIFY aux4ExtensionDeadbandChanged)
93 Q_PROPERTY(
int aux5ExtensionDeadband READ aux5ExtensionDeadband NOTIFY aux5ExtensionDeadbandChanged)
94 Q_PROPERTY(
int aux6ExtensionDeadband READ aux6ExtensionDeadband NOTIFY aux6ExtensionDeadbandChanged)
105 stickFunctionThrottle,
106 stickFunctionMaxRadio,
107 stickFunctionPitchExtension = stickFunctionMaxRadio,
108 stickFunctionRollExtension,
109 stickFunctionAux1Extension,
110 stickFunctionAux2Extension,
111 stickFunctionAux3Extension,
112 stickFunctionAux4Extension,
113 stickFunctionAux5Extension,
114 stickFunctionAux6Extension,
118 Q_INVOKABLE
void cancelButtonClicked();
119 Q_INVOKABLE
void nextButtonClicked();
120 virtual Q_INVOKABLE
void start();
121 Q_INVOKABLE
void copyTrims();
123 int adjustedRollChannelValue();
124 int adjustedPitchChannelValue();
125 int adjustedYawChannelValue();
126 int adjustedThrottleChannelValue();
127 int adjustedRollExtensionChannelValue();
128 int adjustedPitchExtensionChannelValue();
129 int adjustedAux1ExtensionChannelValue();
130 int adjustedAux2ExtensionChannelValue();
131 int adjustedAux3ExtensionChannelValue();
132 int adjustedAux4ExtensionChannelValue();
133 int adjustedAux5ExtensionChannelValue();
134 int adjustedAux6ExtensionChannelValue();
135 bool rollChannelMapped();
136 bool pitchChannelMapped();
137 bool rollExtensionChannelMapped();
138 bool pitchExtensionChannelMapped();
139 bool aux1ExtensionChannelMapped();
140 bool aux2ExtensionChannelMapped();
141 bool aux3ExtensionChannelMapped();
142 bool aux4ExtensionChannelMapped();
143 bool aux5ExtensionChannelMapped();
144 bool aux6ExtensionChannelMapped();
145 bool yawChannelMapped();
146 bool throttleChannelMapped();
147 bool pitchExtensionEnabled();
148 bool rollExtensionEnabled();
149 bool aux1ExtensionEnabled();
150 bool aux2ExtensionEnabled();
151 bool aux3ExtensionEnabled();
152 bool aux4ExtensionEnabled();
153 bool aux5ExtensionEnabled();
154 bool aux6ExtensionEnabled();
155 bool anyExtensionEnabled();
156 bool rollChannelReversed();
157 bool pitchChannelReversed();
158 bool rollExtensionChannelReversed();
159 bool pitchExtensionChannelReversed();
160 bool aux1ExtensionChannelReversed();
161 bool aux2ExtensionChannelReversed();
162 bool aux3ExtensionChannelReversed();
163 bool aux4ExtensionChannelReversed();
164 bool aux5ExtensionChannelReversed();
165 bool aux6ExtensionChannelReversed();
166 bool yawChannelReversed();
167 bool throttleChannelReversed();
170 int rollExtensionDeadband();
171 int pitchExtensionDeadband();
172 int aux1ExtensionDeadband();
173 int aux2ExtensionDeadband();
174 int aux3ExtensionDeadband();
175 int aux4ExtensionDeadband();
176 int aux5ExtensionDeadband();
177 int aux6ExtensionDeadband();
179 int throttleDeadband();
180 int channelCount()
const {
return _chanCount; }
181 int transmitterMode()
const {
return _transmitterMode; }
182 QList<int> stickDisplayPositions()
const {
return _stickDisplayPositions; }
183 bool centeredThrottle()
const {
return _centeredThrottle; }
184 bool joystickMode()
const {
return _joystickMode; }
185 bool calibrating()
const {
return _calibrating; }
186 bool singleStickDisplay()
const {
return _singleStickDisplay; }
188 void setTransmitterMode(
int mode);
189 void setCenteredThrottle(
bool centered);
190 void setJoystickMode(
bool joystickMode);
263 void rawChannelValuesChanged(QVector<int> channelValues);
287 int _stickDetectSettleMSecs = 1000;
290 static constexpr int _chanMinimum = 4;
293 int _rgFunctionChannelMapping[stickFunctionMax];
295 void _validateAndAdjustCalibrationValues();
296 QString _stickFunctionToString(StickFunction stickFunction);
297 void _signalAllAttitudeValueChanges();
298 void _resetInternalCalibrationValues();
300 virtual bool _stickFunctionEnabled(StickFunction stickFunction);
303 virtual void _saveStoredCalibrationValues() = 0;
304 virtual void _readStoredCalibrationValues() = 0;
309 struct StickDisplayPosition {
314 struct BothSticksDisplayPositions {
315 StickDisplayPosition leftStick;
316 StickDisplayPosition rightStick;
319 enum StateMachineStepFunction {
320 StateMachineStepStickNeutral,
321 StateMachineStepThrottleUp,
322 StateMachineStepThrottleDown,
323 StateMachineStepYawRight,
324 StateMachineStepYawLeft,
325 StateMachineStepRollRight,
326 StateMachineStepRollLeft,
327 StateMachineStepPitchUp,
328 StateMachineStepPitchDown,
329 StateMachineStepPitchCenter,
330 StateMachineStepSwitchMinMax,
331 StateMachineStepExtensionHighHorz,
332 StateMachineStepExtensionHighVert,
333 StateMachineStepExtensionLowHorz,
334 StateMachineStepExtensionLowVert,
335 StateMachineStepComplete
340 struct StateMachineEntry {
341 enum StickFunction stickFunction;
342 enum StateMachineStepFunction stepFunction;
343 inputFn channelInputFn;
344 buttonFn nextButtonFn;
347 const StateMachineEntry &_getStateMachineEntry(
int step)
const;
348 void _advanceState();
349 void _setupCurrentState();
350 void _inputCenterWaitBegin(StickFunction stickFunction,
int channel,
int value);
351 void _inputStickDetect(StickFunction stickFunction,
int channel,
int value);
352 void _inputStickMin(StickFunction stickFunction,
int channel,
int value);
353 void _inputCenterWait(StickFunction stickFunction,
int channel,
int value);
354 void _inputSwitchMinMax(StickFunction stickFunction,
int channel,
int value);
355 void _saveCalibrationValues();
356 void _saveAllTrims();
357 bool _stickSettleComplete(
int value);
358 void _startCalibration();
359 void _stopCalibration();
360 void _saveCurrentRawValues();
361 void _loadCalibrationUISettings();
362 void _saveCalibrationUISettings();
363 int _deadbandForFunction(StickFunction stickFunction)
const;
364 void _emitDeadbandChanged(StickFunction stickFunction);
365 void _setSingleStickDisplay(
bool singleStickDisplay);
366 int _adjustChannelRawValue(
const ChannelInfo& info,
int rawValue)
const;
368 int _currentStep = -1;
369 int _transmitterMode = 2;
373 rcCalStateChannelWait,
377 rcCalStateCenterThrottle,
378 rcCalStateDetectInversion,
383 int _channelValueSave[_chanMax]{};
384 int _channelRawValue[_chanMax]{};
386 int _stickDetectChannel = 0;
387 int _stickDetectValue = 0;
388 bool _stickDetectSettleStarted =
false;
389 QElapsedTimer _stickDetectSettleElapsed;
391 QQuickItem *_statusText =
nullptr;
392 QQuickItem *_cancelButton =
nullptr;
393 QQuickItem *_nextButton =
nullptr;
395 QList<int> _stickDisplayPositions;
396 bool _centeredThrottle =
false;
397 bool _joystickMode =
false;
398 bool _calibrating =
false;
399 bool _singleStickDisplay =
false;
400 QMap<StateMachineStepFunction, QString> _stepFunctionToMsgStringMap;
401 QMap<StateMachineStepFunction, QMap<int, BothSticksDisplayPositions>> _bothStickDisplayPositionThrottleCenteredMap;
402 QMap<StateMachineStepFunction, QMap<int, BothSticksDisplayPositions>> _bothStickDisplayPositionThrottleDownMap;
404 QList<StateMachineEntry> _stateMachine;
406 static constexpr int _updateInterval = 150;
408 static constexpr const char *_settingsGroup =
"RadioCalibration";
409 static constexpr const char *_settingsKeyTransmitterMode =
"TransmitterMode";
412 static constexpr StickDisplayPosition _stickDisplayPositionCentered = {0, 0};
413 static constexpr StickDisplayPosition _stickDisplayPositionXCenteredYDown = {0, -1};
414 static constexpr StickDisplayPosition _stickDisplayPositionXCenteredYUp = {0, 1};
415 static constexpr StickDisplayPosition _stickDisplayPositionXLeftYCentered = {-1, 0};
416 static constexpr StickDisplayPosition _stickDisplayPositionXRightYCentered = { 1, 0};
417 static constexpr StickDisplayPosition _stickDisplayPositionXLeftYDown = {-1, -1};
418 static constexpr StickDisplayPosition _stickDisplayPositionXRightYDown = { 1, -1};