From e89706064aa7453cb87671551c29b1af7eaf929c Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 18 Apr 2016 18:30:08 +0200 Subject: [PATCH] Fix flight mode display for PX4. Missed reverse channel check --- src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml | 2 +- .../PX4/PX4SimpleFlightModesController.cc | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml b/src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml index 4099de573..525f91e3d 100644 --- a/src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml +++ b/src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml @@ -114,7 +114,7 @@ Item { QGCLabel { anchors.baseline: modeCombo.baseline - text: qsTr("Flight Mode %1:)").arg(index) + text: qsTr("Flight Mode %1").arg(index) color: controller.activeFlightMode == index ? "yellow" : qgcPal.text } diff --git a/src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc b/src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc index 18808d951..c26ae0ee5 100644 --- a/src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc +++ b/src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc @@ -55,6 +55,8 @@ void PX4SimpleFlightModesController::_rcChannelsChanged(int channelCount, int pw int flightModeChannel = getParameterFact(-1, "RC_MAP_FLTMODE")->rawValue().toInt() - 1; + int flightModeReversed = getParameterFact(1, QString("RC%1_REV").arg(flightModeChannel + 1))->rawValue().toInt(); + if (flightModeChannel < 0 || flightModeChannel > channelCount) { return; } @@ -63,7 +65,7 @@ void PX4SimpleFlightModesController::_rcChannelsChanged(int channelCount, int pw int channelValue = pwmValues[flightModeChannel]; if (channelValue != -1) { bool found = false; - int rgThreshold[] = { 1230, 1360, 1490, 1620, 1749 }; + int rgThreshold[] = { 1200, 1360, 1490, 1620, 1900 }; for (int i=0; i<5; i++) { if (channelValue <= rgThreshold[i]) { _activeFlightMode = i + 1; @@ -71,9 +73,15 @@ void PX4SimpleFlightModesController::_rcChannelsChanged(int channelCount, int pw break; } } + if (!found) { _activeFlightMode = 6; } + + if (flightModeReversed == -1) { + _activeFlightMode = 6 - (_activeFlightMode - 1); + } } + emit activeFlightModeChanged(_activeFlightMode); } -- 2.22.0