mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
LP-230 PFD: Create and centralize functions + fixes
This commit is contained in:
parent
9c176fc7f6
commit
08e6dd8cc6
@ -6,12 +6,55 @@
|
||||
// Librepilot
|
||||
// ***********************
|
||||
|
||||
// Format time
|
||||
|
||||
// Get date
|
||||
function getDateTime() {
|
||||
switch(qmlWidget.timeMode) {
|
||||
case TimeMode.Local:
|
||||
return new Date();
|
||||
case TimeMode.Predefined:
|
||||
return qmlWidget.dateTime;
|
||||
}
|
||||
}
|
||||
|
||||
// Format time with two digits
|
||||
function formatTime(time) {
|
||||
if (time === 0)
|
||||
return "00"
|
||||
return "00";
|
||||
if (time < 10)
|
||||
return "0" + time;
|
||||
else
|
||||
return time.toString();
|
||||
}
|
||||
|
||||
// Returns a formated time value
|
||||
// In: 119 (seconds)
|
||||
// Out: 00:01:59
|
||||
function formatFlightTime(timeValue) {
|
||||
var timeHour = 0;
|
||||
var timeMinutes = 0;
|
||||
var timeSeconds = 0;
|
||||
|
||||
if (timeValue > 0) {
|
||||
timeHour = Math.floor(timeValue / 3600);
|
||||
timeMinutes = Math.floor((timeValue - timeHour * 3600) / 60);
|
||||
timeSeconds = Math.floor(timeValue - timeHour * 3600 - timeMinutes * 60);
|
||||
}
|
||||
|
||||
return formatTime(timeHour) + ":" + formatTime(timeMinutes) + ":" + formatTime(timeSeconds);
|
||||
}
|
||||
|
||||
// Returns a formated ETA
|
||||
function estimatedTimeOfArrival(distance, velocity) {
|
||||
var etaValue = 0;
|
||||
var etaHour = 0;
|
||||
var etaMinutes = 0;
|
||||
var etaSeconds = 0;
|
||||
|
||||
if ((distance > 0) && (velocity > 0)) {
|
||||
etaValue = Math.round(distance/velocity);
|
||||
}
|
||||
|
||||
return formatFlightTime(etaValue);
|
||||
}
|
||||
|
||||
|
@ -4,11 +4,14 @@ import UAVTalk.PositionState 1.0
|
||||
import UAVTalk.NedAccel 1.0
|
||||
import UAVTalk.PathDesired 1.0
|
||||
|
||||
import "../common.js" as Utils
|
||||
import "../uav.js" as UAV
|
||||
|
||||
Item {
|
||||
id: sceneItem
|
||||
property variant sceneSize
|
||||
|
||||
property real altitude : -qmlWidget.altitudeFactor * positionState.down
|
||||
property real altitude : -qmlWidget.altitudeFactor * UAV.positionStateDown()
|
||||
|
||||
SvgElementImage {
|
||||
id: altitude_window
|
||||
@ -64,7 +67,7 @@ Item {
|
||||
elementName: "altitude-vector"
|
||||
sceneSize: sceneItem.sceneSize
|
||||
|
||||
height: -nedAccel.down * altitude_scale.height / 10
|
||||
height: -UAV.nedAccelDown() * altitude_scale.height / 10
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.verticalCenter
|
||||
@ -74,12 +77,13 @@ Item {
|
||||
id: altitude_waypoint
|
||||
elementName: "altitude-waypoint"
|
||||
sceneSize: sceneItem.sceneSize
|
||||
visible: (pathDesired.endDown != 0.0)
|
||||
visible: (UAV.pathDesiredEndDown() != 0.0)
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
anchors.verticalCenterOffset: -altitude_scale.height / 10 * (positionState.Down - pathDesired.endDown) * qmlWidget.altitudeFactor
|
||||
anchors.verticalCenterOffset: -altitude_scale.height / 10 *
|
||||
(UAV.positionStateDown() - UAV.pathDesiredEndDown()) * qmlWidget.altitudeFactor
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +105,7 @@ Item {
|
||||
|
||||
Text {
|
||||
id: altitude_text
|
||||
text: " " +altitude.toFixed(1)
|
||||
text: " " + altitude.toFixed(1)
|
||||
color: "white"
|
||||
font {
|
||||
family: pt_bold.name
|
||||
|
@ -3,7 +3,9 @@ import QtQuick 2.4
|
||||
import UAVTalk.AttitudeState 1.0
|
||||
import UAVTalk.PositionState 1.0
|
||||
import UAVTalk.PathDesired 1.0
|
||||
import UAVTalk.TakeOffLocation 1.0
|
||||
import UAVTalk.TakeOffLocation 1.0 as TakeOffLocation
|
||||
|
||||
import "../uav.js" as UAV
|
||||
|
||||
Item {
|
||||
id: sceneItem
|
||||
@ -36,7 +38,7 @@ Item {
|
||||
x: Math.floor(scaledBounds.x * sceneItem.width)
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
|
||||
rotation: -attitudeState.yaw
|
||||
rotation: -UAV.attitudeYaw()
|
||||
transformOrigin: Item.Center
|
||||
}
|
||||
|
||||
@ -49,12 +51,10 @@ Item {
|
||||
x: Math.floor(scaledBounds.x * sceneItem.width)
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
|
||||
property real home_degrees: 180 / 3.1415 * Math.atan2(takeOffLocation.east - positionState.east, takeOffLocation.north - positionState.north)
|
||||
|
||||
rotation: -attitudeState.yaw + home_degrees
|
||||
rotation: -UAV.attitudeYaw() + UAV.homeHeading()
|
||||
transformOrigin: Item.Bottom
|
||||
|
||||
visible: (takeOffLocation.status == Status.Valid)
|
||||
visible: UAV.isTakeOffLocationValid()
|
||||
}
|
||||
|
||||
SvgElementImage {
|
||||
@ -66,12 +66,10 @@ Item {
|
||||
x: Math.floor(scaledBounds.x * sceneItem.width)
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
|
||||
property real course_degrees: 180 / 3.1415 * Math.atan2(pathDesired.endEast - positionState.east, pathDesired.endNorth - positionState.north)
|
||||
|
||||
rotation: -attitudeState.yaw + course_degrees
|
||||
rotation: -UAV.attitudeYaw() + UAV.waypointHeading()
|
||||
transformOrigin: Item.Center
|
||||
|
||||
visible: ((pathDesired.endEast != 0.0) && (pathDesired.endNorth != 0.0))
|
||||
visible: UAV.isPathDesiredActive()
|
||||
}
|
||||
|
||||
Item {
|
||||
@ -86,7 +84,7 @@ Item {
|
||||
|
||||
Text {
|
||||
id: compass_text
|
||||
text: Math.floor(attitudeState.yaw).toFixed()
|
||||
text: Math.floor(UAV.attitudeYaw()).toFixed()
|
||||
color: "white"
|
||||
font {
|
||||
family: pt_bold.name
|
||||
|
@ -12,14 +12,12 @@ import UAVTalk.FlightBatterySettings 1.0
|
||||
import UAVTalk.FlightBatteryState 1.0
|
||||
|
||||
import "../common.js" as Utils
|
||||
import "../uav.js" as UAV
|
||||
|
||||
Item {
|
||||
id: info
|
||||
property variant sceneSize
|
||||
|
||||
// Uninitialised, Ok, Warning, Critical, Error
|
||||
property variant batColors : ["black", "green", "orange", "red", "red"]
|
||||
|
||||
//
|
||||
// Waypoint functions
|
||||
//
|
||||
@ -31,30 +29,6 @@ Item {
|
||||
|
||||
property bool init_dist: false
|
||||
|
||||
property real home_heading: 180 / 3.1415 * Math.atan2(takeOffLocation.east - positionState.east,
|
||||
takeOffLocation.north - positionState.north)
|
||||
|
||||
property real home_distance: Math.sqrt(Math.pow((takeOffLocation.east - positionState.east), 2) +
|
||||
Math.pow((takeOffLocation.north - positionState.north), 2))
|
||||
|
||||
property real wp_heading: 180 / 3.1415 * Math.atan2(pathDesired.endEast - positionState.east,
|
||||
pathDesired.endNorth - positionState.north)
|
||||
|
||||
property real wp_distance: Math.sqrt(Math.pow((pathDesired.endEast - positionState.east), 2) +
|
||||
Math.pow((pathDesired.endNorth - positionState.north), 2))
|
||||
|
||||
property real current_velocity: Math.sqrt(Math.pow(velocityState.north, 2) + Math.pow(velocityState.east, 2))
|
||||
|
||||
property real home_eta: (home_distance > 0 && current_velocity > 0 ? Math.round(home_distance / current_velocity) : 0)
|
||||
property real home_eta_h: (home_eta > 0 ? Math.floor(home_eta / 3600) : 0 )
|
||||
property real home_eta_m: (home_eta > 0 ? Math.floor((home_eta - home_eta_h * 3600) / 60) : 0)
|
||||
property real home_eta_s: (home_eta > 0 ? Math.floor(home_eta - home_eta_h * 3600 - home_eta_m * 60) : 0)
|
||||
|
||||
property real wp_eta: (wp_distance > 0 && current_velocity > 0 ? Math.round(wp_distance/current_velocity) : 0)
|
||||
property real wp_eta_h: (wp_eta > 0 ? Math.floor(wp_eta / 3600) : 0 )
|
||||
property real wp_eta_m: (wp_eta > 0 ? Math.floor((wp_eta - wp_eta_h * 3600) / 60) : 0)
|
||||
property real wp_eta_s: (wp_eta > 0 ? Math.floor(wp_eta - wp_eta_h * 3600 - wp_eta_m * 60) : 0)
|
||||
|
||||
function reset_distance() {
|
||||
total_distance = 0;
|
||||
}
|
||||
@ -88,14 +62,13 @@ Item {
|
||||
//
|
||||
|
||||
property real bar_width: (info_bg.height + info_bg.width) / 110
|
||||
property int satsInView: gpsSatellites.satsInView
|
||||
property variant gps_tooltip: "Altitude : " + gpsPositionSensor.altitude.toFixed(2) + "m\n" +
|
||||
"H/V/P DOP : " + gpsPositionSensor.hdop.toFixed(2) + "/" + gpsPositionSensor.vdop.toFixed(2) + "/" + gpsPositionSensor.pdop.toFixed(2) + "\n" +
|
||||
satsInView + " Sats in view"
|
||||
|
||||
property variant gps_tooltip: "Altitude : " + UAV.gpsAltitude() + "m\n" +
|
||||
"H/V/P DOP : " + UAV.gpsHdopInfo() +
|
||||
[UAV.gpsSensorType() == "DJI" ? "" : "\n" + UAV.gpsSatsInView() + " Sats in view"]
|
||||
|
||||
Repeater {
|
||||
id: satNumberBar
|
||||
property int satNumber : gpsPositionSensor.satellites
|
||||
|
||||
model: 13
|
||||
Rectangle {
|
||||
@ -111,7 +84,7 @@ Item {
|
||||
height: bar_width * index * 0.6
|
||||
y: (bar_width * 8) - height
|
||||
color: "green"
|
||||
opacity: satNumberBar.satNumber >= minSatNumber ? 1 : 0.4
|
||||
opacity: UAV.gpsNumSat() >= minSatNumber ? 1 : 0.4
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,10 +97,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
property int satNumber : gpsPositionSensor.satellites
|
||||
|
||||
text: [satNumber > 5 ? " " + satNumber.toString() + " sats - " : ""] +
|
||||
["NO GPS", "NO FIX", "2D", "3D"][gpsPositionSensor.status]
|
||||
text: [UAV.gpsNumSat() > 5 ? " " + UAV.gpsNumSat().toString() + " sats - " : ""] + UAV.gpsStatus()
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: parent.height*1.3
|
||||
font.family: pt_bold.name
|
||||
@ -156,7 +126,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: (systemAlarms.alarmPathPlan == Alarm.OK)
|
||||
visible: UAV.isPathPlanValid()
|
||||
}
|
||||
|
||||
SvgElementPositionItem {
|
||||
@ -165,10 +135,10 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: (systemAlarms.alarmPathPlan == Alarm.OK)
|
||||
visible: UAV.isPathPlanValid()
|
||||
|
||||
Text {
|
||||
text: " "+wp_heading.toFixed(1)+"°"
|
||||
text: UAV.isPathPlanValid() ? " " + UAV.waypointHeading().toFixed(1) + "°" : " 0°"
|
||||
anchors.centerIn: parent
|
||||
color: "cyan"
|
||||
|
||||
@ -186,10 +156,10 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: (systemAlarms.alarmPathPlan == Alarm.OK)
|
||||
visible: UAV.isPathPlanValid()
|
||||
|
||||
Text {
|
||||
text: " "+wp_distance.toFixed(0)+" m"
|
||||
text: UAV.isPathPlanValid() ? " " + UAV.waypointDistance().toFixed(0) + " m" : " 0 m"
|
||||
anchors.centerIn: parent
|
||||
color: "cyan"
|
||||
|
||||
@ -207,7 +177,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: (systemAlarms.alarmPathPlan == Alarm.OK)
|
||||
visible: UAV.isPathPlanValid()
|
||||
|
||||
MouseArea { id: total_dist_mouseArea; anchors.fill: parent; cursorShape: Qt.PointingHandCursor; onClicked: reset_distance()}
|
||||
|
||||
@ -235,10 +205,10 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: (systemAlarms.alarmPathPlan == Alarm.OK)
|
||||
visible: UAV.isPathPlanValid()
|
||||
|
||||
Text {
|
||||
text: Utils.formatTime(wp_eta_h) + ":" + Utils.formatTime(wp_eta_m) + ":" + Utils.formatTime(wp_eta_s)
|
||||
text: UAV.isPathPlanValid() ? Utils.estimatedTimeOfArrival(UAV.waypointDistance(), UAV.currentVelocity()) : "00:00:00"
|
||||
anchors.centerIn: parent
|
||||
color: "cyan"
|
||||
|
||||
@ -256,10 +226,10 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: (systemAlarms.alarmPathPlan == Alarm.OK)
|
||||
visible: UAV.isPathPlanValid()
|
||||
|
||||
Text {
|
||||
text: (waypointActive.index + 1) + " / " + pathPlan.waypointCount
|
||||
text: UAV.isPathPlanValid() ? UAV.currentWaypointActive() + " / " + UAV.waypointCount() : "0 / 0"
|
||||
anchors.centerIn: parent
|
||||
color: "cyan"
|
||||
|
||||
@ -277,10 +247,10 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: (systemAlarms.alarmPathPlan == Alarm.OK)
|
||||
visible: UAV.isPathPlanValid()
|
||||
|
||||
Text {
|
||||
text: ["GOTO ENDPOINT","FOLLOW VECTOR","CIRCLE RIGHT","CIRCLE LEFT","FIXED ATTITUDE","SET ACCESSORY","DISARM ALARM","LAND","BRAKE","VELOCITY","AUTO TAKEOFF"][pathDesired.mode]
|
||||
text: UAV.isPathPlanValid() ? UAV.pathModeDesired() : ""
|
||||
anchors.centerIn: parent
|
||||
color: "cyan"
|
||||
|
||||
@ -303,11 +273,11 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
visible: ((systemAlarms.alarmPathPlan != Alarm.OK) && (hwSettings.optionalModulesBattery == OptionalModules.Enabled))
|
||||
visible: (!UAV.isPathPlanValid() && UAV.batteryModuleEnabled())
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: (flightBatterySettings.nbCells > 0) ? info.batColors[systemAlarms.alarmBattery] : "black"
|
||||
color: (UAV.batteryNbCells() > 0) ? UAV.batteryAlarmColor() : "black"
|
||||
|
||||
}
|
||||
}
|
||||
@ -318,7 +288,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: ((systemAlarms.alarmPathPlan != Alarm.OK) && (hwSettings.optionalModulesBattery == OptionalModules.Enabled))
|
||||
visible: (!UAV.isPathPlanValid() && UAV.batteryModuleEnabled())
|
||||
}
|
||||
|
||||
SvgElementPositionItem {
|
||||
@ -329,14 +299,14 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
visible: ((systemAlarms.alarmPathPlan != Alarm.OK) && (hwSettings.optionalModulesBattery == OptionalModules.Enabled))
|
||||
visible: (!UAV.isPathPlanValid() && UAV.batteryModuleEnabled())
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "transparent"
|
||||
|
||||
Text {
|
||||
text: flightBatteryState.voltage.toFixed(2)
|
||||
text: UAV.batteryVoltage()
|
||||
anchors.centerIn: parent
|
||||
color: "white"
|
||||
font {
|
||||
@ -356,14 +326,14 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
visible: ((systemAlarms.alarmPathPlan != Alarm.OK) && (hwSettings.optionalModulesBattery == OptionalModules.Enabled))
|
||||
visible: (!UAV.isPathPlanValid() && UAV.batteryModuleEnabled())
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "transparent"
|
||||
|
||||
Text {
|
||||
text: flightBatteryState.current.toFixed(2)
|
||||
text: UAV.batteryCurrent()
|
||||
anchors.centerIn: parent
|
||||
color: "white"
|
||||
font {
|
||||
@ -383,7 +353,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
visible: ((systemAlarms.alarmPathPlan != Alarm.OK) && (hwSettings.optionalModulesBattery == OptionalModules.Enabled))
|
||||
visible: (!UAV.isPathPlanValid() && UAV.batteryModuleEnabled())
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
@ -399,16 +369,15 @@ Item {
|
||||
onClicked: qmlWidget.resetConsumedEnergy();
|
||||
}
|
||||
|
||||
// Alarm based on flightBatteryState.estimatedFlightTime < 120s orange, < 60s red
|
||||
color: ((flightBatteryState.estimatedFlightTime <= 120) && (flightBatteryState.estimatedFlightTime > 60)) ? "orange" :
|
||||
(flightBatteryState.estimatedFlightTime <= 60) ? "red" : info.batColors[systemAlarms.alarmBattery]
|
||||
// Alarm based on estimatedFlightTime < 120s orange, < 60s red
|
||||
color: UAV.estimatedTimeAlarmColor()
|
||||
|
||||
border.color: "white"
|
||||
border.width: topbattery_volt.width * 0.01
|
||||
radius: border.width * 4
|
||||
|
||||
Text {
|
||||
text: flightBatteryState.consumedEnergy.toFixed(0)
|
||||
text: UAV.batteryConsumedEnergy()
|
||||
anchors.centerIn: parent
|
||||
color: "white"
|
||||
font {
|
||||
@ -429,7 +398,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: (systemAlarms.alarmPathPlan != Alarm.OK)
|
||||
visible: !UAV.isPathPlanValid()
|
||||
}
|
||||
|
||||
SvgElementPositionItem {
|
||||
@ -438,7 +407,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: (systemAlarms.alarmPathPlan != Alarm.OK)
|
||||
visible: !UAV.isPathPlanValid()
|
||||
|
||||
TooltipArea {
|
||||
text: "Reset distance counter"
|
||||
@ -479,7 +448,7 @@ Item {
|
||||
|
||||
states: State {
|
||||
name: "fading"
|
||||
when: (takeOffLocation.status == TakeOffLocation.Status.Valid)
|
||||
when: UAV.isTakeOffLocationValid()
|
||||
PropertyChanges { target: home_bg; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
|
||||
}
|
||||
|
||||
@ -500,7 +469,7 @@ Item {
|
||||
|
||||
states: State {
|
||||
name: "fading_heading"
|
||||
when: (takeOffLocation.status == TakeOffLocation.Status.Valid)
|
||||
when: UAV.isTakeOffLocationValid()
|
||||
PropertyChanges { target: home_heading_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
|
||||
}
|
||||
|
||||
@ -511,7 +480,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: " "+home_heading.toFixed(1)+"°"
|
||||
text: " " + UAV.homeHeading().toFixed(1) + "°"
|
||||
anchors.centerIn: parent
|
||||
color: "cyan"
|
||||
font {
|
||||
@ -531,7 +500,7 @@ Item {
|
||||
|
||||
states: State {
|
||||
name: "fading_distance"
|
||||
when: (takeOffLocation.status == TakeOffLocation.Status.Valid)
|
||||
when: UAV.isTakeOffLocationValid()
|
||||
PropertyChanges { target: home_distance_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
|
||||
}
|
||||
|
||||
@ -542,7 +511,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: home_distance.toFixed(0)+" m"
|
||||
text: UAV.homeDistance().toFixed(0) + " m"
|
||||
anchors.centerIn: parent
|
||||
color: "cyan"
|
||||
font {
|
||||
@ -562,7 +531,7 @@ Item {
|
||||
|
||||
states: State {
|
||||
name: "fading_distance"
|
||||
when: (takeOffLocation.status == TakeOffLocation.Status.Valid)
|
||||
when: UAV.isTakeOffLocationValid()
|
||||
PropertyChanges { target: home_eta_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
|
||||
}
|
||||
|
||||
@ -573,7 +542,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: Utils.formatTime(home_eta_h) + ":" + Utils.formatTime(home_eta_m) + ":" + Utils.formatTime(home_eta_s)
|
||||
text: Utils.estimatedTimeOfArrival(UAV.homeDistance(), UAV.currentVelocity())
|
||||
anchors.centerIn: parent
|
||||
color: "cyan"
|
||||
font {
|
||||
|
@ -11,16 +11,12 @@ import UAVTalk.ReceiverStatus 1.0
|
||||
import UAVTalk.OPLinkStatus 1.0
|
||||
|
||||
import "../common.js" as Utils
|
||||
import "../uav.js" as UAV
|
||||
|
||||
Item {
|
||||
id: panels
|
||||
property variant sceneSize
|
||||
|
||||
property real est_flight_time: Math.round(flightBatteryState.estimatedFlightTime)
|
||||
property real est_time_h: (est_flight_time > 0) ? Math.floor(est_flight_time / 3600) : 0
|
||||
property real est_time_m: (est_flight_time > 0) ? Math.floor((est_flight_time - est_time_h * 3600) / 60) : 0
|
||||
property real est_time_s: (est_flight_time > 0) ? Math.floor(est_flight_time - est_time_h * 3600 - est_time_m * 60) : 0
|
||||
|
||||
//
|
||||
// Panel functions
|
||||
//
|
||||
@ -78,16 +74,8 @@ Item {
|
||||
system_bg.z = 40
|
||||
}
|
||||
|
||||
// Uninitialised, Ok, Warning, Critical, Error
|
||||
property variant batColors : ["#2c2929", "green", "orange", "red", "red"]
|
||||
|
||||
property real smeter_angle
|
||||
|
||||
property real memory_free : (systemStats.heapRemaining > 1024) ? systemStats.heapRemaining / 1024 : systemStats.heapRemaining
|
||||
|
||||
// Needed to get correctly int8 value
|
||||
property int cpuTemp : systemStats.cpuTemp
|
||||
|
||||
// Needed to get correctly int8 value, reset value (-127) on disconnect
|
||||
property int oplm0_db: (telemetry_link == 1) ? opLinkStatus.pairSignalStrengths0 : -127
|
||||
property int oplm1_db: (telemetry_link == 1) ? opLinkStatus.pairSignalStrengths1 : -127
|
||||
@ -451,13 +439,13 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: panels.batColors[systemAlarms.alarmBattery]
|
||||
color: UAV.batteryAlarmColor()
|
||||
border.color: "white"
|
||||
border.width: battery_volt.width * 0.01
|
||||
radius: border.width * 4
|
||||
|
||||
Text {
|
||||
text: flightBatteryState.voltage.toFixed(2)
|
||||
text: UAV.batteryVoltage()
|
||||
anchors.centerIn: parent
|
||||
color: "white"
|
||||
font {
|
||||
@ -492,13 +480,13 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: panels.batColors[systemAlarms.alarmBattery]
|
||||
color: UAV.batteryAlarmColor()
|
||||
border.color: "white"
|
||||
border.width: battery_volt.width * 0.01
|
||||
radius: border.width * 4
|
||||
|
||||
Text {
|
||||
text: flightBatteryState.current.toFixed(2)
|
||||
text: UAV.batteryCurrent()
|
||||
anchors.centerIn: parent
|
||||
color: "white"
|
||||
font {
|
||||
@ -547,16 +535,15 @@ Item {
|
||||
onClicked: qmlWidget.resetConsumedEnergy();
|
||||
}
|
||||
|
||||
// Alarm based on flightBatteryState.estimatedFlightTime < 120s orange, < 60s red
|
||||
color: (flightBatteryState.estimatedFlightTime <= 120 && flightBatteryState.estimatedFlightTime > 60 ? "orange" :
|
||||
(flightBatteryState.estimatedFlightTime <= 60 ? "red": panels.batColors[systemAlarms.alarmBattery]))
|
||||
// Alarm based on estimatedFlightTime < 120s orange, < 60s red
|
||||
color: UAV.estimatedTimeAlarmColor()
|
||||
|
||||
border.color: "white"
|
||||
border.width: battery_volt.width * 0.01
|
||||
radius: border.width * 4
|
||||
|
||||
Text {
|
||||
text: flightBatteryState.consumedEnergy.toFixed(0)
|
||||
text: UAV.batteryConsumedEnergy()
|
||||
anchors.centerIn: parent
|
||||
color: "white"
|
||||
font {
|
||||
@ -591,7 +578,6 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
//color: panels.batColors[systemAlarms.alarmBattery]
|
||||
|
||||
TooltipArea {
|
||||
text: "Reset consumed energy"
|
||||
@ -606,16 +592,15 @@ Item {
|
||||
onClicked: qmlWidget.resetConsumedEnergy();
|
||||
}
|
||||
|
||||
// Alarm based on flightBatteryState.estimatedFlightTime < 120s orange, < 60s red
|
||||
color: (flightBatteryState.estimatedFlightTime <= 120) && (flightBatteryState.estimatedFlightTime > 60) ? "orange" :
|
||||
(flightBatteryState.estimatedFlightTime <= 60) ? "red" : panels.batColors[systemAlarms.alarmBattery]
|
||||
// Alarm based on estimatedFlightTime < 120s orange, < 60s red
|
||||
color: UAV.estimatedTimeAlarmColor()
|
||||
|
||||
border.color: "white"
|
||||
border.width: battery_volt.width * 0.01
|
||||
radius: border.width * 4
|
||||
|
||||
Text {
|
||||
text: Utils.formatTime(est_time_h) + ":" + Utils.formatTime(est_time_m) + ":" + Utils.formatTime(est_time_s)
|
||||
text: Utils.formatFlightTime(UAV.estimatedFlightTimeValue())
|
||||
anchors.centerIn: parent
|
||||
color: "white"
|
||||
font {
|
||||
@ -954,7 +939,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: (receiverStatus.quality > 0) ? receiverStatus.quality + "%" : "?? %"
|
||||
text: UAV.receiverQuality()
|
||||
anchors.right: parent.right
|
||||
color: "white"
|
||||
font {
|
||||
@ -1008,7 +993,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: ["Disabled", "Enabled", "Disconnected", "Connecting", "Connected"][opLinkStatus.linkState]
|
||||
text: UAV.oplmLinkState()
|
||||
anchors.right: parent.right
|
||||
color: "white"
|
||||
font {
|
||||
@ -1094,9 +1079,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: ["FixedWing", "FixedWingElevon", "FixedWingVtail", "VTOL", "HeliCP", "QuadX", "QuadP",
|
||||
"Hexa+", "Octo+", "Custom", "HexaX", "HexaH", "OctoV", "OctoCoaxP", "OctoCoaxX", "OctoX", "HexaCoax",
|
||||
"Tricopter", "GroundVehicleCar", "GroundVehicleDiff", "GroundVehicleMoto"][systemSettings.airframeType]
|
||||
text: UAV.frameType()
|
||||
anchors.right: parent.right
|
||||
color: "white"
|
||||
font {
|
||||
@ -1127,8 +1110,8 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
// Coptercontrol detect with mem free : Only display Cpu load, no temperature available.
|
||||
text: systemStats.cpuLoad + "%" + [(systemStats.heapRemaining < 3000) ? "" : " | " + cpuTemp + "°C"]
|
||||
// CC3D: Only display Cpu load, no temperature available.
|
||||
text: UAV.cpuLoad() + "%" + [UAV.isCC3D() ? "" : " | " + UAV.cpuTemp() + "°C"]
|
||||
anchors.right: parent.right
|
||||
color: "white"
|
||||
font {
|
||||
@ -1159,7 +1142,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: (systemStats.heapRemaining > 1024) ? memory_free.toFixed(2) +"Kb" : memory_free +"bytes"
|
||||
text: UAV.freeMemory()
|
||||
anchors.right: parent.right
|
||||
color: "white"
|
||||
font {
|
||||
@ -1190,7 +1173,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: ["None", "Basic (No Nav)", "CompMag", "Comp+Mag+GPS", "EKFIndoor", "GPSNav (INS13)"][revoSettings.fusionAlgorithm]
|
||||
text: UAV.fusionAlgorithm()
|
||||
anchors.right: parent.right
|
||||
color: "white"
|
||||
font {
|
||||
@ -1221,8 +1204,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: [magState.source == 2 ? ["GPSv9", "Flexi", "I2C", "DJI"][auxMagSettings.type] + " " : ""] +
|
||||
["Invalid", "OnBoard", "ExtMag"][magState.source]
|
||||
text: UAV.magSourceName()
|
||||
anchors.right: parent.right
|
||||
color: "white"
|
||||
font {
|
||||
@ -1253,7 +1235,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: ["Unknown", "NMEA", "UBX", "UBX7", "UBX8", "DJI"][gpsPositionSensor.sensorType]
|
||||
text: UAV.gpsSensorType()
|
||||
anchors.right: parent.right
|
||||
color: "white"
|
||||
font {
|
||||
|
@ -6,6 +6,7 @@ import UAVTalk.AttitudeState 1.0
|
||||
import UAVTalk.HomeLocation 1.0
|
||||
import UAVTalk.GPSPositionSensor 1.0
|
||||
|
||||
import "../common.js" as Utils
|
||||
import "../uav.js" as UAV
|
||||
|
||||
OSGViewport {
|
||||
@ -27,19 +28,8 @@ OSGViewport {
|
||||
OSGSkyNode {
|
||||
id: skyNode
|
||||
sceneData: terrainNode
|
||||
dateTime: getDateTime()
|
||||
dateTime: Utils.getDateTime()
|
||||
minimumAmbientLight: qmlWidget.minimumAmbientLight
|
||||
|
||||
// MOVE...
|
||||
function getDateTime() {
|
||||
switch(qmlWidget.timeMode) {
|
||||
case TimeMode.Local:
|
||||
return new Date();
|
||||
case TimeMode.Predefined:
|
||||
return qmlWidget.dateTime;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
OSGFileNode {
|
||||
@ -82,10 +72,10 @@ OSGViewport {
|
||||
id: pitchTranslate
|
||||
x: Math.round((world.parent.width - world.width)/2)
|
||||
// y is centered around world_center element
|
||||
y: Math.round(horizontCenter - world.height / 2 + attitudeState.pitch * world.pitch1DegHeight)
|
||||
y: Math.round(horizontCenter - world.height / 2 + UAV.attitudePitch() * world.pitch1DegHeight)
|
||||
},
|
||||
Rotation {
|
||||
angle: -attitudeState.roll
|
||||
angle: -UAV.attitudeRoll()
|
||||
origin.x : world.parent.width / 2
|
||||
origin.y : horizontCenter
|
||||
}
|
||||
@ -102,7 +92,7 @@ OSGViewport {
|
||||
width: Math.floor(scaledBounds.width * sceneItem.width)
|
||||
height: Math.floor(scaledBounds.height * sceneItem.height)
|
||||
|
||||
rotation: -attitudeState.roll
|
||||
rotation: -UAV.attitudeRoll()
|
||||
transformOrigin: Item.Center
|
||||
|
||||
smooth: true
|
||||
@ -132,7 +122,7 @@ OSGViewport {
|
||||
sceneSize: background.sceneSize
|
||||
anchors.centerIn: parent
|
||||
|
||||
anchors.verticalCenterOffset: attitudeState.pitch * world.pitch1DegHeight
|
||||
anchors.verticalCenterOffset: UAV.attitudePitch() * world.pitch1DegHeight
|
||||
border: 1
|
||||
smooth: true
|
||||
}
|
||||
@ -143,7 +133,7 @@ OSGViewport {
|
||||
|
||||
sceneSize: background.sceneSize
|
||||
anchors.centerIn: parent
|
||||
anchors.verticalCenterOffset: attitudeState.pitch * world.pitch1DegHeight
|
||||
anchors.verticalCenterOffset: UAV.attitudePitch() * world.pitch1DegHeight
|
||||
border: 1
|
||||
smooth: true
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ import QtQuick 2.4
|
||||
|
||||
import UAVTalk.AttitudeState 1.0
|
||||
|
||||
import "../uav.js" as UAV
|
||||
|
||||
Item {
|
||||
id: worldView
|
||||
property real horizontCenter : horizontCenterItem.horizontCenter
|
||||
@ -33,10 +35,10 @@ Item {
|
||||
id: pitchTranslate
|
||||
x: Math.round((world.parent.width - world.width) / 2)
|
||||
// y is centered around world_center element
|
||||
y: Math.round(horizontCenter - world.height / 2 + attitudeState.pitch * world.pitch1DegHeight)
|
||||
y: Math.round(horizontCenter - world.height / 2 + UAV.attitudePitch() * world.pitch1DegHeight)
|
||||
},
|
||||
Rotation {
|
||||
angle: -attitudeState.roll
|
||||
angle: -UAV.attitudeRoll()
|
||||
origin.x : world.parent.width / 2
|
||||
origin.y : horizontCenter
|
||||
}
|
||||
@ -73,7 +75,7 @@ Item {
|
||||
width: Math.floor(scaledBounds.width * sceneItem.width)
|
||||
height: Math.floor(scaledBounds.height * sceneItem.height)
|
||||
|
||||
rotation: -attitudeState.roll
|
||||
rotation: -UAV.attitudeRoll()
|
||||
transformOrigin: Item.Center
|
||||
|
||||
smooth: true
|
||||
@ -86,7 +88,7 @@ Item {
|
||||
sceneSize: background.sceneSize
|
||||
anchors.centerIn: parent
|
||||
// see comment for world transform
|
||||
anchors.verticalCenterOffset: attitudeState.pitch * world.pitch1DegHeight
|
||||
anchors.verticalCenterOffset: UAV.attitudePitch() * world.pitch1DegHeight
|
||||
border: 64 //sometimes numbers are excluded from bounding rect
|
||||
|
||||
smooth: true
|
||||
|
@ -2,6 +2,8 @@ import QtQuick 2.4
|
||||
|
||||
import UAVTalk.AttitudeState 1.0
|
||||
|
||||
import "../uav.js" as UAV
|
||||
|
||||
Item {
|
||||
id: sceneItem
|
||||
|
||||
@ -25,7 +27,7 @@ Item {
|
||||
|
||||
// rotate it around the center of horizon
|
||||
transform: Rotation {
|
||||
angle: -attitudeState.roll
|
||||
angle: -UAV.attitudeRoll()
|
||||
origin.y : rollscale.height * 2.4
|
||||
origin.x : rollscale.width / 2
|
||||
}
|
||||
|
@ -3,10 +3,12 @@ import QtQuick 2.4
|
||||
import UAVTalk.VelocityState 1.0
|
||||
import UAVTalk.PathDesired 1.0
|
||||
|
||||
import "../uav.js" as UAV
|
||||
|
||||
Item {
|
||||
id: sceneItem
|
||||
property variant sceneSize
|
||||
property real groundSpeed : qmlWidget.speedFactor * Math.sqrt(Math.pow(velocityState.north, 2) + Math.pow(velocityState.east, 2))
|
||||
property real groundSpeed : qmlWidget.speedFactor * UAV.currentVelocity()
|
||||
|
||||
SvgElementImage {
|
||||
id: speed_window
|
||||
@ -65,12 +67,12 @@ Item {
|
||||
id: speed_waypoint
|
||||
elementName: "speed-waypoint"
|
||||
sceneSize: sceneItem.sceneSize
|
||||
visible: (pathDesired.endingVelocity != 0.0)
|
||||
visible: UAV.isPathDesiredActive()
|
||||
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
anchors.verticalCenterOffset: speed_scale.height / 10 * (sceneItem.groundSpeed - (pathDesired.endingVelocity * qmlWidget.speedFactor))
|
||||
anchors.verticalCenterOffset: speed_scale.height / 10 * (sceneItem.groundSpeed - (UAV.pathDesiredEndingVelocity() * qmlWidget.speedFactor))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@ import QtQuick 2.4
|
||||
import UAVTalk.FlightStatus 1.0
|
||||
import UAVTalk.VelocityDesired 1.0
|
||||
|
||||
import "../uav.js" as UAV
|
||||
|
||||
Item {
|
||||
id: sceneItem
|
||||
property variant sceneSize
|
||||
@ -10,7 +12,7 @@ Item {
|
||||
|
||||
Timer {
|
||||
interval: 100; running: true; repeat: true
|
||||
onTriggered: vert_velocity = (0.9 * vert_velocity) + (0.1 * velocityState.down)
|
||||
onTriggered: vert_velocity = (0.9 * vert_velocity) + (0.1 * UAV.velocityStateDown())
|
||||
}
|
||||
|
||||
SvgElementImage {
|
||||
@ -25,11 +27,11 @@ Item {
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
|
||||
smooth: true
|
||||
visible: ((velocityDesired.down != 0.0) && (flightStatus.flightMode > FlightMode.PositionHold))
|
||||
visible: ((UAV.velocityDesiredDown() != 0.0) && (UAV.isFlightModeAssisted()))
|
||||
|
||||
// rotate it around the center
|
||||
transform: Rotation {
|
||||
angle: -velocityDesired.down * 5
|
||||
angle: -UAV.velocityDesiredDown() * 5
|
||||
origin.y : vsi_waypoint.height / 2
|
||||
origin.x : vsi_waypoint.width * 33
|
||||
}
|
||||
|
@ -3,44 +3,15 @@ import QtQuick 2.4
|
||||
import UAVTalk.SystemSettings 1.0
|
||||
import UAVTalk.SystemAlarms 1.0
|
||||
import UAVTalk.FlightStatus 1.0
|
||||
import UAVTalk.VtolPathFollowerSettings 1.0
|
||||
import UAVTalk.VtolPathFollowerSettings 1.0 as VtolPathFollowerSettings
|
||||
|
||||
import "../common.js" as Utils
|
||||
import "../uav.js" as UAV
|
||||
|
||||
Item {
|
||||
id: warnings
|
||||
|
||||
property variant sceneSize
|
||||
|
||||
// Uninitialised, OK, Warning, Error, Critical
|
||||
property variant statusColors : ["gray", "green", "red", "red", "red"]
|
||||
|
||||
// DisArmed , Arming, Armed
|
||||
property variant armColors : ["gray", "orange", "green"]
|
||||
|
||||
// All 'manual modes' are green, 'assisted' modes in cyan
|
||||
// "MANUAL","STAB 1","STAB 2", "STAB 3", "STAB 4", "STAB 5", "STAB 6",
|
||||
// "POS HOLD", "COURSELOCK","VEL ROAM", "HOME LEASH", "ABS POS", "RTB", "LAND", "PATHPLAN", "POI", "AUTOCRUISE", "AUTOTAKEOFF"
|
||||
property variant flightmodeColors : ["gray", "green", "green", "green", "green", "green", "green",
|
||||
"cyan", "cyan", "cyan", "cyan", "cyan", "cyan", "cyan", "cyan", "cyan", "cyan", "cyan"]
|
||||
|
||||
// Manual,Rate,RateTrainer,Attitude,AxisLock,WeakLeveling,VirtualBar,Acro+,Rattitude,
|
||||
// AltitudeHold,AltitudeVario,CruiseControl" + Auto mode (VTOL/Wing pathfollower)
|
||||
// grey : 'disabled' modes
|
||||
property variant thrustmodeColors : ["green", "grey", "grey", "grey", "grey", "grey", "grey", "grey", "grey",
|
||||
"green", "green", "green", "cyan"]
|
||||
|
||||
// systemSettings.airframeType 3 - 17 : VtolPathFollower, check ThrustControl
|
||||
property var thrust_mode: (flightStatus.flightMode < FlightMode.PositionHold) ? stabilizationDesired.stabilizationModeThrust :
|
||||
(flightStatus.flightMode >= FlightMode.PositionHold) && (systemSettings.airframeType > AirframeType.FixedWingVtail) &&
|
||||
(systemSettings.airframeType < AirframeType.GroundVehicleCar) && (vtolPathFollowerSettings.thrustControl == ThrustControl.Auto) ? 12 :
|
||||
(flightStatus.flightMode >= FlightMode.PositionHold) && (systemSettings.airframeType < AirframeType.VTOL) ? 12 : 0
|
||||
|
||||
property real flight_time: Math.round(systemStats.flightTime / 1000)
|
||||
property real time_h: (flight_time > 0 ? Math.floor(flight_time / 3600) : 0 )
|
||||
property real time_m: (flight_time > 0 ? Math.floor((flight_time - time_h*3600)/60) : 0)
|
||||
property real time_s: (flight_time > 0 ? Math.floor(flight_time - time_h*3600 - time_m*60) : 0)
|
||||
|
||||
SvgElementImage {
|
||||
id: warning_bg
|
||||
elementName: "warnings-bg"
|
||||
@ -60,11 +31,11 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: (systemStats.flightTime > 0) ? "green" : "grey"
|
||||
color: (UAV.flightTimeValue() > 0) ? "green" : "grey"
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: Utils.formatTime(time_h) + ":" + Utils.formatTime(time_m) + ":" + Utils.formatTime(time_s)
|
||||
text: Utils.formatFlightTime(UAV.flightTimeValue())
|
||||
font {
|
||||
family: pt_bold.name
|
||||
pixelSize: Math.floor(parent.height * 0.8)
|
||||
@ -85,11 +56,11 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: warnings.armColors[flightStatus.armed]
|
||||
color: UAV.armStatusColor()
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: ["DISARMED","ARMING","ARMED"][flightStatus.armed]
|
||||
text: UAV.armStatusName()
|
||||
font {
|
||||
family: pt_bold.name
|
||||
pixelSize: Math.floor(parent.height * 0.74)
|
||||
@ -110,7 +81,7 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: warnings.statusColors[systemAlarms.alarmManualControl]
|
||||
color: UAV.rcInputStatusColor()
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
@ -133,15 +104,10 @@ Item {
|
||||
x: scaledBounds.x * sceneItem.width
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
|
||||
property bool warningActive: ((systemAlarms.alarmBootFault > Alarm.OK) ||
|
||||
(systemAlarms.alarmOutOfMemory > Alarm.OK) ||
|
||||
(systemAlarms.alarmStackOverflow > Alarm.OK) ||
|
||||
(systemAlarms.alarmCPUOverload > Alarm.OK) ||
|
||||
(systemAlarms.alarmEventSystem > Alarm.OK))
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: parent.warningActive ? "red" : "red"
|
||||
opacity: parent.warningActive ? 1.0 : 0.4
|
||||
color: "red"
|
||||
opacity: UAV.masterCautionWarning() ? 1.0 : 0.4
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
@ -167,7 +133,7 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: warnings.statusColors[systemAlarms.alarmGuidance]
|
||||
color: UAV.autopilotStatusColor()
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
@ -192,14 +158,11 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: warnings.flightmodeColors[flightStatus.flightMode]
|
||||
// Manual,Stabilized1,Stabilized2,Stabilized3,Stabilized4,Stabilized5,Stabilized6,PositionHold,CourseLock,
|
||||
// VelocityRoam,HomeLeash,AbsolutePosition,ReturnToBase,Land,PathPlanner,POI,AutoCruise,AutoTakeoff
|
||||
color: UAV.flightModeColor()
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: ["MANUAL","STAB 1","STAB 2", "STAB 3", "STAB 4", "STAB 5", "STAB 6", "POS HOLD", "COURSELOCK",
|
||||
"VEL ROAM", "HOME LEASH", "ABS POS", "RTB", "LAND", "PATHPLAN", "POI", "AUTOCRUISE", "AUTOTAKEOFF"][flightStatus.flightMode]
|
||||
text: UAV.flightModeName()
|
||||
font {
|
||||
family: pt_bold.name
|
||||
pixelSize: Math.floor(parent.height * 0.74)
|
||||
@ -220,12 +183,12 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: (flightStatus.flightMode == FlightMode.Manual) ? "grey" : warnings.thrustmodeColors[thrust_mode]
|
||||
color: UAV.isFlightModeManual() ? "grey" : UAV.thrustModeColor()
|
||||
|
||||
// grey : 'disabled' modes
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: ["MANUAL"," "," ", " ", " ", " ", " ", " ", " ", "ALT HOLD", "ALT VARIO", "CRUISECTRL", "AUTO"][thrust_mode]
|
||||
text: UAV.thrustModeName()
|
||||
font {
|
||||
family: pt_bold.name
|
||||
pixelSize: Math.floor(parent.height * 0.74)
|
||||
@ -240,7 +203,7 @@ Item {
|
||||
elementName: "warning-gps"
|
||||
sceneSize: warnings.sceneSize
|
||||
|
||||
visible: (systemAlarms.alarmGPS > Alarm.OK)
|
||||
visible: !UAV.isGpsValid()
|
||||
}
|
||||
|
||||
SvgElementImage {
|
||||
@ -248,6 +211,6 @@ Item {
|
||||
elementName: "warning-attitude"
|
||||
sceneSize: warnings.sceneSize
|
||||
anchors.centerIn: background.centerIn
|
||||
visible: (systemAlarms.alarmAttitude > Alarm.OK)
|
||||
visible: !UAV.isAttitudeValid()
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// ***********************
|
||||
// common.js
|
||||
// uav.js
|
||||
//
|
||||
// Common javascript uav utils
|
||||
//
|
||||
@ -12,6 +12,34 @@ function attitude() {
|
||||
return Qt.vector3d(attitudeState.pitch, attitudeState.roll, -attitudeState.yaw);
|
||||
}
|
||||
|
||||
function attitudeRoll() {
|
||||
return attitudeState.roll;
|
||||
}
|
||||
|
||||
function attitudePitch() {
|
||||
return attitudeState.pitch;
|
||||
}
|
||||
|
||||
function attitudeYaw() {
|
||||
return attitudeState.yaw;
|
||||
}
|
||||
|
||||
function currentVelocity() {
|
||||
return Math.sqrt(Math.pow(velocityState.north, 2) + Math.pow(velocityState.east, 2));
|
||||
}
|
||||
|
||||
function positionStateDown() {
|
||||
return positionState.down;
|
||||
}
|
||||
|
||||
function velocityStateDown() {
|
||||
return velocityState.down;
|
||||
}
|
||||
|
||||
function nedAccelDown() {
|
||||
return nedAccel.down;
|
||||
}
|
||||
|
||||
function position() {
|
||||
switch(gpsPositionSensor.status) {
|
||||
case Status.Fix2D:
|
||||
@ -41,3 +69,278 @@ function homePosition() {
|
||||
function defaultPosition() {
|
||||
return Qt.vector3d(qmlWidget.longitude, qmlWidget.latitude, qmlWidget.altitude);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* System
|
||||
*
|
||||
*/
|
||||
function isCC3D() {
|
||||
// Hack: detect Coptercontrol with mem free
|
||||
return (freeMemoryBytes() < 3096);
|
||||
}
|
||||
|
||||
function frameType() {
|
||||
return ["FixedWing", "FixedWingElevon", "FixedWingVtail", "VTOL", "HeliCP", "QuadX", "QuadP",
|
||||
"Hexa+", "Octo+", "Custom", "HexaX", "HexaH", "OctoV", "OctoCoaxP", "OctoCoaxX", "OctoX", "HexaCoax",
|
||||
"Tricopter", "GroundVehicleCar", "GroundVehicleDiff", "GroundVehicleMoto"][systemSettings.airframeType]
|
||||
}
|
||||
|
||||
function isVtolOrMultirotor() {
|
||||
return ((systemSettings.airframeType > AirframeType.FixedWingVtail) &&
|
||||
(systemSettings.airframeType < AirframeType.GroundVehicleCar));
|
||||
}
|
||||
|
||||
function isFixedWing() {
|
||||
return (systemSettings.airframeType <= AirframeType.FixedWingVtail);
|
||||
}
|
||||
|
||||
function isGroundVehicle() {
|
||||
return (systemSettings.airframeType >= AirframeType.GroundVehicleCar);
|
||||
}
|
||||
|
||||
function freeMemoryBytes() {
|
||||
return systemStats.heapRemaining;
|
||||
}
|
||||
|
||||
function freeMemoryKBytes() {
|
||||
return (systemStats.heapRemaining / 1024).toFixed(2);
|
||||
}
|
||||
|
||||
function freeMemory() {
|
||||
return (freeMemoryBytes() > 1024) ? freeMemoryKBytes() + "Kb" : freeMemoryBytes() + "bytes";
|
||||
}
|
||||
|
||||
function cpuLoad() {
|
||||
return systemStats.cpuLoad;
|
||||
}
|
||||
|
||||
function cpuTemp() {
|
||||
return systemStats.cpuTemp;
|
||||
}
|
||||
|
||||
function flightTimeValue() {
|
||||
return Math.round(systemStats.flightTime / 1000)
|
||||
}
|
||||
|
||||
/*
|
||||
* Sensor
|
||||
*
|
||||
*/
|
||||
function isGpsValid() {
|
||||
return (systemAlarms.alarmGPS == Alarm.OK);
|
||||
}
|
||||
|
||||
function isAttitudeValid() {
|
||||
return (systemAlarms.alarmAttitude == Alarm.OK);
|
||||
}
|
||||
|
||||
function magSourceName() {
|
||||
return [magState.source == Source.Aux ? ["GPSv9", "Flexi", "I2C", "DJI"][auxMagSettings.type] + " " : ""] +
|
||||
["Invalid", "OnBoard", "ExtMag"][magState.source];
|
||||
}
|
||||
|
||||
function gpsSensorType() {
|
||||
return ["Unknown", "NMEA", "UBX", "UBX7", "UBX8", "DJI"][gpsPositionSensor.sensorType]
|
||||
}
|
||||
|
||||
function gpsNumSat() {
|
||||
return gpsPositionSensor.satellites;
|
||||
}
|
||||
|
||||
function gpsSatsInView() {
|
||||
return gpsSatellites.satsInView;
|
||||
}
|
||||
|
||||
function gpsHdopInfo() {
|
||||
return gpsPositionSensor.hdop.toFixed(2) + "/" + gpsPositionSensor.vdop.toFixed(2) + "/" + gpsPositionSensor.pdop.toFixed(2);
|
||||
}
|
||||
|
||||
function gpsAltitude() {
|
||||
return gpsPositionSensor.altitude.toFixed(2);
|
||||
}
|
||||
|
||||
function gpsStatus() {
|
||||
return ["NO GPS", "NO FIX", "2D", "3D"][gpsPositionSensor.status];
|
||||
}
|
||||
|
||||
function fusionAlgorithm() {
|
||||
return ["None", "Basic (No Nav)", "CompMag", "Comp+Mag+GPS", "EKFIndoor", "GPSNav (INS13)"][revoSettings.fusionAlgorithm];
|
||||
}
|
||||
|
||||
function receiverQuality() {
|
||||
return (receiverStatus.quality > 0) ? receiverStatus.quality + "%" : "?? %";
|
||||
}
|
||||
|
||||
function oplmLinkState() {
|
||||
return ["Disabled", "Enabled", "Disconnected", "Connecting", "Connected"][opLinkStatus.linkState];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Battery
|
||||
*
|
||||
*/
|
||||
function batteryModuleEnabled() {
|
||||
return (hwSettings.optionalModulesBattery == OptionalModules.Enabled);
|
||||
}
|
||||
|
||||
function batteryNbCells() {
|
||||
return flightBatterySettings.nbCells;
|
||||
}
|
||||
|
||||
function batteryVoltage() {
|
||||
return flightBatteryState.voltage.toFixed(2);
|
||||
}
|
||||
|
||||
function batteryCurrent() {
|
||||
return flightBatteryState.current.toFixed(2);
|
||||
}
|
||||
|
||||
function batteryConsumedEnergy() {
|
||||
return flightBatteryState.consumedEnergy.toFixed(0);
|
||||
}
|
||||
|
||||
function estimatedFlightTimeValue() {
|
||||
return Math.round(flightBatteryState.estimatedFlightTime);
|
||||
}
|
||||
|
||||
function batteryAlarmColor() {
|
||||
// Uninitialised, Ok, Warning, Critical, Error
|
||||
return ["#2c2929", "green", "orange", "red", "red"][systemAlarms.alarmBattery];
|
||||
}
|
||||
|
||||
function estimatedTimeAlarmColor() {
|
||||
return ((estimatedFlightTimeValue() <= 120) && (estimatedFlightTimeValue() > 60)) ? "orange" :
|
||||
(estimatedFlightTimeValue() <= 60) ? "red" : batteryAlarmColor();
|
||||
}
|
||||
|
||||
/*
|
||||
* Pathplan and Waypoints
|
||||
*
|
||||
*/
|
||||
function isPathPlanValid() {
|
||||
return (systemAlarms.alarmPathPlan == Alarm.OK);
|
||||
}
|
||||
|
||||
function isPathDesiredActive() {
|
||||
return ((pathDesired.endEast != 0.0) || (pathDesired.endNorth != 0.0) || (pathDesired.endingVelocity != 0.0))
|
||||
}
|
||||
|
||||
function isTakeOffLocationValid() {
|
||||
return (takeOffLocation.status == TakeOffLocation.Status.Valid);
|
||||
}
|
||||
|
||||
function pathModeDesired() {
|
||||
return ["GOTO ENDPOINT","FOLLOW VECTOR","CIRCLE RIGHT","CIRCLE LEFT","FIXED ATTITUDE",
|
||||
"SET ACCESSORY","DISARM ALARM","LAND","BRAKE","VELOCITY","AUTO TAKEOFF"][pathDesired.mode]
|
||||
}
|
||||
|
||||
function velocityDesiredDown() {
|
||||
return velocityDesired.down;
|
||||
}
|
||||
|
||||
function pathDesiredEndDown() {
|
||||
return pathDesired.endDown;
|
||||
}
|
||||
|
||||
function pathDesiredEndingVelocity() {
|
||||
return pathDesired.endingVelocity;
|
||||
}
|
||||
|
||||
function currentWaypointActive() {
|
||||
return (waypointActive.index + 1);
|
||||
}
|
||||
|
||||
function waypointCount() {
|
||||
return pathPlan.waypointCount;
|
||||
}
|
||||
|
||||
function homeHeading() {
|
||||
return 180 / 3.1415 * Math.atan2(takeOffLocation.east - positionState.east, takeOffLocation.north - positionState.north);
|
||||
}
|
||||
|
||||
function waypointHeading() {
|
||||
return 180 / 3.1415 * Math.atan2(pathDesired.endEast - positionState.east, pathDesired.endNorth - positionState.north);
|
||||
}
|
||||
|
||||
function homeDistance() {
|
||||
return Math.sqrt(Math.pow((takeOffLocation.east - positionState.east), 2) +
|
||||
Math.pow((takeOffLocation.north - positionState.north), 2));
|
||||
}
|
||||
|
||||
function waypointDistance() {
|
||||
return Math.sqrt(Math.pow((pathDesired.endEast - positionState.east), 2) +
|
||||
Math.pow((pathDesired.endNorth - positionState.north), 2));
|
||||
}
|
||||
|
||||
/*
|
||||
* FlightModes, Stabilization, Thrust modes
|
||||
*
|
||||
*/
|
||||
function isFlightModeManual() {
|
||||
return (flightStatus.flightMode == FlightMode.Manual);
|
||||
}
|
||||
|
||||
function isFlightModeAssisted() {
|
||||
return (flightStatus.flightMode > FlightMode.Stabilized6);
|
||||
}
|
||||
|
||||
function isVtolPathFollowerSettingsThrustAuto() {
|
||||
return (vtolPathFollowerSettings.thrustControl == VtolPathFollowerSettings.ThrustControl.Auto);
|
||||
}
|
||||
|
||||
function flightModeName() {
|
||||
return ["MANUAL", "STAB 1", "STAB 2", "STAB 3", "STAB 4", "STAB 5", "STAB 6",
|
||||
"POS HOLD", "COURSELOCK", "VEL ROAM", "HOME LEASH", "ABS POS", "RTB",
|
||||
"LAND", "PATHPLAN", "POI", "AUTOCRUISE", "AUTOTAKEOFF"][flightStatus.flightMode];
|
||||
}
|
||||
|
||||
function flightModeColor() {
|
||||
return ["gray", "green", "green", "green", "green", "green", "green",
|
||||
"cyan", "cyan", "cyan", "cyan", "cyan", "cyan",
|
||||
"cyan", "cyan", "cyan", "cyan", "cyan"][flightStatus.flightMode];
|
||||
}
|
||||
|
||||
function thrustMode() {
|
||||
return !isFlightModeAssisted() ? stabilizationDesired.stabilizationModeThrust :
|
||||
(isFlightModeAssisted() && isVtolOrMultirotor() && isVtolPathFollowerSettingsThrustAuto()) ? 12 :
|
||||
(isFlightModeAssisted() && isFixedWing()) ? 12 : 0;
|
||||
}
|
||||
|
||||
function thrustModeName() {
|
||||
return ["MANUAL", " ", " ", " ", " ", " ", " ", " ", " ",
|
||||
"ALT HOLD", "ALT VARIO", "CRUISECTRL", "AUTO"][thrustMode()]
|
||||
}
|
||||
|
||||
function thrustModeColor() {
|
||||
return ["green", "grey", "grey", "grey", "grey", "grey", "grey", "grey", "grey",
|
||||
"green", "green", "green", "cyan"][thrustMode()];
|
||||
}
|
||||
|
||||
function autopilotStatusColor() {
|
||||
return statusColor(systemAlarms.alarmGuidance)
|
||||
}
|
||||
|
||||
function rcInputStatusColor() {
|
||||
return statusColor(systemAlarms.alarmManualControl)
|
||||
}
|
||||
|
||||
function statusColor(module) {
|
||||
return ["gray", "green", "red", "red", "red"][module];
|
||||
}
|
||||
|
||||
function armStatusName() {
|
||||
return ["DISARMED","ARMING","ARMED"][flightStatus.armed];
|
||||
}
|
||||
|
||||
function armStatusColor() {
|
||||
return ["gray", "orange", "green"][flightStatus.armed];
|
||||
}
|
||||
|
||||
function masterCautionWarning() {
|
||||
return ((systemAlarms.alarmBootFault > Alarm.OK) || (systemAlarms.alarmOutOfMemory > Alarm.OK) ||
|
||||
(systemAlarms.alarmStackOverflow > Alarm.OK) || (systemAlarms.alarmCPUOverload > Alarm.OK) ||
|
||||
(systemAlarms.alarmEventSystem > Alarm.OK))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user