| 1 | // kln89_page_*.[ch]xx - this file is one of the "pages" that |
| 2 | // are used in the KLN89 GPS unit simulation. |
| 3 | // |
| 4 | // Written by David Luff, started 2005. |
| 5 | // |
| 6 | // Copyright (C) 2005 - David C Luff - daveluff AT ntlworld.com |
| 7 | // |
| 8 | // This program is free software; you can redistribute it and/or |
| 9 | // modify it under the terms of the GNU General Public License as |
| 10 | // published by the Free Software Foundation; either version 2 of the |
| 11 | // License, or (at your option) any later version. |
| 12 | // |
| 13 | // This program is distributed in the hope that it will be useful, but |
| 14 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | // General Public License for more details. |
| 17 | // |
| 18 | // You should have received a copy of the GNU General Public License |
| 19 | // along with this program; if not, write to the Free Software |
| 20 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 21 | // |
| 22 | // $Id$ |
| 23 | |
| 24 | #ifdef HAVE_CONFIG_H |
| 25 | # include "config.h" |
| 26 | #endif |
| 27 | |
| 28 | #include <cstdio> |
| 29 | |
| 30 | #include "kln89_page_oth.hxx" |
| 31 | |
| 32 | using std::string; |
| 33 | |
| 34 | KLN89OthPage::KLN89OthPage(KLN89* parent) |
| 35 | : KLN89Page(parent) { |
| 36 | _nSubPages = 12; |
| 37 | _subPage = 0; |
| 38 | _name = "OTH"; |
| 39 | } |
| 40 | |
| 41 | KLN89OthPage::~KLN89OthPage() { |
| 42 | } |
| 43 | |
| 44 | void KLN89OthPage::Update(double dt) { |
| 45 | // The OTH pages aren't terribly important at the moment, since we don't simulate |
| 46 | // error and failure, but lets hardwire some representitive output anyway. |
| 47 | if(_subPage == 0) { |
| 48 | _kln89->DrawText("State", 2, 0, 3); |
| 49 | _kln89->DrawText("GPS Alt", 2, 0, 2); |
| 50 | _kln89->DrawText("Estimated Posn", 2, 0, 1); |
| 51 | _kln89->DrawText("Error", 2, 1, 0); |
| 52 | |
| 53 | // FIXME - hardwired value. |
| 54 | _kln89->DrawText("NAV D", 2, 9, 3); |
| 55 | // TODO: add error physics to FG GPS where the alt value comes from. |
| 56 | char buf[6]; |
| 57 | int n = snprintf(buf, 5, "%i", _kln89->_altUnits == GPS_ALT_UNITS_FT ? (int)_kln89->_alt : (int)(_kln89->_alt * SG_FEET_TO_METER)); |
| 58 | _kln89->DrawText((string)buf, 2, 13-n, 2); |
| 59 | _kln89->DrawText(_kln89->_altUnits == GPS_ALT_UNITS_FT ? "ft" : "m", 2, 13, 2); |
| 60 | // FIXME - hardwired values. |
| 61 | // Note that a 5th digit if required is left padded one further at position 7. |
| 62 | _kln89->DrawText(_kln89->_distUnits == GPS_DIST_UNITS_NM ? "0.02nm" : "0.03km", 2, 8, 0); |
| 63 | } |
| 64 | |
| 65 | KLN89Page::Update(dt); |
| 66 | } |