diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 114ab1c3ad4c13cd4686fb1b85840fd24e217cf0..f8cb1d6881192b0d75a19e319d98bb27072c113e 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -948,6 +948,7 @@ APMFirmwarePlugin { src/AutoPilotPlugins/APM/APMCompassCal.h \ src/AutoPilotPlugins/APM/APMFlightModesComponent.h \ src/AutoPilotPlugins/APM/APMFlightModesComponentController.h \ + src/AutoPilotPlugins/APM/APMHeliComponent.h \ src/AutoPilotPlugins/APM/APMLightsComponent.h \ src/AutoPilotPlugins/APM/APMSubFrameComponent.h \ src/AutoPilotPlugins/APM/APMPowerComponent.h \ @@ -973,6 +974,7 @@ APMFirmwarePlugin { src/AutoPilotPlugins/APM/APMCompassCal.cc \ src/AutoPilotPlugins/APM/APMFlightModesComponent.cc \ src/AutoPilotPlugins/APM/APMFlightModesComponentController.cc \ + src/AutoPilotPlugins/APM/APMHeliComponent.cc \ src/AutoPilotPlugins/APM/APMLightsComponent.cc \ src/AutoPilotPlugins/APM/APMSubFrameComponent.cc \ src/AutoPilotPlugins/APM/APMPowerComponent.cc \ diff --git a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc index 1df7e73923bba6e97fde80c1e60b80a13e777e64..58b3e13b85cb14e686e1298586d15384aee6ef4b 100644 --- a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc @@ -28,27 +28,29 @@ #include "APMLightsComponent.h" #include "APMSubFrameComponent.h" #include "ESP8266Component.h" +#include "APMHeliComponent.h" /// This is the AutoPilotPlugin implementatin for the MAV_AUTOPILOT_ARDUPILOT type. APMAutoPilotPlugin::APMAutoPilotPlugin(Vehicle* vehicle, QObject* parent) - : AutoPilotPlugin(vehicle, parent) + : AutoPilotPlugin (vehicle, parent) , _incorrectParameterVersion(false) - , _airframeComponent(NULL) - , _cameraComponent(NULL) - , _lightsComponent(NULL) - , _subFrameComponent(NULL) - , _flightModesComponent(NULL) - , _powerComponent(NULL) + , _airframeComponent (NULL) + , _cameraComponent (NULL) + , _lightsComponent (NULL) + , _subFrameComponent (NULL) + , _flightModesComponent (NULL) + , _powerComponent (NULL) #if 0 // Temporarily removed, waiting for new command implementation - , _motorComponent(NULL) + , _motorComponent (NULL) #endif - , _radioComponent(NULL) - , _safetyComponent(NULL) - , _sensorsComponent(NULL) - , _tuningComponent(NULL) - , _airframeFacts(new APMAirframeLoader(this, vehicle->uas(), this)) - , _esp8266Component(NULL) + , _radioComponent (NULL) + , _safetyComponent (NULL) + , _sensorsComponent (NULL) + , _tuningComponent (NULL) + , _airframeFacts (new APMAirframeLoader(this, vehicle->uas(), this)) + , _esp8266Component (NULL) + , _heliComponent (NULL) { APMAirframeLoader::loadAirframeFactMetaData(); } @@ -101,6 +103,12 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void) _safetyComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_safetyComponent)); + if (_vehicle->vehicleType() == MAV_TYPE_HELICOPTER) { + _heliComponent = new APMHeliComponent(_vehicle, this); + _heliComponent->setupTriggerSignals(); + _components.append(QVariant::fromValue((VehicleComponent*)_heliComponent)); + } + _tuningComponent = new APMTuningComponent(_vehicle, this); _tuningComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_tuningComponent)); diff --git a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h index fe6246f27e2bde05bbb53af224645b7077093594..018eb11502e8bdbd2dc013412448dc942ce0065d 100644 --- a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h +++ b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h @@ -27,6 +27,7 @@ class APMCameraComponent; class APMLightsComponent; class APMSubFrameComponent; class ESP8266Component; +class APMHeliComponent; /// This is the APM specific implementation of the AutoPilot class. class APMAutoPilotPlugin : public AutoPilotPlugin @@ -59,6 +60,7 @@ protected: APMTuningComponent* _tuningComponent; APMAirframeLoader* _airframeFacts; ESP8266Component* _esp8266Component; + APMHeliComponent* _heliComponent; private: QVariantList _components; diff --git a/src/AutoPilotPlugins/APM/APMHeliComponent.cc b/src/AutoPilotPlugins/APM/APMHeliComponent.cc new file mode 100644 index 0000000000000000000000000000000000000000..9251d299c94c00df3ed9e23444c6e1c44481c531 --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMHeliComponent.cc @@ -0,0 +1,57 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#include "APMHeliComponent.h" +#include "APMAutoPilotPlugin.h" + +APMHeliComponent::APMHeliComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) + : VehicleComponent(vehicle, autopilot, parent) + , _name(tr("Heli")) +{ +} + +QString APMHeliComponent::name(void) const +{ + return _name; +} + +QString APMHeliComponent::description(void) const +{ + return tr("Heli Setup is used to setup parameters which are specific to a helicopter."); +} + +QString APMHeliComponent::iconResource(void) const +{ + return QString(); +} + +bool APMHeliComponent::requiresSetup(void) const +{ + return false; +} + +bool APMHeliComponent::setupComplete(void) const +{ + return true; +} + +QStringList APMHeliComponent::setupCompleteChangedTriggerList(void) const +{ + return QStringList(); +} + +QUrl APMHeliComponent::setupSource(void) const +{ + return QStringLiteral("qrc:/qml/APMHeliComponent.qml"); +} + +QUrl APMHeliComponent::summaryQmlSource(void) const +{ + return QUrl(); +} diff --git a/src/AutoPilotPlugins/APM/APMHeliComponent.h b/src/AutoPilotPlugins/APM/APMHeliComponent.h new file mode 100644 index 0000000000000000000000000000000000000000..cac462523bb80156bbf6e369c4a8e650fb79a4c5 --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMHeliComponent.h @@ -0,0 +1,37 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#pragma once + +#include "VehicleComponent.h" + +class APMHeliComponent : public VehicleComponent +{ + Q_OBJECT + +public: + APMHeliComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); + + // Virtuals from VehicleComponent + QStringList setupCompleteChangedTriggerList(void) const override; + + // Virtuals from VehicleComponent + QString name(void) const override; + QString description(void) const override; + QString iconResource(void) const override; + bool requiresSetup(void) const override; + bool setupComplete(void) const override; + QUrl setupSource(void) const override; + QUrl summaryQmlSource(void) const override; + bool allowSetupWhileArmed(void) const override { return true; } + +private: + const QString _name; + QVariantList _summaryItems; +}; diff --git a/src/AutoPilotPlugins/APM/APMHeliComponent.qml b/src/AutoPilotPlugins/APM/APMHeliComponent.qml new file mode 100644 index 0000000000000000000000000000000000000000..cfe1564c522b294ac11c2e536a3ee877202a51dc --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMHeliComponent.qml @@ -0,0 +1,199 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + + +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtGraphicalEffects 1.0 +import QtQuick.Layouts 1.2 + +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 + +SetupPage { + id: safetyPage + pageComponent: safetyPageComponent + + Component { + id: safetyPageComponent + + Flow { + id: flowLayout + width: availableWidth + spacing: _margins + + FactPanelController { id: controller; factPanel: safetyPage.viewPanel } + + QGCPalette { id: ggcPal; colorGroupEnabled: true } + + property Fact _failsafeGCSEnable: controller.getParameterFact(-1, "FS_GCS_ENABLE") + property Fact _failsafeBattLowAct: controller.getParameterFact(-1, "r.BATT_FS_LOW_ACT") + property Fact _failsafeBattMah: controller.getParameterFact(-1, "r.BATT_LOW_MAH") + property Fact _failsafeBattVoltage: controller.getParameterFact(-1, "r.BATT_LOW_VOLT") + property Fact _failsafeThrEnable: controller.getParameterFact(-1, "FS_THR_ENABLE") + property Fact _failsafeThrValue: controller.getParameterFact(-1, "FS_THR_VALUE") + + property bool _failsafeBattCritActAvailable: controller.parameterExists(-1, "BATT_FS_CRT_ACT") + property bool _failsafeBatt2LowActAvailable: controller.parameterExists(-1, "BATT2_FS_LOW_ACT") + property bool _failsafeBatt2CritActAvailable: controller.parameterExists(-1, "BATT2_FS_CRT_ACT") + property bool _batt2MonitorAvailable: controller.parameterExists(-1, "BATT2_MONITOR") + property bool _batt2MonitorEnabled: _batt2MonitorAvailable ? _batt2Monitor.rawValue !== 0 : false + + property Fact _failsafeBattCritAct: controller.getParameterFact(-1, "BATT_FS_CRT_ACT", false /* reportMissing */) + property Fact _batt2Monitor: controller.getParameterFact(-1, "BATT2_MONITOR", false /* reportMissing */) + property Fact _failsafeBatt2LowAct: controller.getParameterFact(-1, "BATT2_FS_LOW_ACT", false /* reportMissing */) + property Fact _failsafeBatt2CritAct: controller.getParameterFact(-1, "BATT2_FS_CRT_ACT", false /* reportMissing */) + property Fact _failsafeBatt2Mah: controller.getParameterFact(-1, "BATT2_LOW_MAH", false /* reportMissing */) + property Fact _failsafeBatt2Voltage: controller.getParameterFact(-1, "BATT2_LOW_VOLT", false /* reportMissing */) + + property Fact _fenceAction: controller.getParameterFact(-1, "FENCE_ACTION") + property Fact _fenceAltMax: controller.getParameterFact(-1, "FENCE_ALT_MAX") + property Fact _fenceEnable: controller.getParameterFact(-1, "FENCE_ENABLE") + property Fact _fenceMargin: controller.getParameterFact(-1, "FENCE_MARGIN") + property Fact _fenceRadius: controller.getParameterFact(-1, "FENCE_RADIUS") + property Fact _fenceType: controller.getParameterFact(-1, "FENCE_TYPE") + + property Fact _landSpeedFact: controller.getParameterFact(-1, "LAND_SPEED") + property Fact _rtlAltFact: controller.getParameterFact(-1, "RTL_ALT") + property Fact _rtlLoitTimeFact: controller.getParameterFact(-1, "RTL_LOIT_TIME") + property Fact _rtlAltFinalFact: controller.getParameterFact(-1, "RTL_ALT_FINAL") + + property Fact _armingCheck: controller.getParameterFact(-1, "ARMING_CHECK") + + property real _margins: ScreenTools.defaultFontPixelHeight + property bool _showIcon: !ScreenTools.isTinyScreen + + ExclusiveGroup { id: fenceActionRadioGroup } + ExclusiveGroup { id: landLoiterRadioGroup } + ExclusiveGroup { id: returnAltRadioGroup } + + Column { + spacing: _margins / 2 + + QGCLabel { + text: qsTr("Servo Setup") + font.family: ScreenTools.demiboldFontFamily + } + + Rectangle { + width: servoGrid.x + servoGrid.width + _margins + height: servoGrid.y + servoGrid.height + _margins + color: ggcPal.windowShade + + GridLayout { + id: servoGrid + columns: 6 + + QGCLabel { text: qsTr("Servo") } + QGCLabel { text: qsTr("Function") } + QGCLabel { text: qsTr("Min") } + QGCLabel { text: qsTr("Max") } + QGCLabel { text: qsTr("Trim") } + QGCLabel { text: qsTr("Reversed") } + + QGCLabel { text: qsTr("1") } + FactComboBox { + fact: controller.getParameterFact(-1, "SERVO1_FUNCTION") + indexModel: false + Layout.fillWidth: true + } + FactTextField { + fact: controller.getParameterFact(-1, "SERVO1_MIN") + Layout.fillWidth: true + } + FactTextField { + fact: controller.getParameterFact(-1, "SERVO1_MAX") + Layout.fillWidth: true + } + FactTextField { + fact: controller.getParameterFact(-1, "SERVO1_TRIM") + Layout.fillWidth: true + } + FactCheckBox { + fact: controller.getParameterFact(-1, "SERVO1_REVERSED") + Layout.fillWidth: true + } + + QGCLabel { text: qsTr("2") } + FactComboBox { + fact: controller.getParameterFact(-1, "SERVO2_FUNCTION") + indexModel: false + Layout.fillWidth: true + } + FactTextField { + fact: controller.getParameterFact(-1, "SERVO2_MIN") + Layout.fillWidth: true + } + FactTextField { + fact: controller.getParameterFact(-1, "SERVO2_MAX") + Layout.fillWidth: true + } + FactTextField { + fact: controller.getParameterFact(-1, "SERVO2_TRIM") + Layout.fillWidth: true + } + FactCheckBox { + fact: controller.getParameterFact(-1, "SERVO2_REVERSED") + Layout.fillWidth: true + } + + QGCLabel { text: qsTr("3") } + FactComboBox { + fact: controller.getParameterFact(-1, "SERVO3_FUNCTION") + indexModel: false + Layout.fillWidth: true + } + FactTextField { + fact: controller.getParameterFact(-1, "SERVO3_MIN") + Layout.fillWidth: true + } + FactTextField { + fact: controller.getParameterFact(-1, "SERVO3_MAX") + Layout.fillWidth: true + } + FactTextField { + fact: controller.getParameterFact(-1, "SERVO3_TRIM") + Layout.fillWidth: true + } + FactCheckBox { + fact: controller.getParameterFact(-1, "SERVO3_REVERSED") + Layout.fillWidth: true + } + + QGCLabel { text: qsTr("4") } + FactComboBox { + fact: controller.getParameterFact(-1, "SERVO4_FUNCTION") + indexModel: false + Layout.fillWidth: true + } + FactTextField { + fact: controller.getParameterFact(-1, "SERVO4_MIN") + Layout.fillWidth: true + } + FactTextField { + fact: controller.getParameterFact(-1, "SERVO4_MAX") + Layout.fillWidth: true + } + FactTextField { + fact: controller.getParameterFact(-1, "SERVO4_TRIM") + Layout.fillWidth: true + } + FactCheckBox { + fact: controller.getParameterFact(-1, "SERVO4_REVERSED") + Layout.fillWidth: true + } + } // GridLayout + } // Rectangle + } // Column + } // Flow + } // Component +} // SetupView diff --git a/src/FactSystem/FactControls/FactCheckBox.qml b/src/FactSystem/FactControls/FactCheckBox.qml index 4a591e92bc29e69b8613f536fb74ed6f5a6995aa..7ed1757ff41f3b91ae45ceb556f4dfead05365b9 100644 --- a/src/FactSystem/FactControls/FactCheckBox.qml +++ b/src/FactSystem/FactControls/FactCheckBox.qml @@ -16,7 +16,5 @@ QGCCheckBox { (fact.value === 0 ? Qt.Unchecked : Qt.Checked)) : Qt.Unchecked - text: qsTr("Label") - onClicked: fact.value = (checked ? checkedValue : uncheckedValue) } diff --git a/src/FirmwarePlugin/APM/APMResources.qrc b/src/FirmwarePlugin/APM/APMResources.qrc index 58536bab5a085803f4d73bc0e90820ed4aac6966..df6ffa966370b0359dd61078c07874fe78a69a16 100644 --- a/src/FirmwarePlugin/APM/APMResources.qrc +++ b/src/FirmwarePlugin/APM/APMResources.qrc @@ -6,6 +6,7 @@ ../../AutoPilotPlugins/APM/APMCameraComponentSummary.qml ../../AutoPilotPlugins/APM/APMFlightModesComponent.qml ../../AutoPilotPlugins/APM/APMFlightModesComponentSummary.qml + ../../AutoPilotPlugins/APM/APMHeliComponent.qml ../../AutoPilotPlugins/APM/APMLightsComponent.qml ../../AutoPilotPlugins/APM/APMLightsComponentSummary.qml ../../AutoPilotPlugins/APM/APMSubFrameComponent.qml