From: curt Date: Sun, 14 May 2000 04:18:12 +0000 (+0000) Subject: Heading bug (and bfi) now deals with magnetic compass heading rather than X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7863c607bff9d12d38a839847fcb6e5765bece79;p=flightgear.git Heading bug (and bfi) now deals with magnetic compass heading rather than true heading. Internally, the sim (and the autopilot) still runs off of true heading. --- diff --git a/src/Cockpit/sp_panel.cxx b/src/Cockpit/sp_panel.cxx index 5c41d59b2..38de4e5b5 100644 --- a/src/Cockpit/sp_panel.cxx +++ b/src/Cockpit/sp_panel.cxx @@ -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; diff --git a/src/Main/bfi.cxx b/src/Main/bfi.cxx index 2a6314748..229676e77 100644 --- a/src/Main/bfi.cxx +++ b/src/Main/bfi.cxx @@ -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() ); } diff --git a/src/Main/bfi.hxx b/src/Main/bfi.hxx index 1ca3aefb8..759f6d524 100644 --- a/src/Main/bfi.hxx +++ b/src/Main/bfi.hxx @@ -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); diff --git a/src/Main/save.cxx b/src/Main/save.cxx index 464c0de54..9c17714bb 100644 --- a/src/Main/save.cxx +++ b/src/Main/save.cxx @@ -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:") {