1
0
Fork 0

Navradio: disable low-pass filter when changing selected freq or leaving GPS slave mode

When the selected frequency is changed or when leaving GPS slave mode,
disable the low-pass filter applied to signal quality. Otherwise, the
following may happen for instance:
  - the active frequency corresponds to a navaid whose signal is well
    received;
  - user makes it so that the Morse code for the navaid ID can be heard;
  - user then changes the selected frequency to one that doesn't belong
    to a navaid that is close enough to be usable;
  - yet, as soon as the frequency is changed, the Morse code for the ID
    of the newly selected navaid (if any), even if it is way too far for
    its signal to be received, will be very clearly heard for about one
    second---and likely truncated.

This is because before this commit, after the frequency change, the
low-pass filter applied to signal quality made the code behave as if the
signal, supposedly coming from the new navaid, were still strong---which
of course doesn't correspond to physical reality. This fixes the bug
reported at [1].

[1] https://forum.flightgear.org/viewtopic.php?f=25&t=40890#p405708
This commit is contained in:
Florent Rougon 2022-11-05 18:27:08 +01:00
parent 1b5116fb32
commit d2f4807fa2
2 changed files with 13 additions and 5 deletions

View file

@ -511,8 +511,11 @@ void FGNavRadio::updateReceiver(double dt)
signal_quality_norm = 1/(range_exceed_norm*range_exceed_norm);
}
signal_quality_norm = fgGetLowPass( last_signal_quality_norm,
signal_quality_norm, dt );
if (_apply_lowpass_filter) {
signal_quality_norm = fgGetLowPass( last_signal_quality_norm,
signal_quality_norm, dt );
}
_apply_lowpass_filter = true;
signal_quality_norm_node->setDoubleValue( signal_quality_norm );
bool inrange = signal_quality_norm > 0.2;
@ -693,11 +696,12 @@ void FGNavRadio::valueChanged (SGPropertyNode* prop)
}
// slave-to-GPS enabled/disabled, resync NAV station (update all outputs)
_navaid = NULL;
_apply_lowpass_filter = false;
_time_before_search_sec = 0;
} else if ((prop == freq_node) || (prop == alt_freq_node)) {
updateFormattedFrequencies();
// force a frequency update
_time_before_search_sec = 0.0;
_apply_lowpass_filter = false; // signal quality allowed to vary quickly
_time_before_search_sec = 0.0; // force a frequency update
}
}

View file

@ -113,6 +113,10 @@ class FGNavRadio : public AbstractInstrument,
// internal (private) values
// When the selected frequency is changed or when leaving GPS slave mode,
// the low-pass filter applied to signal quality must be disabled. Setting
// this member to 'false' has one-shot behavior.
bool _apply_lowpass_filter = false;
int play_count;
bool _nav_search;
double _last_freq;