From: Dave Luff Date: Thu, 9 Dec 2010 23:32:55 +0000 (+0000) Subject: KLN89: Move units configuration out of dclgps and into KLN89 X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d73a3cd207176f8d842d1a0036d4fd40c0cfb2b8;p=flightgear.git KLN89: Move units configuration out of dclgps and into KLN89 --- diff --git a/src/Instrumentation/KLN89/kln89.cxx b/src/Instrumentation/KLN89/kln89.cxx index 0edc38924..0824d947c 100644 --- a/src/Instrumentation/KLN89/kln89.cxx +++ b/src/Instrumentation/KLN89/kln89.cxx @@ -199,6 +199,16 @@ KLN89::KLN89(RenderArea2D* instrument) _dto = false; _fullLegMode = true; _obsHeading = 215; + + // User-settable configuration. Eventually this should be user-achivable in order that settings can be persistent between sessions. + _altUnits = GPS_ALT_UNITS_FT; + _baroUnits = GPS_PRES_UNITS_IN; + _velUnits = GPS_VEL_UNITS_KT; + _distUnits = GPS_DIST_UNITS_NM; + _suaAlertEnabled = false; + _altAlertEnabled = false; + _minDisplayBrightness = 4; + _defaultFirstChar = 'A'; if(_baroUnits == GPS_PRES_UNITS_IN) { _userBaroSetting = 2992; @@ -232,12 +242,6 @@ KLN89::KLN89(RenderArea2D* instrument) _mapScaleIndex = 7; // I think that the above is more accurate for no-flightplan default, but this is more sane for initial testing! _mapScaleAuto = true; - // Configuration. Eventually this may be user-achivable in order that settings can be persistent between sessions. - _suaAlertEnabled = false; - _altAlertEnabled = false; - _minDisplayBrightness = 4; - _defaultFirstChar = 'A'; - // Mega-hack - hardwire airport town and state names for the FG base area since we don't have any data for these at the moment // TODO - do this better one day! _airportTowns["KSFO"] = "San Francisco"; @@ -462,6 +466,16 @@ void KLN89::CreateDefaultFlightPlans() { */ } +void KLN89::SetBaroUnits(int n, bool wrap) { + if(n < 1) { + _baroUnits = (KLN89PressureUnits)(wrap ? 3 : 1); + } else if(n > 3) { + _baroUnits = (KLN89PressureUnits)(wrap ? 1 : 3); + } else { + _baroUnits = (KLN89PressureUnits)n; + } +} + void KLN89::Knob1Right1() { if(_mode == KLN89_MODE_DISP) { _activePage->LooseFocus(); diff --git a/src/Instrumentation/KLN89/kln89.hxx b/src/Instrumentation/KLN89/kln89.hxx index 1d7ec3d0c..b84d6efdc 100644 --- a/src/Instrumentation/KLN89/kln89.hxx +++ b/src/Instrumentation/KLN89/kln89.hxx @@ -41,6 +41,27 @@ enum KLN89Mode { KLN89_MODE_CRSR }; +enum KLN89DistanceUnits { + GPS_DIST_UNITS_NM = 0, + GPS_DIST_UNITS_KM +}; + +enum KLN89SpeedUnits { + GPS_VEL_UNITS_KT, + GPS_VEL_UNITS_KPH +}; + +enum KLN89AltitudeUnits { + GPS_ALT_UNITS_FT, + GPS_ALT_UNITS_M +}; + +enum KLN89PressureUnits { + GPS_PRES_UNITS_IN = 1, + GPS_PRES_UNITS_MB, + GPS_PRES_UNITS_HP +}; + /* const char* KLN89TimeCodes[20] = { "UTC", "GST", "GDT", "ATS", "ATD", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT", "AKS", "AKD", "HAS", "HAD", "SST", "SDT", "LCL" }; @@ -80,6 +101,20 @@ public: void init(); void update(double dt); + // Set Units + // m if true, ft if false + inline void SetAltUnitsSI(bool b) { _altUnits = (b ? GPS_ALT_UNITS_M : GPS_ALT_UNITS_FT); } + // Returns true if alt units are SI (m), false if ft + inline bool GetAltUnitsSI() { return(_altUnits == GPS_ALT_UNITS_M ? true : false); } + // km and k/h if true, nm and kt if false + inline void SetDistVelUnitsSI(bool b) { _distUnits = (b ? GPS_DIST_UNITS_KM : GPS_DIST_UNITS_NM); _velUnits = (b ? GPS_VEL_UNITS_KPH : GPS_VEL_UNITS_KT); } + // Returns true if dist/vel units are SI + inline bool GetDistVelUnitsSI() { return(_distUnits == GPS_DIST_UNITS_KM && _velUnits == GPS_VEL_UNITS_KPH ? true : false); } + // Set baro units - 1 = in, 2 = mB, 3 = hP Wrapping if for the convienience of the GPS setter. + void SetBaroUnits(int n, bool wrap = false); + // Get baro units: 1 = in, 2 = mB, 3 = hP + inline int GetBaroUnits() { return((int)_baroUnits); } + inline void SetTurnAnticipation(bool b) { _turnAnticipationEnabled = b; } inline bool GetTurnAnticipation() { return(_turnAnticipationEnabled); } @@ -302,6 +337,10 @@ private: bool _dtoReview; // Set true when we a reviewing a waypoint for DTO operation. // Configuration settings that the user can set via. the KLN89 SET pages. + KLN89SpeedUnits _velUnits; + KLN89DistanceUnits _distUnits; + KLN89PressureUnits _baroUnits; + KLN89AltitudeUnits _altUnits; bool _suaAlertEnabled; // Alert user to potential SUA entry bool _altAlertEnabled; // Alert user to min safe alt violation int _minDisplayBrightness; // Minimum display brightness in low light. diff --git a/src/Instrumentation/dclgps.cxx b/src/Instrumentation/dclgps.cxx index 92aa558cf..58e87dc20 100644 --- a/src/Instrumentation/dclgps.cxx +++ b/src/Instrumentation/dclgps.cxx @@ -152,12 +152,6 @@ DCLGPS::DCLGPS(RenderArea2D* instrument) { _instrument = instrument; _nFields = 1; _maxFields = 2; - - // Units - lets default to US units - FG can set them to other units from config during startup if desired. - _altUnits = GPS_ALT_UNITS_FT; - _baroUnits = GPS_PRES_UNITS_IN; - _velUnits = GPS_VEL_UNITS_KT; - _distUnits = GPS_DIST_UNITS_NM; _lon_node = fgGetNode("/instrumentation/gps/indicated-longitude-deg", true); _lat_node = fgGetNode("/instrumentation/gps/indicated-latitude-deg", true); @@ -1098,16 +1092,6 @@ void DCLGPS::DrawChar(char c, int field, int px, int py, bool bold) { void DCLGPS::DrawText(const string& s, int field, int px, int py, bool bold) { } -void DCLGPS::SetBaroUnits(int n, bool wrap) { - if(n < 1) { - _baroUnits = (GPSPressureUnits)(wrap ? 3 : 1); - } else if(n > 3) { - _baroUnits = (GPSPressureUnits)(wrap ? 1 : 3); - } else { - _baroUnits = (GPSPressureUnits)n; - } -} - void DCLGPS::CreateDefaultFlightPlans() {} // Get the time to the active waypoint in seconds. diff --git a/src/Instrumentation/dclgps.hxx b/src/Instrumentation/dclgps.hxx index 226271d1d..11d48bc5e 100644 --- a/src/Instrumentation/dclgps.hxx +++ b/src/Instrumentation/dclgps.hxx @@ -43,27 +43,6 @@ class FGNavRecord; class FGAirport; class FGFix; -enum GPSDistanceUnits { - GPS_DIST_UNITS_NM = 0, - GPS_DIST_UNITS_KM -}; - -enum GPSSpeedUnits { - GPS_VEL_UNITS_KT, - GPS_VEL_UNITS_KPH -}; - -enum GPSAltitudeUnits { - GPS_ALT_UNITS_FT, - GPS_ALT_UNITS_M -}; - -enum GPSPressureUnits { - GPS_PRES_UNITS_IN = 1, - GPS_PRES_UNITS_MB, - GPS_PRES_UNITS_HP -}; - // --------------------- Waypoint / Flightplan stuff ----------------------------- // This should be merged with other similar stuff in FG at some point. @@ -216,20 +195,6 @@ public: // Set the number of fields inline void SetNumFields(int n) { _nFields = (n > _maxFields ? _maxFields : (n < 1 ? 1 : n)); } - // Set Units - // m if true, ft if false - inline void SetAltUnitsSI(bool b) { _altUnits = (b ? GPS_ALT_UNITS_M : GPS_ALT_UNITS_FT); } - // Returns true if alt units are SI (m), false if ft - inline bool GetAltUnitsSI() { return(_altUnits == GPS_ALT_UNITS_M ? true : false); } - // km and k/h if true, nm and kt if false - inline void SetDistVelUnitsSI(bool b) { _distUnits = (b ? GPS_DIST_UNITS_KM : GPS_DIST_UNITS_NM); _velUnits = (b ? GPS_VEL_UNITS_KPH : GPS_VEL_UNITS_KT); } - // Returns true if dist/vel units are SI - inline bool GetDistVelUnitsSI() { return(_distUnits == GPS_DIST_UNITS_KM && _velUnits == GPS_VEL_UNITS_KPH ? true : false); } - // Set baro units - 1 = in, 2 = mB, 3 = hP Wrapping if for the convienience of the GPS setter. - void SetBaroUnits(int n, bool wrap = false); - // Get baro units: 1 = in, 2 = mB, 3 = hP - inline int GetBaroUnits() { return((int)_baroUnits); } - // It is expected that specific GPS units will override these functions. // Increase the CDI full-scale deflection (ie. increase the nm per dot) one (GPS unit dependent) increment. Wraps if necessary (GPS unit dependent). virtual void CDIFSDIncrease(); @@ -317,12 +282,6 @@ protected: // 2D rendering area RenderArea2D* _instrument; - // Units - GPSSpeedUnits _velUnits; - GPSDistanceUnits _distUnits; - GPSPressureUnits _baroUnits; - GPSAltitudeUnits _altUnits; - // CDI full-scale deflection, specified either as an index into a vector of values (standard values) or as a double precision float (intermediate values). // This will influence how an externally driven CDI will display as well as the NAV1 page. // Hence the variables are located here, not in the nav page class.