Skip to content

Commit 4554500

Browse files
f5sohfilnet
authored andcommitted
Merged in f5soh/librepilot/LP-574_PFD_Battery_display (pull request #489)
LP-574 Check if adc inputs are configured before displaying battery data on PFD Approved-by: Lalanne Laurent <f5soh@free.fr> Approved-by: Philippe Renon <philippe_renon@yahoo.fr>
2 parents a4dfa85 + 6c9ecf7 commit 4554500

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

ground/gcs/src/share/qml/js/uav.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,18 @@ function batteryModuleEnabled() {
318318
return (hwSettings.optionalModulesBattery == HwSettings.OptionalModules.Enabled);
319319
}
320320

321+
function batteryADCConfigured() {
322+
for (var i = 0; i < 8; i++) {
323+
var adcRouting = hwSettings.getADCRouting(i);
324+
if (adcRouting == HwSettings.ADCRouting.BatteryVoltage) {
325+
return true;
326+
} else if (adcRouting == HwSettings.ADCRouting.BatteryCurrent) {
327+
return true;
328+
}
329+
}
330+
return false;
331+
}
332+
321333
function batteryNbCells() {
322334
return flightBatterySettings.nbCells;
323335
}

ground/gcs/src/share/qml/pfd/Info.qml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ Item {
271271
}
272272

273273
// Battery Info (Top)
274-
// Only visible when PathPlan not active and Battery module enabled
274+
// Only visible when PathPlan not active and Battery module enabled and ADC input configured
275275

276276
SvgElementPositionItem {
277277
id: topbattery_voltamp_bg
@@ -281,7 +281,7 @@ Item {
281281
width: scaledBounds.width * sceneItem.width
282282
height: scaledBounds.height * sceneItem.height
283283
y: scaledBounds.y * sceneItem.height
284-
visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled())
284+
visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryADCConfigured())
285285

286286
Rectangle {
287287
anchors.fill: parent
@@ -296,7 +296,7 @@ Item {
296296
width: scaledBounds.width * sceneItem.width
297297
height: scaledBounds.height * sceneItem.height
298298
y: Math.floor(scaledBounds.y * sceneItem.height)
299-
visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled())
299+
visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryADCConfigured())
300300
}
301301

302302
SvgElementPositionItem {
@@ -307,7 +307,7 @@ Item {
307307
width: scaledBounds.width * sceneItem.width
308308
height: scaledBounds.height * sceneItem.height
309309
y: scaledBounds.y * sceneItem.height
310-
visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled())
310+
visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryADCConfigured())
311311

312312
Rectangle {
313313
anchors.fill: parent
@@ -334,7 +334,7 @@ Item {
334334
width: scaledBounds.width * sceneItem.width
335335
height: scaledBounds.height * sceneItem.height
336336
y: scaledBounds.y * sceneItem.height
337-
visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled())
337+
visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryADCConfigured())
338338

339339
Rectangle {
340340
anchors.fill: parent
@@ -361,7 +361,7 @@ Item {
361361
width: scaledBounds.width * sceneItem.width
362362
height: scaledBounds.height * sceneItem.height
363363
y: scaledBounds.y * sceneItem.height
364-
visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled())
364+
visible: (!UAV.isPathPlanEnabled() && UAV.batteryModuleEnabled() && UAV.batteryADCConfigured())
365365

366366
Rectangle {
367367
anchors.fill: parent

0 commit comments

Comments
 (0)