1 // kln89_page_*.[ch]xx - this file is one of the "pages" that
2 // are used in the KLN89 GPS unit simulation.
4 // Written by David Luff, started 2010.
6 // Copyright (C) 2010 - David C Luff - daveluff AT ntlworld.com
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.
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.
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.
26 #include "kln89_page_alt.hxx"
30 KLN89AltPage::KLN89AltPage(KLN89* parent)
39 KLN89AltPage::~KLN89AltPage() {
42 void KLN89AltPage::Update(double dt) {
44 _kln89->DrawText("BARO:", 2, 2, 3);
45 if(_kln89->_baroUnits == GPS_PRES_UNITS_IN) {
46 // If the units are not consistent with the setting, then convert to the correct
47 // units. We do it here instead of where the units are set in order to avoid any
48 // possible value creep with multiple unit toggling.
49 if(_kln89->_userBaroSetting >= 745 && _kln89->_userBaroSetting <= 1117) {
50 _kln89->_userBaroSetting = (int)((float)_kln89->_userBaroSetting * 0.0295301 * 100 + 0.5);
53 snprintf(buf, 6, "%2i.%02i", _kln89->_userBaroSetting/100, _kln89->_userBaroSetting % 100);
55 if(!(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1 && _kln89->_blink)) {
56 _kln89->DrawText(s, 2, 7, 3);
58 if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1) {
59 _kln89->Underline(2, 7, 3, 5);
61 _kln89->DrawText("\"", 2, 12, 3);
63 // If the units are not consistent with the setting, then convert to the correct
64 // units. We do it here instead of where the units are set in order to avoid any
65 // possible value creep with multiple unit toggling.
66 if(_kln89->_userBaroSetting >= 2200 && _kln89->_userBaroSetting <= 3299) {
67 _kln89->_userBaroSetting = (int)(((float)_kln89->_userBaroSetting / 100.0) * 33.8637526 + 0.5);
70 snprintf(buf, 5, "%4i", _kln89->_userBaroSetting);
72 if(!(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1 && _kln89->_blink)) {
73 _kln89->DrawText(s, 2, 8, 3);
75 if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1) {
76 _kln89->Underline(2, 8, 3, 4);
78 _kln89->DrawText(_kln89->_baroUnits == GPS_PRES_UNITS_MB ? "mB" : "hP", 2, 12, 3);
81 _kln89->DrawText("MSA", 2, 2, 1);
82 _kln89->DrawText("ESA", 2, 2, 0);
84 // At the moment we have no obstruction database, so dash out MSA & ESA
85 _kln89->DrawText("----", 2, 8, 1);
86 _kln89->DrawText("----", 2, 8, 0);
87 if(_kln89->_altUnits == GPS_ALT_UNITS_FT) {
88 _kln89->DrawText("ft", 2, 12, 1);
89 _kln89->DrawText("ft", 2, 12, 0);
91 _kln89->DrawText("m", 2, 12, 1);
92 _kln89->DrawText("m", 2, 12, 0);
95 _kln89->DrawText("Vnv Inactive", 2, 0, 3);
98 KLN89Page::Update(dt);
101 void KLN89AltPage::CrsrPressed() {
104 void KLN89AltPage::EntPressed() {
107 void KLN89AltPage::Knob2Left1() {
108 _kln89->_userBaroSetting--;
109 if(_kln89->_baroUnits == GPS_PRES_UNITS_IN) {
110 if(_kln89->_userBaroSetting < 2200) _kln89->_userBaroSetting = 3299;
112 if(_kln89->_userBaroSetting < 745) _kln89->_userBaroSetting = 1117;
116 void KLN89AltPage::Knob2Right1() {
117 _kln89->_userBaroSetting++;
118 if(_kln89->_baroUnits == GPS_PRES_UNITS_IN) {
119 if(_kln89->_userBaroSetting > 3299) _kln89->_userBaroSetting = 2200;
121 if(_kln89->_userBaroSetting > 1117) _kln89->_userBaroSetting = 745;
125 void KLN89AltPage::LooseFocus() {