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:
parent
f5160f64b0
commit
295e0870ef
@ -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"]
|
||||
|
||||
//
|
||||
@ -15,16 +15,16 @@ Item {
|
||||
property real posNorth_old
|
||||
property real total_distance
|
||||
property real total_distance_km
|
||||
|
||||
|
||||
property bool init_dist: false
|
||||
|
||||
property real home_heading: 180/3.1415 * Math.atan2(TakeOffLocation.East - PositionState.East,
|
||||
|
||||
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.End_East - PositionState.East,
|
||||
property real wp_heading: 180/3.1415 * Math.atan2(PathDesired.End_East - PositionState.East,
|
||||
PathDesired.End_North - PositionState.North)
|
||||
|
||||
property real wp_distance: Math.sqrt(Math.pow((PathDesired.End_East - PositionState.East),2) +
|
||||
@ -34,28 +34,28 @@ Item {
|
||||
|
||||
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_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_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;
|
||||
}
|
||||
}
|
||||
|
||||
function formatTime(time) {
|
||||
@ -68,7 +68,7 @@ Item {
|
||||
}
|
||||
|
||||
// End Functions
|
||||
//
|
||||
//
|
||||
// Start Drawing
|
||||
|
||||
SvgElementImage {
|
||||
@ -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
|
||||
|
||||
@ -265,7 +281,7 @@ Item {
|
||||
id: topbattery_voltamp_bg
|
||||
sceneSize: info.sceneSize
|
||||
elementName: "topbattery-label-voltamp-bg"
|
||||
|
||||
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
@ -278,7 +294,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
SvgElementImage {
|
||||
SvgElementImage {
|
||||
sceneSize: info.sceneSize
|
||||
elementName: "topbattery-labels"
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
@ -291,7 +307,7 @@ Item {
|
||||
id: topbattery_volt
|
||||
sceneSize: info.sceneSize
|
||||
elementName: "topbattery-volt-text"
|
||||
|
||||
|
||||
width: scaledBounds.width * sceneItem.width
|
||||
height: scaledBounds.height * sceneItem.height
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
@ -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,19 +446,22 @@ 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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SvgElementPositionItem {
|
||||
@ -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,17 +503,17 @@ 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 {
|
||||
text: home_distance.toFixed(0)+" m"
|
||||
@ -522,17 +534,17 @@ 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 {
|
||||
text: formatTime(home_eta_h) + ":" + formatTime(home_eta_m) + ":" + formatTime(home_eta_s)
|
||||
|
Loading…
Reference in New Issue
Block a user