1
0
Fork 0

Implement some of the inner-knob-out scan functionality. The waypoints of the active flightplan can now be scanned on the NAV4 page, and will become the default direct-to waypoint if dto is pressed whilst scan in on on the NAV4 page. Scan functionality on the waypoint pages is still TODO.

This commit is contained in:
daveluff 2006-02-10 23:19:45 +00:00
parent 21387a636f
commit 0bac52705b
4 changed files with 90 additions and 8 deletions

View file

@ -379,7 +379,10 @@ void KLN89::Knob2Right1() {
void KLN89::CrsrPressed() {
_dispMsg = false;
if(_activePage == _nrst_page) return; // CRSR cannot be switched off on nrst page.
// CRSR cannot be switched off on nrst page.
if(_activePage == _nrst_page) { return; }
// CRSR is always off when inner-knob is out on nav4 page.
if(_curPage == 6 && _activePage->GetSubPage() == 3 && fgGetBool("/instrumentation/kln89/scan-pull")) { return; }
if(_cleanUpPage >= 0) {
_pages[(unsigned int)_cleanUpPage]->CleanUp();
_cleanUpPage = -1;
@ -432,10 +435,9 @@ void KLN89::DtoPressed() {
} else {
_dir_page->SetId(_activeWaypoint.id);
}
// } else if(_curPage == 6 && _nav_page->GetSubPage() == 3 && 0) {
} else if(_curPage == 6 && _activePage->GetSubPage() == 3 && fgGetBool("/instrumentation/kln89/scan-pull") && _activeFP->waypoints.size()) {
// NAV 4
// TODO
// The && 0 should be && outer knob is out.
_dir_page->SetId(((KLN89NavPage*)_activePage)->GetNav4WpId());
} else if(_curPage == 7 && _activePage->GetSubPage() == 0 && _mode == KLN89_MODE_CRSR) {
//cout << "Checking the fpl page!\n";
// FPL 0
@ -449,7 +451,7 @@ void KLN89::DtoPressed() {
} else {
_dir_page->SetId(_activeWaypoint.id);
}
// This need to come after the bit before otherwise the FPL page clears it's current ID when it looses focus.
// This need to come after the bit before otherwise the FPL or NAV4 page clears their current ID when it looses focus.
_activePage->LooseFocus();
_activePage = _dir_page;
_mode = KLN89_MODE_CRSR;

View file

@ -22,6 +22,7 @@
// $Id$
#include "kln89_page.hxx"
#include <Main/fg_props.hxx>
KLN89Page::KLN89Page(KLN89* parent)
: GPSPage(parent) {
@ -130,7 +131,7 @@ void KLN89Page::Knob1Right1() {
}
void KLN89Page::Knob2Left1() {
if(_kln89->_mode != KLN89_MODE_CRSR) {
if(_kln89->_mode != KLN89_MODE_CRSR && !fgGetBool("/instrumentation/kln89/scan-pull")) {
GPSPage::Knob2Left1();
} else {
if(_uLinePos == 0 && _kln89->_obsMode) {
@ -144,7 +145,7 @@ void KLN89Page::Knob2Left1() {
}
void KLN89Page::Knob2Right1() {
if(_kln89->_mode != KLN89_MODE_CRSR) {
if(_kln89->_mode != KLN89_MODE_CRSR && !fgGetBool("/instrumentation/kln89/scan-pull")) {
GPSPage::Knob2Right1();
} else {
if(_uLinePos == 0 && _kln89->_obsMode) {

View file

@ -36,6 +36,7 @@ KLN89NavPage::KLN89NavPage(KLN89* parent)
_menuActive = false;
_menuPos = 0;
_suspendAVS = false;
_scanWpSet = false;
}
KLN89NavPage::~KLN89NavPage() {
@ -44,11 +45,15 @@ KLN89NavPage::~KLN89NavPage() {
void KLN89NavPage::Update(double dt) {
GPSFlightPlan* fp = ((KLN89*)_parent)->_activeFP;
GPSWaypoint* awp = _parent->GetActiveWaypoint();
// Scan-pull out on nav4 page switches off the cursor
if(3 == _subPage && fgGetBool("/instrumentation/kln89/scan-pull")) { _kln89->_mode = KLN89_MODE_DISP; }
bool crsr = (_kln89->_mode == KLN89_MODE_CRSR);
bool blink = _kln89->_blink;
double lat = _kln89->_gpsLat * SG_RADIANS_TO_DEGREES;
double lon = _kln89->_gpsLon * SG_RADIANS_TO_DEGREES;
if(_subPage != 3) { _scanWpSet = false; }
if(0 == _subPage) {
if(_kln89->_navFlagged) {
_kln89->DrawText("> F L A G", 2, 0, 2);
@ -240,7 +245,9 @@ void KLN89NavPage::Update(double dt) {
} else {
_kln89->DrawText("-:--", 2, 11, 0);
}
} else {
} else { // if(3 == _subPage)
// Switch the cursor off if scan-pull is out on this page.
if(fgGetBool("/instrumentation/kln89/scan-pull")) { _kln89->_mode = KLN89_MODE_DISP; }
// The moving map page the core KLN89 class draws this.
if(_kln89->_mapOrientation == 2 && _kln89->_groundSpeed_kts < 2) {
// Don't draw it if in track up mode and groundspeed < 2kts, as per real-life unit.
@ -298,6 +305,21 @@ void KLN89NavPage::Update(double dt) {
// Just draw the scale
_kln89->DrawMapText(scle_str, 1, 0, true);
}
// If the scan-pull knob is out, draw one of the waypoints (if applicable).
if(fgGetBool("/instrumentation/kln89/scan-pull")) {
if(_kln89->_activeFP->waypoints.size()) {
//cout << "Need to draw a waypoint!\n";
_kln89->DrawLine(70, 0, 111, 0);
if(!_kln89->_blink) {
//_kln89->DrawMapQuad(45, 0, 97, 8, true);
if(!_scanWpSet) {
_scanWpIndex = _kln89->GetActiveWaypointIndex();
_scanWpSet = true;
}
_kln89->DrawMapText(_kln89->_activeFP->waypoints[_scanWpIndex]->id, 71, 0, true);
}
}
}
// And do part of the field 1 update, since NAV 4 is a special case for the last line.
_kln89->DrawChar('>', 1, 0, 0);
if(crsr && _uLinePos == 1) _kln89->Underline(1, 1, 0, 5);
@ -357,8 +379,25 @@ void KLN89NavPage::Update(double dt) {
KLN89Page::Update(dt);
}
// Returns the id string of the selected waypoint on NAV4 if valid, else returns an empty string.
string KLN89NavPage::GetNav4WpId() {
if(3 == _subPage) {
if(fgGetBool("/instrumentation/kln89/scan-pull")) {
if(_kln89->_activeFP->waypoints.size()) {
if(!_scanWpSet) {
return(_kln89->_activeWaypoint.id);
} else {
return(_kln89->_activeFP->waypoints[_scanWpIndex]->id);
}
}
}
}
return("");
}
void KLN89NavPage::LooseFocus() {
_suspendAVS = false;
_scanWpSet = false;
}
void KLN89NavPage::CrsrPressed() {
@ -440,6 +479,23 @@ void KLN89NavPage::Knob1Right1() {
}
void KLN89NavPage::Knob2Left1() {
// If the inner-knob is out on the nav4 page, the only effect is to cycle the displayed waypoint.
if(3 == _subPage && fgGetBool("/instrumentation/kln89/scan-pull")) {
if(_kln89->_activeFP->waypoints.size()) { // TODO - find out what happens when scan-pull is on on nav4 without an active FP.
// It's unlikely that we could get here without _scanWpSet, but theoretically possible, so we need to cover it.
if(!_scanWpSet) {
_scanWpIndex = _kln89->GetActiveWaypointIndex();
_scanWpSet = true;
} else {
if(0 == _scanWpIndex) {
_scanWpIndex = _kln89->_activeFP->waypoints.size() - 1;
} else {
_scanWpIndex--;
}
}
}
return;
}
if(_kln89->_mode != KLN89_MODE_CRSR || _uLinePos == 0) {
KLN89Page::Knob2Left1();
return;
@ -477,6 +533,22 @@ void KLN89NavPage::Knob2Left1() {
}
void KLN89NavPage::Knob2Right1() {
// If the inner-knob is out on the nav4 page, the only effect is to cycle the displayed waypoint.
if(3 == _subPage && fgGetBool("/instrumentation/kln89/scan-pull")) {
if(_kln89->_activeFP->waypoints.size()) { // TODO - find out what happens when scan-pull is on on nav4 without an active FP.
// It's unlikely that we could get here without _scanWpSet, but theoretically possible, so we need to cover it.
if(!_scanWpSet) {
_scanWpIndex = _kln89->GetActiveWaypointIndex();
_scanWpSet = true;
} else {
_scanWpIndex++;
if(_scanWpIndex > _kln89->_activeFP->waypoints.size() - 1) {
_scanWpIndex = 0;
}
}
}
return;
}
if(_kln89->_mode != KLN89_MODE_CRSR || _uLinePos == 0) {
KLN89Page::Knob2Right1();
return;

View file

@ -41,6 +41,9 @@ public:
void LooseFocus();
// Returns the id string of the selected waypoint on NAV4 if valid, else returns an empty string.
string GetNav4WpId();
private:
int _posFormat; // 0 => lat,lon; 1 => ref to wp.
@ -60,4 +63,8 @@ private:
// NAV 4 menu stuff
bool _menuActive;
int _menuPos;
// NAV 4 waypoint scan drawing housekeeping.
bool _scanWpSet;
int _scanWpIndex;
};