diff --git a/src/AutoPilotPlugins/Common/RadioComponent.qml b/src/AutoPilotPlugins/Common/RadioComponent.qml index 68eb9e5d1890d140245c93961b39ce939bc2e288..3bfc1427b98725cf18064ab7ccb4253d3e4ae12a 100644 --- a/src/AutoPilotPlugins/Common/RadioComponent.qml +++ b/src/AutoPilotPlugins/Common/RadioComponent.qml @@ -471,6 +471,27 @@ QGCView { onClicked: showDialog(copyTrimsDialogComponent, dialogTitle, qgcView.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel) } + Repeater { + model: QGroundControl.multiVehicleManager.activeVehicle.px4Firmware ? [ "RC_MAP_FLAPS", "RC_MAP_AUX1", "RC_MAP_AUX2", "RC_MAP_AUX3" ] : 0 + + Row { + spacing: ScreenTools.defaultFontPixelWidth + + property Fact fact: controller.getParameterFact(-1, modelData) + + QGCLabel { + anchors.baseline: optCombo.baseline + text: fact.shortDescription + ":" + } + + FactComboBox { + id: optCombo + width: ScreenTools.defaultFontPixelWidth * 15 + fact: parent.fact + indexModel: false + } + } + } // Repeater } // Column - Left Column Item { diff --git a/src/AutoPilotPlugins/Common/RadioComponentController.cc b/src/AutoPilotPlugins/Common/RadioComponentController.cc index f5337ab9c4aa94f32aa32928e78c372cb2007ccc..bf5a65dbb7aaf08754820bc7b92aaab805bfc443 100644 --- a/src/AutoPilotPlugins/Common/RadioComponentController.cc +++ b/src/AutoPilotPlugins/Common/RadioComponentController.cc @@ -81,9 +81,6 @@ const struct RadioComponentController::FunctionInfo RadioComponentController::_r { "RC_MAP_LOITER_SW" }, { "RC_MAP_RETURN_SW" }, { "RC_MAP_ACRO_SW" }, - { "RC_MAP_FLAPS" }, - { "RC_MAP_AUX1" }, - { "RC_MAP_AUX2" }, }; const struct RadioComponentController::FunctionInfo RadioComponentController::_rgFunctionInfoAPM[RadioComponentController::rcCalFunctionMax] = { @@ -97,9 +94,6 @@ const struct RadioComponentController::FunctionInfo RadioComponentController::_r { NULL }, { NULL }, { NULL }, - { NULL }, - { NULL }, - { NULL }, }; RadioComponentController::RadioComponentController(void) : @@ -157,16 +151,7 @@ const RadioComponentController::stateMachineEntry* RadioComponentController::_ge static const char* msgPitchDown = "Move the Pitch stick all the way down and hold it there..."; static const char* msgPitchUp = "Move the Pitch stick all the way up and hold it there..."; static const char* msgPitchCenter = "Allow the Pitch stick to move back to center..."; - static const char* msgAux1Switch = "Move the switch or dial you want to use for Aux1.\n\n" - "You can click Skip if you don't want to assign."; - static const char* msgAux2Switch = "Move the switch or dial you want to use for Aux2.\n\n" - "You can click Skip if you don't want to assign."; static const char* msgSwitchMinMax = "Move all the transmitter switches and/or dials back and forth to their extreme positions."; - static const char* msgFlapsDetect = "Move the switch or dial you want to use for Flaps back and forth a few times. " - "Then leave the switch/dial at the position you want to use for Flaps fully extended.\n\n" - "Click Next to continue.\n" - "If you won't be using Flaps, click Skip."; - static const char* msgFlapsUp = "Move the switch or dial you want to use for Flaps to the position you want to use for Flaps fully retracted."; static const char* msgComplete = "All settings have been captured. Click Next to write the new parameters to your board."; static const stateMachineEntry rgStateMachinePX4[] = { @@ -182,10 +167,6 @@ const RadioComponentController::stateMachineEntry* RadioComponentController::_ge { rcCalFunctionPitch, msgPitchDown, _imagePitchDown, &RadioComponentController::_inputStickMin, NULL, NULL }, { rcCalFunctionPitch, msgPitchCenter, _imageHome, &RadioComponentController::_inputCenterWait, NULL, NULL }, { rcCalFunctionMax, msgSwitchMinMax, _imageSwitchMinMax, &RadioComponentController::_inputSwitchMinMax, &RadioComponentController::_advanceState, NULL }, - { rcCalFunctionFlaps, msgFlapsDetect, _imageThrottleDown, &RadioComponentController::_inputFlapsDetect, &RadioComponentController::_saveFlapsDown, &RadioComponentController::_skipFlaps }, - { rcCalFunctionFlaps, msgFlapsUp, _imageThrottleDown, &RadioComponentController::_inputFlapsUp, NULL, NULL }, - { rcCalFunctionAux1, msgAux1Switch, _imageThrottleDown, &RadioComponentController::_inputSwitchDetect, NULL, &RadioComponentController::_advanceState }, - { rcCalFunctionAux2, msgAux2Switch, _imageThrottleDown, &RadioComponentController::_inputSwitchDetect, NULL, &RadioComponentController::_advanceState }, { rcCalFunctionMax, msgComplete, _imageThrottleDown, NULL, &RadioComponentController::_writeCalibration, NULL }, }; @@ -547,100 +528,6 @@ void RadioComponentController::_inputSwitchMinMax(enum rcCalFunctions function, } } -void RadioComponentController::_skipFlaps(void) -{ - // Flaps channel may have been identified. Clear it out. - for (int i=0; i<_chanCount; i++) { - if (_rgChannelInfo[i].function == RadioComponentController::rcCalFunctionFlaps) { - _rgChannelInfo[i].function = rcCalFunctionMax; - } - } - _rgFunctionChannelMapping[RadioComponentController::rcCalFunctionFlaps] = _chanMax(); - - // Skip over flap steps - _currentStep += 2; - _setupCurrentState(); -} - -void RadioComponentController::_saveFlapsDown(void) -{ - int channel = _rgFunctionChannelMapping[rcCalFunctionFlaps]; - - if (channel == _chanMax()) { - // Channel not yet mapped, still waiting for switch to move - if (_unitTestMode) { - emit nextButtonMessageBoxDisplayed(); - } else { - qgcApp()->showMessage("Flaps switch has not yet been detected."); - } - return; - } - - Q_ASSERT(channel != -1); - ChannelInfo* info = &_rgChannelInfo[channel]; - - int rcValue = _rcRawValue[channel]; - - // Switch detection is complete. Switch should be at flaps fully extended position. - - // Channel should be at max value, if it is below initial set point the channel is reversed. - info->reversed = rcValue < _rcValueSave[channel]; - - if (info->reversed) { - _rgChannelInfo[channel].rcMin = rcValue; - } else { - _rgChannelInfo[channel].rcMax = rcValue; - } - - _advanceState(); -} - -void RadioComponentController::_inputFlapsUp(enum rcCalFunctions function, int channel, int value) -{ - Q_UNUSED(function); - - // FIXME: Duplication - - Q_ASSERT(function == rcCalFunctionFlaps); - - // We only care about the channel mapped to flaps - if (_rgFunctionChannelMapping[rcCalFunctionFlaps] != channel) { - return; - } - - if (_stickDetectChannel == _chanMax()) { - // Setup up to detect stick being pegged to extreme position - if (_rgChannelInfo[channel].reversed) { - if (value > _rcCalPWMCenterPoint + _rcCalMoveDelta) { - _stickDetectChannel = channel; - _stickDetectInitialValue = value; - _stickDetectValue = value; - } - } else { - if (value < _rcCalPWMCenterPoint - _rcCalMoveDelta) { - _stickDetectChannel = channel; - _stickDetectInitialValue = value; - _stickDetectValue = value; - } - } - } else { - // We are waiting for the selected channel to settle out - - if (_stickSettleComplete(value)) { - ChannelInfo* info = &_rgChannelInfo[channel]; - - // Stick detection is complete. Stick should be at min position. - if (info->reversed) { - _rgChannelInfo[channel].rcMax = value; - } else { - _rgChannelInfo[channel].rcMin = value; - } - - _advanceState(); - } - } -} - void RadioComponentController::_switchDetect(enum rcCalFunctions function, int channel, int value, bool moveToNextStep) { // If this channel is already used in a mapping we can't use it again @@ -671,11 +558,6 @@ void RadioComponentController::_inputSwitchDetect(enum rcCalFunctions function, _switchDetect(function, channel, value, true /* move to next step after detection */); } -void RadioComponentController::_inputFlapsDetect(enum rcCalFunctions function, int channel, int value) -{ - _switchDetect(function, channel, value, false /* do not move to next step after detection */); -} - /// @brief Resets internal calibration values to their initial state in preparation for a new calibration sequence. void RadioComponentController::_resetInternalCalibrationValues(void) { diff --git a/src/AutoPilotPlugins/Common/RadioComponentController.h b/src/AutoPilotPlugins/Common/RadioComponentController.h index dd3304daffb2b98e9f09dc26cc3385b9777bb741..c1a92cf4d2aa929703ea86c934544a1696cb243c 100644 --- a/src/AutoPilotPlugins/Common/RadioComponentController.h +++ b/src/AutoPilotPlugins/Common/RadioComponentController.h @@ -159,9 +159,6 @@ private: rcCalFunctionLoiterSwitch, rcCalFunctionReturnSwitch, rcCalFunctionAcroSwitch, - rcCalFunctionFlaps, - rcCalFunctionAux1, - rcCalFunctionAux2, rcCalFunctionMax, // Attitude functions are roll/pitch/yaw/throttle @@ -170,7 +167,7 @@ private: // Non-Attitude functions are everything else rcCalFunctionFirstNonAttitudeFunction = rcCalFunctionModeSwitch, - rcCalFunctionLastNonAttitudeFunction = rcCalFunctionAux2, + rcCalFunctionLastNonAttitudeFunction = rcCalFunctionAcroSwitch, }; /// @brief The states of the calibration state machine. @@ -224,15 +221,10 @@ private: void _inputStickMin(enum rcCalFunctions function, int channel, int value); void _inputCenterWait(enum rcCalFunctions function, int channel, int value); void _inputSwitchMinMax(enum rcCalFunctions function, int channel, int value); - void _inputFlapsDown(enum rcCalFunctions function, int channel, int value); - void _inputFlapsUp(enum rcCalFunctions function, int channel, int value); void _inputSwitchDetect(enum rcCalFunctions function, int channel, int value); - void _inputFlapsDetect(enum rcCalFunctions function, int channel, int value); void _switchDetect(enum rcCalFunctions function, int channel, int value, bool moveToNextStep); - void _saveFlapsDown(void); - void _skipFlaps(void); void _saveAllTrims(void); bool _stickSettleComplete(int value); diff --git a/src/qgcunittest/RadioConfigTest.cc b/src/qgcunittest/RadioConfigTest.cc index 99923b04eec47780832a92d4aa434177ed48c879..d5c8a90a772b905679fc8420d5bf94f7ca63a870 100644 --- a/src/qgcunittest/RadioConfigTest.cc +++ b/src/qgcunittest/RadioConfigTest.cc @@ -79,17 +79,15 @@ const struct RadioConfigTest::ChannelSettings RadioConfigTest::_rgChannelSetting { RadioComponentController::rcCalFunctionYaw, _testMinValue, _testMaxValue, 0, true }, { RadioComponentController::rcCalFunctionThrottle, _testMinValue, _testMaxValue, 0, false }, - // Channels 5-8: Not mapped to function, Simulate invalid Min/Max, since available channel Min/Max is still shown. + // Channels 5-11: Not mapped to function, Simulate invalid Min/Max, since available channel Min/Max is still shown. // These are here to skip over the flight mode functions { RadioComponentController::rcCalFunctionMax, _testCenterValue, _testCenterValue, 0, false }, { RadioComponentController::rcCalFunctionMax, _testCenterValue, _testCenterValue, 0, false }, { RadioComponentController::rcCalFunctionMax, _testCenterValue, _testCenterValue, 0, false }, { RadioComponentController::rcCalFunctionMax, _testCenterValue, _testCenterValue, 0, false }, - - // Channels 9-11: Remainder of non-flight mode switches - { RadioComponentController::rcCalFunctionFlaps, _testMinValue, _testMaxValue, 0, false }, - { RadioComponentController::rcCalFunctionAux1, _testMinValue, _testMaxValue, 0, false }, - { RadioComponentController::rcCalFunctionAux2, _testMinValue, _testMaxValue, 0, false }, + { RadioComponentController::rcCalFunctionMax, _testCenterValue, _testCenterValue, 0, false }, + { RadioComponentController::rcCalFunctionMax, _testCenterValue, _testCenterValue, 0, false }, + { RadioComponentController::rcCalFunctionMax, _testCenterValue, _testCenterValue, 0, false }, // Channel 12 : Not mapped to function, Simulate invalid Min, valid Max { RadioComponentController::rcCalFunctionMax, _testCenterValue, _testMaxValue, 0, false }, @@ -118,16 +116,14 @@ const struct RadioConfigTest::ChannelSettings RadioConfigTest::_rgChannelSetting { RadioComponentController::rcCalFunctionYaw, _testMinValue, _testMaxValue, _testCenterValue, true }, { RadioComponentController::rcCalFunctionThrottle, _testMinValue, _testMaxValue, _testMinValue, false }, - // Channels 5-8: not mapped and should be set to defaults + // Channels 5-11: not mapped and should be set to defaults + { RadioComponentController::rcCalFunctionMax, RadioComponentController::_rcCalPWMDefaultMinValue, RadioComponentController::_rcCalPWMDefaultMaxValue, 1500/*RadioComponentController::_rcCalPWMCenterPoint*/, false }, + { RadioComponentController::rcCalFunctionMax, RadioComponentController::_rcCalPWMDefaultMinValue, RadioComponentController::_rcCalPWMDefaultMaxValue, 1500/*RadioComponentController::_rcCalPWMCenterPoint*/, false }, + { RadioComponentController::rcCalFunctionMax, RadioComponentController::_rcCalPWMDefaultMinValue, RadioComponentController::_rcCalPWMDefaultMaxValue, 1500/*RadioComponentController::_rcCalPWMCenterPoint*/, false }, { RadioComponentController::rcCalFunctionMax, RadioComponentController::_rcCalPWMDefaultMinValue, RadioComponentController::_rcCalPWMDefaultMaxValue, 1500/*RadioComponentController::_rcCalPWMCenterPoint*/, false }, { RadioComponentController::rcCalFunctionMax, RadioComponentController::_rcCalPWMDefaultMinValue, RadioComponentController::_rcCalPWMDefaultMaxValue, 1500/*RadioComponentController::_rcCalPWMCenterPoint*/, false }, { RadioComponentController::rcCalFunctionMax, RadioComponentController::_rcCalPWMDefaultMinValue, RadioComponentController::_rcCalPWMDefaultMaxValue, 1500/*RadioComponentController::_rcCalPWMCenterPoint*/, false }, { RadioComponentController::rcCalFunctionMax, RadioComponentController::_rcCalPWMDefaultMinValue, RadioComponentController::_rcCalPWMDefaultMaxValue, 1500/*RadioComponentController::_rcCalPWMCenterPoint*/, false }, - - // Channels 9-11: Remainder of non-flight mode switches - { RadioComponentController::rcCalFunctionFlaps, _testMinValue, _testMaxValue, _testCenterValue, false }, - { RadioComponentController::rcCalFunctionAux1, _testMinValue, _testMaxValue, _testCenterValue, false }, - { RadioComponentController::rcCalFunctionAux2, _testMinValue, _testMaxValue, _testCenterValue, false }, // Channels 12-17 are not mapped and should be set to defaults { RadioComponentController::rcCalFunctionMax, RadioComponentController::_rcCalPWMDefaultMinValue, RadioComponentController::_rcCalPWMDefaultMaxValue, 1500/*RadioComponentController::_rcCalPWMCenterPoint*/, false }, @@ -335,33 +331,6 @@ void RadioConfigTest::_switchMinMaxStep(void) QCOMPARE(_controller->_currentStep, saveStep + 1); } -void RadioConfigTest::_flapsDetectStep(void) -{ - int channel = _rgFunctionChannelMap[RadioComponentController::rcCalFunctionFlaps]; - - qCDebug(RadioConfigTestLog) << "_flapsDetectStep channel" << channel; - - // Test code can't handle reversed flaps channel - Q_ASSERT(!_channelSettings()[channel].reversed); - - CHK_BUTTONS(nextButtonMask | cancelButtonMask | skipButtonMask); - - int saveStep = _controller->_currentStep; - - // Wiggle channel to identify - _stickMoveWaitForSettle(channel, _testMaxValue); - _stickMoveWaitForSettle(channel, _testMinValue); - - // Leave channel on full flaps down - _stickMoveWaitForSettle(channel, _testMaxValue); - - // User has to hit next at this step - QCOMPARE(_controller->_currentStep, saveStep); - CHK_BUTTONS(nextButtonMask | cancelButtonMask | skipButtonMask); - _controller->nextButtonClicked(); - QCOMPARE(_controller->_currentStep, saveStep + 1); -} - void RadioConfigTest::_switchSelectAutoStep(const char* functionStr, RadioComponentController::rcCalFunctions function) { Q_UNUSED(functionStr); @@ -449,12 +418,6 @@ void RadioConfigTest::_fullCalibrationWorker(MAV_AUTOPILOT firmwareType) _stickMoveAutoStep("Pitch", RadioComponentController::rcCalFunctionPitch, moveToMin, false /* not identify step */); _stickMoveAutoStep("Pitch", RadioComponentController::rcCalFunctionPitch, moveToCenter, false /* not identify step */); _switchMinMaxStep(); - if (firmwareType == MAV_AUTOPILOT_PX4) { - _flapsDetectStep(); - _stickMoveAutoStep("Flaps", RadioComponentController::rcCalFunctionFlaps, moveToMin, false /* not identify step */); - _switchSelectAutoStep("Aux1", RadioComponentController::rcCalFunctionAux1); - _switchSelectAutoStep("Aux2", RadioComponentController::rcCalFunctionAux2); - } // One more click and the parameters should get saved _controller->nextButtonClicked(); diff --git a/src/qgcunittest/RadioConfigTest.h b/src/qgcunittest/RadioConfigTest.h index 879b88fcdba4a8072f7e2414817aba9c12dac190..e399844853b043cc9203fc006ada6accb2d534d9 100644 --- a/src/qgcunittest/RadioConfigTest.h +++ b/src/qgcunittest/RadioConfigTest.h @@ -89,7 +89,6 @@ private: void _stickMoveWaitForSettle(int channel, int value); void _stickMoveAutoStep(const char* functionStr, enum RadioComponentController::rcCalFunctions function, enum MoveToDirection direction, bool identifyStep); void _switchMinMaxStep(void); - void _flapsDetectStep(void); void _switchSelectAutoStep(const char* functionStr, RadioComponentController::rcCalFunctions function); bool _px4Vehicle(void) const; const struct RadioComponentController::FunctionInfo* _functionInfo(void) const;