From 1ad71dbbe07ae3814fbaa1ce541de520054665d8 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 19 Jan 2005 02:11:28 +0000 Subject: [PATCH] Add some formated frequency outputs to aid panel builders. --- src/Instrumentation/navradio.cxx | 18 ++++++++++++++++++ src/Instrumentation/navradio.hxx | 10 +++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Instrumentation/navradio.cxx b/src/Instrumentation/navradio.cxx index fe586b3e9..1960cad28 100644 --- a/src/Instrumentation/navradio.cxx +++ b/src/Instrumentation/navradio.cxx @@ -57,6 +57,8 @@ FGNavRadio::FGNavRadio(SGPropertyNode *node) : audio_btn(true), nav_freq(0.0), nav_alt_freq(0.0), + fmt_freq(""), + fmt_alt_freq(""), nav_heading(0.0), nav_radial(0.0), nav_target_radial(0.0), @@ -161,6 +163,14 @@ FGNavRadio::bind () &FGNavRadio::get_nav_alt_freq, &FGNavRadio::set_nav_alt_freq); fgSetArchivable( (branch + "/frequencies/standby-mhz").c_str() ); + fgTie( (branch + "/frequencies/selected-mhz-fmt").c_str() , this, + &FGNavRadio::get_fmt_freq, &FGNavRadio::set_fmt_freq ); + fgSetArchivable( (branch + "/frequencies/selected-mhz-fmt").c_str() ); + + fgTie( (branch + "/frequencies/standby-mhz-fmt").c_str() , this, + &FGNavRadio::get_fmt_alt_freq, &FGNavRadio::set_fmt_alt_freq); + fgSetArchivable( (branch + "/frequencies/standby-mhz-fmt").c_str() ); + fgTie( (branch + "/radials/selected-deg").c_str() , this, &FGNavRadio::get_nav_sel_radial, &FGNavRadio::set_nav_sel_radial ); fgSetArchivable((branch + "/radials/selected-deg").c_str() ); @@ -344,6 +354,14 @@ FGNavRadio::update(double dt) Point3D station; double az1, az2, s; + // Create "formatted" versions of the nav frequencies for + // consistant display output. + char tmp[16]; + sprintf( tmp, "%.2f", nav_freq ); + fmt_freq = tmp; + sprintf( tmp, "%.2f", nav_alt_freq ); + fmt_alt_freq = tmp; + // On timeout, scan again _time_before_search_sec -= dt; if ( _time_before_search_sec < 0 ) { diff --git a/src/Instrumentation/navradio.hxx b/src/Instrumentation/navradio.hxx index b75c5aa15..61072d06a 100644 --- a/src/Instrumentation/navradio.hxx +++ b/src/Instrumentation/navradio.hxx @@ -73,6 +73,8 @@ class FGNavRadio : public SGSubsystem bool nav_loc; double nav_freq; double nav_alt_freq; + string fmt_freq; // formated frequency + string fmt_alt_freq; // formated alternate frequency double nav_heading; // true heading to nav station double nav_radial; // current radial we are on (taking // into consideration the vor station @@ -152,7 +154,9 @@ public: inline void set_nav_freq( double freq ) { nav_freq = freq; need_update = true; } + inline void set_fmt_freq( const char *freq ) { fmt_freq = freq; } inline void set_nav_alt_freq( double freq ) { nav_alt_freq = freq; } + inline void set_fmt_alt_freq( const char *freq ) { fmt_alt_freq = freq; } inline void set_nav_sel_radial( double radial ) { nav_sel_radial = radial; need_update = true; } @@ -170,9 +174,13 @@ public: inline bool get_power_btn() const { return power_btn; } inline bool get_audio_btn() const { return audio_btn; } - // NAV Accessors + // NAV Accessors inline double get_nav_freq () const { return nav_freq; } + inline const char *get_fmt_freq () const { return fmt_freq.c_str(); } inline double get_nav_alt_freq () const { return nav_alt_freq; } + inline const char *get_fmt_alt_freq () const { + return fmt_alt_freq.c_str(); + } inline double get_nav_sel_radial() const { return nav_sel_radial; } inline double get_nav_target_radial() const { return nav_target_radial; } inline double get_nav_target_radial_true() const {