mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-82: New PFD feature, GCS Link status indication. Will add tx/rx rate there too.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1051 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
bbef473ab3
commit
26f46b614d
@ -94,6 +94,36 @@ void PFDGadgetWidget::connectNeedles() {
|
|||||||
std::cout << "Error: Object is unknown (PositionActual)." << std::endl;
|
std::cout << "Error: Object is unknown (PositionActual)." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gcsTelemetryObj = dynamic_cast<UAVDataObject*>(objManager->getObject("GCSTelemetryStats"));
|
||||||
|
if (gcsTelemetryObj != NULL ) {
|
||||||
|
connect(gcsTelemetryObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateLinkStatus(UAVObject*)));
|
||||||
|
} else {
|
||||||
|
std::cout << "Error: Object is unknown (GCSTelemetryStats)." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Updates the link stats
|
||||||
|
*/
|
||||||
|
void PFDGadgetWidget::updateLinkStatus(UAVObject *object1) {
|
||||||
|
// Double check that the field exists:
|
||||||
|
QString st = QString("Status");
|
||||||
|
QString tdr = QString("TxDataRate");
|
||||||
|
QString rdr = QString("RxDataRate");
|
||||||
|
UAVObjectField* field = object1->getField(st);
|
||||||
|
UAVObjectField* field2 = object1->getField(tdr);
|
||||||
|
UAVObjectField* field3 = object1->getField(rdr);
|
||||||
|
if (field && field2 && field3) {
|
||||||
|
QString s = field->getValue().toString();
|
||||||
|
if (m_renderer->elementExists("gcstelemetry-" + s)) {
|
||||||
|
gcsTelemetryArrow->setElementId("gcstelemetry-" + s);
|
||||||
|
} else { // Safeguard
|
||||||
|
gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cout << "UpdateLinkStatus: Wrong field, maybe an issue with object disconnection ?" << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -208,7 +238,8 @@ void PFDGadgetWidget::setDialFile(QString dfn)
|
|||||||
- Black speed window: speed-window.
|
- Black speed window: speed-window.
|
||||||
- Altitude rectangle (right site): altitude-bg.
|
- Altitude rectangle (right site): altitude-bg.
|
||||||
- Altitude scale: altitude-scale.
|
- Altitude scale: altitude-scale.
|
||||||
- Black altitude window: altitude-window.
|
- Black altitude window: altitude-window.
|
||||||
|
- GCS Telemetry status arrow: gcstelemetry-XXXX
|
||||||
*/
|
*/
|
||||||
QGraphicsScene *l_scene = scene();
|
QGraphicsScene *l_scene = scene();
|
||||||
l_scene->clear(); // Deletes all items contained in the scene as well.
|
l_scene->clear(); // Deletes all items contained in the scene as well.
|
||||||
@ -451,9 +482,26 @@ void PFDGadgetWidget::setDialFile(QString dfn)
|
|||||||
matrix.translate(startX,0);
|
matrix.translate(startX,0);
|
||||||
m_altitudetext->setTransform(matrix,false);
|
m_altitudetext->setTransform(matrix,false);
|
||||||
|
|
||||||
|
////////////////
|
||||||
|
// GCS Telemetry Indicator
|
||||||
|
////////////////
|
||||||
|
compassMatrix = m_renderer->matrixForElement("gcstelemetry-Disconnected");
|
||||||
|
startX = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).x();
|
||||||
|
startY = compassMatrix.mapRect(m_renderer->boundsOnElement("gcstelemetry-Disconnected")).y();
|
||||||
|
gcsTelemetryArrow = new QGraphicsSvgItem();
|
||||||
|
gcsTelemetryArrow->setSharedRenderer(m_renderer);
|
||||||
|
gcsTelemetryArrow->setElementId("gcstelemetry-Disconnected");
|
||||||
|
l_scene->addItem(gcsTelemetryArrow);
|
||||||
|
matrix.reset();
|
||||||
|
matrix.translate(startX,startY);
|
||||||
|
gcsTelemetryArrow->setTransform(matrix,false);
|
||||||
|
|
||||||
l_scene->setSceneRect(m_background->boundingRect());
|
l_scene->setSceneRect(m_background->boundingRect());
|
||||||
|
|
||||||
|
/////////////////
|
||||||
|
// Item placement
|
||||||
|
/////////////////
|
||||||
|
|
||||||
// Now Initialize the center for all transforms of the relevant elements to the
|
// Now Initialize the center for all transforms of the relevant elements to the
|
||||||
// center of the background:
|
// center of the background:
|
||||||
|
|
||||||
@ -578,10 +626,10 @@ void PFDGadgetWidget::moveNeedles()
|
|||||||
// Note: rendering can jump oh so very slightly when crossing the 180 degree
|
// Note: rendering can jump oh so very slightly when crossing the 180 degree
|
||||||
// boundary, should not impact actual useability of the display.
|
// boundary, should not impact actual useability of the display.
|
||||||
if ((headingValue < threshold) && ((headingValue+headingDiff)>=threshold)) {
|
if ((headingValue < threshold) && ((headingValue+headingDiff)>=threshold)) {
|
||||||
// We went over 180°: activate a -360 degree offset
|
// We went over 180<EFBFBD>: activate a -360 degree offset
|
||||||
headingOffset = 2*threshold;
|
headingOffset = 2*threshold;
|
||||||
} else if ((headingValue >= threshold) && ((headingValue+headingDiff)<threshold)) {
|
} else if ((headingValue >= threshold) && ((headingValue+headingDiff)<threshold)) {
|
||||||
// We went under 180°: remove the -360 degree offset
|
// We went under 180<EFBFBD>: remove the -360 degree offset
|
||||||
headingOffset = -2*threshold;
|
headingOffset = -2*threshold;
|
||||||
}
|
}
|
||||||
opd = QPointF(headingDiff+headingOffset,0);
|
opd = QPointF(headingDiff+headingOffset,0);
|
||||||
|
@ -63,6 +63,7 @@ public slots:
|
|||||||
void updateAirspeed(UAVObject *object1);
|
void updateAirspeed(UAVObject *object1);
|
||||||
void updateAltitude(UAVObject *object1);
|
void updateAltitude(UAVObject *object1);
|
||||||
void updateBattery(UAVObject *object1);
|
void updateBattery(UAVObject *object1);
|
||||||
|
void updateLinkStatus(UAVObject *object1);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
@ -102,6 +103,8 @@ private:
|
|||||||
QGraphicsItemGroup *m_altitudescale;
|
QGraphicsItemGroup *m_altitudescale;
|
||||||
// Altitude indicator text:
|
// Altitude indicator text:
|
||||||
QGraphicsTextItem *m_altitudetext;
|
QGraphicsTextItem *m_altitudetext;
|
||||||
|
// GCS link status Arrow
|
||||||
|
QGraphicsSvgItem *gcsTelemetryArrow;
|
||||||
|
|
||||||
double n1MinValue;
|
double n1MinValue;
|
||||||
double n1MaxValue;
|
double n1MaxValue;
|
||||||
@ -133,6 +136,7 @@ private:
|
|||||||
// Name of the fields to read when an update is received:
|
// Name of the fields to read when an update is received:
|
||||||
UAVDataObject* attitudeObj;
|
UAVDataObject* attitudeObj;
|
||||||
UAVDataObject* headingObj;
|
UAVDataObject* headingObj;
|
||||||
|
UAVDataObject* gcsTelemetryObj;
|
||||||
|
|
||||||
// Rotation timer
|
// Rotation timer
|
||||||
QTimer dialTimer;
|
QTimer dialTimer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user