1
0
Fork 0

KLN89: Add initial implemenation of ALT pages.

The user can now set the KLN89 baro pressure setting, but this is
not currently used since currently the unit performs no VNAV calcs.
This commit is contained in:
Dave Luff 2010-12-09 22:31:34 +00:00
parent d450900e0b
commit 2102c3c9ff
5 changed files with 215 additions and 3 deletions

View file

@ -4,6 +4,7 @@ libKLN89_a_SOURCES = \
kln89.cxx kln89.hxx \
kln89_page.cxx kln89_page.hxx \
kln89_page_act.cxx kln89_page_act.hxx \
kln89_page_alt.cxx kln89_page_alt.hxx \
kln89_page_apt.cxx kln89_page_apt.hxx \
kln89_page_cal.cxx kln89_page_cal.hxx \
kln89_page_dir.cxx kln89_page_dir.hxx \
@ -18,4 +19,4 @@ libKLN89_a_SOURCES = \
kln89_page_vor.cxx kln89_page_vor.hxx \
kln89_symbols.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -38,6 +38,7 @@
#include "kln89_page_cal.hxx"
#include "kln89_page_set.hxx"
#include "kln89_page_oth.hxx"
#include "kln89_page_alt.hxx"
#include "kln89_page_dir.hxx"
#include "kln89_page_nrst.hxx"
#include "kln89_symbols.hxx"
@ -189,6 +190,7 @@ KLN89::KLN89(RenderArea2D* instrument)
_curPage = 0;
// Other pages
_alt_page = new KLN89AltPage(this);
_dir_page = new KLN89DirPage(this);
_nrst_page = new KLN89NrstPage(this);
@ -198,6 +200,12 @@ KLN89::KLN89(RenderArea2D* instrument)
_fullLegMode = true;
_obsHeading = 215;
if(_baroUnits == GPS_PRES_UNITS_IN) {
_userBaroSetting = 2992;
} else {
_userBaroSetting = 1013;
}
_maxFlightPlans = 26;
for(unsigned int i=0; i<_maxFlightPlans; ++i) {
GPSFlightPlan* fp = new GPSFlightPlan;
@ -270,6 +278,7 @@ KLN89::~KLN89() {
delete _pages[i];
}
delete _alt_page;
delete _dir_page;
delete _nrst_page;
@ -360,7 +369,7 @@ void KLN89::update(double dt) {
// Draw the indicator that shows which page we are on.
if(_curPage == 6 && _activePage->GetSubPage() == 3) {
// Don't draw the bar on the nav-4 page
} else if((_activePage != _nrst_page) && (_activePage != _dir_page) && (!_dispMsg)) {
} else if((_activePage != _nrst_page) && (_activePage != _dir_page) && (_activePage != _alt_page) && (!_dispMsg)) {
// Don't draw the bar on the NRST, DTO or MSG pages
DrawBar(_curPage);
}
@ -601,7 +610,25 @@ void KLN89::NrstPressed() {
}
}
void KLN89::AltPressed() {}
void KLN89::AltPressed() {
if(_activePage != _alt_page) {
_activePage->LooseFocus(); // TODO - check whether we should call loose focus here
_lastActivePage = _activePage;
_alt_page->SetSubPage(0);
_activePage = _alt_page;
_lastMode = _mode;
_mode = KLN89_MODE_CRSR;
} else {
_alt_page->LooseFocus();
if(_alt_page->GetSubPage() == 0) {
_alt_page->SetSubPage(1);
_mode = KLN89_MODE_CRSR;
} else {
_activePage = _lastActivePage;
_mode = _lastMode;
}
}
}
void KLN89::OBSPressed() {
ToggleOBSMode();

View file

@ -67,6 +67,7 @@ class KLN89 : public DCLGPS {
friend class KLN89CalPage;
friend class KLN89SetPage;
friend class KLN89OthPage;
friend class KLN89AltPage;
friend class KLN89DirPage;
friend class KLN89NrstPage;
@ -226,6 +227,8 @@ private:
bool _jumpRestoreCrsr; // Indicates that jump back at this point should restore cursor mode.
// Misc pages that aren't in the cyclic list.
// ALT
KLN89Page* _alt_page;
// Direct To
KLN89Page* _dir_page;
// Nearest
@ -303,6 +306,15 @@ private:
bool _altAlertEnabled; // Alert user to min safe alt violation
int _minDisplayBrightness; // Minimum display brightness in low light.
char _defaultFirstChar; // Default first waypoint character.
// The user-settable barometric pressure.
// This can be set in the range 22.00 -> 32.99", or 745 -> 1117mB/hPa.
// For user input, we maintain a single integer value that is either between 2200 and 3299 (")
// or between 745 and 1117 (mB/hPa). It gets converted from one to the other only when the
// units are changed.
// For internal VNAV calculations (which we don't currently do) this will be converted to a floating
// point value before use.
int _userBaroSetting;
};
#endif // _KLN89_HXX

View file

@ -0,0 +1,125 @@
// kln89_page_*.[ch]xx - this file is one of the "pages" that
// are used in the KLN89 GPS unit simulation.
//
// Written by David Luff, started 2010.
//
// Copyright (C) 2010 - David C Luff - daveluff AT ntlworld.com
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "kln89_page_alt.hxx"
KLN89AltPage::KLN89AltPage(KLN89* parent)
: KLN89Page(parent) {
_nSubPages = 2;
_subPage = 0;
_name = "ALT";
_uLinePos = 1;
_maxULinePos = 1;
}
KLN89AltPage::~KLN89AltPage() {
}
void KLN89AltPage::Update(double dt) {
if(_subPage == 0) {
_kln89->DrawText("BARO:", 2, 2, 3);
if(_kln89->_baroUnits == GPS_PRES_UNITS_IN) {
// If the units are not consistent with the setting, then convert to the correct
// units. We do it here instead of where the units are set in order to avoid any
// possible value creep with multiple unit toggling.
if(_kln89->_userBaroSetting >= 745 && _kln89->_userBaroSetting <= 1117) {
_kln89->_userBaroSetting = (int)((float)_kln89->_userBaroSetting * 0.0295301 * 100 + 0.5);
}
char buf[6];
snprintf(buf, 6, "%2i.%02i", _kln89->_userBaroSetting/100, _kln89->_userBaroSetting % 100);
string s = buf;
if(!(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1 && _kln89->_blink)) {
_kln89->DrawText(s, 2, 7, 3);
}
if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1) {
_kln89->Underline(2, 7, 3, 5);
}
_kln89->DrawText("\"", 2, 12, 3);
} else {
// If the units are not consistent with the setting, then convert to the correct
// units. We do it here instead of where the units are set in order to avoid any
// possible value creep with multiple unit toggling.
if(_kln89->_userBaroSetting >= 2200 && _kln89->_userBaroSetting <= 3299) {
_kln89->_userBaroSetting = (int)(((float)_kln89->_userBaroSetting / 100.0) * 33.8637526 + 0.5);
}
char buf[5];
snprintf(buf, 5, "%4i", _kln89->_userBaroSetting);
string s = buf;
if(!(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1 && _kln89->_blink)) {
_kln89->DrawText(s, 2, 8, 3);
}
if(_kln89->_mode == KLN89_MODE_CRSR && _uLinePos == 1) {
_kln89->Underline(2, 8, 3, 4);
}
_kln89->DrawText(_kln89->_baroUnits == GPS_PRES_UNITS_MB ? "mB" : "hP", 2, 12, 3);
}
_kln89->DrawText("MSA", 2, 2, 1);
_kln89->DrawText("ESA", 2, 2, 0);
// At the moment we have no obstruction database, so dash out MSA & ESA
_kln89->DrawText("----", 2, 8, 1);
_kln89->DrawText("----", 2, 8, 0);
if(_kln89->_altUnits == GPS_ALT_UNITS_FT) {
_kln89->DrawText("ft", 2, 12, 1);
_kln89->DrawText("ft", 2, 12, 0);
} else {
_kln89->DrawText("m", 2, 12, 1);
_kln89->DrawText("m", 2, 12, 0);
}
} else {
_kln89->DrawText("Vnv Inactive", 2, 0, 3);
}
KLN89Page::Update(dt);
}
void KLN89AltPage::CrsrPressed() {
}
void KLN89AltPage::EntPressed() {
}
void KLN89AltPage::Knob2Left1() {
_kln89->_userBaroSetting--;
if(_kln89->_baroUnits == GPS_PRES_UNITS_IN) {
if(_kln89->_userBaroSetting < 2200) _kln89->_userBaroSetting = 3299;
} else {
if(_kln89->_userBaroSetting < 745) _kln89->_userBaroSetting = 1117;
}
}
void KLN89AltPage::Knob2Right1() {
_kln89->_userBaroSetting++;
if(_kln89->_baroUnits == GPS_PRES_UNITS_IN) {
if(_kln89->_userBaroSetting > 3299) _kln89->_userBaroSetting = 2200;
} else {
if(_kln89->_userBaroSetting > 1117) _kln89->_userBaroSetting = 745;
}
}
void KLN89AltPage::LooseFocus() {
_uLinePos = 1;
}

View file

@ -0,0 +1,47 @@
// kln89_page_*.[ch]xx - this file is one of the "pages" that
// are used in the KLN89 GPS unit simulation.
//
// Written by David Luff, started 2010.
//
// Copyright (C) 2010 - David C Luff - daveluff AT ntlworld.com
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef _KLN89_PAGE_ALT
#define _KLN89_PAGE_ALT
#include "kln89.hxx"
class KLN89AltPage : public KLN89Page {
public:
KLN89AltPage(KLN89* parent);
~KLN89AltPage();
void Update(double dt);
//void AltPressed();
void CrsrPressed();
void EntPressed();
//void ClrPressed();
//void Knob1Left1();
//void Knob1Right1();
void Knob2Left1();
void Knob2Right1();
void LooseFocus();
};
#endif // _KLN89_PAGE_ALT