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 --D0T-- 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 #ifndef _KLN89_PAGE_CAL
25 #define _KLN89_PAGE_CAL
26
27 #include "kln89.hxx"
28
29 class KLN89CalPage : public KLN89Page {
30
31 public:
32 KLN89CalPage(KLN89* parent);
33 ~KLN89CalPage();
34
35 void Update(double dt);
36
37 void CrsrPressed();
38 void ClrPressed();
39 void Knob2Left1();
40 void Knob2Right1();
41
42 void LooseFocus();
43
44 private:
45 unsigned int _nFp0; // flightplan no. displayed on page 1 (_subPage == 0).
46 double _ground_speed_ms; // Assumed ground speed for ete calc on page 1 (user can alter this).
47
48 // CAL3 (alarm) page
49 ClockTime _alarmTime;
50 ClockTime _alarmIn;
51 // _alarmAnnotate shows that the alarm has been set at least once
52 // so the time should now be always annotated (there seems to be
53 // no way to remove it once set once!).
54 bool _alarmAnnotate;
55 // _alarmSet indicates that the alarm has been changed by the user
56 // and should be set in the main unit when the page looses focus
57 // (I don't think the alarm goes off unless the user leaves the
58 // CAL3 page after setting it).
59 bool _alarmSet;
60
61 // Calculate the alarm time based on the alarm-in value
62 void CalcAlarmTime();
63 // Calculate alarm-in based on the alarm time.
64 void CalcAlarmIn();
65
66 // Calculate the difference between 2 hr:min times.
67 // It is assumed that the second time is always later than the first one
68 // ie. that the day has wrapped if the second one is less,
69 // but is limited to intervals of < 24hr.
70 void TimeDiff(int hr1, int min1, int hr2, int min2, int &hrDiff, int &minDiff);
71 };
72
73
operator <<(std::ostream & out,const ClockTime & t)74 inline std::ostream& operator<< (std::ostream& out, const ClockTime& t) {
75 return(out << t._hr << ':' << t._min);
76 }
77
78 #endif // _KLN89_PAGE_CAL
79