From a5981a149c9cd5410b93d25b9c38771ec49d87d9 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Tue, 2 Jan 2018 18:01:50 -0800 Subject: [PATCH] Respect FW_ARSP_MODE value --- src/AutoPilotPlugins/PX4/SensorsComponent.cc | 15 ++++++++------- src/AutoPilotPlugins/PX4/SensorsComponent.h | 5 +++-- .../PX4/SensorsComponentSummaryFixedWing.qml | 18 ++++++++++++------ src/AutoPilotPlugins/PX4/SensorsSetup.qml | 1 + 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.cc b/src/AutoPilotPlugins/PX4/SensorsComponent.cc index 60f0758f1..7fbc76bd0 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.cc @@ -16,8 +16,9 @@ #include "QGCQmlWidgetHolder.h" #include "SensorsComponentController.h" -const char* SensorsComponent::_airspeedBreaker = "CBRK_AIRSPD_CHK"; -const char* SensorsComponent::_airspeedCal = "SENS_DPRES_OFF"; +const char* SensorsComponent::_airspeedBreakerParam = "CBRK_AIRSPD_CHK"; +const char* SensorsComponent::_airspeedDisabledParam = "FW_ARSP_MODE"; +const char* SensorsComponent::_airspeedCalParam = "SENS_DPRES_OFF"; SensorsComponent::SensorsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : VehicleComponent(vehicle, autopilot, parent), @@ -55,10 +56,10 @@ bool SensorsComponent::setupComplete(void) const } if (_vehicle->fixedWing() || _vehicle->vtol()) { - if (_vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, _airspeedBreaker)->rawValue().toInt() != 162128) { - if (_vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, _airspeedCal)->rawValue().toFloat() == 0.0f) { - return false; - } + if (!_vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, _airspeedDisabledParam)->rawValue().toBool() && + _vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, _airspeedBreakerParam)->rawValue().toInt() != 162128 && + _vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, _airspeedCalParam)->rawValue().toFloat() == 0.0f) { + return false; } } @@ -71,7 +72,7 @@ QStringList SensorsComponent::setupCompleteChangedTriggerList(void) const triggers << _deviceIds; if (_vehicle->fixedWing() || _vehicle->vtol()) { - triggers << _airspeedCal << _airspeedBreaker; + triggers << _airspeedCalParam << _airspeedBreakerParam; } return triggers; diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.h b/src/AutoPilotPlugins/PX4/SensorsComponent.h index da29a3848..9201c5e8e 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.h +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.h @@ -41,8 +41,9 @@ private: QVariantList _summaryItems; QStringList _deviceIds; - static const char* _airspeedBreaker; - static const char* _airspeedCal; + static const char* _airspeedDisabledParam; + static const char* _airspeedBreakerParam; + static const char* _airspeedCalParam; }; #endif diff --git a/src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml b/src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml index 760a75f9b..4c8887700 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml +++ b/src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml @@ -18,10 +18,15 @@ FactPanel { QGCPalette { id: qgcPal; colorGroupEnabled: enabled } FactPanelController { id: controller; factPanel: panel } - property Fact mag0IdFact: controller.getParameterFact(-1, "CAL_MAG0_ID") - property Fact gyro0IdFact: controller.getParameterFact(-1, "CAL_GYRO0_ID") - property Fact accel0IdFact: controller.getParameterFact(-1, "CAL_ACC0_ID") - property Fact dpressOffFact: controller.getParameterFact(-1, "SENS_DPRES_OFF") + property Fact mag0IdFact: controller.getParameterFact(-1, "CAL_MAG0_ID") + property Fact gyro0IdFact: controller.getParameterFact(-1, "CAL_GYRO0_ID") + property Fact accel0IdFact: controller.getParameterFact(-1, "CAL_ACC0_ID") + property Fact dpressOffFact: controller.getParameterFact(-1, "SENS_DPRES_OFF") + property Fact airspeedDisabledFact: controller.getParameterFact(-1, "FW_ARSP_MODE") + property Fact airspeedBreakerFact: controller.getParameterFact(-1, "CBRK_AIRSPD_CHK") + + property bool _airspeedVisible: airspeedDisabledFact.value == false && airspeedBreakerFact.value != 162128 + property bool _airspeedCalRequired: _airspeedVisible && dpressOffFact.value == 0 Column { anchors.fill: parent @@ -42,8 +47,9 @@ FactPanel { } VehicleSummaryRow { - labelText: qsTr("Airspeed:") - valueText: dpressOffFact ? (dpressOffFact.value === 0 ? qsTr("Setup required") : qsTr("Ready")) : "" + labelText: qsTr("Airspeed:") + visible: _airspeedVisible + valueText: _airspeedCalRequired ? qsTr("Setup required") : qsTr("Ready") } } } diff --git a/src/AutoPilotPlugins/PX4/SensorsSetup.qml b/src/AutoPilotPlugins/PX4/SensorsSetup.qml index 157dcd4da..8a46c11ec 100644 --- a/src/AutoPilotPlugins/PX4/SensorsSetup.qml +++ b/src/AutoPilotPlugins/PX4/SensorsSetup.qml @@ -410,6 +410,7 @@ Item { width: _buttonWidth text: qsTr("Airspeed") visible: (controller.vehicle.fixedWing || controller.vehicle.vtol) && + controller.getParameterFact(-1, "FW_ARSP_MODE").value == false && controller.getParameterFact(-1, "CBRK_AIRSPD_CHK").value != 162128 && QGroundControl.corePlugin.options.showSensorCalibrationAirspeed && showSensorCalibrationAirspeed -- 2.22.0