Commit 58b9c3f6 authored by Don Gagne's avatar Don Gagne

Merge pull request #2432 from DonLakeFlyer/APMPlane

APM  plane fixes
parents 8eced4a7 b887cbd9
...@@ -544,10 +544,12 @@ SOURCES += \ ...@@ -544,10 +544,12 @@ SOURCES += \
# #
INCLUDEPATH += \ INCLUDEPATH += \
src/AutoPilotPlugins/APM \
src/AutoPilotPlugins/Common \ src/AutoPilotPlugins/Common \
src/AutoPilotPlugins/PX4 \ src/AutoPilotPlugins/PX4 \
src/AutoPilotPlugins/APM \
src/FirmwarePlugin \ src/FirmwarePlugin \
src/FirmwarePlugin/APM \
src/FirmwarePlugin/PX4 \
src/Vehicle \ src/Vehicle \
src/VehicleSetup \ src/VehicleSetup \
......
...@@ -25,13 +25,14 @@ ...@@ -25,13 +25,14 @@
/// @author Don Gagne <don@thegagnes.com> /// @author Don Gagne <don@thegagnes.com>
#include "APMAirframeComponent.h" #include "APMAirframeComponent.h"
#include "QGCQmlWidgetHolder.h" #include "ArduCopterFirmwarePlugin.h"
APMAirframeComponent::APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : APMAirframeComponent::APMAirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
APMComponent(vehicle, autopilot, parent), : APMComponent(vehicle, autopilot, parent)
_name(tr("Airframe")) , _copterFirmware(false)
, _name("Airframe")
{ {
_copterFirmware = qobject_cast<ArduCopterFirmwarePlugin*>(_vehicle->firmwarePlugin()) != NULL;
} }
QString APMAirframeComponent::name(void) const QString APMAirframeComponent::name(void) const
...@@ -52,28 +53,45 @@ QString APMAirframeComponent::iconResource(void) const ...@@ -52,28 +53,45 @@ QString APMAirframeComponent::iconResource(void) const
bool APMAirframeComponent::requiresSetup(void) const bool APMAirframeComponent::requiresSetup(void) const
{ {
return true; return _copterFirmware;
} }
bool APMAirframeComponent::setupComplete(void) const bool APMAirframeComponent::setupComplete(void) const
{ {
//: Not the correct one, but it works for the moment. if (_copterFirmware) {
return _autopilot->getParameterFact(FactSystem::defaultComponentId, "FRAME")->rawValue().toInt() != -1; return _autopilot->getParameterFact(FactSystem::defaultComponentId, "FRAME")->rawValue().toInt() >= 0;
} else {
return true;
}
} }
QStringList APMAirframeComponent::setupCompleteChangedTriggerList(void) const QStringList APMAirframeComponent::setupCompleteChangedTriggerList(void) const
{ {
return QStringList(); QStringList list;
if (_copterFirmware) {
list << "FRAME";
}
return list;
} }
QUrl APMAirframeComponent::setupSource(void) const 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 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 QString APMAirframeComponent::prerequisiteSetup(void) const
......
...@@ -47,8 +47,8 @@ public: ...@@ -47,8 +47,8 @@ public:
virtual QString prerequisiteSetup(void) const; virtual QString prerequisiteSetup(void) const;
private: private:
bool _copterFirmware;
const QString _name; const QString _name;
QVariantList _summaryItems;
}; };
#endif #endif
...@@ -67,14 +67,12 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void) ...@@ -67,14 +67,12 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void)
Q_ASSERT(_vehicle); Q_ASSERT(_vehicle);
if (parametersReady()) { if (parametersReady()) {
if (dynamic_cast<ArduCopterFirmwarePlugin*>(_vehicle->firmwarePlugin())){ _airframeComponent = new APMAirframeComponent(_vehicle, this);
_airframeComponent = new APMAirframeComponent(_vehicle, this); if(_airframeComponent) {
if(_airframeComponent) { _airframeComponent->setupTriggerSignals();
_airframeComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent));
_components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent)); } else {
} else { qWarning() << "new APMAirframeComponent failed";
qWarning() << "new APMAirframeComponent failed";
}
} }
_flightModesComponent = new APMFlightModesComponent(_vehicle, this); _flightModesComponent = new APMFlightModesComponent(_vehicle, this);
......
...@@ -36,6 +36,7 @@ QGCView { ...@@ -36,6 +36,7 @@ QGCView {
viewPanel: panel viewPanel: panel
property real _margins: ScreenTools.defaultFontPixelHeight 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 } QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled }
...@@ -116,6 +117,7 @@ QGCView { ...@@ -116,6 +117,7 @@ QGCView {
anchors.left: flightModeSettings.right anchors.left: flightModeSettings.right
text: "Channel Options" text: "Channel Options"
font.weight: Font.DemiBold font.weight: Font.DemiBold
visible: _channelOptionsAvailable
} }
Rectangle { Rectangle {
...@@ -126,6 +128,7 @@ QGCView { ...@@ -126,6 +128,7 @@ QGCView {
width: channelOptColumn.width + (_margins * 2) width: channelOptColumn.width + (_margins * 2)
height: channelOptColumn.height + ScreenTools.defaultFontPixelHeight height: channelOptColumn.height + ScreenTools.defaultFontPixelHeight
color: qgcPal.windowShade color: qgcPal.windowShade
visible: _channelOptionsAvailable
Column { Column {
id: channelOptColumn id: channelOptColumn
...@@ -141,19 +144,18 @@ QGCView { ...@@ -141,19 +144,18 @@ QGCView {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
property int index: modelData + 7 property int index: modelData + 7
property Fact nullFact: Fact { }
QGCLabel { QGCLabel {
anchors.baseline: optCombo.baseline anchors.baseline: optCombo.baseline
text: "Channel option " + index + ":" text: "Channel option " + index + ":"
color: controller.channelOptionEnabled[modelData] ? qgcPal.buttonHighlight : qgcPal.text color: controller.channelOptionEnabled[modelData] ? qgcPal.buttonHighlight : qgcPal.text
Component.onCompleted: console.log(index, controller.channelOptionEnabled[modelData])
} }
FactComboBox { FactComboBox {
id: optCombo id: optCombo
width: ScreenTools.defaultFontPixelWidth * 15 width: ScreenTools.defaultFontPixelWidth * 15
fact: controller.getParameterFact(-1, "CH" + index + "_OPT") fact: _channelOptionsAvailable ? controller.getParameterFact(-1, "CH" + index + "_OPT") : nullFact
indexModel: false indexModel: false
} }
} }
......
...@@ -299,6 +299,8 @@ Rectangle { ...@@ -299,6 +299,8 @@ Rectangle {
setupComplete: modelData.setupComplete setupComplete: modelData.setupComplete
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
text: modelData.name text: modelData.name
visible: modelData.setupSource.toString() != ""
onClicked: showVehicleComponentPanel(modelData) onClicked: showVehicleComponentPanel(modelData)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment