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 2005.
6 // Copyright (C) 2005 - David C Luff - david.luff@nottingham.ac.uk
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.
28 #include "kln89_page_set.hxx"
33 KLN89SetPage::KLN89SetPage(KLN89* parent)
40 KLN89SetPage::~KLN89SetPage() {
43 void KLN89SetPage::Update(double dt) {
44 string sBaro, sAlt, sVel;
47 _kln89->DrawText("INIT POS:", 2, 0, 3);
50 _kln89->DrawText("DATE", 2, 0, 3);
51 _kln89->DrawText("TIME", 2, 0, 2);
52 _kln89->DrawText("Cord", 2, 0, 1);
53 _kln89->DrawText("Mag Var:", 2, 0, 0);
56 _kln89->DrawText("Update DB on", 2, 1, 3);
57 _kln89->DrawText("ground only", 2, 1, 2);
58 _kln89->DrawText("Key", 2, 0, 1);
59 _kln89->DrawText("Update pub DB?", 2, 0, 0);
62 //cout << "_uLinePos = " << _uLinePos << '\n';
63 _kln89->DrawText("TURN", 2, 5, 3);
64 _kln89->DrawText("ANTICIPATION", 2, 1, 2);
65 if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1) {
67 _kln89->DrawText((_kln89->GetTurnAnticipation() ? "ENABLED" : "DISABLED"), 2, 3, 1);
69 _kln89->Underline(2, 3, 1, 8);
71 _kln89->DrawText((_kln89->GetTurnAnticipation() ? "ENABLED" : "DISABLED"), 2, 3, 1);
75 _kln89->DrawText("Default First", 2, 0, 3);
76 _kln89->DrawText("Character of", 2, 1, 2);
77 _kln89->DrawText("Wpt identifier", 2, 0, 1);
78 _kln89->DrawText("Entry:", 2, 3, 0);
81 _kln89->DrawText("NEAREST APT", 2, 1, 3);
82 _kln89->DrawText("CRITERIA", 2, 3, 2);
83 _kln89->DrawText("Length:", 2, 0, 1);
84 _kln89->DrawText("Surface:", 2, 0, 0);
87 _kln89->DrawText("SUA ALERT", 2, 3, 3);
88 if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1) {
90 _kln89->DrawText((_kln89->GetSuaAlertEnabled() ? "ENABLED" : "DISABLED"), 2, 4, 2);
92 _kln89->Underline(2, 4, 2, 8);
94 _kln89->DrawText((_kln89->GetSuaAlertEnabled() ? "ENABLED" : "DISABLED"), 2, 4, 2);
96 if(_kln89->GetSuaAlertEnabled()) {
97 _kln89->DrawText("Buffer:", 2, 0, 1);
98 _kln89->DrawSpecialChar(5, 2, 7, 1); // +- sign.
99 if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 2) {
100 if(!_kln89->_blink) {
101 _kln89->DrawText("00300", 2, 8, 1); // TODO - fix this hardwiring!!!!
103 _kln89->Underline(2, 8, 1, 5);
105 _kln89->DrawText("00300", 2, 8, 1); // TODO - fix this hardwiring!!!!
107 _kln89->DrawText("ft", 2, 13, 1); // TODO - fix this hardwiring!!!!
111 _kln89->DrawText("SET UNITS:", 2, 3, 3);
112 _kln89->DrawText("Baro :", 2, 0, 2);
113 _kln89->DrawText("Alt-APT :", 2, 0, 1);
114 _kln89->DrawText("Dist-Vel:", 2, 0, 0);
115 switch(_kln89->_baroUnits) {
116 case GPS_PRES_UNITS_IN:
119 case GPS_PRES_UNITS_MB:
122 case GPS_PRES_UNITS_HP:
126 if(_kln89->_altUnits == GPS_ALT_UNITS_FT) sAlt = "ft";
128 if(_kln89->_distUnits == GPS_DIST_UNITS_NM) sVel = "nm-kt";
131 if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1) {
132 if(!_kln89->_blink) {
133 _kln89->DrawText(sBaro, 2, 10, 2);
135 _kln89->Underline(2, 10, 2, 2);
137 _kln89->DrawText(sBaro, 2, 10, 2);
139 if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 2) {
140 if(!_kln89->_blink) {
141 _kln89->DrawText(sAlt, 2, 10, 1);
143 _kln89->Underline(2, 10, 1, 2);
145 _kln89->DrawText(sAlt, 2, 10, 1);
147 if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 3) {
148 if(!_kln89->_blink) {
149 _kln89->DrawText(sVel, 2, 10, 0);
150 if(_kln89->_distUnits != GPS_DIST_UNITS_NM) _kln89->DrawKPH(2, 13, 0);
152 _kln89->Underline(2, 10, 0, 5);
154 _kln89->DrawText(sVel, 2, 10, 0);
155 if(_kln89->_distUnits != GPS_DIST_UNITS_NM) _kln89->DrawKPH(2, 13, 0);
159 _kln89->DrawText("Altitude", 2, 3, 3);
160 _kln89->DrawText("Alert:", 2, 1, 2);
163 _kln89->DrawText("BUS MONITOR", 2, 2, 3);
164 _kln89->DrawText("Bus Volt", 2, 0, 2);
165 _kln89->DrawText("Alert Volt", 2, 0, 1);
166 _kln89->DrawText("Alert Delay", 2, 0, 0);
169 _kln89->DrawText("MIN DISPLAY", 2, 2, 3);
170 _kln89->DrawText("BRIGHTNESS ADJ", 2, 1, 2);
174 KLN89Page::Update(dt);
177 void KLN89SetPage::CrsrPressed() {
178 if(_kln89->_mode == KLN89_MODE_DISP) return;
179 if(_kln89->_obsMode) {
200 if(_kln89->GetSuaAlertEnabled()) _maxULinePos = 2;
201 else _maxULinePos = 1;
215 void KLN89SetPage::Knob2Left1() {
216 if(_kln89->_mode != KLN89_MODE_CRSR || _uLinePos == 0) {
217 KLN89Page::Knob2Left1();
228 _kln89->SetTurnAnticipation(!_kln89->GetTurnAnticipation());
237 _kln89->SetSuaAlertEnabled(!_kln89->GetSuaAlertEnabled());
238 _maxULinePos = (_kln89->GetSuaAlertEnabled() ? 2 : 1);
239 } else if(_uLinePos == 2) {
240 // TODO - implement variable sua alert buffer
244 if(_uLinePos == 1) { // baro units
245 _kln89->SetBaroUnits(_kln89->GetBaroUnits() - 1, true);
246 } else if(_uLinePos == 2) {
247 _kln89->SetAltUnitsSI(!_kln89->GetAltUnitsSI());
248 } else if(_uLinePos == 3) {
249 _kln89->SetDistVelUnitsSI(!_kln89->GetDistVelUnitsSI());
256 void KLN89SetPage::Knob2Right1() {
257 if(_kln89->_mode != KLN89_MODE_CRSR || _uLinePos == 0) {
258 KLN89Page::Knob2Right1();
268 if(_uLinePos == 1) { // Which it should be!
269 _kln89->SetTurnAnticipation(!_kln89->GetTurnAnticipation());
278 _kln89->SetSuaAlertEnabled(!_kln89->GetSuaAlertEnabled());
279 _maxULinePos = (_kln89->GetSuaAlertEnabled() ? 2 : 1);
280 } else if(_uLinePos == 2) {
281 // TODO - implement variable sua alert buffer
285 if(_uLinePos == 1) { // baro units
286 _kln89->SetBaroUnits(_kln89->GetBaroUnits() + 1, true);
287 } else if(_uLinePos == 2) {
288 _kln89->SetAltUnitsSI(!_kln89->GetAltUnitsSI());
289 } else if(_uLinePos == 3) {
290 _kln89->SetDistVelUnitsSI(!_kln89->GetDistVelUnitsSI());