1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

OP-1887 Gps display, 12bars - Add text

This commit is contained in:
Laurent Lalanne 2015-05-13 23:39:41 +02:00
parent f5160f64b0
commit 295e0870ef

View File

@ -4,7 +4,7 @@ Item {
id: info
property variant sceneSize
// Uninitialised, Ok, Warning, Critical, Error
// Uninitialised, Ok, Warning, Critical, Error
property variant batColors : ["black", "green", "orange", "red", "red"]
//
@ -42,19 +42,19 @@ Item {
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(){
function reset_distance() {
total_distance = 0;
}
function compute_distance(posEast,posNorth) {
if (total_distance == 0 && !init_dist){init_dist = "true"; posEast_old = posEast; posNorth_old = posNorth;}
if (total_distance == 0 && !init_dist) { init_dist = "true"; posEast_old = posEast; posNorth_old = posNorth; }
if (posEast > posEast_old+3 || posEast < posEast_old-3 || posNorth > posNorth_old+3 || posNorth < posNorth_old-3) {
total_distance += Math.sqrt(Math.pow((posEast - posEast_old ),2) + Math.pow((posNorth - posNorth_old),2));
total_distance_km = total_distance / 1000;
total_distance += Math.sqrt(Math.pow((posEast - posEast_old ),2) + Math.pow((posNorth - posNorth_old),2));
total_distance_km = total_distance / 1000;
posEast_old = posEast;
posNorth_old = posNorth;
return total_distance;
posEast_old = posEast;
posNorth_old = posNorth;
return total_distance;
}
}
@ -76,24 +76,32 @@ Item {
sceneSize: info.sceneSize
elementName: "info-bg"
width: parent.width
opacity: qmlWidget.terrainEnabled ? 0.3 : 1
}
//
// GPS Info (Top)
//
property real bar_width: (info_bg.height + info_bg.width) / 110
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)
model: 10
SvgElementImage {
property int minSatNumber : index+1
elementName: "gps" + minSatNumber
sceneSize: info.sceneSize
visible: satNumberBar.satNumber >= minSatNumber
model: 13
Rectangle {
property int minSatNumber : index
width: Math.round(bar_width)
radius: width / 4
x: Math.round((bar_width*4.5) + (bar_width * 1.6 * index))
height: bar_width * index * 0.6
y: (bar_width*8) - height
color: "green"
opacity: satNumberBar.satNumber >= minSatNumber ? 1 : 0.4
}
}
@ -102,20 +110,29 @@ Item {
elementName: "gps-mode-text"
Text {
text: ["NO GPS", "NO FIX", "FIX 2D", "FIX 3D"][GPSPositionSensor.Status]
property int satNumber : String(GPSPositionSensor.Satellites).charCodeAt(0)
text: [satNumber > 5 ? " " + satNumber.toString() + " sats - " : ""] +
["NO GPS", "NO FIX", "2D", "3D"][GPSPositionSensor.Status]
anchors.centerIn: parent
font.pixelSize: Math.floor(parent.height*1.3)
font.pixelSize: parent.height*1.3
font.family: pt_bold.name
font.weight: Font.DemiBold
color: "white"
}
}
//
SvgElementImage {
sceneSize: info.sceneSize
elementName: "gps-icon"
width: scaledBounds.width * sceneItem.width
height: scaledBounds.height * sceneItem.height
}
// Waypoint Info (Top)
// Only visible when PathPlan is active (WP loaded)
SvgElementImage {
SvgElementImage {
sceneSize: info.sceneSize
elementName: "waypoint-labels"
width: scaledBounds.width * sceneItem.width
@ -257,7 +274,6 @@ Item {
}
}
//
// Battery Info (Top)
// Only visible when PathPlan not active and Battery module enabled
@ -278,7 +294,7 @@ Item {
}
}
SvgElementImage {
SvgElementImage {
sceneSize: info.sceneSize
elementName: "topbattery-labels"
width: scaledBounds.width * sceneItem.width
@ -382,11 +398,10 @@ Item {
}
}
//
// Default counter
// Only visible when PathPlan not active
SvgElementImage {
SvgElementImage {
sceneSize: info.sceneSize
elementName: "topbattery-total-distance-label"
width: scaledBounds.width * sceneItem.width
@ -423,13 +438,6 @@ Item {
}
}
SvgElementImage {
id: mask_SatBar
elementName: "satbar-mask"
sceneSize: info.sceneSize
}
//
// Home info (visible after arming)
//
@ -438,18 +446,21 @@ Item {
id: home_bg
elementName: "home-bg"
sceneSize: info.sceneSize
x: Math.floor(scaledBounds.x * sceneItem.width)
y: Math.floor(scaledBounds.y * sceneItem.height)
states: State {
opacity: qmlWidget.terrainEnabled ? 0.6 : 1
states: State {
name: "fading"
when: TakeOffLocation.Status !== 0
PropertyChanges { target: home_bg; x: Math.floor(scaledBounds.x * sceneItem.width) + home_bg.width; }
when: TakeOffLocation.Status == 0
PropertyChanges { target: home_bg; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
}
transitions: Transition {
SequentialAnimation {
PropertyAnimation { property: "x"; duration: 800 }
}
transitions: Transition {
SequentialAnimation {
PropertyAnimation { property: "x"; duration: 800 }
}
}
}
@ -461,17 +472,18 @@ Item {
height: scaledBounds.height * sceneItem.height
y: Math.floor(scaledBounds.y * sceneItem.height)
states: State {
states: State {
name: "fading_heading"
when: TakeOffLocation.Status !== 0
PropertyChanges { target: home_heading_text; x: Math.floor(scaledBounds.x * sceneItem.width) + home_bg.width; }
when: TakeOffLocation.Status == 0
PropertyChanges { target: home_heading_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
}
transitions: Transition {
SequentialAnimation {
PropertyAnimation { property: "x"; duration: 800 }
}
transitions: Transition {
SequentialAnimation {
PropertyAnimation { property: "x"; duration: 800 }
}
}
Text {
text: " "+home_heading.toFixed(1)+"°"
anchors.centerIn: parent
@ -491,16 +503,16 @@ Item {
height: scaledBounds.height * sceneItem.height
y: Math.floor(scaledBounds.y * sceneItem.height)
states: State {
states: State {
name: "fading_distance"
when: TakeOffLocation.Status !== 0
PropertyChanges { target: home_distance_text; x: Math.floor(scaledBounds.x * sceneItem.width) + home_bg.width; }
when: TakeOffLocation.Status == 0
PropertyChanges { target: home_distance_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
}
transitions: Transition {
SequentialAnimation {
PropertyAnimation { property: "x"; duration: 800 }
}
transitions: Transition {
SequentialAnimation {
PropertyAnimation { property: "x"; duration: 800 }
}
}
Text {
@ -522,16 +534,16 @@ Item {
height: scaledBounds.height * sceneItem.height
y: Math.floor(scaledBounds.y * sceneItem.height)
states: State {
states: State {
name: "fading_distance"
when: TakeOffLocation.Status !== 0
PropertyChanges { target: home_eta_text; x: Math.floor(scaledBounds.x * sceneItem.width) + home_bg.width; }
when: TakeOffLocation.Status == 0
PropertyChanges { target: home_eta_text; x: Math.floor(scaledBounds.x * sceneItem.width) - home_bg.width; }
}
transitions: Transition {
SequentialAnimation {
PropertyAnimation { property: "x"; duration: 800 }
}
transitions: Transition {
SequentialAnimation {
PropertyAnimation { property: "x"; duration: 800 }
}
}
Text {