From 71a9e3d4198e8d0d091b7698a3fb641ac3edeec7 Mon Sep 17 00:00:00 2001
From: jmt <jmt>
Date: Sun, 18 Oct 2009 21:08:22 +0000
Subject: [PATCH] HUD tweak - don't show cross-track error if it's
 (effectively) zero.

---
 src/Cockpit/hud.cxx | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/Cockpit/hud.cxx b/src/Cockpit/hud.cxx
index 27208d540..6b126a702 100644
--- a/src/Cockpit/hud.cxx
+++ b/src/Cockpit/hud.cxx
@@ -488,10 +488,16 @@ void drawHUD(osg::State* state)
       apY -= 15;
       
       double courseError = curWp->getDoubleValue("course-error-nm");
-      // generate an arrow indicatinng if the pilot should turn left or right
-      char dir = (courseError < 0.0) ? '<' : '>';
-      snprintf(hud_gps_text1, 256, "GPS TRK:%03.0f XTRK:%c%4.2fnm",
-        gps->getDoubleValue("indicated-track-magnetic-deg"), dir, fabs(courseError));
+      if (fabs(courseError) >= 0.01) {
+        // generate an arrow indicatinng if the pilot should turn left or right
+        char dir = (courseError < 0.0) ? '<' : '>';
+        snprintf(hud_gps_text1, 256, "GPS TRK:%03.0f XTRK:%c%4.2fnm",
+          gps->getDoubleValue("indicated-track-magnetic-deg"), dir, fabs(courseError));
+      } else { // on course, don't bother showing the XTRK error
+        snprintf(hud_gps_text1, 256, "GPS TRK:%03.0f",
+          gps->getDoubleValue("indicated-track-magnetic-deg"));
+      }
+      
       HUD_TextList.add( fgText( 40, apY, hud_gps_text1) );
       apY -= 15;
     } // of valid GPS output