From 9410aa80fa94c20a1e56c777530dea9b407d6c39 Mon Sep 17 00:00:00 2001 From: edouard Date: Tue, 20 Jul 2010 15:01:22 +0000 Subject: [PATCH] OP-102: of course I did not get it right the first time... Better now? git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1147 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/pfd/pfdgadgetwidget.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ground/src/plugins/pfd/pfdgadgetwidget.cpp b/ground/src/plugins/pfd/pfdgadgetwidget.cpp index 38dd026d8..053fd47c3 100644 --- a/ground/src/plugins/pfd/pfdgadgetwidget.cpp +++ b/ground/src/plugins/pfd/pfdgadgetwidget.cpp @@ -804,7 +804,6 @@ void PFDGadgetWidget::moveNeedles() // to it. That way you always get the "shorter difference" to turn in. ////// if (headingValue != headingTarget) { - double headingOffset = 0; double headingDiff; if ((abs((headingValue-headingTarget)*10) > 5)) { headingDiff = (headingTarget - headingValue)/5; @@ -812,17 +811,19 @@ void PFDGadgetWidget::moveNeedles() headingDiff = headingTarget-headingValue; dialCount--; } - double threshold = -180*compassBandWidth/540; + double threshold = 180*compassBandWidth/540; // Note: rendering can jump oh so very slightly when crossing the 180 degree // boundary, should not impact actual useability of the display. - if ((headingValue < threshold) && ((headingValue+headingDiff)>=threshold)) { - // We went over 180°: activate a -360 degree offset - headingOffset = 2*threshold; - } else if ((headingValue >= threshold) && ((headingValue+headingDiff)=threshold) { + // We went over 180°: activate a -360 degree offset + headingDiff -= 2*threshold; + headingTarget -= 2*threshold; + } else if ((headingValue+headingDiff)<-threshold) { + // We went under -180°: remove the -360 degree offset + headingDiff += 2*threshold; + headingTarget += 2*threshold; } - QPointF opd = QPointF(headingDiff+headingOffset,0); + QPointF opd = QPointF(headingDiff,0); m_compassband->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), true); headingValue += headingDiff; } else {