]> git.mxchange.org Git - flightgear.git/commitdiff
Heading bug (and bfi) now deals with magnetic compass heading rather than
authorcurt <curt>
Sun, 14 May 2000 04:18:12 +0000 (04:18 +0000)
committercurt <curt>
Sun, 14 May 2000 04:18:12 +0000 (04:18 +0000)
true heading.  Internally, the sim (and the autopilot) still runs off of
true heading.

src/Cockpit/sp_panel.cxx
src/Main/bfi.cxx
src/Main/bfi.hxx
src/Main/save.cxx

index 5c41d59b209fb22fca8d9eec395b3b58a3d79edb..38de4e5b5c3580c4043d8bfc92802197fd255903 100644 (file)
@@ -207,20 +207,20 @@ createGyroCompass (int x, int y)
 
                                // Action: move heading bug
   inst->addAction(0, SIX_W/2 - SIX_W/5, -SIX_W/2, SIX_W/10, SIX_W/5,
-                 new FGAdjustAction(FGBFI::getAPHeading,
-                                    FGBFI::setAPHeading,
+                 new FGAdjustAction(FGBFI::getAPHeadingMag,
+                                    FGBFI::setAPHeadingMag,
                                     -1.0, -360.0, 360.0, true));
   inst->addAction(0, SIX_W/2 - SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
-                 new FGAdjustAction(FGBFI::getAPHeading,
-                                    FGBFI::setAPHeading,
+                 new FGAdjustAction(FGBFI::getAPHeadingMag,
+                                    FGBFI::setAPHeadingMag,
                                     1.0, -360.0, 360.0, true));
   inst->addAction(1, SIX_W/2 - SIX_W/5, -SIX_W/2, SIX_W/10, SIX_W/5,
-                 new FGAdjustAction(FGBFI::getAPHeading,
-                                    FGBFI::setAPHeading,
+                 new FGAdjustAction(FGBFI::getAPHeadingMag,
+                                    FGBFI::setAPHeadingMag,
                                     -5.0, -360.0, 360.0, true));
   inst->addAction(1, SIX_W/2 - SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
-                 new FGAdjustAction(FGBFI::getAPHeading,
-                                    FGBFI::setAPHeading,
+                 new FGAdjustAction(FGBFI::getAPHeadingMag,
+                                    FGBFI::setAPHeadingMag,
                                     5.0, -360.0, 360.0, true));
 
                                // Layer 0: compass background
@@ -237,7 +237,7 @@ createGyroCompass (int x, int y)
                          FGSteam::get_MH_deg,
                          -720.0, 720.0, -1.0, 0.0);
   inst->addTransformation(FGInstrumentLayer::ROTATION,
-                         FGBFI::getAPHeading,
+                         FGBFI::getAPHeadingMag,
                          -720.0, 720.0, 1.0, 0.0);
 
                                // Layer 2: fixed center
@@ -250,7 +250,7 @@ createGyroCompass (int x, int y)
   inst->addTransformation(FGInstrumentLayer::XSHIFT, SIX_W/2 - 10); 
   inst->addTransformation(FGInstrumentLayer::YSHIFT, -SIX_W/2 + 10); 
   inst->addTransformation(FGInstrumentLayer::ROTATION,
-                         FGBFI::getAPHeading,
+                         FGBFI::getAPHeadingMag,
                          -360.0, 360.0, 1.0, 0.0);
 
   return inst;
index 2a631474826c72cf7a69304b5516bb857995edd1..229676e772f873fb5019b8644f3406c2fce13215 100644 (file)
@@ -117,7 +117,7 @@ FGBFI::reinit ()
   double flaps = getFlaps();
   double brake = getBrake();
   bool apHeadingLock = getAPHeadingLock();
-  double apHeading = getAPHeading();
+  double apHeadingMag = getAPHeadingMag();
   bool apAltitudeLock = getAPAltitudeLock();
   double apAltitude = getAPAltitude();
   const string &targetAirport = getTargetAirport();
@@ -138,7 +138,7 @@ FGBFI::reinit ()
   setFlaps(flaps);
   setBrake(brake);
   setAPHeadingLock(apHeadingLock);
-  setAPHeading(apHeading);
+  setAPHeadingMag(apHeadingMag);
   setAPAltitudeLock(apAltitudeLock);
   setAPAltitude(apAltitude);
   setTargetAirport(targetAirport);
@@ -786,9 +786,9 @@ FGBFI::setAPHeadingLock (bool lock)
  * Get the autopilot target heading in degrees.
  */
 double
-FGBFI::getAPHeading ()
+FGBFI::getAPHeadingMag ()
 {
-  return current_autopilot->get_TargetHeading();
+  return current_autopilot->get_TargetHeading() - getMagVar();
 }
 
 
@@ -796,9 +796,9 @@ FGBFI::getAPHeading ()
  * Set the autopilot target heading in degrees.
  */
 void
-FGBFI::setAPHeading (double heading)
+FGBFI::setAPHeadingMag (double heading)
 {
-  current_autopilot->set_TargetHeading( heading );
+  current_autopilot->set_TargetHeading( heading + getMagVar() );
 }
 
 
index 1ca3aefb83b53aa789bcd370f28451f16329e57b..759f6d5244a833cc518d79a933ec341fe28c875d 100644 (file)
@@ -121,12 +121,12 @@ public:
   static bool getAPAltitudeLock ();
   static double getAPAltitude ();
   static bool getAPHeadingLock ();
-  static double getAPHeading ();
+  static double getAPHeadingMag ();
 
   static void setAPAltitudeLock (bool lock);
   static void setAPAltitude (double altitude);
   static void setAPHeadingLock (bool lock);
-  static void setAPHeading (double heading);
+  static void setAPHeadingMag (double heading);
 
   static bool getAPNAV1Lock ();
   static void setAPNAV1Lock (bool lock);
index 464c0de54db2c6af15919680ec24b2d8f08512ee..9c17714bb84b6c75faa17b9af8b46f721a23c7ae 100644 (file)
@@ -128,7 +128,7 @@ fgSaveFlight (ostream &output)
   SAVE("autopilot-altitude-lock", FGBFI::getAPAltitudeLock());
   SAVE("autopilot-altitude", FGBFI::getAPAltitude());
   SAVE("autopilot-heading-lock", FGBFI::getAPHeadingLock());
-  SAVE("autopilot-heading", FGBFI::getAPHeading());
+  SAVE("autopilot-heading", FGBFI::getAPHeadingMag());
   SAVE("autopilot-gps-lock", FGBFI::getGPSLock());
   SAVE("autopilot-gps-lat", FGBFI::getGPSTargetLatitude());
   SAVE("autopilot-gps-lon", FGBFI::getGPSTargetLongitude());
@@ -408,7 +408,7 @@ fgLoadFlight (istream &input)
     else if (text == "autopilot-heading:") {
       input >> n;
       cout << "autopilot heading is " << n << endl;
-      FGBFI::setAPHeading(n);
+      FGBFI::setAPHeadingMag(n);
     }
 
     else if (text == "autopilot-gps-lock:") {