mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-82: GPS info includes HDOP as well. PFD plugin is now pretty much ready feature-wise. Additional features such as waypoint/home display will be added then OpenPilot supports this too.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1094 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
be63c71de4
commit
57fe878b64
@ -47,17 +47,22 @@ PFDGadgetWidget::PFDGadgetWidget(QWidget *parent) : QGraphicsView(parent)
|
|||||||
headingObj = NULL;
|
headingObj = NULL;
|
||||||
gcsBatteryObj = NULL;
|
gcsBatteryObj = NULL;
|
||||||
compassBandWidth = 0;
|
compassBandWidth = 0;
|
||||||
/*
|
pfdError = true;
|
||||||
obj2 = NULL;
|
rollTarget = 0;
|
||||||
obj3 = NULL;
|
rollValue = 0;
|
||||||
*/
|
pitchTarget = 0;
|
||||||
|
pitchValue = 0;
|
||||||
|
headingTarget = 0;
|
||||||
|
headingValue = 0;
|
||||||
|
groundspeedTarget = 0;
|
||||||
|
groundspeedValue = 0;
|
||||||
|
altitudeTarget = 0;
|
||||||
|
altitudeValue = 0;
|
||||||
|
|
||||||
|
|
||||||
// This timer mechanism makes needles rotate smoothly
|
// This timer mechanism makes needles rotate smoothly
|
||||||
connect(&dialTimer, SIGNAL(timeout()), this, SLOT(moveNeedles()));
|
connect(&dialTimer, SIGNAL(timeout()), this, SLOT(moveNeedles()));
|
||||||
dialTimer.start(20);
|
dialTimer.start(20);
|
||||||
/*
|
|
||||||
connect(&dialTimer2,SIGNAL(timeout()), this, SLOT(moveVerticalScales()));
|
|
||||||
dialTimer2.start(20);
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +74,8 @@ PFDGadgetWidget::~PFDGadgetWidget()
|
|||||||
/*!
|
/*!
|
||||||
\brief Connects the widget to the relevant UAVObjects
|
\brief Connects the widget to the relevant UAVObjects
|
||||||
|
|
||||||
We want: AttitudeActual, FlightBattery, Location
|
Should only be called after the PFD artwork is loaded.
|
||||||
|
We want: AttitudeActual, FlightBattery, Location.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void PFDGadgetWidget::connectNeedles() {
|
void PFDGadgetWidget::connectNeedles() {
|
||||||
@ -102,19 +108,24 @@ void PFDGadgetWidget::connectNeedles() {
|
|||||||
qDebug() << "Error: Object is unknown (PositionActual).";
|
qDebug() << "Error: Object is unknown (PositionActual).";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gcsTelemetryArrow || gcsTelemetryStats ) {
|
||||||
|
// Only register if the PFD wants link stats/status
|
||||||
gcsTelemetryObj = dynamic_cast<UAVDataObject*>(objManager->getObject("GCSTelemetryStats"));
|
gcsTelemetryObj = dynamic_cast<UAVDataObject*>(objManager->getObject("GCSTelemetryStats"));
|
||||||
if (gcsTelemetryObj != NULL ) {
|
if (gcsTelemetryObj != NULL ) {
|
||||||
connect(gcsTelemetryObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateLinkStatus(UAVObject*)));
|
connect(gcsTelemetryObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateLinkStatus(UAVObject*)));
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Error: Object is unknown (GCSTelemetryStats).";
|
qDebug() << "Error: Object is unknown (GCSTelemetryStats).";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gcsBatteryStats) { // Only register if the PFD wants battery display
|
||||||
gcsBatteryObj = dynamic_cast<UAVDataObject*>(objManager->getObject("FlightBatteryState"));
|
gcsBatteryObj = dynamic_cast<UAVDataObject*>(objManager->getObject("FlightBatteryState"));
|
||||||
if (gcsBatteryObj != NULL ) {
|
if (gcsBatteryObj != NULL ) {
|
||||||
connect(gcsBatteryObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateBattery(UAVObject*)));
|
connect(gcsBatteryObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateBattery(UAVObject*)));
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Error: Object is unknown (FlightBatteryState).";
|
qDebug() << "Error: Object is unknown (FlightBatteryState).";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +142,7 @@ void PFDGadgetWidget::updateLinkStatus(UAVObject *object1) {
|
|||||||
UAVObjectField* field3 = object1->getField(rdr);
|
UAVObjectField* field3 = object1->getField(rdr);
|
||||||
if (field && field2 && field3) {
|
if (field && field2 && field3) {
|
||||||
QString s = field->getValue().toString();
|
QString s = field->getValue().toString();
|
||||||
if (m_renderer->elementExists("gcstelemetry-" + s)) {
|
if (m_renderer->elementExists("gcstelemetry-" + s) && gcsTelemetryArrow) {
|
||||||
gcsTelemetryArrow->setElementId("gcstelemetry-" + s);
|
gcsTelemetryArrow->setElementId("gcstelemetry-" + s);
|
||||||
} else { // Safeguard
|
} else { // Safeguard
|
||||||
gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected");
|
gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected");
|
||||||
@ -139,7 +150,7 @@ void PFDGadgetWidget::updateLinkStatus(UAVObject *object1) {
|
|||||||
double v1 = field2->getDouble();
|
double v1 = field2->getDouble();
|
||||||
double v2 = field3->getDouble();
|
double v2 = field3->getDouble();
|
||||||
s.sprintf("%.0f/%.0f",v1,v2);
|
s.sprintf("%.0f/%.0f",v1,v2);
|
||||||
gcsTelemetryStats->setPlainText(s);
|
if (gcsTelemetryStats) gcsTelemetryStats->setPlainText(s);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "UpdateLinkStatus: Wrong field, maybe an issue with object disconnection ?";
|
qDebug() << "UpdateLinkStatus: Wrong field, maybe an issue with object disconnection ?";
|
||||||
}
|
}
|
||||||
@ -159,6 +170,8 @@ void PFDGadgetWidget::updateAttitude(UAVObject *object1) {
|
|||||||
// - Roll value in degrees
|
// - Roll value in degrees
|
||||||
// - Pitch lines are 300px high for a +20/-20 range, which means
|
// - Pitch lines are 300px high for a +20/-20 range, which means
|
||||||
// 7.5 pixels per pitch degree.
|
// 7.5 pixels per pitch degree.
|
||||||
|
// TODO: loosen this constraint and only require a +/- 20 deg range,
|
||||||
|
// and compute the height from the SVG element.
|
||||||
rollTarget = field->getDouble()*(-1);
|
rollTarget = field->getDouble()*(-1);
|
||||||
pitchTarget = field2->getDouble()*7.5;
|
pitchTarget = field2->getDouble()*7.5;
|
||||||
if (!dialTimer.isActive())
|
if (!dialTimer.isActive())
|
||||||
@ -205,16 +218,20 @@ void PFDGadgetWidget::updateHeading(UAVObject *object1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GPS Stats
|
// GPS Stats
|
||||||
|
if (gcsGPSStats) {
|
||||||
fieldname = QString("Satellites");
|
fieldname = QString("Satellites");
|
||||||
field = object1->getField(fieldname);
|
field = object1->getField(fieldname);
|
||||||
if (field) {
|
fieldname = QString("HDOP");
|
||||||
QString s = QString("GPS: ") + field->getValue().toString();
|
UAVObjectField* field1 = object1->getField(fieldname);
|
||||||
|
if (field && field1) {
|
||||||
|
QString s = QString("GPS: ") + field->getValue().toString() + "\nHDP: "
|
||||||
|
+ field1->getValue().toString();
|
||||||
gcsGPSStats->setPlainText(s);
|
gcsGPSStats->setPlainText(s);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!dialTimer.isActive())
|
if (!dialTimer.isActive())
|
||||||
dialTimer.start(); // Rearm the dial Timer which might be stopped.
|
dialTimer.start(); // Rearm the dial Timer which might be stopped.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -530,6 +547,7 @@ void PFDGadgetWidget::setDialFile(QString dfn)
|
|||||||
////////////////
|
////////////////
|
||||||
// GCS Telemetry Indicator
|
// GCS Telemetry Indicator
|
||||||
////////////////
|
////////////////
|
||||||
|
if (m_renderer->elementExists("gcstelemetry-Disconnected")) {
|
||||||
compassMatrix = m_renderer->matrixForElement("gcstelemetry-Disconnected");
|
compassMatrix = m_renderer->matrixForElement("gcstelemetry-Disconnected");
|
||||||
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).x();
|
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).x();
|
||||||
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).y();
|
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).y();
|
||||||
@ -540,7 +558,11 @@ void PFDGadgetWidget::setDialFile(QString dfn)
|
|||||||
matrix.reset();
|
matrix.reset();
|
||||||
matrix.translate(startX,startY);
|
matrix.translate(startX,startY);
|
||||||
gcsTelemetryArrow->setTransform(matrix,false);
|
gcsTelemetryArrow->setTransform(matrix,false);
|
||||||
|
} else {
|
||||||
|
gcsTelemetryArrow = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_renderer->elementExists("linkrate")) {
|
||||||
compassMatrix = m_renderer->matrixForElement("linkrate");
|
compassMatrix = m_renderer->matrixForElement("linkrate");
|
||||||
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("linkrate")).x();
|
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("linkrate")).x();
|
||||||
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("linkrate")).y();
|
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("linkrate")).y();
|
||||||
@ -552,6 +574,10 @@ void PFDGadgetWidget::setDialFile(QString dfn)
|
|||||||
matrix.reset();
|
matrix.reset();
|
||||||
matrix.translate(startX,startY-linkRateHeight/2);
|
matrix.translate(startX,startY-linkRateHeight/2);
|
||||||
gcsTelemetryStats->setTransform(matrix,false);
|
gcsTelemetryStats->setTransform(matrix,false);
|
||||||
|
} else {
|
||||||
|
gcsTelemetryStats = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// GCS Battery Indicator
|
// GCS Battery Indicator
|
||||||
@ -569,6 +595,7 @@ void PFDGadgetWidget::setDialFile(QString dfn)
|
|||||||
gcsTelemetryArrow->setTransform(matrix,false);
|
gcsTelemetryArrow->setTransform(matrix,false);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (m_renderer->elementExists("battery-txt")) {
|
||||||
compassMatrix = m_renderer->matrixForElement("battery-txt");
|
compassMatrix = m_renderer->matrixForElement("battery-txt");
|
||||||
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("battery-txt")).x();
|
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("battery-txt")).x();
|
||||||
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("battery-txt")).y();
|
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("battery-txt")).y();
|
||||||
@ -580,6 +607,9 @@ void PFDGadgetWidget::setDialFile(QString dfn)
|
|||||||
matrix.reset();
|
matrix.reset();
|
||||||
matrix.translate(startX,startY-batStatHeight/2);
|
matrix.translate(startX,startY-batStatHeight/2);
|
||||||
gcsBatteryStats->setTransform(matrix,false);
|
gcsBatteryStats->setTransform(matrix,false);
|
||||||
|
} else {
|
||||||
|
gcsBatteryStats = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// GCS GPS Indicator
|
// GCS GPS Indicator
|
||||||
@ -597,6 +627,7 @@ void PFDGadgetWidget::setDialFile(QString dfn)
|
|||||||
gcsTelemetryArrow->setTransform(matrix,false);
|
gcsTelemetryArrow->setTransform(matrix,false);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (m_renderer->elementExists("gps-txt")) {
|
||||||
compassMatrix = m_renderer->matrixForElement("gps-txt");
|
compassMatrix = m_renderer->matrixForElement("gps-txt");
|
||||||
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gps-txt")).x();
|
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gps-txt")).x();
|
||||||
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gps-txt")).y();
|
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gps-txt")).y();
|
||||||
@ -608,8 +639,9 @@ void PFDGadgetWidget::setDialFile(QString dfn)
|
|||||||
matrix.reset();
|
matrix.reset();
|
||||||
matrix.translate(startX,startY-gpsStatHeight/2);
|
matrix.translate(startX,startY-gpsStatHeight/2);
|
||||||
gcsGPSStats->setTransform(matrix,false);
|
gcsGPSStats->setTransform(matrix,false);
|
||||||
|
} else {
|
||||||
|
gcsGPSStats = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
l_scene->setSceneRect(m_background->boundingRect());
|
l_scene->setSceneRect(m_background->boundingRect());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user