X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCockpit%2Fkr_87.cxx;h=67a0586dbf341ae13d53f58ab928e8525f079cc2;hb=f38c88b762bc6c317669e8e0b00a92b09ee4671a;hp=b3242099d4febaf673fdf6d95b6bf407576c0105;hpb=ebb180f09439914d0412814c163adbc5897c2e24;p=flightgear.git diff --git a/src/Cockpit/kr_87.cxx b/src/Cockpit/kr_87.cxx index b3242099d..67a0586db 100644 --- a/src/Cockpit/kr_87.cxx +++ b/src/Cockpit/kr_87.cxx @@ -73,6 +73,7 @@ FGKR_87::FGKR_87() : lon_node(fgGetNode("/position/longitude-deg", true)), lat_node(fgGetNode("/position/latitude-deg", true)), alt_node(fgGetNode("/position/altitude-ft", true)), + bus_power(fgGetNode("/systems/electrical/outputs/adf", true)), need_update(true), valid(false), inrange(false), @@ -85,7 +86,8 @@ FGKR_87::FGKR_87() : timer_mode(0), count_mode(0), rotation(0), - on_off_vol_btn(0.5), + power_btn(true), + vol_btn(0.5), adf_btn(true), bfo_btn(false), frq_btn(false), @@ -102,32 +104,16 @@ FGKR_87::FGKR_87() : elapsed_timer(0.0), tmp_timer(0.0) { - SGPath path( globals->get_fg_root() ); - SGPath term = path; - term.append( "Navaids/range.term" ); - SGPath low = path; - low.append( "Navaids/range.low" ); - SGPath high = path; - high.append( "Navaids/range.high" ); - - term_tbl = new SGInterpTable( term.str() ); - low_tbl = new SGInterpTable( low.str() ); - high_tbl = new SGInterpTable( high.str() ); } // Destructor FGKR_87::~FGKR_87() { - delete term_tbl; - delete low_tbl; - delete high_tbl; } void FGKR_87::init () { morse.init(); - - update(0); // FIXME: use dt } @@ -152,10 +138,14 @@ void FGKR_87::bind () { fgTie("/radios/kr-87/inputs/rotation-deg", this, &FGKR_87::get_rotation, &FGKR_87::set_rotation); fgSetArchivable("/radios/kr-87/inputs/rotation-deg"); - fgTie("/radios/kr-87/inputs/on-off-volume", this, - &FGKR_87::get_on_off_vol_btn, - &FGKR_87::set_on_off_vol_btn); - fgSetArchivable("/radios/kr-87/inputs/on-off-volume"); + fgTie("/radios/kr-87/inputs/power-btn", this, + &FGKR_87::get_power_btn, + &FGKR_87::set_power_btn); + fgSetArchivable("/radios/kr-87/inputs/power-btn"); + fgTie("/radios/kr-87/inputs/volume", this, + &FGKR_87::get_vol_btn, + &FGKR_87::set_vol_btn); + fgSetArchivable("/radios/kr-87/inputs/volume"); fgTie("/radios/kr-87/inputs/adf-btn", this, &FGKR_87::get_adf_btn, &FGKR_87::set_adf_btn); @@ -213,7 +203,8 @@ void FGKR_87::unbind () { // input and buttons fgUntie("/radios/kr-87/inputs/rotation-deg"); - fgUntie("/radios/kr-87/inputs/on-off-volume"); + fgUntie("/radios/kr-87/inputs/power-btn"); + fgUntie("/radios/kr-87/inputs/volume"); fgUntie("/radios/kr-87/inputs/adf-btn"); fgUntie("/radios/kr-87/inputs/bfo-btn"); fgUntie("/radios/kr-87/inputs/frq-btn"); @@ -254,7 +245,7 @@ void FGKR_87::update( double dt ) { // Radio //////////////////////////////////////////////////////////////////////// - if ( on_off_vol_btn >= 0.01 ) { + if ( has_power() ) { // buttons if ( adf_btn == 0 ) { ant_mode = 1; @@ -397,7 +388,39 @@ void FGKR_87::update( double dt ) { et_ann = false; } - + // formatted timer + double time; + int hours, min, sec; + if ( timer_mode == 0 ) { + time = flight_timer; + } else { + time = elapsed_timer; + } + // cout << time << endl; + hours = (int)(time / 3600.0); + time -= hours * 3600.00; + min = (int)(time / 60.0); + time -= min * 60.0; + sec = (int)time; + int big, little; + if ( hours > 0 ) { + big = hours; + if ( big > 99 ) { + big = 99; + } + little = min; + } else { + big = min; + little = sec; + } + if ( big > 99 ) { + big = 99; + } + char formatted_timer[128]; + // cout << big << ":" << little << endl; + snprintf(formatted_timer, 6, "%02d:%02d", big, little); + fgSetString( "/radios/kr-87/outputs/timer-string", formatted_timer ); + while ( goal_needle_deg < 0.0 ) { goal_needle_deg += 360.0; } while ( goal_needle_deg >= 360.0 ) { goal_needle_deg -= 360.0; } @@ -418,11 +441,11 @@ void FGKR_87::update( double dt ) { if ( valid && inrange ) { // play station ident via audio system if on + ident_btn, // otherwise turn it off - if ( on_off_vol_btn >= 0.01 && ident_btn ) { + if ( vol_btn >= 0.01 && ident_btn ) { FGSimpleSound *sound; sound = globals->get_soundmgr()->find( "adf-ident" ); if ( sound != NULL ) { - sound->set_volume( on_off_vol_btn ); + sound->set_volume( vol_btn ); } else { SG_LOG( SG_COCKPIT, SG_ALERT, "Can't find adf-ident sound" ); }