diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index e6f7fcde31effefdb635195de556f2ca1b733f6a..167a06a679383f797969ebead4d7d9ef93284cf2 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -544,10 +544,12 @@ SOURCES += \ # INCLUDEPATH += \ + src/AutoPilotPlugins/APM \ src/AutoPilotPlugins/Common \ src/AutoPilotPlugins/PX4 \ - src/AutoPilotPlugins/APM \ src/FirmwarePlugin \ + src/FirmwarePlugin/APM \ + src/FirmwarePlugin/PX4 \ src/Vehicle \ src/VehicleSetup \ diff --git a/src/AutoPilotPlugins/APM/APMAirframeComponent.cc b/src/AutoPilotPlugins/APM/APMAirframeComponent.cc index 19899f11f903a068faccf89db10feea733f76082..12fb5df929072bbf60e279bde9c4e2e9b3c9ddd9 100644 --- a/src/AutoPilotPlugins/APM/APMAirframeComponent.cc +++ b/src/AutoPilotPlugins/APM/APMAirframeComponent.cc @@ -25,13 +25,14 @@ /// @author Don Gagne #include "APMAirframeComponent.h" -#include "QGCQmlWidgetHolder.h" +#include "ArduCopterFirmwarePlugin.h" -APMAirframeComponent::APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : - APMComponent(vehicle, autopilot, parent), - _name(tr("Airframe")) +APMAirframeComponent::APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) + : APMComponent(vehicle, autopilot, parent) + , _copterFirmware(false) + , _name("Airframe") { - + _copterFirmware = qobject_cast(_vehicle->firmwarePlugin()) != NULL; } QString APMAirframeComponent::name(void) const @@ -52,28 +53,45 @@ QString APMAirframeComponent::iconResource(void) const bool APMAirframeComponent::requiresSetup(void) const { - return true; + return _copterFirmware; } bool APMAirframeComponent::setupComplete(void) const { - //: Not the correct one, but it works for the moment. - return _autopilot->getParameterFact(FactSystem::defaultComponentId, "FRAME")->rawValue().toInt() != -1; + if (_copterFirmware) { + return _autopilot->getParameterFact(FactSystem::defaultComponentId, "FRAME")->rawValue().toInt() >= 0; + } else { + return true; + } } QStringList APMAirframeComponent::setupCompleteChangedTriggerList(void) const { - return QStringList(); + QStringList list; + + if (_copterFirmware) { + list << "FRAME"; + } + + return list; } QUrl APMAirframeComponent::setupSource(void) const { - return QUrl::fromUserInput("qrc:/qml/APMAirframeComponent.qml"); + if (_copterFirmware) { + return QUrl::fromUserInput("qrc:/qml/APMAirframeComponent.qml"); + } else { + return QUrl(); + } } QUrl APMAirframeComponent::summaryQmlSource(void) const { - return QUrl::fromUserInput("qrc:/qml/APMAirframeComponentSummary.qml"); + if (_copterFirmware) { + return QUrl::fromUserInput("qrc:/qml/APMAirframeComponentSummary.qml"); + } else { + return QUrl(); + } } QString APMAirframeComponent::prerequisiteSetup(void) const diff --git a/src/AutoPilotPlugins/APM/APMAirframeComponent.h b/src/AutoPilotPlugins/APM/APMAirframeComponent.h index a37f9d3f98e62b2207b3846116cc541735233b3c..774193815acdf969b3b168208bdd8b0231831d38 100644 --- a/src/AutoPilotPlugins/APM/APMAirframeComponent.h +++ b/src/AutoPilotPlugins/APM/APMAirframeComponent.h @@ -47,8 +47,8 @@ public: virtual QString prerequisiteSetup(void) const; private: + bool _copterFirmware; const QString _name; - QVariantList _summaryItems; }; #endif diff --git a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc index 338ce0d7ab7668d0e4e2b292c46a0e0b137d4d09..e0bdf1676fa58d48387ebb35c459615fccb1621b 100644 --- a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc @@ -67,14 +67,12 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void) Q_ASSERT(_vehicle); if (parametersReady()) { - if (dynamic_cast(_vehicle->firmwarePlugin())){ - _airframeComponent = new APMAirframeComponent(_vehicle, this); - if(_airframeComponent) { - _airframeComponent->setupTriggerSignals(); - _components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent)); - } else { - qWarning() << "new APMAirframeComponent failed"; - } + _airframeComponent = new APMAirframeComponent(_vehicle, this); + if(_airframeComponent) { + _airframeComponent->setupTriggerSignals(); + _components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent)); + } else { + qWarning() << "new APMAirframeComponent failed"; } _flightModesComponent = new APMFlightModesComponent(_vehicle, this); diff --git a/src/AutoPilotPlugins/APM/APMFlightModesComponent.qml b/src/AutoPilotPlugins/APM/APMFlightModesComponent.qml index 9fbeeab7b7497abff50d62b95aefb28136885698..34c76beca06af5ad19b131fa9a801da52e661bd6 100644 --- a/src/AutoPilotPlugins/APM/APMFlightModesComponent.qml +++ b/src/AutoPilotPlugins/APM/APMFlightModesComponent.qml @@ -36,6 +36,7 @@ QGCView { viewPanel: panel property real _margins: ScreenTools.defaultFontPixelHeight + property bool _channelOptionsAvailable: controller.parameterExists(-1, "CH7_OPT") // Not available in all firmware types QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } @@ -116,6 +117,7 @@ QGCView { anchors.left: flightModeSettings.right text: "Channel Options" font.weight: Font.DemiBold + visible: _channelOptionsAvailable } Rectangle { @@ -126,6 +128,7 @@ QGCView { width: channelOptColumn.width + (_margins * 2) height: channelOptColumn.height + ScreenTools.defaultFontPixelHeight color: qgcPal.windowShade + visible: _channelOptionsAvailable Column { id: channelOptColumn @@ -141,19 +144,18 @@ QGCView { spacing: ScreenTools.defaultFontPixelWidth property int index: modelData + 7 + property Fact nullFact: Fact { } QGCLabel { anchors.baseline: optCombo.baseline text: "Channel option " + index + ":" color: controller.channelOptionEnabled[modelData] ? qgcPal.buttonHighlight : qgcPal.text - - Component.onCompleted: console.log(index, controller.channelOptionEnabled[modelData]) } FactComboBox { id: optCombo width: ScreenTools.defaultFontPixelWidth * 15 - fact: controller.getParameterFact(-1, "CH" + index + "_OPT") + fact: _channelOptionsAvailable ? controller.getParameterFact(-1, "CH" + index + "_OPT") : nullFact indexModel: false } } diff --git a/src/VehicleSetup/SetupView.qml b/src/VehicleSetup/SetupView.qml index 27e8c33a131e69f4cd1650d530799dba793e4f8b..a6bef3b741542be78be29fbbcbb2c3a0b8a82835 100644 --- a/src/VehicleSetup/SetupView.qml +++ b/src/VehicleSetup/SetupView.qml @@ -299,6 +299,8 @@ Rectangle { setupComplete: modelData.setupComplete exclusiveGroup: setupButtonGroup text: modelData.name + visible: modelData.setupSource.toString() != "" + onClicked: showVehicleComponentPanel(modelData) }