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)
}
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 ) {
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 ;