diff --git a/src/FactSystem/FactControls/FactComboBox.qml b/src/FactSystem/FactControls/FactComboBox.qml index 7c61bd4278cc099ff2841ecc5b2b0d14117caae2..d56bbf11fc4ffc2a7c5115e76d7cd103639f6333 100644 --- a/src/FactSystem/FactControls/FactComboBox.qml +++ b/src/FactSystem/FactControls/FactComboBox.qml @@ -10,7 +10,7 @@ QGCComboBox { property Fact fact: Fact { } property bool indexModel: true ///< true: model must be specifed, selected index is fact value, false: use enum meta data - model: fact.enumStrings + model: fact ? fact.enumStrings : null currentIndex: indexModel ? fact.value : fact.enumIndex diff --git a/src/FirmwarePlugin/APM/APMFirmwarePlugin.h b/src/FirmwarePlugin/APM/APMFirmwarePlugin.h index 56f935aa8ea089264a6cb1e39d2b5689d4109a2f..80a20945ca672d566e4f619087070f0cc7a1084d 100644 --- a/src/FirmwarePlugin/APM/APMFirmwarePlugin.h +++ b/src/FirmwarePlugin/APM/APMFirmwarePlugin.h @@ -79,7 +79,7 @@ public: bool setFlightMode(const QString& flightMode, uint8_t* base_mode, uint32_t* custom_mode) final; bool isGuidedMode(const Vehicle* vehicle) const final; void pauseVehicle(Vehicle* vehicle); - int manualControlReservedButtonCount(void) final; + int manualControlReservedButtonCount(void); bool adjustIncomingMavlinkMessage(Vehicle* vehicle, mavlink_message_t* message) final; void adjustOutgoingMavlinkMessage(Vehicle* vehicle, mavlink_message_t* message) final; void initializeVehicle(Vehicle* vehicle) final; diff --git a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc index e6fad43ea24d8abd36b2a6f1cb382fc2d6c25d81..ea1538a9e473525da69ae6ff0e82c4c9e750bcc9 100644 --- a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc +++ b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc @@ -47,3 +47,8 @@ ArduSubFirmwarePlugin::ArduSubFirmwarePlugin(void) supportedFlightModes << APMSubMode(APMSubMode::ALT_HOLD ,true); setSupportedModes(supportedFlightModes); } + +int ArduSubFirmwarePlugin::manualControlReservedButtonCount(void) +{ + return 0; +} diff --git a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h index 1030a459dc7ad9227f8aacd9370014a3c37591b2..a927a44d9edd004754206324bb5544fa334d2a6d 100644 --- a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h +++ b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h @@ -67,6 +67,7 @@ public: ArduSubFirmwarePlugin(void); // Overrides from FirmwarePlugin + int manualControlReservedButtonCount(void); }; diff --git a/src/Joystick/Joystick.cc b/src/Joystick/Joystick.cc index 725019b026ab493a4c25dc2b0d398af3d56395de..93dc847dabe5105dbb52dd2f055a7c10cff812e6 100644 --- a/src/Joystick/Joystick.cc +++ b/src/Joystick/Joystick.cc @@ -284,7 +284,7 @@ void Joystick::run(void) throttle = std::max(-1.0f, std::min(tanf(asinf(throttle_limited)), 1.0f)); // Adjust throttle to 0:1 range - if (_throttleMode == ThrottleModeCenterZero) { + if (_throttleMode == ThrottleModeCenterZero && !_activeVehicle->sub()) { throttle = std::max(0.0f, throttle); } else { throttle = (throttle + 1.0f) / 2.0f; diff --git a/src/VehicleSetup/JoystickConfig.qml b/src/VehicleSetup/JoystickConfig.qml index 79f8ce119274e265176373fbaa310eeb7fcb0f09..c53a742739e0dc6bec54b0204c3f352f3edc9252 100644 --- a/src/VehicleSetup/JoystickConfig.qml +++ b/src/VehicleSetup/JoystickConfig.qml @@ -18,6 +18,7 @@ import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 import QGroundControl.Controllers 1.0 import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 /// Joystick Config QGCView { @@ -380,6 +381,7 @@ QGCView { Column { spacing: ScreenTools.defaultFontPixelHeight / 3 + visible: !_activeVehicle.sub ExclusiveGroup { id: throttleModeExclusiveGroup } @@ -447,6 +449,9 @@ QGCView { if (buttonActionRepeater.itemAt(index)) { buttonActionRepeater.itemAt(index).pressed = pressed } + if (subButtonActionRepeater.itemAt(index)) { + subButtonActionRepeater.itemAt(index).pressed = pressed + } } } @@ -469,7 +474,7 @@ QGCView { Row { spacing: ScreenTools.defaultFontPixelWidth - visible: _activeVehicle.manualControlReservedButtonCount == -1 ? false : modelData >= _activeVehicle.manualControlReservedButtonCount + visible: (_activeVehicle.manualControlReservedButtonCount == -1 ? false : modelData >= _activeVehicle.manualControlReservedButtonCount) && !_activeVehicle.sub property bool pressed @@ -508,6 +513,71 @@ QGCView { } } } // Repeater + + Row { + spacing: ScreenTools.defaultFontPixelWidth + visible: _activeVehicle.sub + + QGCLabel { + horizontalAlignment: Text.AlignHCenter + width: ScreenTools.defaultFontPixelHeight * 1.5 + text: qsTr("#") + } + + QGCLabel { + width: ScreenTools.defaultFontPixelWidth * 15 + text: qsTr("Function: ") + } + + QGCLabel { + width: ScreenTools.defaultFontPixelWidth * 15 + text: qsTr("Shift Function: ") + } + } // Row + + Repeater { + id: subButtonActionRepeater + model: _activeJoystick.totalButtonCount + + Row { + spacing: ScreenTools.defaultFontPixelWidth + visible: _activeVehicle.sub + + property bool pressed + + Rectangle { + anchors.verticalCenter: parent.verticalCenter + width: ScreenTools.defaultFontPixelHeight * 1.5 + height: width + border.width: 1 + border.color: qgcPal.text + color: pressed ? qgcPal.buttonHighlight : qgcPal.button + + + QGCLabel { + anchors.fill: parent + color: pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + text: modelData + } + } + + FactComboBox { + id: mainSubButtonActionCombo + width: ScreenTools.defaultFontPixelWidth * 15 + fact: controller.parameterExists(-1, "BTN"+index+"_FUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_FUNCTION") : null; + indexModel: false + } + + FactComboBox { + id: shiftSubButtonActionCombo + width: ScreenTools.defaultFontPixelWidth * 15 + fact: controller.parameterExists(-1, "BTN"+index+"_SFUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_SFUNCTION") : null; + indexModel: false + } + } // Row + } // Repeater } // Column } // Column - right setting column } // Row - Settings