1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-27 16:54:15 +01:00

LP-181 PFD update works only with Qt5.5

This commit is contained in:
Laurent Lalanne 2015-11-09 14:18:19 +01:00
parent 8c3beaa28c
commit 3e6313e95e
3 changed files with 73 additions and 60 deletions

View File

@ -7,6 +7,11 @@ 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
//
@ -84,16 +89,14 @@ Item {
//
property real bar_width: (info_bg.height + info_bg.width) / 110
property int satsInView: String(GPSSatellites.SatsInView).charCodeAt(0)
property int satsInView: qint8toInt(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
//smooth: true
// hack, qml/js treats qint8 as a char, necessary to convert it back to integer value
property int satNumber : String(GPSPositionSensor.Satellites).charCodeAt(0)
property int satNumber : qint8toInt(GPSPositionSensor.Satellites)
model: 13
Rectangle {
@ -122,10 +125,10 @@ Item {
}
Text {
property int satNumber : String(GPSPositionSensor.Satellites).charCodeAt(0)
property int satNumber : qint8toInt(GPSPositionSensor.Satellites)
text: [satNumber > 5 ? " " + satNumber.toString() + " sats - " : ""] +
["NO GPS", "NO FIX", "2D", "3D"][GPSPositionSensor.Status]
["NO GPS", "NO FIX", "2D", "3D"][qint8toInt(GPSPositionSensor.Status)]
anchors.centerIn: parent
font.pixelSize: parent.height*1.3
font.family: pt_bold.name
@ -154,7 +157,7 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: Math.floor(scaledBounds.y * sceneItem.height)
visible: SystemAlarms.Alarm_PathPlan == 1
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) == 1
}
SvgElementPositionItem {
@ -163,7 +166,7 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: Math.floor(scaledBounds.y * sceneItem.height)
visible: SystemAlarms.Alarm_PathPlan == 1
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) == 1
Text {
text: " "+wp_heading.toFixed(1)+"°"
@ -184,7 +187,7 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: Math.floor(scaledBounds.y * sceneItem.height)
visible: SystemAlarms.Alarm_PathPlan == 1
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) == 1
Text {
text: " "+wp_distance.toFixed(0)+" m"
@ -205,7 +208,7 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: Math.floor(scaledBounds.y * sceneItem.height)
visible: SystemAlarms.Alarm_PathPlan == 1
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) == 1
MouseArea { id: total_dist_mouseArea; anchors.fill: parent; cursorShape: Qt.PointingHandCursor; onClicked: reset_distance()}
@ -223,7 +226,7 @@ Item {
Timer {
interval: 1000; running: true; repeat: true;
onTriggered: {if (GPSPositionSensor.Status == 3) compute_distance(PositionState.East,PositionState.North)}
onTriggered: {if (qint8toInt(GPSPositionSensor.Status) == 3) compute_distance(PositionState.East,PositionState.North)}
}
}
@ -233,7 +236,7 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: Math.floor(scaledBounds.y * sceneItem.height)
visible: SystemAlarms.Alarm_PathPlan == 1
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) == 1
Text {
text: formatTime(wp_eta_h) + ":" + formatTime(wp_eta_m) + ":" + formatTime(wp_eta_s)
@ -254,7 +257,7 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: Math.floor(scaledBounds.y * sceneItem.height)
visible: SystemAlarms.Alarm_PathPlan == 1
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) == 1
Text {
text: (WaypointActive.Index+1)+" / "+PathPlan.WaypointCount
@ -275,10 +278,10 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: Math.floor(scaledBounds.y * sceneItem.height)
visible: SystemAlarms.Alarm_PathPlan == 1
visible: qint8toInt(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"][PathDesired.Mode]
text: ["GOTO ENDPOINT","FOLLOW VECTOR","CIRCLE RIGHT","CIRCLE LEFT","FIXED ATTITUDE","SET ACCESSORY","DISARM ALARM","LAND","BRAKE","VELOCITY","AUTO TAKEOFF"][qint8toInt(PathDesired.Mode)]
anchors.centerIn: parent
color: "cyan"
@ -301,11 +304,11 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: scaledBounds.y * sceneItem.height
visible: (SystemAlarms.Alarm_PathPlan != 1) && (HwSettings.OptionalModules_Battery == 1)
visible: (qint8toInt(SystemAlarms.Alarm_PathPlan) != 1) && (qint8toInt(HwSettings.OptionalModules_Battery) == 1)
Rectangle {
anchors.fill: parent
color: FlightBatterySettings.NbCells > 0 ? info.batColors[SystemAlarms.Alarm_Battery] : "black"
color: FlightBatterySettings.NbCells > 0 ? info.batColors[qint8toInt(SystemAlarms.Alarm_Battery)] : "black"
}
}
@ -316,7 +319,7 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: Math.floor(scaledBounds.y * sceneItem.height)
visible: (SystemAlarms.Alarm_PathPlan != 1) && (HwSettings.OptionalModules_Battery == 1)
visible: (qint8toInt(SystemAlarms.Alarm_PathPlan) != 1) && (qint8toInt(HwSettings.OptionalModules_Battery) == 1)
}
SvgElementPositionItem {
@ -327,7 +330,7 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: scaledBounds.y * sceneItem.height
visible: (SystemAlarms.Alarm_PathPlan != 1) && (HwSettings.OptionalModules_Battery == 1)
visible: (qint8toInt(SystemAlarms.Alarm_PathPlan) != 1) && (qint8toInt(HwSettings.OptionalModules_Battery) == 1)
Rectangle {
anchors.fill: parent
@ -354,7 +357,7 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: scaledBounds.y * sceneItem.height
visible: (SystemAlarms.Alarm_PathPlan != 1) && (HwSettings.OptionalModules_Battery == 1)
visible: (qint8toInt(SystemAlarms.Alarm_PathPlan) != 1) && (qint8toInt(HwSettings.OptionalModules_Battery) == 1)
Rectangle {
anchors.fill: parent
@ -381,7 +384,7 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: scaledBounds.y * sceneItem.height
visible: (SystemAlarms.Alarm_PathPlan != 1) && (HwSettings.OptionalModules_Battery == 1)
visible: (qint8toInt(SystemAlarms.Alarm_PathPlan) != 1) && (qint8toInt(HwSettings.OptionalModules_Battery) == 1)
Rectangle {
anchors.fill: parent
@ -399,7 +402,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[SystemAlarms.Alarm_Battery]))
(FlightBatteryState.EstimatedFlightTime <= 60 ? "red": info.batColors[qint8toInt(SystemAlarms.Alarm_Battery)]))
border.color: "white"
border.width: topbattery_volt.width * 0.01
@ -427,7 +430,7 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: Math.floor(scaledBounds.y * sceneItem.height)
visible: SystemAlarms.Alarm_PathPlan != 1
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) != 1
}
SvgElementPositionItem {
@ -436,7 +439,7 @@ Item {
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
y: Math.floor(scaledBounds.y * sceneItem.height)
visible: SystemAlarms.Alarm_PathPlan != 1
visible: qint8toInt(SystemAlarms.Alarm_PathPlan) != 1
TooltipArea {
text: "Reset distance counter"
@ -458,7 +461,7 @@ Item {
Timer {
interval: 1000; running: true; repeat: true;
onTriggered: {if (GPSPositionSensor.Status == 3) compute_distance(PositionState.East,PositionState.North)}
onTriggered: {if (qint8toInt(GPSPositionSensor.Status) == 3) compute_distance(PositionState.East,PositionState.North)}
}
}
@ -477,7 +480,7 @@ Item {
states: State {
name: "fading"
when: TakeOffLocation.Status == 0
when: qint8toInt(TakeOffLocation.Status) == 0
PropertyChanges { target: home_bg; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
}
@ -498,7 +501,7 @@ Item {
states: State {
name: "fading_heading"
when: TakeOffLocation.Status == 0
when: qint8toInt(TakeOffLocation.Status) == 0
PropertyChanges { target: home_heading_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
}
@ -529,7 +532,7 @@ Item {
states: State {
name: "fading_distance"
when: TakeOffLocation.Status == 0
when: qint8toInt(TakeOffLocation.Status) == 0
PropertyChanges { target: home_distance_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
}
@ -560,7 +563,7 @@ Item {
states: State {
name: "fading_distance"
when: TakeOffLocation.Status == 0
when: qint8toInt(TakeOffLocation.Status) == 0
PropertyChanges { target: home_eta_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
}

View File

@ -18,6 +18,11 @@ Item {
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
//
@ -100,7 +105,7 @@ Item {
function telemetry_check() {
telemetry_sum = OPLinkStatus.RXRate + OPLinkStatus.RXRate
if (telemetry_sum != telemetry_sum_old || OPLinkStatus.LinkState == 4) {
if (telemetry_sum != telemetry_sum_old || qint8toInt(OPLinkStatus.LinkState) == 4) {
telemetry_link = 1
} else {
telemetry_link = 0
@ -451,7 +456,7 @@ Item {
Rectangle {
anchors.fill: parent
color: panels.batColors[SystemAlarms.Alarm_Battery]
color: panels.batColors[qint8toInt(SystemAlarms.Alarm_Battery)]
border.color: "white"
border.width: battery_volt.width * 0.01
radius: border.width * 4
@ -492,7 +497,7 @@ Item {
Rectangle {
anchors.fill: parent
color: panels.batColors[SystemAlarms.Alarm_Battery]
color: panels.batColors[qint8toInt(SystemAlarms.Alarm_Battery)]
border.color: "white"
border.width: battery_volt.width * 0.01
radius: border.width * 4
@ -549,7 +554,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[SystemAlarms.Alarm_Battery]))
(FlightBatteryState.EstimatedFlightTime <= 60 ? "red": panels.batColors[qint8toInt(SystemAlarms.Alarm_Battery)]))
border.color: "white"
border.width: battery_volt.width * 0.01
@ -591,7 +596,7 @@ Item {
Rectangle {
anchors.fill: parent
//color: panels.batColors[SystemAlarms.Alarm_Battery]
//color: panels.batColors[qint8toInt(SystemAlarms.Alarm_Battery)]
TooltipArea {
text: "Reset consumed energy"
@ -608,7 +613,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[SystemAlarms.Alarm_Battery]))
(FlightBatteryState.EstimatedFlightTime <= 60 ? "red": panels.batColors[qint8toInt(SystemAlarms.Alarm_Battery)]))
border.color: "white"
border.width: battery_volt.width * 0.01
@ -954,7 +959,7 @@ Item {
}
Text {
text: ReceiverStatus.Quality > 0 ? ReceiverStatus.Quality+"%" : "?? %"
text: qint8toInt(ReceiverStatus.Quality) > 0 ? qint8toInt(ReceiverStatus.Quality)+"%" : "?? %"
anchors.centerIn: parent
color: "white"
font {
@ -1043,7 +1048,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]
"Tricopter", "GroundVehicleCar", "GroundVehicleDiff", "GroundVehicleMoto"][qint8toInt(SystemSettings.AirframeType)]
anchors.right: parent.right
color: "white"
font {
@ -1075,7 +1080,7 @@ Item {
Text {
// Coptercontrol detect with mem free : Only display Cpu load, no temperature available.
text: SystemStats.CPULoad+"%"+
text: qint8toInt(SystemStats.CPULoad)+"%"+
[SystemStats.HeapRemaining < 3000 ? "" : " | "+cpuTemp+"°C"]
anchors.right: parent.right
color: "white"
@ -1138,7 +1143,7 @@ Item {
}
Text {
text: ["None", "Basic (No Nav)", "CompMag", "Comp+Mag+GPS", "EKFIndoor", "GPS Nav (INS13)"][RevoSettings.FusionAlgorithm]
text: ["None", "Basic (No Nav)", "CompMag", "Comp+Mag+GPS", "EKFIndoor", "GPS Nav (INS13)"][qint8toInt(RevoSettings.FusionAlgorithm)]
anchors.right: parent.right
color: "white"
font {
@ -1169,7 +1174,7 @@ Item {
}
Text {
text: ["Invalid", "OnBoard", "External"][MagState.Source]
text: ["Invalid", "OnBoard", "External"][qint8toInt(MagState.Source)]
anchors.right: parent.right
color: "white"
font {
@ -1200,7 +1205,7 @@ Item {
}
Text {
text: ["Unknown", "NMEA", "UBX", "UBX7", "UBX8"][GPSPositionSensor.SensorType]
text: ["Unknown", "NMEA", "UBX", "UBX7", "UBX8"][qint8toInt(GPSPositionSensor.SensorType)]
anchors.right: parent.right
color: "white"
font {

View File

@ -3,6 +3,11 @@ import QtQuick 2.0
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"]
@ -26,10 +31,10 @@ Item {
// SystemSettings.AirframeType 3 - 17 : VtolPathFollower, check ThrustControl
property var thrust_mode: FlightStatus.FlightMode < 7 ? StabilizationDesired.StabilizationMode_Thrust :
FlightStatus.FlightMode > 6 && SystemSettings.AirframeType > 2 && SystemSettings.AirframeType < 18
&& VtolPathFollowerSettings.ThrustControl == 1 ? 12 :
FlightStatus.FlightMode > 6 && SystemSettings.AirframeType < 3 ? 12: 0
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 real flight_time: Math.round(SystemStats.FlightTime / 1000)
@ -90,11 +95,11 @@ Item {
Rectangle {
anchors.fill: parent
color: warnings.armColors[FlightStatus.Armed]
color: warnings.armColors[qint8toInt(FlightStatus.Armed)]
Text {
anchors.centerIn: parent
text: ["DISARMED","ARMING","ARMED"][FlightStatus.Armed]
text: ["DISARMED","ARMING","ARMED"][qint8toInt(FlightStatus.Armed)]
font {
family: pt_bold.name
pixelSize: Math.floor(parent.height * 0.74)
@ -115,7 +120,7 @@ Item {
Rectangle {
anchors.fill: parent
color: warnings.statusColors[SystemAlarms.Alarm_ManualControl]
color: warnings.statusColors[qint8toInt(SystemAlarms.Alarm_ManualControl)]
Text {
anchors.centerIn: parent
@ -138,11 +143,11 @@ Item {
x: scaledBounds.x * sceneItem.width
y: scaledBounds.y * sceneItem.height
property bool warningActive: (SystemAlarms.Alarm_BootFault > 1 ||
SystemAlarms.Alarm_OutOfMemory > 1 ||
SystemAlarms.Alarm_StackOverflow > 1 ||
SystemAlarms.Alarm_CPUOverload > 1 ||
SystemAlarms.Alarm_EventSystem > 1)
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)
Rectangle {
anchors.fill: parent
color: parent.warningActive ? "red" : "red"
@ -172,7 +177,7 @@ Item {
Rectangle {
anchors.fill: parent
color: warnings.statusColors[SystemAlarms.Alarm_Guidance]
color: warnings.statusColors[qint8toInt(SystemAlarms.Alarm_Guidance)]
Text {
anchors.centerIn: parent
@ -197,14 +202,14 @@ Item {
Rectangle {
anchors.fill: parent
color: warnings.flightmodeColors[FlightStatus.FlightMode]
color: warnings.flightmodeColors[qint8toInt(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"][FlightStatus.FlightMode]
"VEL ROAM", "HOME LEASH", "ABS POS", "RTB", "LAND", "PATHPLAN", "POI", "AUTOCRUISE", "AUTOTAKEOFF"][qint8toInt(FlightStatus.FlightMode)]
font {
family: pt_bold.name
pixelSize: Math.floor(parent.height * 0.74)
@ -225,7 +230,7 @@ Item {
Rectangle {
anchors.fill: parent
color: FlightStatus.FlightMode < 1 ? "grey" : warnings.thrustmodeColors[thrust_mode.toString()]
color: qint8toInt(FlightStatus.FlightMode) < 1 ? "grey" : warnings.thrustmodeColors[thrust_mode]
// Manual,Rate,RateTrainer,Attitude,AxisLock,WeakLeveling,VirtualBar,Acro+,Rattitude,
// AltitudeHold,AltitudeVario,CruiseControl
@ -233,7 +238,7 @@ Item {
Text {
anchors.centerIn: parent
text: ["MANUAL"," "," ", " ", " ", " ", " ", " ", " ",
"ALT HOLD", "ALT VARIO", "CRUISECTRL", "AUTO"][thrust_mode.toString()]
"ALT HOLD", "ALT VARIO", "CRUISECTRL", "AUTO"][thrust_mode]
font {
family: pt_bold.name
pixelSize: Math.floor(parent.height * 0.74)
@ -248,7 +253,7 @@ Item {
elementName: "warning-gps"
sceneSize: warnings.sceneSize
visible: SystemAlarms.Alarm_GPS > 1
visible: qint8toInt(SystemAlarms.Alarm_GPS) > 1
}
SvgElementImage {
@ -256,6 +261,6 @@ Item {
elementName: "warning-attitude"
sceneSize: warnings.sceneSize
anchors.centerIn: background.centerIn
visible: SystemAlarms.Alarm_Attitude > 1
visible: qint8toInt(SystemAlarms.Alarm_Attitude) > 1
}
}