Various tweaks and fixes to navcom radios.
Oops, taking the address of a temporary in main.cxx: 3dcloud rendering.
This commit is contained in:
parent
5eef7d7ad1
commit
29e72b0b90
7 changed files with 507 additions and 508 deletions
|
@ -70,18 +70,20 @@ FGNavCom::FGNavCom() :
|
||||||
lon_node(fgGetNode("/position/longitude-deg", true)),
|
lon_node(fgGetNode("/position/longitude-deg", true)),
|
||||||
lat_node(fgGetNode("/position/latitude-deg", true)),
|
lat_node(fgGetNode("/position/latitude-deg", true)),
|
||||||
alt_node(fgGetNode("/position/altitude-ft", true)),
|
alt_node(fgGetNode("/position/altitude-ft", true)),
|
||||||
last_nav_ident(""),
|
last_nav_id(""),
|
||||||
last_nav_vor(false),
|
last_nav_vor(false),
|
||||||
nav_play_count(0),
|
nav_play_count(0),
|
||||||
nav_last_time(0),
|
nav_last_time(0),
|
||||||
need_update(true),
|
need_update(true),
|
||||||
|
power_btn(true),
|
||||||
comm_freq(0.0),
|
comm_freq(0.0),
|
||||||
comm_alt_freq(0.0),
|
comm_alt_freq(0.0),
|
||||||
comm_vol_btn(0.0),
|
comm_vol_btn(0.0),
|
||||||
nav_freq(0.0),
|
nav_freq(0.0),
|
||||||
nav_alt_freq(0.0),
|
nav_alt_freq(0.0),
|
||||||
nav_radial(0.0),
|
nav_radial(0.0),
|
||||||
nav_vol_btn(0.0)
|
nav_vol_btn(0.0),
|
||||||
|
nav_ident_btn(true)
|
||||||
{
|
{
|
||||||
SGPath path( globals->get_fg_root() );
|
SGPath path( globals->get_fg_root() );
|
||||||
SGPath term = path;
|
SGPath term = path;
|
||||||
|
@ -124,6 +126,11 @@ FGNavCom::bind ()
|
||||||
char propname[256];
|
char propname[256];
|
||||||
|
|
||||||
// User inputs
|
// User inputs
|
||||||
|
sprintf( propname, "/radios/comm[%d]/inputs/power-btn", index );
|
||||||
|
fgTie( propname, this,
|
||||||
|
&FGNavCom::get_power_btn, &FGNavCom::set_power_btn );
|
||||||
|
fgSetArchivable( propname );
|
||||||
|
|
||||||
sprintf( propname, "/radios/comm[%d]/frequencies/selected-mhz", index );
|
sprintf( propname, "/radios/comm[%d]/frequencies/selected-mhz", index );
|
||||||
fgTie( propname, this, &FGNavCom::get_comm_freq, &FGNavCom::set_comm_freq );
|
fgTie( propname, this, &FGNavCom::get_comm_freq, &FGNavCom::set_comm_freq );
|
||||||
fgSetArchivable( propname );
|
fgSetArchivable( propname );
|
||||||
|
@ -138,11 +145,6 @@ FGNavCom::bind ()
|
||||||
&FGNavCom::get_comm_vol_btn, &FGNavCom::set_comm_vol_btn );
|
&FGNavCom::get_comm_vol_btn, &FGNavCom::set_comm_vol_btn );
|
||||||
fgSetArchivable( propname );
|
fgSetArchivable( propname );
|
||||||
|
|
||||||
sprintf( propname, "/radios/comm[%d]/ident", index );
|
|
||||||
fgTie( propname, this,
|
|
||||||
&FGNavCom::get_comm_ident_btn, &FGNavCom::set_comm_ident_btn );
|
|
||||||
fgSetArchivable( propname );
|
|
||||||
|
|
||||||
sprintf( propname, "/radios/nav[%d]/frequencies/selected-mhz", index );
|
sprintf( propname, "/radios/nav[%d]/frequencies/selected-mhz", index );
|
||||||
fgTie( propname, this,
|
fgTie( propname, this,
|
||||||
&FGNavCom::get_nav_freq, &FGNavCom::set_nav_freq );
|
&FGNavCom::get_nav_freq, &FGNavCom::set_nav_freq );
|
||||||
|
@ -194,14 +196,12 @@ FGNavCom::unbind ()
|
||||||
{
|
{
|
||||||
char propname[256];
|
char propname[256];
|
||||||
|
|
||||||
|
sprintf( propname, "/radios/comm[%d]/inputs/power-btn", index );
|
||||||
|
fgUntie( propname );
|
||||||
sprintf( propname, "/radios/comm[%d]/frequencies/selected-mhz", index );
|
sprintf( propname, "/radios/comm[%d]/frequencies/selected-mhz", index );
|
||||||
fgUntie( propname );
|
fgUntie( propname );
|
||||||
sprintf( propname, "/radios/comm[%d]/frequencies/standby-mhz", index );
|
sprintf( propname, "/radios/comm[%d]/frequencies/standby-mhz", index );
|
||||||
fgUntie( propname );
|
fgUntie( propname );
|
||||||
sprintf( propname, "/radios/comm[%d]/on", index );
|
|
||||||
fgUntie( propname );
|
|
||||||
sprintf( propname, "/radios/comm[%d]/ident", index );
|
|
||||||
fgUntie( propname );
|
|
||||||
|
|
||||||
sprintf( propname, "/radios/nav[%d]/frequencies/selected-mhz", index );
|
sprintf( propname, "/radios/nav[%d]/frequencies/selected-mhz", index );
|
||||||
fgUntie( propname );
|
fgUntie( propname );
|
||||||
|
@ -211,8 +211,6 @@ FGNavCom::unbind ()
|
||||||
fgUntie( propname );
|
fgUntie( propname );
|
||||||
sprintf( propname, "/radios/nav[%d]/radials/selected-deg", index );
|
sprintf( propname, "/radios/nav[%d]/radials/selected-deg", index );
|
||||||
fgUntie( propname );
|
fgUntie( propname );
|
||||||
sprintf( propname, "/radios/nav[%d]/on", index );
|
|
||||||
fgUntie( propname );
|
|
||||||
sprintf( propname, "/radios/nav[%d]/ident", index );
|
sprintf( propname, "/radios/nav[%d]/ident", index );
|
||||||
fgUntie( propname );
|
fgUntie( propname );
|
||||||
sprintf( propname, "/radios/nav[%d]/to-flag", index );
|
sprintf( propname, "/radios/nav[%d]/to-flag", index );
|
||||||
|
@ -308,7 +306,7 @@ FGNavCom::update(double dt)
|
||||||
// Nav.
|
// Nav.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if ( nav_valid ) {
|
if ( nav_valid && power_btn ) {
|
||||||
station = Point3D( nav_x, nav_y, nav_z );
|
station = Point3D( nav_x, nav_y, nav_z );
|
||||||
nav_loc_dist = aircraft.distance3D( station );
|
nav_loc_dist = aircraft.distance3D( station );
|
||||||
|
|
||||||
|
@ -363,7 +361,7 @@ FGNavCom::update(double dt)
|
||||||
if ( nav_valid && nav_inrange ) {
|
if ( nav_valid && nav_inrange ) {
|
||||||
// play station ident via audio system if on + ident,
|
// play station ident via audio system if on + ident,
|
||||||
// otherwise turn it off
|
// otherwise turn it off
|
||||||
if ( nav_vol_btn > 0.1 && nav_ident_btn ) {
|
if ( power_btn && nav_ident_btn ) {
|
||||||
FGSimpleSound *sound;
|
FGSimpleSound *sound;
|
||||||
sound = globals->get_soundmgr()->find( nav_fx_name );
|
sound = globals->get_soundmgr()->find( nav_fx_name );
|
||||||
if ( sound != NULL ) {
|
if ( sound != NULL ) {
|
||||||
|
@ -429,11 +427,11 @@ void FGNavCom::search()
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if ( current_ilslist->query( lon, lat, elev, nav_freq, &ils ) ) {
|
if ( current_ilslist->query( lon, lat, elev, nav_freq, &ils ) ) {
|
||||||
nav_ident = ils.get_locident();
|
nav_id = ils.get_locident();
|
||||||
nav_valid = true;
|
nav_valid = true;
|
||||||
if ( last_nav_ident != nav_ident || last_nav_vor ) {
|
if ( last_nav_id != nav_id || last_nav_vor ) {
|
||||||
nav_trans_ident = ils.get_trans_ident();
|
nav_trans_ident = ils.get_trans_ident();
|
||||||
last_nav_ident = nav_ident;
|
last_nav_id = nav_id;
|
||||||
last_nav_vor = false;
|
last_nav_vor = false;
|
||||||
nav_loc = true;
|
nav_loc = true;
|
||||||
nav_has_dme = ils.get_has_dme();
|
nav_has_dme = ils.get_has_dme();
|
||||||
|
@ -489,10 +487,10 @@ void FGNavCom::search()
|
||||||
// cout << " id = " << ils.get_locident() << endl;
|
// cout << " id = " << ils.get_locident() << endl;
|
||||||
}
|
}
|
||||||
} else if ( current_navlist->query( lon, lat, elev, nav_freq, &nav ) ) {
|
} else if ( current_navlist->query( lon, lat, elev, nav_freq, &nav ) ) {
|
||||||
nav_ident = nav.get_ident();
|
nav_id = nav.get_ident();
|
||||||
nav_valid = true;
|
nav_valid = true;
|
||||||
if ( last_nav_ident != nav_ident || !last_nav_vor ) {
|
if ( last_nav_id != nav_id || !last_nav_vor ) {
|
||||||
last_nav_ident = nav_ident;
|
last_nav_id = nav_id;
|
||||||
last_nav_vor = true;
|
last_nav_vor = true;
|
||||||
nav_trans_ident = nav.get_trans_ident();
|
nav_trans_ident = nav.get_trans_ident();
|
||||||
nav_loc = false;
|
nav_loc = false;
|
||||||
|
@ -545,10 +543,10 @@ void FGNavCom::search()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nav_valid = false;
|
nav_valid = false;
|
||||||
nav_ident = "";
|
nav_id = "";
|
||||||
nav_radial = 0;
|
nav_radial = 0;
|
||||||
nav_trans_ident = "";
|
nav_trans_ident = "";
|
||||||
last_nav_ident = "";
|
last_nav_id = "";
|
||||||
#ifdef ENABLE_AUDIO_SUPPORT
|
#ifdef ENABLE_AUDIO_SUPPORT
|
||||||
if ( ! globals->get_soundmgr()->remove( nav_fx_name ) ) {
|
if ( ! globals->get_soundmgr()->remove( nav_fx_name ) ) {
|
||||||
cout << "Failed to remove nav-vor-ident sound" << endl;
|
cout << "Failed to remove nav-vor-ident sound" << endl;
|
||||||
|
|
|
@ -51,7 +51,7 @@ class FGNavCom : public FGSubsystem
|
||||||
SGPropertyNode *lat_node;
|
SGPropertyNode *lat_node;
|
||||||
SGPropertyNode *alt_node;
|
SGPropertyNode *alt_node;
|
||||||
|
|
||||||
string last_nav_ident;
|
string last_nav_id;
|
||||||
bool last_nav_vor;
|
bool last_nav_vor;
|
||||||
int nav_play_count;
|
int nav_play_count;
|
||||||
time_t nav_last_time;
|
time_t nav_last_time;
|
||||||
|
@ -62,7 +62,8 @@ class FGNavCom : public FGSubsystem
|
||||||
|
|
||||||
bool need_update;
|
bool need_update;
|
||||||
|
|
||||||
string comm_ident;
|
bool power_btn;
|
||||||
|
|
||||||
bool comm_valid;
|
bool comm_valid;
|
||||||
bool comm_inrange;
|
bool comm_inrange;
|
||||||
double comm_freq;
|
double comm_freq;
|
||||||
|
@ -77,7 +78,7 @@ class FGNavCom : public FGSubsystem
|
||||||
double comm_range;
|
double comm_range;
|
||||||
double comm_effective_range;
|
double comm_effective_range;
|
||||||
|
|
||||||
string nav_ident;
|
string nav_id;
|
||||||
string nav_trans_ident;
|
string nav_trans_ident;
|
||||||
bool nav_valid;
|
bool nav_valid;
|
||||||
bool nav_inrange;
|
bool nav_inrange;
|
||||||
|
@ -138,6 +139,12 @@ public:
|
||||||
sprintf( dme_fx_name, "dme%d-vor-ident", index );
|
sprintf( dme_fx_name, "dme%d-vor-ident", index );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NavCom Setters
|
||||||
|
inline void set_power_btn( bool val ) {
|
||||||
|
power_btn = val;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// COMM Setters
|
// COMM Setters
|
||||||
inline void set_comm_freq( double freq ) {
|
inline void set_comm_freq( double freq ) {
|
||||||
comm_freq = freq; need_update = true;
|
comm_freq = freq; need_update = true;
|
||||||
|
@ -165,6 +172,9 @@ public:
|
||||||
}
|
}
|
||||||
inline void set_nav_ident_btn( bool val ) { nav_ident_btn = val; }
|
inline void set_nav_ident_btn( bool val ) { nav_ident_btn = val; }
|
||||||
|
|
||||||
|
// NavCom Accessors
|
||||||
|
inline bool get_power_btn() const { return power_btn; }
|
||||||
|
|
||||||
// COMM Accessors
|
// COMM Accessors
|
||||||
inline double get_comm_freq () const { return comm_freq; }
|
inline double get_comm_freq () const { return comm_freq; }
|
||||||
inline double get_comm_alt_freq () const { return comm_alt_freq; }
|
inline double get_comm_alt_freq () const { return comm_alt_freq; }
|
||||||
|
|
|
@ -205,68 +205,6 @@ FGRadioStack::unbind ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
|
|
||||||
double FGRadioStack::adjustNavRange( double stationElev, double aircraftElev,
|
|
||||||
double nominalRange )
|
|
||||||
{
|
|
||||||
// extend out actual usable range to be 1.3x the published safe range
|
|
||||||
const double usability_factor = 1.3;
|
|
||||||
|
|
||||||
// assumptions we model the standard service volume, plus
|
|
||||||
// ... rather than specifying a cylinder, we model a cone that
|
|
||||||
// contains the cylinder. Then we put an upside down cone on top
|
|
||||||
// to model diminishing returns at too-high altitudes.
|
|
||||||
|
|
||||||
// altitude difference
|
|
||||||
double alt = ( aircraftElev * SG_METER_TO_FEET - stationElev );
|
|
||||||
// cout << "aircraft elev = " << aircraftElev * SG_METER_TO_FEET
|
|
||||||
// << " station elev = " << stationElev << endl;
|
|
||||||
|
|
||||||
if ( nominalRange < 25.0 + SG_EPSILON ) {
|
|
||||||
// Standard Terminal Service Volume
|
|
||||||
return term_tbl->interpolate( alt ) * usability_factor;
|
|
||||||
} else if ( nominalRange < 50.0 + SG_EPSILON ) {
|
|
||||||
// Standard Low Altitude Service Volume
|
|
||||||
// table is based on range of 40, scale to actual range
|
|
||||||
return low_tbl->interpolate( alt ) * nominalRange / 40.0
|
|
||||||
* usability_factor;
|
|
||||||
} else {
|
|
||||||
// Standard High Altitude Service Volume
|
|
||||||
// table is based on range of 130, scale to actual range
|
|
||||||
return high_tbl->interpolate( alt ) * nominalRange / 130.0
|
|
||||||
* usability_factor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// model standard ILS service volumes as per AIM 1-1-9
|
|
||||||
double FGRadioStack::adjustILSRange( double stationElev, double aircraftElev,
|
|
||||||
double offsetDegrees, double distance )
|
|
||||||
{
|
|
||||||
// assumptions we model the standard service volume, plus
|
|
||||||
|
|
||||||
// altitude difference
|
|
||||||
// double alt = ( aircraftElev * SG_METER_TO_FEET - stationElev );
|
|
||||||
double offset = fabs( offsetDegrees );
|
|
||||||
|
|
||||||
if ( offset < 10 ) {
|
|
||||||
return FG_ILS_DEFAULT_RANGE;
|
|
||||||
} else if ( offset < 35 ) {
|
|
||||||
return 10 + (35 - offset) * (FG_ILS_DEFAULT_RANGE - 10) / 25;
|
|
||||||
} else if ( offset < 45 ) {
|
|
||||||
return (45 - offset);
|
|
||||||
} else if ( offset > 170 ) {
|
|
||||||
return FG_ILS_DEFAULT_RANGE;
|
|
||||||
} else if ( offset > 145 ) {
|
|
||||||
return 10 + (offset - 145) * (FG_ILS_DEFAULT_RANGE - 10) / 25;
|
|
||||||
} else if ( offset > 135 ) {
|
|
||||||
return (offset - 135);
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Update the various nav values based on position and valid tuned in navs
|
// Update the various nav values based on position and valid tuned in navs
|
||||||
void
|
void
|
||||||
FGRadioStack::update(double dt)
|
FGRadioStack::update(double dt)
|
||||||
|
@ -287,46 +225,48 @@ FGRadioStack::update(double dt)
|
||||||
// DME.
|
// DME.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if (dme_valid) {
|
if ( dme_valid ) {
|
||||||
station = Point3D( dme_x, dme_y, dme_z );
|
station = Point3D( dme_x, dme_y, dme_z );
|
||||||
dme_dist = aircraft.distance3D( station ) * SG_METER_TO_NM;
|
dme_dist = aircraft.distance3D( station ) * SG_METER_TO_NM;
|
||||||
dme_effective_range = kludgeRange(dme_elev, elev, dme_range);
|
dme_effective_range = kludgeRange(dme_elev, elev, dme_range);
|
||||||
if (dme_dist < dme_effective_range * SG_NM_TO_METER) {
|
if (dme_dist < dme_effective_range * SG_NM_TO_METER) {
|
||||||
dme_inrange = true;
|
dme_inrange = true;
|
||||||
} else if (dme_dist < 2 * dme_effective_range * SG_NM_TO_METER) {
|
} else if (dme_dist < 2 * dme_effective_range * SG_NM_TO_METER) {
|
||||||
dme_inrange = sg_random() <
|
dme_inrange = sg_random() <
|
||||||
(2 * dme_effective_range * SG_NM_TO_METER - dme_dist) /
|
(2 * dme_effective_range * SG_NM_TO_METER - dme_dist) /
|
||||||
(dme_effective_range * SG_NM_TO_METER);
|
(dme_effective_range * SG_NM_TO_METER);
|
||||||
} else {
|
} else {
|
||||||
dme_inrange = false;
|
dme_inrange = false;
|
||||||
}
|
}
|
||||||
if (dme_inrange) {
|
if ( dme_inrange ) {
|
||||||
SGTimeStamp current_time;
|
SGTimeStamp current_time;
|
||||||
station = Point3D( dme_x, dme_y, dme_z );
|
station = Point3D( dme_x, dme_y, dme_z );
|
||||||
dme_dist = aircraft.distance3D( station ) * SG_METER_TO_NM;
|
dme_dist = aircraft.distance3D( station ) * SG_METER_TO_NM;
|
||||||
current_time.stamp();
|
current_time.stamp();
|
||||||
long dMs = (current_time - dme_last_time) / 1000;
|
long dMs = (current_time - dme_last_time) / 1000;
|
||||||
// Update every second
|
// Update every second
|
||||||
if (dMs >= 1000) {
|
if (dMs >= 1000) {
|
||||||
double dDist = dme_dist - dme_prev_dist;
|
double dDist = dme_dist - dme_prev_dist;
|
||||||
dme_spd = fabs((dDist/dMs) * 3600000);
|
dme_spd = fabs((dDist/dMs) * 3600000);
|
||||||
// FIXME: the panel should be able to
|
// FIXME: the panel should be able to
|
||||||
// handle this!!!
|
// handle this!!!
|
||||||
if (dme_spd > 999.0)
|
if (dme_spd > 999.0)
|
||||||
dme_spd = 999.0;
|
dme_spd = 999.0;
|
||||||
dme_ete = fabs((dme_dist/dme_spd) * 60.0);
|
dme_ete = fabs((dme_dist/dme_spd) * 60.0);
|
||||||
// FIXME: the panel should be able to
|
// FIXME: the panel should be able to
|
||||||
// handle this!!!
|
// handle this!!!
|
||||||
if (dme_ete > 99.0)
|
if (dme_ete > 99.0)
|
||||||
dme_ete = 99.0;
|
dme_ete = 99.0;
|
||||||
dme_prev_dist = dme_dist;
|
dme_prev_dist = dme_dist;
|
||||||
dme_last_time.stamp();
|
dme_last_time.stamp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dme_inrange = false;
|
dme_inrange = false;
|
||||||
dme_dist = 0.0;
|
dme_dist = 0.0;
|
||||||
dme_prev_dist = 0.0;
|
dme_prev_dist = 0.0;
|
||||||
|
dme_spd = 0.0;
|
||||||
|
dme_ete = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// marker beacon blinking
|
// marker beacon blinking
|
||||||
|
@ -380,19 +320,19 @@ void FGRadioStack::search()
|
||||||
// don't worry about overhead for now,
|
// don't worry about overhead for now,
|
||||||
// since this is handled only periodically
|
// since this is handled only periodically
|
||||||
int dme_switch_pos = fgGetInt("/radios/dme/switch-position");
|
int dme_switch_pos = fgGetInt("/radios/dme/switch-position");
|
||||||
if (dme_switch_pos == 0) {
|
if ( dme_switch_pos == 1 && navcom1.get_power_btn() ) {
|
||||||
dme_freq = 0;
|
if ( dme_freq != navcom1.get_nav_freq() ) {
|
||||||
dme_inrange = false;
|
dme_freq = navcom1.get_nav_freq();
|
||||||
} else if (dme_switch_pos == 1) {
|
need_update = true;
|
||||||
if (dme_freq != navcom1.get_nav_freq()) {
|
}
|
||||||
dme_freq = navcom1.get_nav_freq();
|
} else if ( dme_switch_pos == 3 && navcom2.get_power_btn() ) {
|
||||||
need_update = true;
|
if ( dme_freq != navcom2.get_nav_freq() ) {
|
||||||
}
|
dme_freq = navcom2.get_nav_freq();
|
||||||
} else if (dme_switch_pos == 3) {
|
need_update = true;
|
||||||
if (dme_freq != navcom2.get_nav_freq()) {
|
}
|
||||||
dme_freq = navcom2.get_nav_freq();
|
} else {
|
||||||
need_update = true;
|
dme_freq = 0;
|
||||||
}
|
dme_inrange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FGILS ils;
|
FGILS ils;
|
||||||
|
|
|
@ -88,14 +88,6 @@ class FGRadioStack : public FGSubsystem
|
||||||
FGNavCom navcom1;
|
FGNavCom navcom1;
|
||||||
FGNavCom navcom2;
|
FGNavCom navcom2;
|
||||||
|
|
||||||
// model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
|
|
||||||
double adjustNavRange( double stationElev, double aircraftElev,
|
|
||||||
double nominalRange );
|
|
||||||
|
|
||||||
// model standard ILS service volumes as per AIM 1-1-9
|
|
||||||
double adjustILSRange( double stationElev, double aircraftElev,
|
|
||||||
double offsetDegrees, double distance );
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGRadioStack();
|
FGRadioStack();
|
||||||
|
|
|
@ -499,8 +499,8 @@ void fgRenderFrame() {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ) ;
|
glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ) ;
|
||||||
if ( _bcloud_orig ) {
|
if ( _bcloud_orig ) {
|
||||||
sgClouds3d->Set_Cloud_Orig( &(globals->get_scenery()->
|
Point3D c = globals->get_scenery()->get_center();
|
||||||
get_center()) );
|
sgClouds3d->Set_Cloud_Orig( &c );
|
||||||
_bcloud_orig = false;
|
_bcloud_orig = false;
|
||||||
}
|
}
|
||||||
sgClouds3d->Update( current__view->get_absolute_view_pos() );
|
sgClouds3d->Update( current__view->get_absolute_view_pos() );
|
||||||
|
|
|
@ -398,9 +398,13 @@ bool FGATC610x::open() {
|
||||||
dme_kt = fgGetNode( "/radios/dme/speed-kt", true );
|
dme_kt = fgGetNode( "/radios/dme/speed-kt", true );
|
||||||
dme_nm = fgGetNode( "/radios/dme/distance-nm", true );
|
dme_nm = fgGetNode( "/radios/dme/distance-nm", true );
|
||||||
|
|
||||||
|
navcom1_power = fgGetNode( "/radios/comm[0]/inputs/power-btn", true );
|
||||||
|
navcom2_power = fgGetNode( "/radios/comm[1]/inputs/power-btn", true );
|
||||||
|
|
||||||
com1_freq = fgGetNode( "/radios/comm[0]/frequencies/selected-mhz", true );
|
com1_freq = fgGetNode( "/radios/comm[0]/frequencies/selected-mhz", true );
|
||||||
com1_stby_freq
|
com1_stby_freq
|
||||||
= fgGetNode( "/radios/comm[0]/frequencies/standby-mhz", true );
|
= fgGetNode( "/radios/comm[0]/frequencies/standby-mhz", true );
|
||||||
|
|
||||||
com2_freq = fgGetNode( "/radios/comm[1]/frequencies/selected-mhz", true );
|
com2_freq = fgGetNode( "/radios/comm[1]/frequencies/selected-mhz", true );
|
||||||
com2_stby_freq
|
com2_stby_freq
|
||||||
= fgGetNode( "/radios/comm[1]/frequencies/standby-mhz", true );
|
= fgGetNode( "/radios/comm[1]/frequencies/standby-mhz", true );
|
||||||
|
@ -666,328 +670,346 @@ bool FGATC610x::do_radio_switches() {
|
||||||
fgSetInt( "/radios/dme/switch-position", 3 );
|
fgSetInt( "/radios/dme/switch-position", 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Com1 Power
|
// NavCom1 Power
|
||||||
fgSetBool( "/radios/comm[0]/inputs/power-btn",
|
fgSetBool( "/radios/comm[0]/inputs/power-btn",
|
||||||
radio_switch_data[7] & 0x01 );
|
radio_switch_data[7] & 0x01 );
|
||||||
|
|
||||||
// Com1 Swap
|
if ( navcom1_power->getBoolValue() ) {
|
||||||
int com1_swap = !((radio_switch_data[7] >> 1) & 0x01);
|
// Com1 Swap
|
||||||
static int last_com1_swap;
|
int com1_swap = !((radio_switch_data[7] >> 1) & 0x01);
|
||||||
if ( com1_swap && (last_com1_swap != com1_swap) ) {
|
static int last_com1_swap;
|
||||||
float tmp = com1_freq->getFloatValue();
|
if ( com1_swap && (last_com1_swap != com1_swap) ) {
|
||||||
fgSetFloat( "/radios/comm[0]/frequencies/selected-mhz",
|
float tmp = com1_freq->getFloatValue();
|
||||||
com1_stby_freq->getFloatValue() );
|
fgSetFloat( "/radios/comm[0]/frequencies/selected-mhz",
|
||||||
fgSetFloat( "/radios/comm[0]/frequencies/standby-mhz", tmp );
|
com1_stby_freq->getFloatValue() );
|
||||||
|
fgSetFloat( "/radios/comm[0]/frequencies/standby-mhz", tmp );
|
||||||
|
}
|
||||||
|
last_com1_swap = com1_swap;
|
||||||
}
|
}
|
||||||
last_com1_swap = com1_swap;
|
|
||||||
|
|
||||||
// Com2 Power
|
// NavCom2 Power
|
||||||
fgSetBool( "/radios/comm[1]/inputs/power-btn",
|
fgSetBool( "/radios/comm[1]/inputs/power-btn",
|
||||||
radio_switch_data[15] & 0x01 );
|
radio_switch_data[15] & 0x01 );
|
||||||
|
|
||||||
// Com2 Swap
|
if ( navcom2_power->getBoolValue() ) {
|
||||||
int com2_swap = !((radio_switch_data[15] >> 1) & 0x01);
|
// Com2 Swap
|
||||||
static int last_com2_swap;
|
int com2_swap = !((radio_switch_data[15] >> 1) & 0x01);
|
||||||
if ( com2_swap && (last_com2_swap != com2_swap) ) {
|
static int last_com2_swap;
|
||||||
float tmp = com2_freq->getFloatValue();
|
if ( com2_swap && (last_com2_swap != com2_swap) ) {
|
||||||
fgSetFloat( "/radios/comm[1]/frequencies/selected-mhz",
|
float tmp = com2_freq->getFloatValue();
|
||||||
com2_stby_freq->getFloatValue() );
|
fgSetFloat( "/radios/comm[1]/frequencies/selected-mhz",
|
||||||
fgSetFloat( "/radios/comm[1]/frequencies/standby-mhz", tmp );
|
com2_stby_freq->getFloatValue() );
|
||||||
}
|
fgSetFloat( "/radios/comm[1]/frequencies/standby-mhz", tmp );
|
||||||
last_com2_swap = com2_swap;
|
|
||||||
|
|
||||||
// Nav1 Swap
|
|
||||||
int nav1_swap = radio_switch_data[11] & 0x01;
|
|
||||||
static int last_nav1_swap;
|
|
||||||
if ( nav1_swap && (last_nav1_swap != nav1_swap) ) {
|
|
||||||
float tmp = nav1_freq->getFloatValue();
|
|
||||||
fgSetFloat( "/radios/nav[0]/frequencies/selected-mhz",
|
|
||||||
nav1_stby_freq->getFloatValue() );
|
|
||||||
fgSetFloat( "/radios/nav[0]/frequencies/standby-mhz", tmp );
|
|
||||||
}
|
|
||||||
last_nav1_swap = nav1_swap;
|
|
||||||
|
|
||||||
// Nav2 Swap
|
|
||||||
int nav2_swap = !(radio_switch_data[19] & 0x01);
|
|
||||||
static int last_nav2_swap;
|
|
||||||
if ( nav2_swap && (last_nav2_swap != nav2_swap) ) {
|
|
||||||
float tmp = nav2_freq->getFloatValue();
|
|
||||||
fgSetFloat( "/radios/nav[1]/frequencies/selected-mhz",
|
|
||||||
nav2_stby_freq->getFloatValue() );
|
|
||||||
fgSetFloat( "/radios/nav[1]/frequencies/standby-mhz", tmp );
|
|
||||||
}
|
|
||||||
last_nav2_swap = nav2_swap;
|
|
||||||
|
|
||||||
// Com1 Tuner
|
|
||||||
int com1_tuner_fine = ((radio_switch_data[5] >> 4) & 0x0f) - 1;
|
|
||||||
int com1_tuner_coarse = (radio_switch_data[5] & 0x0f) - 1;
|
|
||||||
static int last_com1_tuner_fine = com1_tuner_fine;
|
|
||||||
static int last_com1_tuner_coarse = com1_tuner_coarse;
|
|
||||||
|
|
||||||
freq = com1_stby_freq->getFloatValue();
|
|
||||||
coarse_freq = (int)freq;
|
|
||||||
fine_freq = (int)((freq - coarse_freq) * 40 + 0.5);
|
|
||||||
|
|
||||||
if ( com1_tuner_fine != last_com1_tuner_fine ) {
|
|
||||||
diff = com1_tuner_fine - last_com1_tuner_fine;
|
|
||||||
if ( abs(diff) > 4 ) {
|
|
||||||
// roll over
|
|
||||||
if ( com1_tuner_fine < last_com1_tuner_fine ) {
|
|
||||||
// going up
|
|
||||||
diff = 12 - last_com1_tuner_fine + com1_tuner_fine;
|
|
||||||
} else {
|
|
||||||
// going down
|
|
||||||
diff = com1_tuner_fine - 12 - last_com1_tuner_fine;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fine_freq += diff;
|
last_com2_swap = com2_swap;
|
||||||
}
|
}
|
||||||
while ( fine_freq >= 40.0 ) { fine_freq -= 40.0; }
|
|
||||||
while ( fine_freq < 0.0 ) { fine_freq += 40.0; }
|
|
||||||
|
|
||||||
if ( com1_tuner_coarse != last_com1_tuner_coarse ) {
|
if ( navcom1_power->getBoolValue() ) {
|
||||||
diff = com1_tuner_coarse - last_com1_tuner_coarse;
|
// Nav1 Swap
|
||||||
if ( abs(diff) > 4 ) {
|
int nav1_swap = radio_switch_data[11] & 0x01;
|
||||||
// roll over
|
static int last_nav1_swap;
|
||||||
if ( com1_tuner_coarse < last_com1_tuner_coarse ) {
|
if ( nav1_swap && (last_nav1_swap != nav1_swap) ) {
|
||||||
// going up
|
float tmp = nav1_freq->getFloatValue();
|
||||||
diff = 12 - last_com1_tuner_coarse + com1_tuner_coarse;
|
fgSetFloat( "/radios/nav[0]/frequencies/selected-mhz",
|
||||||
} else {
|
nav1_stby_freq->getFloatValue() );
|
||||||
// going down
|
fgSetFloat( "/radios/nav[0]/frequencies/standby-mhz", tmp );
|
||||||
diff = com1_tuner_coarse - 12 - last_com1_tuner_coarse;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
coarse_freq += diff;
|
last_nav1_swap = nav1_swap;
|
||||||
}
|
}
|
||||||
if ( coarse_freq < 118.0 ) { coarse_freq += 19.0; }
|
|
||||||
if ( coarse_freq > 136.0 ) { coarse_freq -= 19.0; }
|
|
||||||
|
|
||||||
last_com1_tuner_fine = com1_tuner_fine;
|
if ( navcom2_power->getBoolValue() ) {
|
||||||
last_com1_tuner_coarse = com1_tuner_coarse;
|
// Nav2 Swap
|
||||||
|
int nav2_swap = !(radio_switch_data[19] & 0x01);
|
||||||
fgSetFloat( "/radios/comm[0]/frequencies/standby-mhz",
|
static int last_nav2_swap;
|
||||||
coarse_freq + fine_freq / 40.0 );
|
if ( nav2_swap && (last_nav2_swap != nav2_swap) ) {
|
||||||
|
float tmp = nav2_freq->getFloatValue();
|
||||||
// Com2 Tuner
|
fgSetFloat( "/radios/nav[1]/frequencies/selected-mhz",
|
||||||
int com2_tuner_fine = ((radio_switch_data[13] >> 4) & 0x0f) - 1;
|
nav2_stby_freq->getFloatValue() );
|
||||||
int com2_tuner_coarse = (radio_switch_data[13] & 0x0f) - 1;
|
fgSetFloat( "/radios/nav[1]/frequencies/standby-mhz", tmp );
|
||||||
static int last_com2_tuner_fine = com2_tuner_fine;
|
|
||||||
static int last_com2_tuner_coarse = com2_tuner_coarse;
|
|
||||||
|
|
||||||
freq = com2_stby_freq->getFloatValue();
|
|
||||||
coarse_freq = (int)freq;
|
|
||||||
fine_freq = (int)((freq - coarse_freq) * 40 + 0.5);
|
|
||||||
|
|
||||||
if ( com2_tuner_fine != last_com2_tuner_fine ) {
|
|
||||||
diff = com2_tuner_fine - last_com2_tuner_fine;
|
|
||||||
if ( abs(diff) > 4 ) {
|
|
||||||
// roll over
|
|
||||||
if ( com2_tuner_fine < last_com2_tuner_fine ) {
|
|
||||||
// going up
|
|
||||||
diff = 12 - last_com2_tuner_fine + com2_tuner_fine;
|
|
||||||
} else {
|
|
||||||
// going down
|
|
||||||
diff = com2_tuner_fine - 12 - last_com2_tuner_fine;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fine_freq += diff;
|
last_nav2_swap = nav2_swap;
|
||||||
}
|
}
|
||||||
while ( fine_freq >= 40.0 ) { fine_freq -= 40.0; }
|
|
||||||
while ( fine_freq < 0.0 ) { fine_freq += 40.0; }
|
|
||||||
|
|
||||||
if ( com2_tuner_coarse != last_com2_tuner_coarse ) {
|
if ( navcom1_power->getBoolValue() ) {
|
||||||
diff = com2_tuner_coarse - last_com2_tuner_coarse;
|
// Com1 Tuner
|
||||||
if ( abs(diff) > 4 ) {
|
int com1_tuner_fine = ((radio_switch_data[5] >> 4) & 0x0f) - 1;
|
||||||
// roll over
|
int com1_tuner_coarse = (radio_switch_data[5] & 0x0f) - 1;
|
||||||
if ( com2_tuner_coarse < last_com2_tuner_coarse ) {
|
static int last_com1_tuner_fine = com1_tuner_fine;
|
||||||
// going up
|
static int last_com1_tuner_coarse = com1_tuner_coarse;
|
||||||
diff = 12 - last_com2_tuner_coarse + com2_tuner_coarse;
|
|
||||||
} else {
|
freq = com1_stby_freq->getFloatValue();
|
||||||
// going down
|
coarse_freq = (int)freq;
|
||||||
diff = com2_tuner_coarse - 12 - last_com2_tuner_coarse;
|
fine_freq = (int)((freq - coarse_freq) * 40 + 0.5);
|
||||||
|
|
||||||
|
if ( com1_tuner_fine != last_com1_tuner_fine ) {
|
||||||
|
diff = com1_tuner_fine - last_com1_tuner_fine;
|
||||||
|
if ( abs(diff) > 4 ) {
|
||||||
|
// roll over
|
||||||
|
if ( com1_tuner_fine < last_com1_tuner_fine ) {
|
||||||
|
// going up
|
||||||
|
diff = 12 - last_com1_tuner_fine + com1_tuner_fine;
|
||||||
|
} else {
|
||||||
|
// going down
|
||||||
|
diff = com1_tuner_fine - 12 - last_com1_tuner_fine;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
fine_freq += diff;
|
||||||
}
|
}
|
||||||
coarse_freq += diff;
|
while ( fine_freq >= 40.0 ) { fine_freq -= 40.0; }
|
||||||
}
|
while ( fine_freq < 0.0 ) { fine_freq += 40.0; }
|
||||||
if ( coarse_freq < 118.0 ) { coarse_freq += 19.0; }
|
|
||||||
if ( coarse_freq > 136.0 ) { coarse_freq -= 19.0; }
|
|
||||||
|
|
||||||
last_com2_tuner_fine = com2_tuner_fine;
|
if ( com1_tuner_coarse != last_com1_tuner_coarse ) {
|
||||||
last_com2_tuner_coarse = com2_tuner_coarse;
|
diff = com1_tuner_coarse - last_com1_tuner_coarse;
|
||||||
|
if ( abs(diff) > 4 ) {
|
||||||
fgSetFloat( "/radios/comm[1]/frequencies/standby-mhz",
|
// roll over
|
||||||
coarse_freq + fine_freq / 40.0 );
|
if ( com1_tuner_coarse < last_com1_tuner_coarse ) {
|
||||||
|
// going up
|
||||||
// Nav1 Tuner
|
diff = 12 - last_com1_tuner_coarse + com1_tuner_coarse;
|
||||||
int nav1_tuner_fine = ((radio_switch_data[9] >> 4) & 0x0f) - 1;
|
} else {
|
||||||
int nav1_tuner_coarse = (radio_switch_data[9] & 0x0f) - 1;
|
// going down
|
||||||
static int last_nav1_tuner_fine = nav1_tuner_fine;
|
diff = com1_tuner_coarse - 12 - last_com1_tuner_coarse;
|
||||||
static int last_nav1_tuner_coarse = nav1_tuner_coarse;
|
}
|
||||||
|
|
||||||
freq = nav1_stby_freq->getFloatValue();
|
|
||||||
coarse_freq = (int)freq;
|
|
||||||
fine_freq = (int)((freq - coarse_freq) * 20 + 0.5);
|
|
||||||
|
|
||||||
if ( nav1_tuner_fine != last_nav1_tuner_fine ) {
|
|
||||||
diff = nav1_tuner_fine - last_nav1_tuner_fine;
|
|
||||||
if ( abs(diff) > 4 ) {
|
|
||||||
// roll over
|
|
||||||
if ( nav1_tuner_fine < last_nav1_tuner_fine ) {
|
|
||||||
// going up
|
|
||||||
diff = 12 - last_nav1_tuner_fine + nav1_tuner_fine;
|
|
||||||
} else {
|
|
||||||
// going down
|
|
||||||
diff = nav1_tuner_fine - 12 - last_nav1_tuner_fine;
|
|
||||||
}
|
}
|
||||||
|
coarse_freq += diff;
|
||||||
}
|
}
|
||||||
fine_freq += diff;
|
if ( coarse_freq < 118.0 ) { coarse_freq += 19.0; }
|
||||||
}
|
if ( coarse_freq > 136.0 ) { coarse_freq -= 19.0; }
|
||||||
while ( fine_freq >= 20.0 ) { fine_freq -= 20.0; }
|
|
||||||
while ( fine_freq < 0.0 ) { fine_freq += 20.0; }
|
|
||||||
|
|
||||||
if ( nav1_tuner_coarse != last_nav1_tuner_coarse ) {
|
last_com1_tuner_fine = com1_tuner_fine;
|
||||||
diff = nav1_tuner_coarse - last_nav1_tuner_coarse;
|
last_com1_tuner_coarse = com1_tuner_coarse;
|
||||||
if ( abs(diff) > 4 ) {
|
|
||||||
// roll over
|
fgSetFloat( "/radios/comm[0]/frequencies/standby-mhz",
|
||||||
if ( nav1_tuner_coarse < last_nav1_tuner_coarse ) {
|
coarse_freq + fine_freq / 40.0 );
|
||||||
// going up
|
}
|
||||||
diff = 12 - last_nav1_tuner_coarse + nav1_tuner_coarse;
|
|
||||||
} else {
|
if ( navcom2_power->getBoolValue() ) {
|
||||||
// going down
|
// Com2 Tuner
|
||||||
diff = nav1_tuner_coarse - 12 - last_nav1_tuner_coarse;
|
int com2_tuner_fine = ((radio_switch_data[13] >> 4) & 0x0f) - 1;
|
||||||
|
int com2_tuner_coarse = (radio_switch_data[13] & 0x0f) - 1;
|
||||||
|
static int last_com2_tuner_fine = com2_tuner_fine;
|
||||||
|
static int last_com2_tuner_coarse = com2_tuner_coarse;
|
||||||
|
|
||||||
|
freq = com2_stby_freq->getFloatValue();
|
||||||
|
coarse_freq = (int)freq;
|
||||||
|
fine_freq = (int)((freq - coarse_freq) * 40 + 0.5);
|
||||||
|
|
||||||
|
if ( com2_tuner_fine != last_com2_tuner_fine ) {
|
||||||
|
diff = com2_tuner_fine - last_com2_tuner_fine;
|
||||||
|
if ( abs(diff) > 4 ) {
|
||||||
|
// roll over
|
||||||
|
if ( com2_tuner_fine < last_com2_tuner_fine ) {
|
||||||
|
// going up
|
||||||
|
diff = 12 - last_com2_tuner_fine + com2_tuner_fine;
|
||||||
|
} else {
|
||||||
|
// going down
|
||||||
|
diff = com2_tuner_fine - 12 - last_com2_tuner_fine;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
fine_freq += diff;
|
||||||
}
|
}
|
||||||
coarse_freq += diff;
|
while ( fine_freq >= 40.0 ) { fine_freq -= 40.0; }
|
||||||
}
|
while ( fine_freq < 0.0 ) { fine_freq += 40.0; }
|
||||||
if ( coarse_freq < 108.0 ) { coarse_freq += 10.0; }
|
|
||||||
if ( coarse_freq > 117.0 ) { coarse_freq -= 10.0; }
|
|
||||||
|
|
||||||
last_nav1_tuner_fine = nav1_tuner_fine;
|
if ( com2_tuner_coarse != last_com2_tuner_coarse ) {
|
||||||
last_nav1_tuner_coarse = nav1_tuner_coarse;
|
diff = com2_tuner_coarse - last_com2_tuner_coarse;
|
||||||
|
if ( abs(diff) > 4 ) {
|
||||||
fgSetFloat( "/radios/nav[0]/frequencies/standby-mhz",
|
// roll over
|
||||||
coarse_freq + fine_freq / 20.0 );
|
if ( com2_tuner_coarse < last_com2_tuner_coarse ) {
|
||||||
|
// going up
|
||||||
// Nav2 Tuner
|
diff = 12 - last_com2_tuner_coarse + com2_tuner_coarse;
|
||||||
int nav2_tuner_fine = ((radio_switch_data[17] >> 4) & 0x0f) - 1;
|
} else {
|
||||||
int nav2_tuner_coarse = (radio_switch_data[17] & 0x0f) - 1;
|
// going down
|
||||||
static int last_nav2_tuner_fine = nav2_tuner_fine;
|
diff = com2_tuner_coarse - 12 - last_com2_tuner_coarse;
|
||||||
static int last_nav2_tuner_coarse = nav2_tuner_coarse;
|
}
|
||||||
|
|
||||||
freq = nav2_stby_freq->getFloatValue();
|
|
||||||
coarse_freq = (int)freq;
|
|
||||||
fine_freq = (int)((freq - coarse_freq) * 20 + 0.5);
|
|
||||||
|
|
||||||
if ( nav2_tuner_fine != last_nav2_tuner_fine ) {
|
|
||||||
diff = nav2_tuner_fine - last_nav2_tuner_fine;
|
|
||||||
if ( abs(diff) > 4 ) {
|
|
||||||
// roll over
|
|
||||||
if ( nav2_tuner_fine < last_nav2_tuner_fine ) {
|
|
||||||
// going up
|
|
||||||
diff = 12 - last_nav2_tuner_fine + nav2_tuner_fine;
|
|
||||||
} else {
|
|
||||||
// going down
|
|
||||||
diff = nav2_tuner_fine - 12 - last_nav2_tuner_fine;
|
|
||||||
}
|
}
|
||||||
|
coarse_freq += diff;
|
||||||
}
|
}
|
||||||
fine_freq += diff;
|
if ( coarse_freq < 118.0 ) { coarse_freq += 19.0; }
|
||||||
}
|
if ( coarse_freq > 136.0 ) { coarse_freq -= 19.0; }
|
||||||
while ( fine_freq >= 20.0 ) { fine_freq -= 20.0; }
|
|
||||||
while ( fine_freq < 0.0 ) { fine_freq += 20.0; }
|
|
||||||
|
|
||||||
if ( nav2_tuner_coarse != last_nav2_tuner_coarse ) {
|
last_com2_tuner_fine = com2_tuner_fine;
|
||||||
diff = nav2_tuner_coarse - last_nav2_tuner_coarse;
|
last_com2_tuner_coarse = com2_tuner_coarse;
|
||||||
if ( abs(diff) > 4 ) {
|
|
||||||
// roll over
|
fgSetFloat( "/radios/comm[1]/frequencies/standby-mhz",
|
||||||
if ( nav2_tuner_coarse < last_nav2_tuner_coarse ) {
|
coarse_freq + fine_freq / 40.0 );
|
||||||
// going up
|
}
|
||||||
diff = 12 - last_nav2_tuner_coarse + nav2_tuner_coarse;
|
|
||||||
} else {
|
if ( navcom1_power->getBoolValue() ) {
|
||||||
// going down
|
// Nav1 Tuner
|
||||||
diff = nav2_tuner_coarse - 12 - last_nav2_tuner_coarse;
|
int nav1_tuner_fine = ((radio_switch_data[9] >> 4) & 0x0f) - 1;
|
||||||
|
int nav1_tuner_coarse = (radio_switch_data[9] & 0x0f) - 1;
|
||||||
|
static int last_nav1_tuner_fine = nav1_tuner_fine;
|
||||||
|
static int last_nav1_tuner_coarse = nav1_tuner_coarse;
|
||||||
|
|
||||||
|
freq = nav1_stby_freq->getFloatValue();
|
||||||
|
coarse_freq = (int)freq;
|
||||||
|
fine_freq = (int)((freq - coarse_freq) * 20 + 0.5);
|
||||||
|
|
||||||
|
if ( nav1_tuner_fine != last_nav1_tuner_fine ) {
|
||||||
|
diff = nav1_tuner_fine - last_nav1_tuner_fine;
|
||||||
|
if ( abs(diff) > 4 ) {
|
||||||
|
// roll over
|
||||||
|
if ( nav1_tuner_fine < last_nav1_tuner_fine ) {
|
||||||
|
// going up
|
||||||
|
diff = 12 - last_nav1_tuner_fine + nav1_tuner_fine;
|
||||||
|
} else {
|
||||||
|
// going down
|
||||||
|
diff = nav1_tuner_fine - 12 - last_nav1_tuner_fine;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
fine_freq += diff;
|
||||||
}
|
}
|
||||||
coarse_freq += diff;
|
while ( fine_freq >= 20.0 ) { fine_freq -= 20.0; }
|
||||||
|
while ( fine_freq < 0.0 ) { fine_freq += 20.0; }
|
||||||
|
|
||||||
|
if ( nav1_tuner_coarse != last_nav1_tuner_coarse ) {
|
||||||
|
diff = nav1_tuner_coarse - last_nav1_tuner_coarse;
|
||||||
|
if ( abs(diff) > 4 ) {
|
||||||
|
// roll over
|
||||||
|
if ( nav1_tuner_coarse < last_nav1_tuner_coarse ) {
|
||||||
|
// going up
|
||||||
|
diff = 12 - last_nav1_tuner_coarse + nav1_tuner_coarse;
|
||||||
|
} else {
|
||||||
|
// going down
|
||||||
|
diff = nav1_tuner_coarse - 12 - last_nav1_tuner_coarse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
coarse_freq += diff;
|
||||||
|
}
|
||||||
|
if ( coarse_freq < 108.0 ) { coarse_freq += 10.0; }
|
||||||
|
if ( coarse_freq > 117.0 ) { coarse_freq -= 10.0; }
|
||||||
|
|
||||||
|
last_nav1_tuner_fine = nav1_tuner_fine;
|
||||||
|
last_nav1_tuner_coarse = nav1_tuner_coarse;
|
||||||
|
|
||||||
|
fgSetFloat( "/radios/nav[0]/frequencies/standby-mhz",
|
||||||
|
coarse_freq + fine_freq / 20.0 );
|
||||||
}
|
}
|
||||||
if ( coarse_freq < 108.0 ) { coarse_freq += 10.0; }
|
|
||||||
if ( coarse_freq > 117.0 ) { coarse_freq -= 10.0; }
|
|
||||||
|
|
||||||
last_nav2_tuner_fine = nav2_tuner_fine;
|
if ( navcom2_power->getBoolValue() ) {
|
||||||
last_nav2_tuner_coarse = nav2_tuner_coarse;
|
// Nav2 Tuner
|
||||||
|
int nav2_tuner_fine = ((radio_switch_data[17] >> 4) & 0x0f) - 1;
|
||||||
|
int nav2_tuner_coarse = (radio_switch_data[17] & 0x0f) - 1;
|
||||||
|
static int last_nav2_tuner_fine = nav2_tuner_fine;
|
||||||
|
static int last_nav2_tuner_coarse = nav2_tuner_coarse;
|
||||||
|
|
||||||
fgSetFloat( "/radios/nav[1]/frequencies/standby-mhz",
|
freq = nav2_stby_freq->getFloatValue();
|
||||||
coarse_freq + fine_freq / 20.0);
|
coarse_freq = (int)freq;
|
||||||
|
fine_freq = (int)((freq - coarse_freq) * 20 + 0.5);
|
||||||
|
|
||||||
// ADF Tuner
|
if ( nav2_tuner_fine != last_nav2_tuner_fine ) {
|
||||||
int adf_tuner_fine = ((radio_switch_data[21] >> 4) & 0x0f) - 1;
|
diff = nav2_tuner_fine - last_nav2_tuner_fine;
|
||||||
int adf_tuner_coarse = (radio_switch_data[21] & 0x0f) - 1;
|
if ( abs(diff) > 4 ) {
|
||||||
static int last_adf_tuner_fine = adf_tuner_fine;
|
// roll over
|
||||||
static int last_adf_tuner_coarse = adf_tuner_coarse;
|
if ( nav2_tuner_fine < last_nav2_tuner_fine ) {
|
||||||
|
// going up
|
||||||
|
diff = 12 - last_nav2_tuner_fine + nav2_tuner_fine;
|
||||||
|
} else {
|
||||||
|
// going down
|
||||||
|
diff = nav2_tuner_fine - 12 - last_nav2_tuner_fine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fine_freq += diff;
|
||||||
|
}
|
||||||
|
while ( fine_freq >= 20.0 ) { fine_freq -= 20.0; }
|
||||||
|
while ( fine_freq < 0.0 ) { fine_freq += 20.0; }
|
||||||
|
|
||||||
// cout << "adf_stby_mode = " << adf_stby_mode->getIntValue() << endl;
|
if ( nav2_tuner_coarse != last_nav2_tuner_coarse ) {
|
||||||
if ( adf_count_mode->getIntValue() == 2 ) {
|
diff = nav2_tuner_coarse - last_nav2_tuner_coarse;
|
||||||
// tune count down timer
|
if ( abs(diff) > 4 ) {
|
||||||
value = adf_elapsed_timer->getDoubleValue();
|
// roll over
|
||||||
} else {
|
if ( nav2_tuner_coarse < last_nav2_tuner_coarse ) {
|
||||||
// tune frequency
|
// going up
|
||||||
if ( adf_stby_mode->getIntValue() == 1 ) {
|
diff = 12 - last_nav2_tuner_coarse + nav2_tuner_coarse;
|
||||||
value = adf_freq->getFloatValue();
|
} else {
|
||||||
|
// going down
|
||||||
|
diff = nav2_tuner_coarse - 12 - last_nav2_tuner_coarse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
coarse_freq += diff;
|
||||||
|
}
|
||||||
|
if ( coarse_freq < 108.0 ) { coarse_freq += 10.0; }
|
||||||
|
if ( coarse_freq > 117.0 ) { coarse_freq -= 10.0; }
|
||||||
|
|
||||||
|
last_nav2_tuner_fine = nav2_tuner_fine;
|
||||||
|
last_nav2_tuner_coarse = nav2_tuner_coarse;
|
||||||
|
|
||||||
|
fgSetFloat( "/radios/nav[1]/frequencies/standby-mhz",
|
||||||
|
coarse_freq + fine_freq / 20.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( adf_power->getBoolValue() ) {
|
||||||
|
// ADF Tuner
|
||||||
|
int adf_tuner_fine = ((radio_switch_data[21] >> 4) & 0x0f) - 1;
|
||||||
|
int adf_tuner_coarse = (radio_switch_data[21] & 0x0f) - 1;
|
||||||
|
static int last_adf_tuner_fine = adf_tuner_fine;
|
||||||
|
static int last_adf_tuner_coarse = adf_tuner_coarse;
|
||||||
|
|
||||||
|
// cout << "adf_stby_mode = " << adf_stby_mode->getIntValue() << endl;
|
||||||
|
if ( adf_count_mode->getIntValue() == 2 ) {
|
||||||
|
// tune count down timer
|
||||||
|
value = adf_elapsed_timer->getDoubleValue();
|
||||||
} else {
|
} else {
|
||||||
value = adf_stby_freq->getFloatValue();
|
// tune frequency
|
||||||
}
|
if ( adf_stby_mode->getIntValue() == 1 ) {
|
||||||
}
|
value = adf_freq->getFloatValue();
|
||||||
|
|
||||||
if ( adf_tuner_fine != last_adf_tuner_fine ) {
|
|
||||||
diff = adf_tuner_fine - last_adf_tuner_fine;
|
|
||||||
if ( abs(diff) > 4 ) {
|
|
||||||
// roll over
|
|
||||||
if ( adf_tuner_fine < last_adf_tuner_fine ) {
|
|
||||||
// going up
|
|
||||||
diff = 12 - last_adf_tuner_fine + adf_tuner_fine;
|
|
||||||
} else {
|
} else {
|
||||||
// going down
|
value = adf_stby_freq->getFloatValue();
|
||||||
diff = adf_tuner_fine - 12 - last_adf_tuner_fine;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
value += diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( adf_tuner_coarse != last_adf_tuner_coarse ) {
|
if ( adf_tuner_fine != last_adf_tuner_fine ) {
|
||||||
diff = adf_tuner_coarse - last_adf_tuner_coarse;
|
diff = adf_tuner_fine - last_adf_tuner_fine;
|
||||||
if ( abs(diff) > 4 ) {
|
if ( abs(diff) > 4 ) {
|
||||||
// roll over
|
// roll over
|
||||||
if ( adf_tuner_coarse < last_adf_tuner_coarse ) {
|
if ( adf_tuner_fine < last_adf_tuner_fine ) {
|
||||||
// going up
|
// going up
|
||||||
diff = 12 - last_adf_tuner_coarse + adf_tuner_coarse;
|
diff = 12 - last_adf_tuner_fine + adf_tuner_fine;
|
||||||
|
} else {
|
||||||
|
// going down
|
||||||
|
diff = adf_tuner_fine - 12 - last_adf_tuner_fine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value += diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( adf_tuner_coarse != last_adf_tuner_coarse ) {
|
||||||
|
diff = adf_tuner_coarse - last_adf_tuner_coarse;
|
||||||
|
if ( abs(diff) > 4 ) {
|
||||||
|
// roll over
|
||||||
|
if ( adf_tuner_coarse < last_adf_tuner_coarse ) {
|
||||||
|
// going up
|
||||||
|
diff = 12 - last_adf_tuner_coarse + adf_tuner_coarse;
|
||||||
|
} else {
|
||||||
|
// going down
|
||||||
|
diff = adf_tuner_coarse - 12 - last_adf_tuner_coarse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( adf_count_mode->getIntValue() == 2 ) {
|
||||||
|
value += 60 * diff;
|
||||||
} else {
|
} else {
|
||||||
// going down
|
value += 25 * diff;
|
||||||
diff = adf_tuner_coarse - 12 - last_adf_tuner_coarse;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( adf_count_mode->getIntValue() == 2 ) {
|
if ( adf_count_mode->getIntValue() == 2 ) {
|
||||||
value += 60 * diff;
|
if ( value < 0 ) { value += 3600; }
|
||||||
|
if ( value > 3599 ) { value -= 3600; }
|
||||||
} else {
|
} else {
|
||||||
value += 25 * diff;
|
if ( value < 200 ) { value += 1600; }
|
||||||
|
if ( value > 1799 ) { value -= 1600; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ( adf_count_mode->getIntValue() == 2 ) {
|
|
||||||
if ( value < 0 ) { value += 3600; }
|
|
||||||
if ( value > 3599 ) { value -= 3600; }
|
|
||||||
} else {
|
|
||||||
if ( value < 200 ) { value += 1600; }
|
|
||||||
if ( value > 1799 ) { value -= 1600; }
|
|
||||||
}
|
|
||||||
|
|
||||||
last_adf_tuner_fine = adf_tuner_fine;
|
last_adf_tuner_fine = adf_tuner_fine;
|
||||||
last_adf_tuner_coarse = adf_tuner_coarse;
|
last_adf_tuner_coarse = adf_tuner_coarse;
|
||||||
|
|
||||||
if ( adf_count_mode->getIntValue() == 2 ) {
|
if ( adf_count_mode->getIntValue() == 2 ) {
|
||||||
fgSetFloat( "/radios/kr-87/outputs/elapsed-timer", value );
|
fgSetFloat( "/radios/kr-87/outputs/elapsed-timer", value );
|
||||||
} else {
|
|
||||||
if ( adf_stby_mode->getIntValue() == 1 ) {
|
|
||||||
fgSetFloat( "/radios/kr-87/outputs/selected-khz", value );
|
|
||||||
} else {
|
} else {
|
||||||
fgSetFloat( "/radios/kr-87/outputs/standby-khz", value );
|
if ( adf_stby_mode->getIntValue() == 1 ) {
|
||||||
|
fgSetFloat( "/radios/kr-87/outputs/selected-khz", value );
|
||||||
|
} else {
|
||||||
|
fgSetFloat( "/radios/kr-87/outputs/standby-khz", value );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -999,7 +1021,7 @@ bool FGATC610x::do_radio_switches() {
|
||||||
fgSetInt( "/radios/kr-87/inputs/frq-btn",
|
fgSetInt( "/radios/kr-87/inputs/frq-btn",
|
||||||
(radio_switch_data[23] >> 2 & 0x01) );
|
(radio_switch_data[23] >> 2 & 0x01) );
|
||||||
fgSetInt( "/radios/kr-87/inputs/flt-et-btn",
|
fgSetInt( "/radios/kr-87/inputs/flt-et-btn",
|
||||||
!(radio_switch_data[23] >> 3 & 0x01) );
|
!(radio_switch_data[23] >> 3 & 0x01) );
|
||||||
fgSetInt( "/radios/kr-87/inputs/set-rst-btn",
|
fgSetInt( "/radios/kr-87/inputs/set-rst-btn",
|
||||||
!(radio_switch_data[23] >> 4 & 0x01) );
|
!(radio_switch_data[23] >> 4 & 0x01) );
|
||||||
fgSetInt( "/radios/kr-87/inputs/power-btn",
|
fgSetInt( "/radios/kr-87/inputs/power-btn",
|
||||||
|
@ -1130,117 +1152,153 @@ bool FGATC610x::do_radio_display() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Com1 standby frequency
|
if ( navcom1_power->getBoolValue() ) {
|
||||||
float com1_stby = com1_stby_freq->getFloatValue();
|
// Com1 standby frequency
|
||||||
if ( fabs(com1_stby) > 999.99 ) {
|
float com1_stby = com1_stby_freq->getFloatValue();
|
||||||
com1_stby = 0.0;
|
if ( fabs(com1_stby) > 999.99 ) {
|
||||||
}
|
com1_stby = 0.0;
|
||||||
snprintf(digits, 7, "%06.3f", com1_stby);
|
}
|
||||||
for ( i = 0; i < 6; ++i ) {
|
snprintf(digits, 7, "%06.3f", com1_stby);
|
||||||
digits[i] -= '0';
|
for ( i = 0; i < 6; ++i ) {
|
||||||
}
|
digits[i] -= '0';
|
||||||
radio_display_data[6] = digits[4] << 4 | digits[5];
|
}
|
||||||
radio_display_data[7] = digits[1] << 4 | digits[2];
|
radio_display_data[6] = digits[4] << 4 | digits[5];
|
||||||
radio_display_data[8] = 0xf0 | digits[0];
|
radio_display_data[7] = digits[1] << 4 | digits[2];
|
||||||
|
radio_display_data[8] = 0xf0 | digits[0];
|
||||||
|
|
||||||
// Com1 in use frequency
|
// Com1 in use frequency
|
||||||
float com1 = com1_freq->getFloatValue();
|
float com1 = com1_freq->getFloatValue();
|
||||||
if ( fabs(com1) > 999.99 ) {
|
if ( fabs(com1) > 999.99 ) {
|
||||||
com1 = 0.0;
|
com1 = 0.0;
|
||||||
|
}
|
||||||
|
snprintf(digits, 7, "%06.3f", com1);
|
||||||
|
for ( i = 0; i < 6; ++i ) {
|
||||||
|
digits[i] -= '0';
|
||||||
|
}
|
||||||
|
radio_display_data[9] = digits[4] << 4 | digits[5];
|
||||||
|
radio_display_data[10] = digits[1] << 4 | digits[2];
|
||||||
|
radio_display_data[11] = 0x00 | digits[0];
|
||||||
|
// the 0x00 in the upper nibble of the 6th byte of each display
|
||||||
|
// turns on the decimal point
|
||||||
|
} else {
|
||||||
|
radio_display_data[6] = 0xff;
|
||||||
|
radio_display_data[7] = 0xff;
|
||||||
|
radio_display_data[8] = 0xff;
|
||||||
|
radio_display_data[9] = 0xff;
|
||||||
|
radio_display_data[10] = 0xff;
|
||||||
|
radio_display_data[11] = 0xff;
|
||||||
}
|
}
|
||||||
snprintf(digits, 7, "%06.3f", com1);
|
|
||||||
for ( i = 0; i < 6; ++i ) {
|
|
||||||
digits[i] -= '0';
|
|
||||||
}
|
|
||||||
radio_display_data[9] = digits[4] << 4 | digits[5];
|
|
||||||
radio_display_data[10] = digits[1] << 4 | digits[2];
|
|
||||||
radio_display_data[11] = 0x00 | digits[0];
|
|
||||||
// the 0x00 in the upper nibble of the 6th byte of each display
|
|
||||||
// turns on the decimal point
|
|
||||||
|
|
||||||
// Com2 standby frequency
|
if ( navcom2_power->getBoolValue() ) {
|
||||||
float com2_stby = com2_stby_freq->getFloatValue();
|
// Com2 standby frequency
|
||||||
if ( fabs(com2_stby) > 999.99 ) {
|
float com2_stby = com2_stby_freq->getFloatValue();
|
||||||
com2_stby = 0.0;
|
if ( fabs(com2_stby) > 999.99 ) {
|
||||||
}
|
com2_stby = 0.0;
|
||||||
snprintf(digits, 7, "%06.3f", com2_stby);
|
}
|
||||||
for ( i = 0; i < 6; ++i ) {
|
snprintf(digits, 7, "%06.3f", com2_stby);
|
||||||
digits[i] -= '0';
|
for ( i = 0; i < 6; ++i ) {
|
||||||
}
|
digits[i] -= '0';
|
||||||
radio_display_data[18] = digits[4] << 4 | digits[5];
|
}
|
||||||
radio_display_data[19] = digits[1] << 4 | digits[2];
|
radio_display_data[18] = digits[4] << 4 | digits[5];
|
||||||
radio_display_data[20] = 0xf0 | digits[0];
|
radio_display_data[19] = digits[1] << 4 | digits[2];
|
||||||
|
radio_display_data[20] = 0xf0 | digits[0];
|
||||||
|
|
||||||
// Com2 in use frequency
|
// Com2 in use frequency
|
||||||
float com2 = com2_freq->getFloatValue();
|
float com2 = com2_freq->getFloatValue();
|
||||||
if ( fabs(com2) > 999.99 ) {
|
if ( fabs(com2) > 999.99 ) {
|
||||||
com2 = 0.0;
|
com2 = 0.0;
|
||||||
|
}
|
||||||
|
snprintf(digits, 7, "%06.3f", com2);
|
||||||
|
for ( i = 0; i < 6; ++i ) {
|
||||||
|
digits[i] -= '0';
|
||||||
|
}
|
||||||
|
radio_display_data[21] = digits[4] << 4 | digits[5];
|
||||||
|
radio_display_data[22] = digits[1] << 4 | digits[2];
|
||||||
|
radio_display_data[23] = 0x00 | digits[0];
|
||||||
|
// the 0x00 in the upper nibble of the 6th byte of each display
|
||||||
|
// turns on the decimal point
|
||||||
|
} else {
|
||||||
|
radio_display_data[18] = 0xff;
|
||||||
|
radio_display_data[19] = 0xff;
|
||||||
|
radio_display_data[20] = 0xff;
|
||||||
|
radio_display_data[21] = 0xff;
|
||||||
|
radio_display_data[22] = 0xff;
|
||||||
|
radio_display_data[23] = 0xff;
|
||||||
}
|
}
|
||||||
snprintf(digits, 7, "%06.3f", com2);
|
|
||||||
for ( i = 0; i < 6; ++i ) {
|
|
||||||
digits[i] -= '0';
|
|
||||||
}
|
|
||||||
radio_display_data[21] = digits[4] << 4 | digits[5];
|
|
||||||
radio_display_data[22] = digits[1] << 4 | digits[2];
|
|
||||||
radio_display_data[23] = 0x00 | digits[0];
|
|
||||||
// the 0x00 in the upper nibble of the 6th byte of each display
|
|
||||||
// turns on the decimal point
|
|
||||||
|
|
||||||
// Nav1 standby frequency
|
if ( navcom1_power->getBoolValue() ) {
|
||||||
float nav1_stby = nav1_stby_freq->getFloatValue();
|
// Nav1 standby frequency
|
||||||
if ( fabs(nav1_stby) > 999.99 ) {
|
float nav1_stby = nav1_stby_freq->getFloatValue();
|
||||||
|
if ( fabs(nav1_stby) > 999.99 ) {
|
||||||
nav1_stby = 0.0;
|
nav1_stby = 0.0;
|
||||||
}
|
}
|
||||||
snprintf(digits, 7, "%06.2f", nav1_stby);
|
snprintf(digits, 7, "%06.2f", nav1_stby);
|
||||||
for ( i = 0; i < 6; ++i ) {
|
for ( i = 0; i < 6; ++i ) {
|
||||||
digits[i] -= '0';
|
digits[i] -= '0';
|
||||||
}
|
}
|
||||||
radio_display_data[12] = digits[4] << 4 | digits[5];
|
radio_display_data[12] = digits[4] << 4 | digits[5];
|
||||||
radio_display_data[13] = digits[1] << 4 | digits[2];
|
radio_display_data[13] = digits[1] << 4 | digits[2];
|
||||||
radio_display_data[14] = 0xf0 | digits[0];
|
radio_display_data[14] = 0xf0 | digits[0];
|
||||||
|
|
||||||
// Nav1 in use frequency
|
// Nav1 in use frequency
|
||||||
float nav1 = nav1_freq->getFloatValue();
|
float nav1 = nav1_freq->getFloatValue();
|
||||||
if ( fabs(nav1) > 999.99 ) {
|
if ( fabs(nav1) > 999.99 ) {
|
||||||
nav1 = 0.0;
|
nav1 = 0.0;
|
||||||
|
}
|
||||||
|
snprintf(digits, 7, "%06.2f", nav1);
|
||||||
|
for ( i = 0; i < 6; ++i ) {
|
||||||
|
digits[i] -= '0';
|
||||||
|
}
|
||||||
|
radio_display_data[15] = digits[4] << 4 | digits[5];
|
||||||
|
radio_display_data[16] = digits[1] << 4 | digits[2];
|
||||||
|
radio_display_data[17] = 0x00 | digits[0];
|
||||||
|
// the 0x00 in the upper nibble of the 6th byte of each display
|
||||||
|
// turns on the decimal point
|
||||||
|
} else {
|
||||||
|
radio_display_data[12] = 0xff;
|
||||||
|
radio_display_data[13] = 0xff;
|
||||||
|
radio_display_data[14] = 0xff;
|
||||||
|
radio_display_data[15] = 0xff;
|
||||||
|
radio_display_data[16] = 0xff;
|
||||||
|
radio_display_data[17] = 0xff;
|
||||||
}
|
}
|
||||||
snprintf(digits, 7, "%06.2f", nav1);
|
|
||||||
for ( i = 0; i < 6; ++i ) {
|
|
||||||
digits[i] -= '0';
|
|
||||||
}
|
|
||||||
radio_display_data[15] = digits[4] << 4 | digits[5];
|
|
||||||
radio_display_data[16] = digits[1] << 4 | digits[2];
|
|
||||||
radio_display_data[17] = 0x00 | digits[0];
|
|
||||||
// the 0x00 in the upper nibble of the 6th byte of each display
|
|
||||||
// turns on the decimal point
|
|
||||||
|
|
||||||
// Nav2 standby frequency
|
if ( navcom2_power->getBoolValue() ) {
|
||||||
float nav2_stby = nav2_stby_freq->getFloatValue();
|
// Nav2 standby frequency
|
||||||
if ( fabs(nav2_stby) > 999.99 ) {
|
float nav2_stby = nav2_stby_freq->getFloatValue();
|
||||||
nav2_stby = 0.0;
|
if ( fabs(nav2_stby) > 999.99 ) {
|
||||||
}
|
nav2_stby = 0.0;
|
||||||
snprintf(digits, 7, "%06.2f", nav2_stby);
|
}
|
||||||
for ( i = 0; i < 6; ++i ) {
|
snprintf(digits, 7, "%06.2f", nav2_stby);
|
||||||
digits[i] -= '0';
|
for ( i = 0; i < 6; ++i ) {
|
||||||
}
|
digits[i] -= '0';
|
||||||
radio_display_data[24] = digits[4] << 4 | digits[5];
|
}
|
||||||
radio_display_data[25] = digits[1] << 4 | digits[2];
|
radio_display_data[24] = digits[4] << 4 | digits[5];
|
||||||
radio_display_data[26] = 0xf0 | digits[0];
|
radio_display_data[25] = digits[1] << 4 | digits[2];
|
||||||
|
radio_display_data[26] = 0xf0 | digits[0];
|
||||||
|
|
||||||
// Nav2 in use frequency
|
// Nav2 in use frequency
|
||||||
float nav2 = nav2_freq->getFloatValue();
|
float nav2 = nav2_freq->getFloatValue();
|
||||||
if ( fabs(nav2) > 999.99 ) {
|
if ( fabs(nav2) > 999.99 ) {
|
||||||
nav2 = 0.0;
|
nav2 = 0.0;
|
||||||
|
}
|
||||||
|
snprintf(digits, 7, "%06.2f", nav2);
|
||||||
|
for ( i = 0; i < 6; ++i ) {
|
||||||
|
digits[i] -= '0';
|
||||||
|
}
|
||||||
|
radio_display_data[27] = digits[4] << 4 | digits[5];
|
||||||
|
radio_display_data[28] = digits[1] << 4 | digits[2];
|
||||||
|
radio_display_data[29] = 0x00 | digits[0];
|
||||||
|
// the 0x00 in the upper nibble of the 6th byte of each display
|
||||||
|
// turns on the decimal point
|
||||||
|
} else {
|
||||||
|
radio_display_data[24] = 0xff;
|
||||||
|
radio_display_data[25] = 0xff;
|
||||||
|
radio_display_data[26] = 0xff;
|
||||||
|
radio_display_data[27] = 0xff;
|
||||||
|
radio_display_data[28] = 0xff;
|
||||||
|
radio_display_data[29] = 0xff;
|
||||||
}
|
}
|
||||||
snprintf(digits, 7, "%06.2f", nav2);
|
|
||||||
for ( i = 0; i < 6; ++i ) {
|
|
||||||
digits[i] -= '0';
|
|
||||||
}
|
|
||||||
radio_display_data[27] = digits[4] << 4 | digits[5];
|
|
||||||
radio_display_data[28] = digits[1] << 4 | digits[2];
|
|
||||||
radio_display_data[29] = 0x00 | digits[0];
|
|
||||||
// the 0x00 in the upper nibble of the 6th byte of each display
|
|
||||||
// turns on the decimal point
|
|
||||||
|
|
||||||
// ADF standby frequency / timer
|
// ADF standby frequency / timer
|
||||||
if ( adf_power->getBoolValue() ) {
|
if ( adf_power->getBoolValue() ) {
|
||||||
|
|
|
@ -73,6 +73,7 @@ class FGATC610x : public FGProtocol {
|
||||||
|
|
||||||
SGPropertyNode *mag_compass;
|
SGPropertyNode *mag_compass;
|
||||||
SGPropertyNode *dme_min, *dme_kt, *dme_nm;
|
SGPropertyNode *dme_min, *dme_kt, *dme_nm;
|
||||||
|
SGPropertyNode *navcom1_power, *navcom2_power;
|
||||||
SGPropertyNode *com1_freq, *com1_stby_freq;
|
SGPropertyNode *com1_freq, *com1_stby_freq;
|
||||||
SGPropertyNode *com2_freq, *com2_stby_freq;
|
SGPropertyNode *com2_freq, *com2_stby_freq;
|
||||||
SGPropertyNode *nav1_freq, *nav1_stby_freq;
|
SGPropertyNode *nav1_freq, *nav1_stby_freq;
|
||||||
|
|
Loading…
Add table
Reference in a new issue