KLN89: Remove several bugs related to OBS mode
This commit is contained in:
parent
e6aea6dcde
commit
9eca656a98
3 changed files with 42 additions and 9 deletions
|
@ -606,8 +606,11 @@ void KLN89::AltPressed() {}
|
|||
void KLN89::OBSPressed() {
|
||||
ToggleOBSMode();
|
||||
if(_obsMode) {
|
||||
// if(ORS 02)
|
||||
_mode = KLN89_MODE_CRSR;
|
||||
if(!fgGetBool("/instrumentation/nav/slaved-to-gps")) {
|
||||
// NOTE: this only applies to ORS 02 firmware, in ORS 01
|
||||
// CRSR mode is not automatically set when OBS is started.
|
||||
_mode = KLN89_MODE_CRSR;
|
||||
}
|
||||
_activePage->OBSPressed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,9 @@ void KLN89NavPage::Update(double dt) {
|
|||
}
|
||||
_kln89->DrawText(awp->id, 2, 10, 3);
|
||||
if(!_kln89->_dto && !_kln89->_obsMode && !_kln89->_fromWaypoint.id.empty()) {
|
||||
_kln89->DrawText(_kln89->_fromWaypoint.id, 2, 1, 3);
|
||||
if(_kln89->_fromWaypoint.type != GPS_WP_VIRT) { // Don't draw the virtual waypoint names
|
||||
_kln89->DrawText(_kln89->_fromWaypoint.id, 2, 1, 3);
|
||||
}
|
||||
}
|
||||
if(!(crsr && blink && _uLinePos == 1)) {
|
||||
if(_cdiFormat == 0) {
|
||||
|
|
|
@ -489,8 +489,7 @@ void DCLGPS::update(double dt) {
|
|||
_fromWaypoint = _activeWaypoint;
|
||||
_activeWaypoint = *_activeFP->waypoints[idx + 1];
|
||||
_dto = false;
|
||||
// TODO - course alteration message format is dependent on whether we are slaved HSI/CDI indicator or not.
|
||||
// For now assume we are not.
|
||||
// Course alteration message format is dependent on whether we are slaved HSI/CDI indicator or not.
|
||||
string s;
|
||||
if(fgGetBool("/instrumentation/nav[0]/slaved-to-gps")) {
|
||||
// TODO - avoid the hardwiring on nav[0]
|
||||
|
@ -1010,7 +1009,7 @@ void DCLGPS::DtoInitiate(const string& s) {
|
|||
_fromWaypoint.lat = _gpsLat;
|
||||
_fromWaypoint.lon = _gpsLon;
|
||||
_fromWaypoint.type = GPS_WP_VIRT;
|
||||
_fromWaypoint.id = "DTOWP";
|
||||
_fromWaypoint.id = "_DTOWP_";
|
||||
delete wp;
|
||||
} else {
|
||||
// TODO - Should bring up the user waypoint page.
|
||||
|
@ -1030,9 +1029,37 @@ void DCLGPS::DtoCancel() {
|
|||
void DCLGPS::ToggleOBSMode() {
|
||||
_obsMode = !_obsMode;
|
||||
if(_obsMode) {
|
||||
if(!_activeWaypoint.id.empty()) {
|
||||
_obsHeading = static_cast<int>(_dtkMag);
|
||||
// We need to set the OBS heading. The rules for this are:
|
||||
//
|
||||
// If the KLN89 is connected to an external HSI or CDI, then the OBS heading must be set
|
||||
// to the OBS radial on the external indicator, and cannot be changed in the KLN89.
|
||||
//
|
||||
// If the KLN89 is not connected to an external indicator, then:
|
||||
// If there is an active waypoint, the OBS heading is set such that the
|
||||
// deviation indicator remains at the same deviation (i.e. set to DTK,
|
||||
// although there may be some small difference).
|
||||
//
|
||||
// If there is not an active waypoint, I am not sure what value should be
|
||||
// set.
|
||||
//
|
||||
if(fgGetBool("/instrumentation/nav/slaved-to-gps")) {
|
||||
_obsHeading = static_cast<int>(fgGetDouble("/instrumentation/nav/radials/selected-deg") + 0.5);
|
||||
} else if(!_activeWaypoint.id.empty()) {
|
||||
// NOTE: I am not sure if this is completely correct. There are sometimes small differences
|
||||
// between DTK and default OBS heading in the simulator (~ 1 or 2 degrees). It might also
|
||||
// be that OBS heading should be stored as float and only displayed as int, in order to maintain
|
||||
// the initial bar deviation?
|
||||
_obsHeading = static_cast<int>(_dtkMag + 0.5);
|
||||
//cout << "_dtkMag = " << _dtkMag << ", _dtkTrue = " << _dtkTrue << ", _obsHeading = " << _obsHeading << '\n';
|
||||
} else {
|
||||
// TODO - what should we really do here?
|
||||
_obsHeading = 0;
|
||||
}
|
||||
|
||||
// Valid OBS heading values are 0 -> 359 degrees inclusive (from kln89 simulator).
|
||||
if(_obsHeading > 359) _obsHeading -= 360;
|
||||
if(_obsHeading < 0) _obsHeading += 360;
|
||||
|
||||
// TODO - the _fromWaypoint location will change as the OBS heading changes.
|
||||
// Might need to store the OBS initiation position somewhere in case it is needed again.
|
||||
SetOBSFromWaypoint();
|
||||
|
@ -1046,7 +1073,8 @@ void DCLGPS::SetOBSFromWaypoint() {
|
|||
|
||||
// TODO - base the 180 deg correction on the to/from flag.
|
||||
_fromWaypoint = GetPositionOnMagRadial(_activeWaypoint, 10, _obsHeading + 180.0);
|
||||
_fromWaypoint.id = "OBSWP";
|
||||
_fromWaypoint.type = GPS_WP_VIRT;
|
||||
_fromWaypoint.id = "_OBSWP_";
|
||||
}
|
||||
|
||||
void DCLGPS::CDIFSDIncrease() {
|
||||
|
|
Loading…
Add table
Reference in a new issue