1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +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 "."
import QtQuick 1.1
Rectangle {
color: "#666666"
@ -14,6 +13,8 @@ Rectangle {
Item {
id: sceneItem
property variant viewportSize : Qt.size(width, height)
width: parent.paintedWidth
height: parent.paintedHeight
anchors.centerIn: parent
@ -27,13 +28,13 @@ Rectangle {
HorizontCenter {
id: horizontCenterItem
sceneSize: background.sceneSize
sceneSize: sceneItem.viewportSize
anchors.fill: parent
}
RollScale {
id: rollscale
sceneSize: background.sceneSize
sceneSize: sceneItem.viewportSize
horizontCenter: horizontCenterItem.horizontCenter
anchors.fill: parent
}
@ -41,7 +42,7 @@ Rectangle {
SvgElementImage {
id: foreground
elementName: "foreground"
sceneSize: background.sceneSize
sceneSize: sceneItem.viewportSize
anchors.centerIn: parent
}
@ -49,7 +50,7 @@ Rectangle {
SvgElementImage {
id: side_slip
elementName: "sideslip"
sceneSize: background.sceneSize
sceneSize: sceneItem.viewportSize
smooth: true
property real sideSlip: AccelState.y
@ -70,27 +71,37 @@ Rectangle {
Compass {
anchors.fill: parent
sceneSize: background.sceneSize
sceneSize: sceneItem.viewportSize
}
SpeedScale {
anchors.fill: parent
sceneSize: background.sceneSize
sceneSize: sceneItem.viewportSize
}
AltitudeScale {
anchors.fill: parent
sceneSize: background.sourceSize
sceneSize: sceneItem.viewportSize
}
VsiScale {
anchors.fill: parent
sceneSize: background.sourceSize
sceneSize: sceneItem.viewportSize
}
PfdIndicators {
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.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 = ""
if (hSliceCount > 1)
params += "hslice="+hSlice+":"+hSliceCount+";"
@ -30,5 +37,6 @@ Image {
params = "?" + 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)));
QStringList objectsToExport;
objectsToExport << "VelocityState" <<
objectsToExport <<
"VelocityState" <<
"PositionState" <<
"AttitudeState" <<
"AccelState" <<
@ -62,6 +63,7 @@ PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) :
"AltitudeHoldDesired" <<
"GPSPositionSensor" <<
"GCSTelemetryStats" <<
"SystemAlarms" <<
"FlightBatteryState";
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();