]> git.mxchange.org Git - flightgear.git/commitdiff
Added "ETA" to display.
authorcurt <curt>
Sun, 10 Oct 1999 16:47:21 +0000 (16:47 +0000)
committercurt <curt>
Sun, 10 Oct 1999 16:47:21 +0000 (16:47 +0000)
src/Autopilot/autopilot.cxx
src/Autopilot/autopilot.hxx

index 90d7397e1cb7493300014f564820de114de58170..2226f5e1996a69ef92799ba87e6ace3d5b84b771 100644 (file)
@@ -140,6 +140,14 @@ extern char *coord_format_lat(float);
 extern char *coord_format_lon(float);
                        
 
+static inline double get_ground_speed( void ) {
+    // starts in ft/s so we convert to kts
+    double ft_s = current_aircraft.fdm_state->get_V_ground_speed() 
+       * current_options.get_speed_up();;
+    double kts = ft_s * FEET_TO_METER * 3600 * METER_TO_NM;
+    return kts;
+}
+
 // The below routines were copied right from hud.c ( I hate reinventing
 // the wheel more than necessary)
 
@@ -165,7 +173,23 @@ static void MakeTargetHeadingStr( fgAPDataPtr APData, double bearing ) {
 }
 
 static inline void MakeTargetDistanceStr( fgAPDataPtr APData, double distance ) {
-    sprintf(APData->TargetDistanceStr, "APDistance %.2f NM", distance*METER_TO_NM);
+    double eta = distance*METER_TO_NM / get_ground_speed();
+    if ( eta >= 100.0 ) { eta = 99.999; }
+    int major, minor;
+    if ( eta < (1.0/6.0) ) {
+       // within 10 minutes, bump up to min/secs
+       eta *= 60.0;
+    }
+    major = (int)eta;
+    minor = (int)((eta - (int)eta) * 60.0);
+    sprintf(APData->TargetDistanceStr, "APDistance %.2f NM  ETA %d:%02d",
+           distance*METER_TO_NM, major, minor);
+    // cout << "distance = " << distance*METER_TO_NM
+    //      << "  gndsp = " << get_ground_speed() 
+    //      << "  time = " << eta
+    //      << "  major = " << major
+    //      << "  minor = " << minor
+    //      << endl;
 }
 
 static inline void MakeTargetAltitudeStr( fgAPDataPtr APData, double altitude ) {
index 0dd777c8bb26493825c4b903ffdc2e83adf0acea..bae1b9c1c1ccc8c6991ec5dffbc5d7d7b4fd2b2c 100644 (file)
@@ -73,23 +73,23 @@ typedef struct {
     double old_elevator_trim;
     double old_rudder;
        
-       // manual controls override beyond this value
-       double disengage_threshold; 
-
-       // For future cross track error adjust
-       double old_lat;
-       double old_lon;
-
-       // keeping these locally to save work inside main loop
-       char TargetLatitudeStr[32];
-       char TargetLongitudeStr[32];
-    char TargetLatLonStr[32];
-       char TargetDistanceStr[32];
-    char TargetHeadingStr[32];
-    char TargetAltitudeStr[32];
-//     char jnk[32];
-       // using current_options.airport_id for now
-//     string tgt_airport_id;  // ID of initial starting airport    
+    // manual controls override beyond this value
+    double disengage_threshold; 
+
+    // For future cross track error adjust
+    double old_lat;
+    double old_lon;
+
+    // keeping these locally to save work inside main loop
+    char TargetLatitudeStr[64];
+    char TargetLongitudeStr[64];
+    char TargetLatLonStr[64];
+    char TargetDistanceStr[64];
+    char TargetHeadingStr[64];
+    char TargetAltitudeStr[64];
+    // char jnk[32];
+    // using current_options.airport_id for now
+    // string tgt_airport_id;  // ID of initial starting airport    
 } fgAPData, *fgAPDataPtr ;