mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
LP-181 Compatible Qt5.4 / Qt5.5 - Added file for javascript functions
This commit is contained in:
parent
3e6313e95e
commit
df841fda29
@ -1,5 +1,6 @@
|
||||
import QtQuick 2.0
|
||||
import "."
|
||||
import "common.js" as Utils
|
||||
|
||||
Item {
|
||||
id: sceneItem
|
||||
@ -50,7 +51,7 @@ Item {
|
||||
|
||||
rotation: -AttitudeState.Yaw + home_degrees
|
||||
transformOrigin: Item.Bottom
|
||||
visible: TakeOffLocation.Status == 0
|
||||
visible: Utils.toInt(TakeOffLocation.Status) == 0
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import QtQuick 2.0
|
||||
import "common.js" as Utils
|
||||
|
||||
Item {
|
||||
id: info
|
||||
@ -7,11 +8,6 @@ Item {
|
||||
// Uninitialised, Ok, Warning, Critical, Error
|
||||
property variant batColors : ["black", "green", "orange", "red", "red"]
|
||||
|
||||
// qml/js treats qint8 as a char, necessary to convert it back to integer value
|
||||
function qint8toInt(qint8_value) {
|
||||
return String(qint8_value).charCodeAt(0)
|
||||
}
|
||||
|
||||
//
|
||||
// Waypoint functions
|
||||
//
|
||||
@ -63,15 +59,6 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
function formatTime(time) {
|
||||
if (time === 0)
|
||||
return "00"
|
||||
if (time < 10)
|
||||
return "0" + time;
|
||||
else
|
||||
return time.toString();
|
||||
}
|
||||
|
||||
// End Functions
|
||||
//
|
||||
// Start Drawing
|
||||
@ -89,14 +76,14 @@ Item {
|
||||
//
|
||||
|
||||
property real bar_width: (info_bg.height + info_bg.width) / 110
|
||||
property int satsInView: qint8toInt(GPSSatellites.SatsInView)
|
||||
property int satsInView: Utils.toInt(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)+"m\n"+
|
||||
satsInView+" Sats in view"
|
||||
|
||||
Repeater {
|
||||
id: satNumberBar
|
||||
property int satNumber : qint8toInt(GPSPositionSensor.Satellites)
|
||||
property int satNumber : Utils.toInt(GPSPositionSensor.Satellites)
|
||||
|
||||
model: 13
|
||||
Rectangle {
|
||||
@ -125,10 +112,10 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
property int satNumber : qint8toInt(GPSPositionSensor.Satellites)
|
||||
property int satNumber : Utils.toInt(GPSPositionSensor.Satellites)
|
||||
|
||||
text: [satNumber > 5 ? " " + satNumber.toString() + " sats - " : ""] +
|
||||
["NO GPS", "NO FIX", "2D", "3D"][qint8toInt(GPSPositionSensor.Status)]
|
||||
["NO GPS", "NO FIX", "2D", "3D"][Utils.toInt(GPSPositionSensor.Status)]
|
||||
anchors.centerIn: parent
|
||||
font.pixelSize: parent.height*1.3
|
||||
font.family: pt_bold.name
|
||||
@ -157,7 +144,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
}
|
||||
|
||||
SvgElementPositionItem {
|
||||
@ -166,7 +153,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
|
||||
Text {
|
||||
text: " "+wp_heading.toFixed(1)+"°"
|
||||
@ -187,7 +174,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
|
||||
Text {
|
||||
text: " "+wp_distance.toFixed(0)+" m"
|
||||
@ -208,7 +195,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
|
||||
MouseArea { id: total_dist_mouseArea; anchors.fill: parent; cursorShape: Qt.PointingHandCursor; onClicked: reset_distance()}
|
||||
|
||||
@ -226,7 +213,7 @@ Item {
|
||||
|
||||
Timer {
|
||||
interval: 1000; running: true; repeat: true;
|
||||
onTriggered: {if (qint8toInt(GPSPositionSensor.Status) == 3) compute_distance(PositionState.East,PositionState.North)}
|
||||
onTriggered: {if (Utils.toInt(GPSPositionSensor.Status) == 3) compute_distance(PositionState.East,PositionState.North)}
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,10 +223,10 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
|
||||
Text {
|
||||
text: formatTime(wp_eta_h) + ":" + formatTime(wp_eta_m) + ":" + formatTime(wp_eta_s)
|
||||
text: Utils.formatTime(wp_eta_h) + ":" + Utils.formatTime(wp_eta_m) + ":" + Utils.formatTime(wp_eta_s)
|
||||
anchors.centerIn: parent
|
||||
color: "cyan"
|
||||
|
||||
@ -257,7 +244,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
|
||||
Text {
|
||||
text: (WaypointActive.Index+1)+" / "+PathPlan.WaypointCount
|
||||
@ -278,10 +265,10 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) == 1
|
||||
|
||||
Text {
|
||||
text: ["GOTO ENDPOINT","FOLLOW VECTOR","CIRCLE RIGHT","CIRCLE LEFT","FIXED ATTITUDE","SET ACCESSORY","DISARM ALARM","LAND","BRAKE","VELOCITY","AUTO TAKEOFF"][qint8toInt(PathDesired.Mode)]
|
||||
text: ["GOTO ENDPOINT","FOLLOW VECTOR","CIRCLE RIGHT","CIRCLE LEFT","FIXED ATTITUDE","SET ACCESSORY","DISARM ALARM","LAND","BRAKE","VELOCITY","AUTO TAKEOFF"][Utils.toInt(PathDesired.Mode)]
|
||||
anchors.centerIn: parent
|
||||
color: "cyan"
|
||||
|
||||
@ -304,11 +291,11 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
visible: (qint8toInt(SystemAlarms.Alarm_PathPlan) != 1) && (qint8toInt(HwSettings.OptionalModules_Battery) == 1)
|
||||
visible: (Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1) && (Utils.toInt(HwSettings.OptionalModules_Battery) == 1)
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: FlightBatterySettings.NbCells > 0 ? info.batColors[qint8toInt(SystemAlarms.Alarm_Battery)] : "black"
|
||||
color: Utils.toInt(FlightBatterySettings.NbCells) > 0 ? info.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)] : "black"
|
||||
|
||||
}
|
||||
}
|
||||
@ -319,7 +306,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: (qint8toInt(SystemAlarms.Alarm_PathPlan) != 1) && (qint8toInt(HwSettings.OptionalModules_Battery) == 1)
|
||||
visible: (Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1) && (Utils.toInt(HwSettings.OptionalModules_Battery) == 1)
|
||||
}
|
||||
|
||||
SvgElementPositionItem {
|
||||
@ -330,7 +317,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
visible: (qint8toInt(SystemAlarms.Alarm_PathPlan) != 1) && (qint8toInt(HwSettings.OptionalModules_Battery) == 1)
|
||||
visible: (Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1) && (Utils.toInt(HwSettings.OptionalModules_Battery) == 1)
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
@ -357,7 +344,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
visible: (qint8toInt(SystemAlarms.Alarm_PathPlan) != 1) && (qint8toInt(HwSettings.OptionalModules_Battery) == 1)
|
||||
visible: (Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1) && (Utils.toInt(HwSettings.OptionalModules_Battery) == 1)
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
@ -384,7 +371,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
visible: (qint8toInt(SystemAlarms.Alarm_PathPlan) != 1) && (qint8toInt(HwSettings.OptionalModules_Battery) == 1)
|
||||
visible: (Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1) && (Utils.toInt(HwSettings.OptionalModules_Battery) == 1)
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
@ -402,7 +389,7 @@ Item {
|
||||
|
||||
// Alarm based on FlightBatteryState.EstimatedFlightTime < 120s orange, < 60s red
|
||||
color: (FlightBatteryState.EstimatedFlightTime <= 120 && FlightBatteryState.EstimatedFlightTime > 60 ? "orange" :
|
||||
(FlightBatteryState.EstimatedFlightTime <= 60 ? "red": info.batColors[qint8toInt(SystemAlarms.Alarm_Battery)]))
|
||||
(FlightBatteryState.EstimatedFlightTime <= 60 ? "red": info.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)]))
|
||||
|
||||
border.color: "white"
|
||||
border.width: topbattery_volt.width * 0.01
|
||||
@ -430,7 +417,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) != 1
|
||||
visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1
|
||||
}
|
||||
|
||||
SvgElementPositionItem {
|
||||
@ -439,7 +426,7 @@ Item {
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) != 1
|
||||
visible: Utils.toInt(SystemAlarms.Alarm_PathPlan) != 1
|
||||
|
||||
TooltipArea {
|
||||
text: "Reset distance counter"
|
||||
@ -461,7 +448,7 @@ Item {
|
||||
|
||||
Timer {
|
||||
interval: 1000; running: true; repeat: true;
|
||||
onTriggered: {if (qint8toInt(GPSPositionSensor.Status) == 3) compute_distance(PositionState.East,PositionState.North)}
|
||||
onTriggered: {if (Utils.toInt(GPSPositionSensor.Status) == 3) compute_distance(PositionState.East,PositionState.North)}
|
||||
}
|
||||
}
|
||||
|
||||
@ -480,7 +467,7 @@ Item {
|
||||
|
||||
states: State {
|
||||
name: "fading"
|
||||
when: qint8toInt(TakeOffLocation.Status) == 0
|
||||
when: Utils.toInt(TakeOffLocation.Status) == 0
|
||||
PropertyChanges { target: home_bg; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
|
||||
}
|
||||
|
||||
@ -501,7 +488,7 @@ Item {
|
||||
|
||||
states: State {
|
||||
name: "fading_heading"
|
||||
when: qint8toInt(TakeOffLocation.Status) == 0
|
||||
when: Utils.toInt(TakeOffLocation.Status) == 0
|
||||
PropertyChanges { target: home_heading_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
|
||||
}
|
||||
|
||||
@ -532,7 +519,7 @@ Item {
|
||||
|
||||
states: State {
|
||||
name: "fading_distance"
|
||||
when: qint8toInt(TakeOffLocation.Status) == 0
|
||||
when: Utils.toInt(TakeOffLocation.Status) == 0
|
||||
PropertyChanges { target: home_distance_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
|
||||
}
|
||||
|
||||
@ -563,7 +550,7 @@ Item {
|
||||
|
||||
states: State {
|
||||
name: "fading_distance"
|
||||
when: qint8toInt(TakeOffLocation.Status) == 0
|
||||
when: Utils.toInt(TakeOffLocation.Status) == 0
|
||||
PropertyChanges { target: home_eta_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
|
||||
}
|
||||
|
||||
@ -574,7 +561,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: formatTime(home_eta_h) + ":" + formatTime(home_eta_m) + ":" + formatTime(home_eta_s)
|
||||
text: Utils.formatTime(home_eta_h) + ":" + Utils.formatTime(home_eta_m) + ":" + Utils.formatTime(home_eta_s)
|
||||
anchors.centerIn: parent
|
||||
color: "cyan"
|
||||
font {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import QtQuick 2.0
|
||||
import "common.js" as Utils
|
||||
|
||||
Item {
|
||||
id: panels
|
||||
@ -9,20 +10,6 @@ Item {
|
||||
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)
|
||||
|
||||
function formatTime(time) {
|
||||
if (time === 0)
|
||||
return "00"
|
||||
if (time < 10)
|
||||
return "0" + time;
|
||||
else
|
||||
return time.toString();
|
||||
}
|
||||
|
||||
// qml/js treats qint8 as a char, necessary to convert it back to integer value
|
||||
function qint8toInt(qint8_value) {
|
||||
return String(qint8_value).charCodeAt(0)
|
||||
}
|
||||
|
||||
//
|
||||
// Panel functions
|
||||
//
|
||||
@ -105,7 +92,7 @@ Item {
|
||||
function telemetry_check() {
|
||||
telemetry_sum = OPLinkStatus.RXRate + OPLinkStatus.RXRate
|
||||
|
||||
if (telemetry_sum != telemetry_sum_old || qint8toInt(OPLinkStatus.LinkState) == 4) {
|
||||
if (telemetry_sum != telemetry_sum_old || Utils.toInt(OPLinkStatus.LinkState) == 4) {
|
||||
telemetry_link = 1
|
||||
} else {
|
||||
telemetry_link = 0
|
||||
@ -456,7 +443,7 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: panels.batColors[qint8toInt(SystemAlarms.Alarm_Battery)]
|
||||
color: panels.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)]
|
||||
border.color: "white"
|
||||
border.width: battery_volt.width * 0.01
|
||||
radius: border.width * 4
|
||||
@ -497,7 +484,7 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: panels.batColors[qint8toInt(SystemAlarms.Alarm_Battery)]
|
||||
color: panels.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)]
|
||||
border.color: "white"
|
||||
border.width: battery_volt.width * 0.01
|
||||
radius: border.width * 4
|
||||
@ -554,7 +541,7 @@ Item {
|
||||
|
||||
// Alarm based on FlightBatteryState.EstimatedFlightTime < 120s orange, < 60s red
|
||||
color: (FlightBatteryState.EstimatedFlightTime <= 120 && FlightBatteryState.EstimatedFlightTime > 60 ? "orange" :
|
||||
(FlightBatteryState.EstimatedFlightTime <= 60 ? "red": panels.batColors[qint8toInt(SystemAlarms.Alarm_Battery)]))
|
||||
(FlightBatteryState.EstimatedFlightTime <= 60 ? "red": panels.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)]))
|
||||
|
||||
border.color: "white"
|
||||
border.width: battery_volt.width * 0.01
|
||||
@ -596,7 +583,7 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
//color: panels.batColors[qint8toInt(SystemAlarms.Alarm_Battery)]
|
||||
//color: panels.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)]
|
||||
|
||||
TooltipArea {
|
||||
text: "Reset consumed energy"
|
||||
@ -613,14 +600,14 @@ Item {
|
||||
|
||||
// Alarm based on FlightBatteryState.EstimatedFlightTime < 120s orange, < 60s red
|
||||
color: (FlightBatteryState.EstimatedFlightTime <= 120 && FlightBatteryState.EstimatedFlightTime > 60 ? "orange" :
|
||||
(FlightBatteryState.EstimatedFlightTime <= 60 ? "red": panels.batColors[qint8toInt(SystemAlarms.Alarm_Battery)]))
|
||||
(FlightBatteryState.EstimatedFlightTime <= 60 ? "red": panels.batColors[Utils.toInt(SystemAlarms.Alarm_Battery)]))
|
||||
|
||||
border.color: "white"
|
||||
border.width: battery_volt.width * 0.01
|
||||
radius: border.width * 4
|
||||
|
||||
Text {
|
||||
text: formatTime(est_time_h) + ":" + formatTime(est_time_m) + ":" + formatTime(est_time_s)
|
||||
text: Utils.formatTime(est_time_h) + ":" + Utils.formatTime(est_time_m) + ":" + Utils.formatTime(est_time_s)
|
||||
anchors.centerIn: parent
|
||||
color: "white"
|
||||
font {
|
||||
@ -959,7 +946,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: qint8toInt(ReceiverStatus.Quality) > 0 ? qint8toInt(ReceiverStatus.Quality)+"%" : "?? %"
|
||||
text: Utils.toInt(ReceiverStatus.Quality) > 0 ? Utils.toInt(ReceiverStatus.Quality)+"%" : "?? %"
|
||||
anchors.centerIn: parent
|
||||
color: "white"
|
||||
font {
|
||||
@ -1048,7 +1035,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"][qint8toInt(SystemSettings.AirframeType)]
|
||||
"Tricopter", "GroundVehicleCar", "GroundVehicleDiff", "GroundVehicleMoto"][Utils.toInt(SystemSettings.AirframeType)]
|
||||
anchors.right: parent.right
|
||||
color: "white"
|
||||
font {
|
||||
@ -1080,7 +1067,7 @@ Item {
|
||||
|
||||
Text {
|
||||
// Coptercontrol detect with mem free : Only display Cpu load, no temperature available.
|
||||
text: qint8toInt(SystemStats.CPULoad)+"%"+
|
||||
text: Utils.toInt(SystemStats.CPULoad)+"%"+
|
||||
[SystemStats.HeapRemaining < 3000 ? "" : " | "+cpuTemp+"°C"]
|
||||
anchors.right: parent.right
|
||||
color: "white"
|
||||
@ -1143,7 +1130,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: ["None", "Basic (No Nav)", "CompMag", "Comp+Mag+GPS", "EKFIndoor", "GPS Nav (INS13)"][qint8toInt(RevoSettings.FusionAlgorithm)]
|
||||
text: ["None", "Basic (No Nav)", "CompMag", "Comp+Mag+GPS", "EKFIndoor", "GPS Nav (INS13)"][Utils.toInt(RevoSettings.FusionAlgorithm)]
|
||||
anchors.right: parent.right
|
||||
color: "white"
|
||||
font {
|
||||
@ -1174,7 +1161,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: ["Invalid", "OnBoard", "External"][qint8toInt(MagState.Source)]
|
||||
text: ["Invalid", "OnBoard", "External"][Utils.toInt(MagState.Source)]
|
||||
anchors.right: parent.right
|
||||
color: "white"
|
||||
font {
|
||||
@ -1205,7 +1192,7 @@ Item {
|
||||
}
|
||||
|
||||
Text {
|
||||
text: ["Unknown", "NMEA", "UBX", "UBX7", "UBX8"][qint8toInt(GPSPositionSensor.SensorType)]
|
||||
text: ["Unknown", "NMEA", "UBX", "UBX7", "UBX8"][Utils.toInt(GPSPositionSensor.SensorType)]
|
||||
anchors.right: parent.right
|
||||
color: "white"
|
||||
font {
|
||||
|
@ -1,67 +0,0 @@
|
||||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
id: sceneItem
|
||||
property variant sceneSize
|
||||
|
||||
//telemetry status arrow
|
||||
SvgElementImage {
|
||||
id: telemetry_status
|
||||
elementName: "gcstelemetry-"+statusName
|
||||
sceneSize: sceneItem.sceneSize
|
||||
|
||||
property string statusName : ["Disconnected","HandshakeReq","HandshakeAck","Connected"][GCSTelemetryStats.Status]
|
||||
|
||||
scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "gcstelemetry-Disconnected")
|
||||
x: Math.floor(scaledBounds.x * sceneItem.width)
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
}
|
||||
|
||||
//telemetry rate text
|
||||
Text {
|
||||
id: telemetry_rate
|
||||
text: GCSTelemetryStats.TxDataRate.toFixed()+"/"+GCSTelemetryStats.RxDataRate.toFixed()
|
||||
color: "white"
|
||||
font.family: pt_bold.name
|
||||
font.pixelSize: telemetry_status.height * 0.75
|
||||
|
||||
anchors.top: telemetry_status.bottom
|
||||
anchors.horizontalCenter: telemetry_status.horizontalCenter
|
||||
}
|
||||
|
||||
Text {
|
||||
id: gps_text
|
||||
text: "GPS: " + GPSPositionSensor.Satellites + "\nPDP: " + Math.round(GPSPositionSensor.PDOP*10)/10
|
||||
color: "white"
|
||||
font.family: pt_bold.name
|
||||
font.pixelSize: telemetry_status.height * 0.75
|
||||
|
||||
visible: GPSPositionSensor.Satellites > 0
|
||||
|
||||
property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "gps-txt")
|
||||
x: Math.floor(scaledBounds.x * sceneItem.width)
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
}
|
||||
|
||||
Text {
|
||||
id: battery_text
|
||||
|
||||
text: FlightBatteryState.Voltage.toFixed(2)+" V\n" +
|
||||
FlightBatteryState.Current.toFixed(2)+" A\n" +
|
||||
FlightBatteryState.ConsumedEnergy.toFixed()+" mAh"
|
||||
|
||||
|
||||
color: "white"
|
||||
font.family: pt_bold.name
|
||||
|
||||
//I think it should be pixel size,
|
||||
//but making it more consistent with C++ version instead
|
||||
font.pointSize: scaledBounds.height * sceneItem.height
|
||||
|
||||
visible: FlightBatteryState.Voltage > 0 || FlightBatteryState.Current > 0
|
||||
|
||||
property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "battery-txt")
|
||||
x: Math.floor(scaledBounds.x * sceneItem.width)
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import QtQuick 2.0
|
||||
import "common.js" as Utils
|
||||
|
||||
Item {
|
||||
id: sceneItem
|
||||
@ -22,7 +23,7 @@ Item {
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
|
||||
smooth: true
|
||||
visible: VelocityDesired.Down !== 0.0 && FlightStatus.FlightMode > 7
|
||||
visible: VelocityDesired.Down !== 0.0 && Utils.toInt(FlightStatus.FlightMode) > 7
|
||||
|
||||
//rotate it around the center
|
||||
transform: Rotation {
|
||||
|
@ -1,13 +1,9 @@
|
||||
import QtQuick 2.0
|
||||
import "common.js" as Utils
|
||||
|
||||
Item {
|
||||
id: warnings
|
||||
|
||||
// qml/js treats qint8 as a char, necessary to convert it back to integer value
|
||||
function qint8toInt(qint8_value) {
|
||||
return String(qint8_value).charCodeAt(0)
|
||||
}
|
||||
|
||||
property variant sceneSize
|
||||
// Uninitialised, OK, Warning, Error, Critical
|
||||
property variant statusColors : ["gray", "green", "red", "red", "red"]
|
||||
@ -31,10 +27,10 @@ Item {
|
||||
|
||||
// SystemSettings.AirframeType 3 - 17 : VtolPathFollower, check ThrustControl
|
||||
|
||||
property var thrust_mode: qint8toInt(FlightStatus.FlightMode) < 7 ? qint8toInt(StabilizationDesired.StabilizationMode_Thrust) :
|
||||
qint8toInt(FlightStatus.FlightMode) > 6 && qint8toInt(SystemSettings.AirframeType) > 2 &&
|
||||
qint8toInt(SystemSettings.AirframeType) < 18 && qint8toInt(VtolPathFollowerSettings.ThrustControl) == 1 ? 12 :
|
||||
qint8toInt(FlightStatus.FlightMode) > 6 && qint8toInt(SystemSettings.AirframeType) < 3 ? 12: 0
|
||||
property var thrust_mode: Utils.toInt(FlightStatus.FlightMode) < 7 ? Utils.toInt(StabilizationDesired.StabilizationMode_Thrust) :
|
||||
Utils.toInt(FlightStatus.FlightMode) > 6 && Utils.toInt(SystemSettings.AirframeType) > 2 &&
|
||||
Utils.toInt(SystemSettings.AirframeType) < 18 && Utils.toInt(VtolPathFollowerSettings.ThrustControl) == 1 ? 12 :
|
||||
Utils.toInt(FlightStatus.FlightMode) > 6 && Utils.toInt(SystemSettings.AirframeType) < 3 ? 12: 0
|
||||
|
||||
|
||||
property real flight_time: Math.round(SystemStats.FlightTime / 1000)
|
||||
@ -42,15 +38,6 @@ Item {
|
||||
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)
|
||||
|
||||
function formatTime(time) {
|
||||
if (time === 0)
|
||||
return "00"
|
||||
if (time < 10)
|
||||
return "0" + time;
|
||||
else
|
||||
return time.toString();
|
||||
}
|
||||
|
||||
SvgElementImage {
|
||||
id: warning_bg
|
||||
elementName: "warnings-bg"
|
||||
@ -74,7 +61,7 @@ Item {
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: formatTime(time_h) + ":" + formatTime(time_m) + ":" + formatTime(time_s)
|
||||
text: Utils.formatTime(time_h) + ":" + Utils.formatTime(time_m) + ":" + Utils.formatTime(time_s)
|
||||
font {
|
||||
family: pt_bold.name
|
||||
pixelSize: Math.floor(parent.height * 0.8)
|
||||
@ -95,11 +82,11 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: warnings.armColors[qint8toInt(FlightStatus.Armed)]
|
||||
color: warnings.armColors[Utils.toInt(FlightStatus.Armed)]
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: ["DISARMED","ARMING","ARMED"][qint8toInt(FlightStatus.Armed)]
|
||||
text: ["DISARMED","ARMING","ARMED"][Utils.toInt(FlightStatus.Armed)]
|
||||
font {
|
||||
family: pt_bold.name
|
||||
pixelSize: Math.floor(parent.height * 0.74)
|
||||
@ -120,7 +107,7 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: warnings.statusColors[qint8toInt(SystemAlarms.Alarm_ManualControl)]
|
||||
color: warnings.statusColors[Utils.toInt(SystemAlarms.Alarm_ManualControl)]
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
@ -143,11 +130,11 @@ Item {
|
||||
x: scaledBounds.x * sceneItem.width
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
|
||||
property bool warningActive: (qint8toInt(SystemAlarms.Alarm_BootFault) > 1 ||
|
||||
qint8toInt(SystemAlarms.Alarm_OutOfMemory) > 1 ||
|
||||
qint8toInt(SystemAlarms.Alarm_StackOverflow) > 1 ||
|
||||
qint8toInt(SystemAlarms.Alarm_CPUOverload) > 1 ||
|
||||
qint8toInt(SystemAlarms.Alarm_EventSystem) > 1)
|
||||
property bool warningActive: (Utils.toInt(SystemAlarms.Alarm_BootFault) > 1 ||
|
||||
Utils.toInt(SystemAlarms.Alarm_OutOfMemory) > 1 ||
|
||||
Utils.toInt(SystemAlarms.Alarm_StackOverflow) > 1 ||
|
||||
Utils.toInt(SystemAlarms.Alarm_CPUOverload) > 1 ||
|
||||
Utils.toInt(SystemAlarms.Alarm_EventSystem) > 1)
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: parent.warningActive ? "red" : "red"
|
||||
@ -177,7 +164,7 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: warnings.statusColors[qint8toInt(SystemAlarms.Alarm_Guidance)]
|
||||
color: warnings.statusColors[Utils.toInt(SystemAlarms.Alarm_Guidance)]
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
@ -202,14 +189,14 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: warnings.flightmodeColors[qint8toInt(FlightStatus.FlightMode)]
|
||||
color: warnings.flightmodeColors[Utils.toInt(FlightStatus.FlightMode)]
|
||||
// Manual,Stabilized1,Stabilized2,Stabilized3,Stabilized4,Stabilized5,Stabilized6,PositionHold,CourseLock,
|
||||
// VelocityRoam,HomeLeash,AbsolutePosition,ReturnToBase,Land,PathPlanner,POI,AutoCruise,AutoTakeoff
|
||||
|
||||
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"][qint8toInt(FlightStatus.FlightMode)]
|
||||
"VEL ROAM", "HOME LEASH", "ABS POS", "RTB", "LAND", "PATHPLAN", "POI", "AUTOCRUISE", "AUTOTAKEOFF"][Utils.toInt(FlightStatus.FlightMode)]
|
||||
font {
|
||||
family: pt_bold.name
|
||||
pixelSize: Math.floor(parent.height * 0.74)
|
||||
@ -230,7 +217,7 @@ Item {
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: qint8toInt(FlightStatus.FlightMode) < 1 ? "grey" : warnings.thrustmodeColors[thrust_mode]
|
||||
color: Utils.toInt(FlightStatus.FlightMode) < 1 ? "grey" : warnings.thrustmodeColors[thrust_mode]
|
||||
|
||||
// Manual,Rate,RateTrainer,Attitude,AxisLock,WeakLeveling,VirtualBar,Acro+,Rattitude,
|
||||
// AltitudeHold,AltitudeVario,CruiseControl
|
||||
@ -253,7 +240,7 @@ Item {
|
||||
elementName: "warning-gps"
|
||||
sceneSize: warnings.sceneSize
|
||||
|
||||
visible: qint8toInt(SystemAlarms.Alarm_GPS) > 1
|
||||
visible: Utils.toInt(SystemAlarms.Alarm_GPS) > 1
|
||||
}
|
||||
|
||||
SvgElementImage {
|
||||
@ -261,6 +248,6 @@ Item {
|
||||
elementName: "warning-attitude"
|
||||
sceneSize: warnings.sceneSize
|
||||
anchors.centerIn: background.centerIn
|
||||
visible: qint8toInt(SystemAlarms.Alarm_Attitude) > 1
|
||||
visible: Utils.toInt(SystemAlarms.Alarm_Attitude) > 1
|
||||
}
|
||||
}
|
||||
|
26
ground/gcs/src/share/pfd/default/common.js
Normal file
26
ground/gcs/src/share/pfd/default/common.js
Normal file
@ -0,0 +1,26 @@
|
||||
// ***********************
|
||||
// common.js
|
||||
//
|
||||
// Common javascript utils
|
||||
//
|
||||
// Librepilot
|
||||
// ***********************
|
||||
//
|
||||
// qml/js treats qint8 as a char, necessary to convert it back to integer value
|
||||
function toInt(enum_value) {
|
||||
if (Object.prototype.toString.call(enum_value) == "[object String]") {
|
||||
return enum_value.charCodeAt(0);
|
||||
}
|
||||
return enum_value;
|
||||
}
|
||||
|
||||
// Format time
|
||||
function formatTime(time) {
|
||||
if (time === 0)
|
||||
return "00"
|
||||
if (time < 10)
|
||||
return "0" + time;
|
||||
else
|
||||
return time.toString();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user