From 4b2dfde7bf8b7df4374104a04336f9e903da5141 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 12 Feb 1999 23:22:35 +0000 Subject: [PATCH] Allow auto-throttle adjustment while active. --- Autopilot/autopilot.cxx | 42 +++++++++++++++++++++++++++++++---------- Autopilot/autopilot.hxx | 5 +++++ Main/GLUTkey.cxx | 27 ++++++++++++++++++++++---- 3 files changed, 60 insertions(+), 14 deletions(-) diff --git a/Autopilot/autopilot.cxx b/Autopilot/autopilot.cxx index d556aa7cb..76c8d3737 100644 --- a/Autopilot/autopilot.cxx +++ b/Autopilot/autopilot.cxx @@ -116,21 +116,31 @@ bool fgAPHeadingEnabled( void ) fgAPDataPtr APData; APData = APDataGlobal; - // end section // heading hold enabled? - return( APData->heading_hold ); + return APData->heading_hold; } + bool fgAPAltitudeEnabled( void ) { fgAPDataPtr APData; APData = APDataGlobal; - // end section // altitude hold or terrain follow enabled? - return( APData->altitude_hold || APData->terrain_follow ); + return APData->altitude_hold || APData->terrain_follow ; +} + +bool fgAPAutoThrottleEnabled( void ) +{ + fgAPDataPtr APData; + + APData = APDataGlobal; + + // autothrottle enabled? + return APData->auto_throttle; } + void fgAPAltitudeAdjust( double inc ) { // Remove at a later date @@ -156,19 +166,28 @@ void fgAPAltitudeAdjust( double inc ) target_agl *= FEET_TO_METER; } - // heading hold enabled? APData->TargetAltitude = target_alt; APData->TargetAGL = target_agl; } + void fgAPHeadingAdjust( double inc ) { fgAPDataPtr APData; - APData = APDataGlobal; - // end section - - // heading hold enabled? - APData->TargetHeading = NormalizeDegrees(APData->TargetHeading + inc); + + double target = (int)(APData->TargetHeading / inc) * inc + inc; + + APData->TargetHeading = NormalizeDegrees(target); +} + +void fgAPAutoThrottleAdjust( double inc ) +{ + fgAPDataPtr APData; + APData = APDataGlobal; + + double target = (int)(APData->TargetSpeed / inc) * inc + inc; + + APData->TargetSpeed = target; } void fgAPInit( fgAIRCRAFT *current_aircraft ) @@ -562,6 +581,9 @@ double NormalizeDegrees(double Input) // $Log$ +// Revision 1.15 1999/02/12 23:22:35 curt +// Allow auto-throttle adjustment while active. +// // Revision 1.14 1999/02/12 22:17:14 curt // Changes contributed by Norman Vine to allow adjustment of the autopilot // while it is activated. diff --git a/Autopilot/autopilot.hxx b/Autopilot/autopilot.hxx index 45e11757c..18235c735 100644 --- a/Autopilot/autopilot.hxx +++ b/Autopilot/autopilot.hxx @@ -73,14 +73,19 @@ void fgAPToggleAutoThrottle( void ); bool fgAPAltitudeEnabled( void ); bool fgAPHeadingEnabled( void ); +bool fgAPAutoThrottleEnabled( void ); void fgAPAltitudeAdjust( double inc ); void fgAPHeadingAdjust( double inc ); +void fgAPAutoThrottleAdjust( double inc ); #endif // _AUTOPILOT_HXX // $Log$ +// Revision 1.9 1999/02/12 23:22:36 curt +// Allow auto-throttle adjustment while active. +// // Revision 1.8 1999/02/12 22:17:15 curt // Changes contributed by Norman Vine to allow adjustment of the autopilot // while it is activated. diff --git a/Main/GLUTkey.cxx b/Main/GLUTkey.cxx index 3799d9e25..e04a1db54 100644 --- a/Main/GLUTkey.cxx +++ b/Main/GLUTkey.cxx @@ -221,10 +221,18 @@ void GLUTkey(unsigned char k, int x, int y) { controls.set_rudder(0.0); return; case 57: // numeric keypad 9 (Pg Up) - controls.move_throttle( FGControls::ALL_ENGINES, 0.01 ); + if( fgAPAutoThrottleEnabled() ) { + fgAPAutoThrottleAdjust( 5 ); + } else { + controls.move_throttle( FGControls::ALL_ENGINES, 0.01 ); + } return; case 51: // numeric keypad 3 (Pg Dn) - controls.move_throttle( FGControls::ALL_ENGINES, -0.01 ); + if( fgAPAutoThrottleEnabled() ) { + fgAPAutoThrottleAdjust( -5 ); + } else { + controls.move_throttle( FGControls::ALL_ENGINES, -0.01 ); + } return; case 98: // b key int b_ret; @@ -407,10 +415,18 @@ void GLUTspecialkey(int k, int x, int y) { controls.set_rudder(0.0); return; case GLUT_KEY_PAGE_UP: // numeric keypad 9 (Pg Up) - controls.move_throttle( FGControls::ALL_ENGINES, 0.01 ); + if( fgAPAutoThrottleEnabled() ) { + fgAPAutoThrottleAdjust( 5 ); + } else { + controls.move_throttle( FGControls::ALL_ENGINES, 0.01 ); + } return; case GLUT_KEY_PAGE_DOWN: // numeric keypad 3 (Pg Dn) - controls.move_throttle( FGControls::ALL_ENGINES, -0.01 ); + if( fgAPAutoThrottleEnabled() ) { + fgAPAutoThrottleAdjust( -5 ); + } else { + controls.move_throttle( FGControls::ALL_ENGINES, -0.01 ); + } return; } } @@ -418,6 +434,9 @@ void GLUTspecialkey(int k, int x, int y) { // $Log$ +// Revision 1.41 1999/02/12 23:22:43 curt +// Allow auto-throttle adjustment while active. +// // Revision 1.40 1999/02/12 22:17:59 curt // Changes to allow adjustment of the autopilot settings while it is activated. // -- 2.39.5