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., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "kln89_page_cal.hxx"
26 KLN89CalPage::KLN89CalPage(KLN89* parent)
32 _ground_speed_ms = 110 * 0.514444444444;
35 KLN89CalPage::~KLN89CalPage() {
38 void KLN89CalPage::Update(double dt) {
40 if(1) { // TODO - fix this hardwiring!
42 _kln89->DrawText(">Fpl:", 2, 0, 3);
43 _kln89->DrawText("0", 2, 6, 3);// TODO - fix this hardwiring!
44 GPSFlightPlan* fp = _kln89->_flightPlans[_nFp0];
46 unsigned int n = fp->waypoints.size();
48 // TODO - check that this is what really happens
49 _kln89->DrawText("----", 2, 9, 3);
50 _kln89->DrawText("----", 2, 9, 2);
52 _kln89->DrawText(fp->waypoints[0]->id, 2, 9, 3);
53 _kln89->DrawText(fp->waypoints[n-1]->id, 2, 9, 2);
54 double cum_tot_m = 0.0;
55 for(unsigned int i = 1; i < fp->waypoints.size(); ++i) {
56 cum_tot_m += _kln89->GetGreatCircleDistance(fp->waypoints[i-1]->lat, fp->waypoints[i-1]->lon,
57 fp->waypoints[i]->lat, fp->waypoints[i]->lon);
59 double ete = (cum_tot_m * SG_NM_TO_METER) / _ground_speed_ms;
60 _kln89->DrawDist(cum_tot_m, 2, 5, 1);
61 _kln89->DrawSpeed(_ground_speed_ms / 0.5144444444, 2, 5, 0);
62 _kln89->DrawTime(ete, 2, 14, 0);
65 _kln89->DrawText("----", 2, 9, 3);
66 _kln89->DrawText("----", 2, 9, 2);
69 _kln89->DrawText(">Wpt:", 2, 0, 3);
71 _kln89->DrawText("To", 2, 6, 2);
72 _kln89->DrawText("ESA ----'", 2, 7, 1); // TODO - implement an ESA calc
73 _kln89->DrawText("ETE", 2, 7, 0);
74 } else if(_subPage == 1) {
75 _kln89->DrawText(">Fpl: 0", 2, 0, 3); // TODO - fix this hardwiring!
76 _kln89->DrawText("FF:", 2, 0, 2);
77 _kln89->DrawText("Res:", 2, 7, 1);
78 _kln89->DrawText("Fuel Req", 2, 0, 0);
79 } else if(_subPage == 2) {
80 _kln89->DrawText("Time:", 2, 0, 3);
81 _kln89->DrawText("Alarm at:", 2, 0, 2);
82 _kln89->DrawText("in:", 2, 6, 1);
83 _kln89->DrawText("Elapsed", 2, 0, 0);
84 } else if(_subPage == 3) {
85 _kln89->DrawText("PRESSURE ALT", 2, 1, 3);
86 _kln89->DrawText("Ind:", 2, 0, 2);
87 _kln89->DrawText("Baro:", 2, 0, 1);
88 _kln89->DrawText("Prs", 2, 0, 0);
89 } else if(_subPage == 4) {
90 _kln89->DrawText("DENSITY ALT", 2, 1, 3);
91 _kln89->DrawText("Prs:", 2, 0, 2);
92 _kln89->DrawText("Temp:", 2, 0, 1);
93 _kln89->DrawText("Den", 2, 0, 0);
94 } else if(_subPage == 5) {
95 _kln89->DrawText("CAS:", 2, 0, 3);
96 _kln89->DrawText("Prs:", 2, 0, 2);
97 _kln89->DrawText("Temp:", 2, 0, 1);
98 _kln89->DrawText("TAS", 2, 0, 0);
99 } else if(_subPage == 6) {
100 _kln89->DrawText("TAS:", 2, 0, 3);
101 _kln89->DrawText("Hdg:", 2, 0, 2);
102 _kln89->DrawText("Headwind:", 2, 0, 1);
103 _kln89->DrawText("True", 2, 4, 0);
105 _kln89->DrawText("SUNRISE", 2, 0, 1);
106 _kln89->DrawText("SUNSET", 2, 0, 0);
109 KLN89Page::Update(dt);