Added "ETA" to display.
This commit is contained in:
parent
5f5905f6e8
commit
4e043de1f1
2 changed files with 40 additions and 16 deletions
|
@ -140,6 +140,14 @@ extern char *coord_format_lat(float);
|
||||||
extern char *coord_format_lon(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 below routines were copied right from hud.c ( I hate reinventing
|
||||||
// the wheel more than necessary)
|
// the wheel more than necessary)
|
||||||
|
|
||||||
|
@ -165,7 +173,23 @@ static void MakeTargetHeadingStr( fgAPDataPtr APData, double bearing ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void MakeTargetDistanceStr( fgAPDataPtr APData, double distance ) {
|
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 ) {
|
static inline void MakeTargetAltitudeStr( fgAPDataPtr APData, double altitude ) {
|
||||||
|
|
|
@ -73,23 +73,23 @@ typedef struct {
|
||||||
double old_elevator_trim;
|
double old_elevator_trim;
|
||||||
double old_rudder;
|
double old_rudder;
|
||||||
|
|
||||||
// manual controls override beyond this value
|
// manual controls override beyond this value
|
||||||
double disengage_threshold;
|
double disengage_threshold;
|
||||||
|
|
||||||
// For future cross track error adjust
|
// For future cross track error adjust
|
||||||
double old_lat;
|
double old_lat;
|
||||||
double old_lon;
|
double old_lon;
|
||||||
|
|
||||||
// keeping these locally to save work inside main loop
|
// keeping these locally to save work inside main loop
|
||||||
char TargetLatitudeStr[32];
|
char TargetLatitudeStr[64];
|
||||||
char TargetLongitudeStr[32];
|
char TargetLongitudeStr[64];
|
||||||
char TargetLatLonStr[32];
|
char TargetLatLonStr[64];
|
||||||
char TargetDistanceStr[32];
|
char TargetDistanceStr[64];
|
||||||
char TargetHeadingStr[32];
|
char TargetHeadingStr[64];
|
||||||
char TargetAltitudeStr[32];
|
char TargetAltitudeStr[64];
|
||||||
// char jnk[32];
|
// char jnk[32];
|
||||||
// using current_options.airport_id for now
|
// using current_options.airport_id for now
|
||||||
// string tgt_airport_id; // ID of initial starting airport
|
// string tgt_airport_id; // ID of initial starting airport
|
||||||
} fgAPData, *fgAPDataPtr ;
|
} fgAPData, *fgAPDataPtr ;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue