From bdf66cafd70d5a5de5c351be1c5b72f7f12d5985 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sat, 27 Jan 2018 12:19:29 +0100 Subject: [PATCH 1/3] LP-574 Check if adc inputs are configured before displaying battery data on PFD --- ground/gcs/src/share/qml/js/uav.js | 22 ++++++++++++++++++++++ ground/gcs/src/share/qml/pfd/Info.qml | 12 ++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ground/gcs/src/share/qml/js/uav.js b/ground/gcs/src/share/qml/js/uav.js index 95489ec28..b81a2533f 100644 --- a/ground/gcs/src/share/qml/js/uav.js +++ b/ground/gcs/src/share/qml/js/uav.js @@ -318,6 +318,28 @@ function batteryModuleEnabled() { return (hwSettings.optionalModulesBattery == HwSettings.OptionalModules.Enabled); } +function batteryModuleADCConfigured() { + if ((hwSettings.adcRoutingadc0 == HwSettings.ADCRouting.BatteryVoltage) || + (hwSettings.adcRoutingadc0 == HwSettings.ADCRouting.BatteryCurrent) || + (hwSettings.adcRoutingadc1 == HwSettings.ADCRouting.BatteryVoltage) || + (hwSettings.adcRoutingadc1 == HwSettings.ADCRouting.BatteryCurrent) || + (hwSettings.adcRoutingadc2 == HwSettings.ADCRouting.BatteryVoltage) || + (hwSettings.adcRoutingadc2 == HwSettings.ADCRouting.BatteryCurrent) || + (hwSettings.adcRoutingadc3 == HwSettings.ADCRouting.BatteryVoltage) || + (hwSettings.adcRoutingadc3 == HwSettings.ADCRouting.BatteryCurrent) || + (hwSettings.adcRoutingadc4 == HwSettings.ADCRouting.BatteryVoltage) || + (hwSettings.adcRoutingadc4 == HwSettings.ADCRouting.BatteryCurrent) || + (hwSettings.adcRoutingadc5 == HwSettings.ADCRouting.BatteryVoltage) || + (hwSettings.adcRoutingadc5 == HwSettings.ADCRouting.BatteryCurrent) || + (hwSettings.adcRoutingadc6 == HwSettings.ADCRouting.BatteryVoltage) || + (hwSettings.adcRoutingadc6 == HwSettings.ADCRouting.BatteryCurrent) || + (hwSettings.adcRoutingadc7 == HwSettings.ADCRouting.BatteryVoltage) || + (hwSettings.adcRoutingadc7 == HwSettings.ADCRouting.BatteryCurrent)) { + return true; + } + return false; +} + function batteryNbCells() { return flightBatterySettings.nbCells; } diff --git a/ground/gcs/src/share/qml/pfd/Info.qml b/ground/gcs/src/share/qml/pfd/Info.qml index 0a0fb911e..94fb2bafe 100644 --- a/ground/gcs/src/share/qml/pfd/Info.qml +++ b/ground/gcs/src/share/qml/pfd/Info.qml @@ -271,7 +271,7 @@ Item { } // Battery Info (Top) - // Only visible when PathPlan not active and Battery module enabled + // Only visible when PathPlan not active and Battery module enabled and ADC input configured SvgElementPositionItem { id: topbattery_voltamp_bg @@ -281,7 +281,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: scaledBounds.y * sceneItem.height - visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled()) + visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryModuleADCConfigured()) Rectangle { anchors.fill: parent @@ -296,7 +296,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: Math.floor(scaledBounds.y * sceneItem.height) - visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled()) + visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryModuleADCConfigured()) } SvgElementPositionItem { @@ -307,7 +307,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: scaledBounds.y * sceneItem.height - visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled()) + visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryModuleADCConfigured()) Rectangle { anchors.fill: parent @@ -334,7 +334,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: scaledBounds.y * sceneItem.height - visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled()) + visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryModuleADCConfigured()) Rectangle { anchors.fill: parent @@ -361,7 +361,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: scaledBounds.y * sceneItem.height - visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled()) + visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryModuleADCConfigured()) Rectangle { anchors.fill: parent From 773bc084e52e5c86435661d6160cf03f5e703fa3 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Tue, 6 Feb 2018 11:41:30 +0100 Subject: [PATCH 2/3] LP-574 Use loop for ADCRouting --- ground/gcs/src/share/qml/js/uav.js | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/ground/gcs/src/share/qml/js/uav.js b/ground/gcs/src/share/qml/js/uav.js index b81a2533f..ec810c9de 100644 --- a/ground/gcs/src/share/qml/js/uav.js +++ b/ground/gcs/src/share/qml/js/uav.js @@ -319,23 +319,13 @@ function batteryModuleEnabled() { } function batteryModuleADCConfigured() { - if ((hwSettings.adcRoutingadc0 == HwSettings.ADCRouting.BatteryVoltage) || - (hwSettings.adcRoutingadc0 == HwSettings.ADCRouting.BatteryCurrent) || - (hwSettings.adcRoutingadc1 == HwSettings.ADCRouting.BatteryVoltage) || - (hwSettings.adcRoutingadc1 == HwSettings.ADCRouting.BatteryCurrent) || - (hwSettings.adcRoutingadc2 == HwSettings.ADCRouting.BatteryVoltage) || - (hwSettings.adcRoutingadc2 == HwSettings.ADCRouting.BatteryCurrent) || - (hwSettings.adcRoutingadc3 == HwSettings.ADCRouting.BatteryVoltage) || - (hwSettings.adcRoutingadc3 == HwSettings.ADCRouting.BatteryCurrent) || - (hwSettings.adcRoutingadc4 == HwSettings.ADCRouting.BatteryVoltage) || - (hwSettings.adcRoutingadc4 == HwSettings.ADCRouting.BatteryCurrent) || - (hwSettings.adcRoutingadc5 == HwSettings.ADCRouting.BatteryVoltage) || - (hwSettings.adcRoutingadc5 == HwSettings.ADCRouting.BatteryCurrent) || - (hwSettings.adcRoutingadc6 == HwSettings.ADCRouting.BatteryVoltage) || - (hwSettings.adcRoutingadc6 == HwSettings.ADCRouting.BatteryCurrent) || - (hwSettings.adcRoutingadc7 == HwSettings.ADCRouting.BatteryVoltage) || - (hwSettings.adcRoutingadc7 == HwSettings.ADCRouting.BatteryCurrent)) { - return true; + for (var adc = 0; adc < 8; adc++) { + var adc_set = hwSettings.getADCRouting(adc); + if (adc_set == HwSettings.ADCRouting.BatteryVoltage) { + return true; + } else if (adc_set == HwSettings.ADCRouting.BatteryCurrent) { + return true; + } } return false; } From 6c9ecf703b758665731cd9ce1417053a0bde6a84 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Wed, 14 Feb 2018 13:19:09 +0100 Subject: [PATCH 3/3] LP-574 Rename function and var names --- ground/gcs/src/share/qml/js/uav.js | 10 +++++----- ground/gcs/src/share/qml/pfd/Info.qml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ground/gcs/src/share/qml/js/uav.js b/ground/gcs/src/share/qml/js/uav.js index ec810c9de..95660ae8a 100644 --- a/ground/gcs/src/share/qml/js/uav.js +++ b/ground/gcs/src/share/qml/js/uav.js @@ -318,12 +318,12 @@ function batteryModuleEnabled() { return (hwSettings.optionalModulesBattery == HwSettings.OptionalModules.Enabled); } -function batteryModuleADCConfigured() { - for (var adc = 0; adc < 8; adc++) { - var adc_set = hwSettings.getADCRouting(adc); - if (adc_set == HwSettings.ADCRouting.BatteryVoltage) { +function batteryADCConfigured() { + for (var i = 0; i < 8; i++) { + var adcRouting = hwSettings.getADCRouting(i); + if (adcRouting == HwSettings.ADCRouting.BatteryVoltage) { return true; - } else if (adc_set == HwSettings.ADCRouting.BatteryCurrent) { + } else if (adcRouting == HwSettings.ADCRouting.BatteryCurrent) { return true; } } diff --git a/ground/gcs/src/share/qml/pfd/Info.qml b/ground/gcs/src/share/qml/pfd/Info.qml index 94fb2bafe..ed76cb3a9 100644 --- a/ground/gcs/src/share/qml/pfd/Info.qml +++ b/ground/gcs/src/share/qml/pfd/Info.qml @@ -281,7 +281,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: scaledBounds.y * sceneItem.height - visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryModuleADCConfigured()) + visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryADCConfigured()) Rectangle { anchors.fill: parent @@ -296,7 +296,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: Math.floor(scaledBounds.y * sceneItem.height) - visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryModuleADCConfigured()) + visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryADCConfigured()) } SvgElementPositionItem { @@ -307,7 +307,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: scaledBounds.y * sceneItem.height - visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryModuleADCConfigured()) + visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryADCConfigured()) Rectangle { anchors.fill: parent @@ -334,7 +334,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: scaledBounds.y * sceneItem.height - visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryModuleADCConfigured()) + visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryADCConfigured()) Rectangle { anchors.fill: parent @@ -361,7 +361,7 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height y: scaledBounds.y * sceneItem.height - visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryModuleADCConfigured()) + visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryADCConfigured()) Rectangle { anchors.fill: parent