1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-01 18:29:16 +01:00

PFD view: added Warning and incomplete Info views

Only GPS info is implemented
This commit is contained in:
Dmytro Poplavskiy 2013-10-20 23:05:14 +10:00 committed by Alessio Morale
parent bac42e92c4
commit ecbbfd0891
6 changed files with 201 additions and 13 deletions

View File

@ -0,0 +1,38 @@
import Qt 4.7
Item {
id: info
property variant sceneSize
SvgElementImage {
id: info_bg
elementName: "info-bg"
sceneSize: info.sceneSize
}
Repeater {
id: satNumberBar
// 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
}
}
Text {
text: ["No GPS", "No Fix", "Fix2D", "Fix3D"][GPSPositionSensor.Status]
// TODO: get coords from svg file, as soon as "gps-mode-text" text is converted to path
x: info.sceneSize.width * 0.05
y: info.sceneSize.height * 0.006
font.pixelSize: info.sceneSize.height * 0.02
color: "white"
}
}

View File

@ -1,5 +1,4 @@
import Qt 4.7 import QtQuick 1.1
import "."
Rectangle { Rectangle {
color: "#666666" color: "#666666"
@ -14,6 +13,8 @@ Rectangle {
Item { Item {
id: sceneItem id: sceneItem
property variant viewportSize : Qt.size(width, height)
width: parent.paintedWidth width: parent.paintedWidth
height: parent.paintedHeight height: parent.paintedHeight
anchors.centerIn: parent anchors.centerIn: parent
@ -27,13 +28,13 @@ Rectangle {
HorizontCenter { HorizontCenter {
id: horizontCenterItem id: horizontCenterItem
sceneSize: background.sceneSize sceneSize: sceneItem.viewportSize
anchors.fill: parent anchors.fill: parent
} }
RollScale { RollScale {
id: rollscale id: rollscale
sceneSize: background.sceneSize sceneSize: sceneItem.viewportSize
horizontCenter: horizontCenterItem.horizontCenter horizontCenter: horizontCenterItem.horizontCenter
anchors.fill: parent anchors.fill: parent
} }
@ -41,7 +42,7 @@ Rectangle {
SvgElementImage { SvgElementImage {
id: foreground id: foreground
elementName: "foreground" elementName: "foreground"
sceneSize: background.sceneSize sceneSize: sceneItem.viewportSize
anchors.centerIn: parent anchors.centerIn: parent
} }
@ -49,7 +50,7 @@ Rectangle {
SvgElementImage { SvgElementImage {
id: side_slip id: side_slip
elementName: "sideslip" elementName: "sideslip"
sceneSize: background.sceneSize sceneSize: sceneItem.viewportSize
smooth: true smooth: true
property real sideSlip: AccelState.y property real sideSlip: AccelState.y
@ -70,27 +71,37 @@ Rectangle {
Compass { Compass {
anchors.fill: parent anchors.fill: parent
sceneSize: background.sceneSize sceneSize: sceneItem.viewportSize
} }
SpeedScale { SpeedScale {
anchors.fill: parent anchors.fill: parent
sceneSize: background.sceneSize sceneSize: sceneItem.viewportSize
} }
AltitudeScale { AltitudeScale {
anchors.fill: parent anchors.fill: parent
sceneSize: background.sourceSize sceneSize: sceneItem.viewportSize
} }
VsiScale { VsiScale {
anchors.fill: parent anchors.fill: parent
sceneSize: background.sourceSize sceneSize: sceneItem.viewportSize
} }
PfdIndicators { PfdIndicators {
anchors.fill: parent anchors.fill: parent
sceneSize: background.sourceSize sceneSize: sceneItem.viewportSize
}
Info {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
}
Warnings {
anchors.fill: parent
sceneSize: sceneItem.viewportSize
} }
} }
} }

View File

@ -17,7 +17,14 @@ Image {
sourceSize.width: Math.round(sceneSize.width*scaledBounds.width) sourceSize.width: Math.round(sceneSize.width*scaledBounds.width)
sourceSize.height: Math.round(sceneSize.height*scaledBounds.height) sourceSize.height: Math.round(sceneSize.height*scaledBounds.height)
Component.onCompleted: { x: Math.floor(scaledBounds.x * sceneSize.width)
y: Math.floor(scaledBounds.y * sceneSize.height)
Component.onCompleted: reloadImage()
onElementNameChanged: reloadImage()
onSceneSizeChanged: reloadImage()
function reloadImage() {
var params = "" var params = ""
if (hSliceCount > 1) if (hSliceCount > 1)
params += "hslice="+hSlice+":"+hSliceCount+";" params += "hslice="+hSlice+":"+hSliceCount+";"
@ -30,5 +37,6 @@ Image {
params = "?" + params params = "?" + params
source = "image://svg/"+svgFileName+"!"+elementName+params source = "image://svg/"+svgFileName+"!"+elementName+params
scaledBounds = svgRenderer.scaledElementBounds(svgFileName, elementName)
} }
} }

View File

@ -0,0 +1,14 @@
import Qt 4.7
Item {
id: sceneItem
property variant sceneSize
property string elementName
property string svgFileName: "pfd.svg"
property variant scaledBounds: svgRenderer.scaledElementBounds(svgFileName, elementName)
x: Math.floor(scaledBounds.x * sceneSize.width)
y: Math.floor(scaledBounds.y * sceneSize.height)
width: Math.floor(scaledBounds.width * sceneSize.width)
height: Math.floor(scaledBounds.height * sceneSize.height)
}

View File

@ -0,0 +1,115 @@
import Qt 4.7
Item {
id: warnings
property variant sceneSize
// Uninitialised, OK, Warning, Error, Critical
property variant statusColors : ["gray", "green", "red", "red", "red"]
SvgElementImage {
id: warning_bg
elementName: "warnings-bg"
sceneSize: warnings.sceneSize
}
SvgElementPositionItem {
id: warning_rc_input
sceneSize: parent.sceneSize
elementName: "warning-rc-input"
Rectangle {
anchors.fill: parent
color: warnings.statusColors[SystemAlarms.Alarm_ManualControl]
Text {
anchors.centerIn: parent
text: "RC INPUT"
font {
family: "Arial"
pixelSize: parent.height * 0.8
weight: Font.DemiBold
}
}
}
}
SvgElementPositionItem {
id: warning_master_caution
sceneSize: parent.sceneSize
elementName: "warning-master-caution"
property bool warningActive: (SystemAlarms.Alarm_BootFault > 1 ||
SystemAlarms.Alarm_OutOfMemory > 1 ||
SystemAlarms.Alarm_StackOverflow > 1 ||
SystemAlarms.Alarm_CPUOverload > 1 ||
SystemAlarms.Alarm_EventSystem > 1)
Rectangle {
anchors.fill: parent
color: parent.warningActive ? "red" : "red"
opacity: parent.warningActive ? 1.0 : 0.15
Text {
anchors.centerIn: parent
text: "MASTER CAUTION"
font {
family: "Arial"
pixelSize: parent.height * 0.8
weight: Font.DemiBold
}
}
}
}
SvgElementPositionItem {
id: warning_autopilot
sceneSize: parent.sceneSize
elementName: "warning-autopilot"
Rectangle {
anchors.fill: parent
color: warnings.statusColors[SystemAlarms.Alarm_Guidance]
Text {
anchors.centerIn: parent
text: "AUTOPILOT"
font {
family: "Arial"
pixelSize: parent.height * 0.8
weight: Font.DemiBold
}
}
}
}
SvgElementImage {
id: warning_gps
elementName: "warning-gps"
sceneSize: warnings.sceneSize
visible: SystemAlarms.Alarm_GPS > 1
}
SvgElementImage {
id: warning_telemetry
elementName: "warning-telemetry"
sceneSize: warnings.sceneSize
visible: SystemAlarms.Alarm_Telemetry > 1
}
SvgElementImage {
id: warning_battery
elementName: "warning-battery"
sceneSize: warnings.sceneSize
visible: SystemAlarms.Alarm_Battery > 1
}
SvgElementImage {
id: warning_attitude
elementName: "warning-attitude"
sceneSize: warnings.sceneSize
visible: SystemAlarms.Alarm_Attitude > 1
}
}

View File

@ -53,7 +53,8 @@ PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) :
// setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); // setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
QStringList objectsToExport; QStringList objectsToExport;
objectsToExport << "VelocityState" << objectsToExport <<
"VelocityState" <<
"PositionState" << "PositionState" <<
"AttitudeState" << "AttitudeState" <<
"AccelState" << "AccelState" <<
@ -62,6 +63,7 @@ PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) :
"AltitudeHoldDesired" << "AltitudeHoldDesired" <<
"GPSPositionSensor" << "GPSPositionSensor" <<
"GCSTelemetryStats" << "GCSTelemetryStats" <<
"SystemAlarms" <<
"FlightBatteryState"; "FlightBatteryState";
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();