1
0
Fork 0

Various tweaks and fixes to navcom radios.

Oops, taking the address of a temporary in main.cxx: 3dcloud rendering.
This commit is contained in:
curt 2002-09-23 18:44:09 +00:00
parent 5eef7d7ad1
commit 29e72b0b90
7 changed files with 507 additions and 508 deletions

View file

@ -70,18 +70,20 @@ FGNavCom::FGNavCom() :
lon_node(fgGetNode("/position/longitude-deg", true)),
lat_node(fgGetNode("/position/latitude-deg", true)),
alt_node(fgGetNode("/position/altitude-ft", true)),
last_nav_ident(""),
last_nav_id(""),
last_nav_vor(false),
nav_play_count(0),
nav_last_time(0),
need_update(true),
power_btn(true),
comm_freq(0.0),
comm_alt_freq(0.0),
comm_vol_btn(0.0),
nav_freq(0.0),
nav_alt_freq(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 term = path;
@ -124,6 +126,11 @@ FGNavCom::bind ()
char propname[256];
// 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 );
fgTie( propname, this, &FGNavCom::get_comm_freq, &FGNavCom::set_comm_freq );
fgSetArchivable( propname );
@ -138,11 +145,6 @@ FGNavCom::bind ()
&FGNavCom::get_comm_vol_btn, &FGNavCom::set_comm_vol_btn );
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 );
fgTie( propname, this,
&FGNavCom::get_nav_freq, &FGNavCom::set_nav_freq );
@ -194,14 +196,12 @@ FGNavCom::unbind ()
{
char propname[256];
sprintf( propname, "/radios/comm[%d]/inputs/power-btn", index );
fgUntie( propname );
sprintf( propname, "/radios/comm[%d]/frequencies/selected-mhz", index );
fgUntie( propname );
sprintf( propname, "/radios/comm[%d]/frequencies/standby-mhz", index );
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 );
fgUntie( propname );
@ -211,8 +211,6 @@ FGNavCom::unbind ()
fgUntie( propname );
sprintf( propname, "/radios/nav[%d]/radials/selected-deg", index );
fgUntie( propname );
sprintf( propname, "/radios/nav[%d]/on", index );
fgUntie( propname );
sprintf( propname, "/radios/nav[%d]/ident", index );
fgUntie( propname );
sprintf( propname, "/radios/nav[%d]/to-flag", index );
@ -308,7 +306,7 @@ FGNavCom::update(double dt)
// Nav.
////////////////////////////////////////////////////////////////////////
if ( nav_valid ) {
if ( nav_valid && power_btn ) {
station = Point3D( nav_x, nav_y, nav_z );
nav_loc_dist = aircraft.distance3D( station );
@ -363,7 +361,7 @@ FGNavCom::update(double dt)
if ( nav_valid && nav_inrange ) {
// play station ident via audio system if on + ident,
// otherwise turn it off
if ( nav_vol_btn > 0.1 && nav_ident_btn ) {
if ( power_btn && nav_ident_btn ) {
FGSimpleSound *sound;
sound = globals->get_soundmgr()->find( nav_fx_name );
if ( sound != NULL ) {
@ -429,11 +427,11 @@ void FGNavCom::search()
////////////////////////////////////////////////////////////////////////
if ( current_ilslist->query( lon, lat, elev, nav_freq, &ils ) ) {
nav_ident = ils.get_locident();
nav_id = ils.get_locident();
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();
last_nav_ident = nav_ident;
last_nav_id = nav_id;
last_nav_vor = false;
nav_loc = true;
nav_has_dme = ils.get_has_dme();
@ -489,10 +487,10 @@ void FGNavCom::search()
// cout << " id = " << ils.get_locident() << endl;
}
} else if ( current_navlist->query( lon, lat, elev, nav_freq, &nav ) ) {
nav_ident = nav.get_ident();
nav_id = nav.get_ident();
nav_valid = true;
if ( last_nav_ident != nav_ident || !last_nav_vor ) {
last_nav_ident = nav_ident;
if ( last_nav_id != nav_id || !last_nav_vor ) {
last_nav_id = nav_id;
last_nav_vor = true;
nav_trans_ident = nav.get_trans_ident();
nav_loc = false;
@ -545,10 +543,10 @@ void FGNavCom::search()
}
} else {
nav_valid = false;
nav_ident = "";
nav_id = "";
nav_radial = 0;
nav_trans_ident = "";
last_nav_ident = "";
last_nav_id = "";
#ifdef ENABLE_AUDIO_SUPPORT
if ( ! globals->get_soundmgr()->remove( nav_fx_name ) ) {
cout << "Failed to remove nav-vor-ident sound" << endl;

View file

@ -51,7 +51,7 @@ class FGNavCom : public FGSubsystem
SGPropertyNode *lat_node;
SGPropertyNode *alt_node;
string last_nav_ident;
string last_nav_id;
bool last_nav_vor;
int nav_play_count;
time_t nav_last_time;
@ -62,7 +62,8 @@ class FGNavCom : public FGSubsystem
bool need_update;
string comm_ident;
bool power_btn;
bool comm_valid;
bool comm_inrange;
double comm_freq;
@ -77,7 +78,7 @@ class FGNavCom : public FGSubsystem
double comm_range;
double comm_effective_range;
string nav_ident;
string nav_id;
string nav_trans_ident;
bool nav_valid;
bool nav_inrange;
@ -138,6 +139,12 @@ public:
sprintf( dme_fx_name, "dme%d-vor-ident", index );
}
// NavCom Setters
inline void set_power_btn( bool val ) {
power_btn = val;
}
// COMM Setters
inline void set_comm_freq( double freq ) {
comm_freq = freq; need_update = true;
@ -165,6 +172,9 @@ public:
}
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
inline double get_comm_freq () const { return comm_freq; }
inline double get_comm_alt_freq () const { return comm_alt_freq; }

View file

@ -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
void
FGRadioStack::update(double dt)
@ -287,46 +225,48 @@ FGRadioStack::update(double dt)
// DME.
////////////////////////////////////////////////////////////////////////
if (dme_valid) {
if ( dme_valid ) {
station = Point3D( dme_x, dme_y, dme_z );
dme_dist = aircraft.distance3D( station ) * SG_METER_TO_NM;
dme_effective_range = kludgeRange(dme_elev, elev, dme_range);
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) {
dme_inrange = sg_random() <
(2 * dme_effective_range * SG_NM_TO_METER - dme_dist) /
(dme_effective_range * SG_NM_TO_METER);
dme_inrange = sg_random() <
(2 * dme_effective_range * SG_NM_TO_METER - dme_dist) /
(dme_effective_range * SG_NM_TO_METER);
} else {
dme_inrange = false;
dme_inrange = false;
}
if (dme_inrange) {
SGTimeStamp current_time;
station = Point3D( dme_x, dme_y, dme_z );
dme_dist = aircraft.distance3D( station ) * SG_METER_TO_NM;
current_time.stamp();
long dMs = (current_time - dme_last_time) / 1000;
if ( dme_inrange ) {
SGTimeStamp current_time;
station = Point3D( dme_x, dme_y, dme_z );
dme_dist = aircraft.distance3D( station ) * SG_METER_TO_NM;
current_time.stamp();
long dMs = (current_time - dme_last_time) / 1000;
// Update every second
if (dMs >= 1000) {
double dDist = dme_dist - dme_prev_dist;
dme_spd = fabs((dDist/dMs) * 3600000);
if (dMs >= 1000) {
double dDist = dme_dist - dme_prev_dist;
dme_spd = fabs((dDist/dMs) * 3600000);
// FIXME: the panel should be able to
// handle this!!!
if (dme_spd > 999.0)
dme_spd = 999.0;
dme_ete = fabs((dme_dist/dme_spd) * 60.0);
if (dme_spd > 999.0)
dme_spd = 999.0;
dme_ete = fabs((dme_dist/dme_spd) * 60.0);
// FIXME: the panel should be able to
// handle this!!!
if (dme_ete > 99.0)
dme_ete = 99.0;
dme_prev_dist = dme_dist;
dme_last_time.stamp();
}
if (dme_ete > 99.0)
dme_ete = 99.0;
dme_prev_dist = dme_dist;
dme_last_time.stamp();
}
}
} else {
dme_inrange = false;
dme_dist = 0.0;
dme_prev_dist = 0.0;
dme_inrange = false;
dme_dist = 0.0;
dme_prev_dist = 0.0;
dme_spd = 0.0;
dme_ete = 0.0;
}
// marker beacon blinking
@ -380,19 +320,19 @@ void FGRadioStack::search()
// don't worry about overhead for now,
// since this is handled only periodically
int dme_switch_pos = fgGetInt("/radios/dme/switch-position");
if (dme_switch_pos == 0) {
dme_freq = 0;
dme_inrange = false;
} else if (dme_switch_pos == 1) {
if (dme_freq != navcom1.get_nav_freq()) {
dme_freq = navcom1.get_nav_freq();
need_update = true;
}
} else if (dme_switch_pos == 3) {
if (dme_freq != navcom2.get_nav_freq()) {
dme_freq = navcom2.get_nav_freq();
need_update = true;
}
if ( dme_switch_pos == 1 && navcom1.get_power_btn() ) {
if ( dme_freq != navcom1.get_nav_freq() ) {
dme_freq = navcom1.get_nav_freq();
need_update = true;
}
} else if ( dme_switch_pos == 3 && navcom2.get_power_btn() ) {
if ( dme_freq != navcom2.get_nav_freq() ) {
dme_freq = navcom2.get_nav_freq();
need_update = true;
}
} else {
dme_freq = 0;
dme_inrange = false;
}
FGILS ils;

View file

@ -88,14 +88,6 @@ class FGRadioStack : public FGSubsystem
FGNavCom navcom1;
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:
FGRadioStack();

View file

@ -499,8 +499,8 @@ void fgRenderFrame() {
glEnable(GL_BLEND);
glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ) ;
if ( _bcloud_orig ) {
sgClouds3d->Set_Cloud_Orig( &(globals->get_scenery()->
get_center()) );
Point3D c = globals->get_scenery()->get_center();
sgClouds3d->Set_Cloud_Orig( &c );
_bcloud_orig = false;
}
sgClouds3d->Update( current__view->get_absolute_view_pos() );

View file

@ -398,9 +398,13 @@ bool FGATC610x::open() {
dme_kt = fgGetNode( "/radios/dme/speed-kt", 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_stby_freq
= fgGetNode( "/radios/comm[0]/frequencies/standby-mhz", true );
com2_freq = fgGetNode( "/radios/comm[1]/frequencies/selected-mhz", true );
com2_stby_freq
= fgGetNode( "/radios/comm[1]/frequencies/standby-mhz", true );
@ -666,328 +670,346 @@ bool FGATC610x::do_radio_switches() {
fgSetInt( "/radios/dme/switch-position", 3 );
}
// Com1 Power
// NavCom1 Power
fgSetBool( "/radios/comm[0]/inputs/power-btn",
radio_switch_data[7] & 0x01 );
// Com1 Swap
int com1_swap = !((radio_switch_data[7] >> 1) & 0x01);
static int last_com1_swap;
if ( com1_swap && (last_com1_swap != com1_swap) ) {
float tmp = com1_freq->getFloatValue();
fgSetFloat( "/radios/comm[0]/frequencies/selected-mhz",
com1_stby_freq->getFloatValue() );
fgSetFloat( "/radios/comm[0]/frequencies/standby-mhz", tmp );
if ( navcom1_power->getBoolValue() ) {
// Com1 Swap
int com1_swap = !((radio_switch_data[7] >> 1) & 0x01);
static int last_com1_swap;
if ( com1_swap && (last_com1_swap != com1_swap) ) {
float tmp = com1_freq->getFloatValue();
fgSetFloat( "/radios/comm[0]/frequencies/selected-mhz",
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",
radio_switch_data[15] & 0x01 );
// Com2 Swap
int com2_swap = !((radio_switch_data[15] >> 1) & 0x01);
static int last_com2_swap;
if ( com2_swap && (last_com2_swap != com2_swap) ) {
float tmp = com2_freq->getFloatValue();
fgSetFloat( "/radios/comm[1]/frequencies/selected-mhz",
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;
}
if ( navcom2_power->getBoolValue() ) {
// Com2 Swap
int com2_swap = !((radio_switch_data[15] >> 1) & 0x01);
static int last_com2_swap;
if ( com2_swap && (last_com2_swap != com2_swap) ) {
float tmp = com2_freq->getFloatValue();
fgSetFloat( "/radios/comm[1]/frequencies/selected-mhz",
com2_stby_freq->getFloatValue() );
fgSetFloat( "/radios/comm[1]/frequencies/standby-mhz", tmp );
}
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 ) {
diff = com1_tuner_coarse - last_com1_tuner_coarse;
if ( abs(diff) > 4 ) {
// roll over
if ( com1_tuner_coarse < last_com1_tuner_coarse ) {
// going up
diff = 12 - last_com1_tuner_coarse + com1_tuner_coarse;
} else {
// going down
diff = com1_tuner_coarse - 12 - last_com1_tuner_coarse;
}
if ( navcom1_power->getBoolValue() ) {
// 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 );
}
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;
last_com1_tuner_coarse = com1_tuner_coarse;
fgSetFloat( "/radios/comm[0]/frequencies/standby-mhz",
coarse_freq + fine_freq / 40.0 );
// Com2 Tuner
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;
}
if ( navcom2_power->getBoolValue() ) {
// 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 );
}
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 ) {
diff = com2_tuner_coarse - last_com2_tuner_coarse;
if ( abs(diff) > 4 ) {
// roll over
if ( com2_tuner_coarse < last_com2_tuner_coarse ) {
// going up
diff = 12 - last_com2_tuner_coarse + com2_tuner_coarse;
} else {
// going down
diff = com2_tuner_coarse - 12 - last_com2_tuner_coarse;
if ( navcom1_power->getBoolValue() ) {
// 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;
}
coarse_freq += diff;
}
if ( coarse_freq < 118.0 ) { coarse_freq += 19.0; }
if ( coarse_freq > 136.0 ) { coarse_freq -= 19.0; }
while ( fine_freq >= 40.0 ) { fine_freq -= 40.0; }
while ( fine_freq < 0.0 ) { fine_freq += 40.0; }
last_com2_tuner_fine = com2_tuner_fine;
last_com2_tuner_coarse = com2_tuner_coarse;
fgSetFloat( "/radios/comm[1]/frequencies/standby-mhz",
coarse_freq + fine_freq / 40.0 );
// Nav1 Tuner
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;
if ( com1_tuner_coarse != last_com1_tuner_coarse ) {
diff = com1_tuner_coarse - last_com1_tuner_coarse;
if ( abs(diff) > 4 ) {
// roll over
if ( com1_tuner_coarse < last_com1_tuner_coarse ) {
// going up
diff = 12 - last_com1_tuner_coarse + com1_tuner_coarse;
} else {
// going down
diff = com1_tuner_coarse - 12 - last_com1_tuner_coarse;
}
}
coarse_freq += diff;
}
fine_freq += diff;
}
while ( fine_freq >= 20.0 ) { fine_freq -= 20.0; }
while ( fine_freq < 0.0 ) { fine_freq += 20.0; }
if ( coarse_freq < 118.0 ) { coarse_freq += 19.0; }
if ( coarse_freq > 136.0 ) { coarse_freq -= 19.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;
last_com1_tuner_fine = com1_tuner_fine;
last_com1_tuner_coarse = com1_tuner_coarse;
fgSetFloat( "/radios/comm[0]/frequencies/standby-mhz",
coarse_freq + fine_freq / 40.0 );
}
if ( navcom2_power->getBoolValue() ) {
// Com2 Tuner
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;
}
if ( coarse_freq < 108.0 ) { coarse_freq += 10.0; }
if ( coarse_freq > 117.0 ) { coarse_freq -= 10.0; }
while ( fine_freq >= 40.0 ) { fine_freq -= 40.0; }
while ( fine_freq < 0.0 ) { fine_freq += 40.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 );
// 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;
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;
if ( com2_tuner_coarse != last_com2_tuner_coarse ) {
diff = com2_tuner_coarse - last_com2_tuner_coarse;
if ( abs(diff) > 4 ) {
// roll over
if ( com2_tuner_coarse < last_com2_tuner_coarse ) {
// going up
diff = 12 - last_com2_tuner_coarse + com2_tuner_coarse;
} else {
// going down
diff = com2_tuner_coarse - 12 - last_com2_tuner_coarse;
}
}
coarse_freq += diff;
}
fine_freq += diff;
}
while ( fine_freq >= 20.0 ) { fine_freq -= 20.0; }
while ( fine_freq < 0.0 ) { fine_freq += 20.0; }
if ( coarse_freq < 118.0 ) { coarse_freq += 19.0; }
if ( coarse_freq > 136.0 ) { coarse_freq -= 19.0; }
if ( nav2_tuner_coarse != last_nav2_tuner_coarse ) {
diff = nav2_tuner_coarse - last_nav2_tuner_coarse;
if ( abs(diff) > 4 ) {
// roll over
if ( nav2_tuner_coarse < last_nav2_tuner_coarse ) {
// going up
diff = 12 - last_nav2_tuner_coarse + nav2_tuner_coarse;
} else {
// going down
diff = nav2_tuner_coarse - 12 - last_nav2_tuner_coarse;
last_com2_tuner_fine = com2_tuner_fine;
last_com2_tuner_coarse = com2_tuner_coarse;
fgSetFloat( "/radios/comm[1]/frequencies/standby-mhz",
coarse_freq + fine_freq / 40.0 );
}
if ( navcom1_power->getBoolValue() ) {
// Nav1 Tuner
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;
last_nav2_tuner_coarse = nav2_tuner_coarse;
if ( navcom2_power->getBoolValue() ) {
// 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",
coarse_freq + fine_freq / 20.0);
freq = nav2_stby_freq->getFloatValue();
coarse_freq = (int)freq;
fine_freq = (int)((freq - coarse_freq) * 20 + 0.5);
// 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;
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;
}
}
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 ( adf_count_mode->getIntValue() == 2 ) {
// tune count down timer
value = adf_elapsed_timer->getDoubleValue();
} else {
// tune frequency
if ( adf_stby_mode->getIntValue() == 1 ) {
value = adf_freq->getFloatValue();
if ( nav2_tuner_coarse != last_nav2_tuner_coarse ) {
diff = nav2_tuner_coarse - last_nav2_tuner_coarse;
if ( abs(diff) > 4 ) {
// roll over
if ( nav2_tuner_coarse < last_nav2_tuner_coarse ) {
// going up
diff = 12 - last_nav2_tuner_coarse + nav2_tuner_coarse;
} 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 {
value = adf_stby_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;
// tune frequency
if ( adf_stby_mode->getIntValue() == 1 ) {
value = adf_freq->getFloatValue();
} else {
// going down
diff = adf_tuner_fine - 12 - last_adf_tuner_fine;
value = adf_stby_freq->getFloatValue();
}
}
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;
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 {
// 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 {
// going down
diff = adf_tuner_coarse - 12 - last_adf_tuner_coarse;
value += 25 * diff;
}
}
if ( adf_count_mode->getIntValue() == 2 ) {
value += 60 * diff;
if ( value < 0 ) { value += 3600; }
if ( value > 3599 ) { value -= 3600; }
} 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_coarse = adf_tuner_coarse;
last_adf_tuner_fine = adf_tuner_fine;
last_adf_tuner_coarse = adf_tuner_coarse;
if ( adf_count_mode->getIntValue() == 2 ) {
fgSetFloat( "/radios/kr-87/outputs/elapsed-timer", value );
} else {
if ( adf_stby_mode->getIntValue() == 1 ) {
fgSetFloat( "/radios/kr-87/outputs/selected-khz", value );
if ( adf_count_mode->getIntValue() == 2 ) {
fgSetFloat( "/radios/kr-87/outputs/elapsed-timer", value );
} 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",
(radio_switch_data[23] >> 2 & 0x01) );
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",
!(radio_switch_data[23] >> 4 & 0x01) );
fgSetInt( "/radios/kr-87/inputs/power-btn",
@ -1130,117 +1152,153 @@ bool FGATC610x::do_radio_display() {
}
}
// Com1 standby frequency
float com1_stby = com1_stby_freq->getFloatValue();
if ( fabs(com1_stby) > 999.99 ) {
com1_stby = 0.0;
}
snprintf(digits, 7, "%06.3f", com1_stby);
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[8] = 0xf0 | digits[0];
if ( navcom1_power->getBoolValue() ) {
// Com1 standby frequency
float com1_stby = com1_stby_freq->getFloatValue();
if ( fabs(com1_stby) > 999.99 ) {
com1_stby = 0.0;
}
snprintf(digits, 7, "%06.3f", com1_stby);
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[8] = 0xf0 | digits[0];
// Com1 in use frequency
float com1 = com1_freq->getFloatValue();
if ( fabs(com1) > 999.99 ) {
com1 = 0.0;
// Com1 in use frequency
float com1 = com1_freq->getFloatValue();
if ( fabs(com1) > 999.99 ) {
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
float com2_stby = com2_stby_freq->getFloatValue();
if ( fabs(com2_stby) > 999.99 ) {
com2_stby = 0.0;
}
snprintf(digits, 7, "%06.3f", com2_stby);
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[20] = 0xf0 | digits[0];
if ( navcom2_power->getBoolValue() ) {
// Com2 standby frequency
float com2_stby = com2_stby_freq->getFloatValue();
if ( fabs(com2_stby) > 999.99 ) {
com2_stby = 0.0;
}
snprintf(digits, 7, "%06.3f", com2_stby);
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[20] = 0xf0 | digits[0];
// Com2 in use frequency
float com2 = com2_freq->getFloatValue();
if ( fabs(com2) > 999.99 ) {
// Com2 in use frequency
float com2 = com2_freq->getFloatValue();
if ( fabs(com2) > 999.99 ) {
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
float nav1_stby = nav1_stby_freq->getFloatValue();
if ( fabs(nav1_stby) > 999.99 ) {
if ( navcom1_power->getBoolValue() ) {
// Nav1 standby frequency
float nav1_stby = nav1_stby_freq->getFloatValue();
if ( fabs(nav1_stby) > 999.99 ) {
nav1_stby = 0.0;
}
snprintf(digits, 7, "%06.2f", nav1_stby);
for ( i = 0; i < 6; ++i ) {
digits[i] -= '0';
}
radio_display_data[12] = digits[4] << 4 | digits[5];
radio_display_data[13] = digits[1] << 4 | digits[2];
radio_display_data[14] = 0xf0 | digits[0];
}
snprintf(digits, 7, "%06.2f", nav1_stby);
for ( i = 0; i < 6; ++i ) {
digits[i] -= '0';
}
radio_display_data[12] = digits[4] << 4 | digits[5];
radio_display_data[13] = digits[1] << 4 | digits[2];
radio_display_data[14] = 0xf0 | digits[0];
// Nav1 in use frequency
float nav1 = nav1_freq->getFloatValue();
if ( fabs(nav1) > 999.99 ) {
nav1 = 0.0;
// Nav1 in use frequency
float nav1 = nav1_freq->getFloatValue();
if ( fabs(nav1) > 999.99 ) {
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
float nav2_stby = nav2_stby_freq->getFloatValue();
if ( fabs(nav2_stby) > 999.99 ) {
nav2_stby = 0.0;
}
snprintf(digits, 7, "%06.2f", nav2_stby);
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[26] = 0xf0 | digits[0];
if ( navcom2_power->getBoolValue() ) {
// Nav2 standby frequency
float nav2_stby = nav2_stby_freq->getFloatValue();
if ( fabs(nav2_stby) > 999.99 ) {
nav2_stby = 0.0;
}
snprintf(digits, 7, "%06.2f", nav2_stby);
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[26] = 0xf0 | digits[0];
// Nav2 in use frequency
float nav2 = nav2_freq->getFloatValue();
if ( fabs(nav2) > 999.99 ) {
nav2 = 0.0;
// Nav2 in use frequency
float nav2 = nav2_freq->getFloatValue();
if ( fabs(nav2) > 999.99 ) {
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
if ( adf_power->getBoolValue() ) {

View file

@ -73,6 +73,7 @@ class FGATC610x : public FGProtocol {
SGPropertyNode *mag_compass;
SGPropertyNode *dme_min, *dme_kt, *dme_nm;
SGPropertyNode *navcom1_power, *navcom2_power;
SGPropertyNode *com1_freq, *com1_stby_freq;
SGPropertyNode *com2_freq, *com2_stby_freq;
SGPropertyNode *nav1_freq, *nav1_stby_freq;