mirror of
https://github.com/smittix/intercept.git
synced 2026-07-02 06:48:58 -07:00
Use pending click target for monitor retune frequency
This commit is contained in:
@@ -45,6 +45,7 @@ const Waterfall = (function () {
|
|||||||
let _monitorSource = 'process';
|
let _monitorSource = 'process';
|
||||||
let _pendingSharedMonitorRearm = false;
|
let _pendingSharedMonitorRearm = false;
|
||||||
let _pendingCaptureVfoMhz = null;
|
let _pendingCaptureVfoMhz = null;
|
||||||
|
let _pendingMonitorTuneMhz = null;
|
||||||
let _audioConnectNonce = 0;
|
let _audioConnectNonce = 0;
|
||||||
let _audioAnalyser = null;
|
let _audioAnalyser = null;
|
||||||
let _audioContext = null;
|
let _audioContext = null;
|
||||||
@@ -1185,6 +1186,7 @@ const Waterfall = (function () {
|
|||||||
const clamped = _clamp(freqMhz, 0.001, 6000.0);
|
const clamped = _clamp(freqMhz, 0.001, 6000.0);
|
||||||
_monitorFreqMhz = clamped;
|
_monitorFreqMhz = clamped;
|
||||||
_pendingCaptureVfoMhz = clamped;
|
_pendingCaptureVfoMhz = clamped;
|
||||||
|
_pendingMonitorTuneMhz = clamped;
|
||||||
_updateFreqDisplay();
|
_updateFreqDisplay();
|
||||||
|
|
||||||
if (_monitoring && !_isSharedMonitorActive()) {
|
if (_monitoring && !_isSharedMonitorActive()) {
|
||||||
@@ -1876,6 +1878,7 @@ const Waterfall = (function () {
|
|||||||
|
|
||||||
_monitorFreqMhz = clamped;
|
_monitorFreqMhz = clamped;
|
||||||
_pendingCaptureVfoMhz = clamped;
|
_pendingCaptureVfoMhz = clamped;
|
||||||
|
_pendingMonitorTuneMhz = clamped;
|
||||||
const currentSpan = _endMhz - _startMhz;
|
const currentSpan = _endMhz - _startMhz;
|
||||||
const configuredSpan = _clamp(_currentSpan(), 0.05, 30.0);
|
const configuredSpan = _clamp(_currentSpan(), 0.05, 30.0);
|
||||||
const activeSpan = Number.isFinite(currentSpan) && currentSpan > 0 ? currentSpan : configuredSpan;
|
const activeSpan = Number.isFinite(currentSpan) && currentSpan > 0 ? currentSpan : configuredSpan;
|
||||||
@@ -1935,6 +1938,7 @@ const Waterfall = (function () {
|
|||||||
if (Number.isFinite(msg.vfo_freq_mhz)) {
|
if (Number.isFinite(msg.vfo_freq_mhz)) {
|
||||||
_monitorFreqMhz = Number(msg.vfo_freq_mhz);
|
_monitorFreqMhz = Number(msg.vfo_freq_mhz);
|
||||||
_pendingCaptureVfoMhz = _monitorFreqMhz;
|
_pendingCaptureVfoMhz = _monitorFreqMhz;
|
||||||
|
_pendingMonitorTuneMhz = _monitorFreqMhz;
|
||||||
const input = document.getElementById('wfCenterFreq');
|
const input = document.getElementById('wfCenterFreq');
|
||||||
if (input) input.value = Number(msg.vfo_freq_mhz).toFixed(4);
|
if (input) input.value = Number(msg.vfo_freq_mhz).toFixed(4);
|
||||||
}
|
}
|
||||||
@@ -2243,7 +2247,9 @@ const Waterfall = (function () {
|
|||||||
function _sendWsStartCmd() {
|
function _sendWsStartCmd() {
|
||||||
if (!_ws || _ws.readyState !== WebSocket.OPEN) return;
|
if (!_ws || _ws.readyState !== WebSocket.OPEN) return;
|
||||||
const cfg = _waterfallRequestConfig();
|
const cfg = _waterfallRequestConfig();
|
||||||
const targetVfoMhz = Number.isFinite(_monitorFreqMhz) ? _monitorFreqMhz : cfg.centerMhz;
|
const targetVfoMhz = Number.isFinite(_pendingCaptureVfoMhz)
|
||||||
|
? _pendingCaptureVfoMhz
|
||||||
|
: (Number.isFinite(_monitorFreqMhz) ? _monitorFreqMhz : cfg.centerMhz);
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
cmd: 'start',
|
cmd: 'start',
|
||||||
@@ -2535,6 +2541,7 @@ const Waterfall = (function () {
|
|||||||
} else if (msg.status === 'stopped') {
|
} else if (msg.status === 'stopped') {
|
||||||
_running = false;
|
_running = false;
|
||||||
_pendingCaptureVfoMhz = null;
|
_pendingCaptureVfoMhz = null;
|
||||||
|
_pendingMonitorTuneMhz = null;
|
||||||
_scanAwaitingCapture = false;
|
_scanAwaitingCapture = false;
|
||||||
_scanStartPending = false;
|
_scanStartPending = false;
|
||||||
_scanRestartAttempts = 0;
|
_scanRestartAttempts = 0;
|
||||||
@@ -2547,6 +2554,7 @@ const Waterfall = (function () {
|
|||||||
} else if (msg.status === 'error') {
|
} else if (msg.status === 'error') {
|
||||||
_running = false;
|
_running = false;
|
||||||
_pendingCaptureVfoMhz = null;
|
_pendingCaptureVfoMhz = null;
|
||||||
|
_pendingMonitorTuneMhz = null;
|
||||||
_scanStartPending = false;
|
_scanStartPending = false;
|
||||||
_pendingSharedMonitorRearm = false;
|
_pendingSharedMonitorRearm = false;
|
||||||
// If the monitor was using the shared IQ stream that
|
// If the monitor was using the shared IQ stream that
|
||||||
@@ -2750,9 +2758,18 @@ const Waterfall = (function () {
|
|||||||
_resumeWaterfallAfterMonitor = !!wasRunningWaterfall;
|
_resumeWaterfallAfterMonitor = !!wasRunningWaterfall;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For retune-only calls, keep the current VFO frequency so
|
// Keep an explicit pending tune target so retunes cannot fall
|
||||||
// user clicks during the async reconnect are not overridden.
|
// back to a stale frequency during capture restart churn.
|
||||||
const centerMhz = retuneOnly ? _monitorFreqMhz : _currentCenter();
|
const requestedTuneMhz = Number.isFinite(_pendingMonitorTuneMhz)
|
||||||
|
? _pendingMonitorTuneMhz
|
||||||
|
: (
|
||||||
|
Number.isFinite(_pendingCaptureVfoMhz)
|
||||||
|
? _pendingCaptureVfoMhz
|
||||||
|
: (Number.isFinite(_monitorFreqMhz) ? _monitorFreqMhz : _currentCenter())
|
||||||
|
);
|
||||||
|
const centerMhz = retuneOnly
|
||||||
|
? (Number.isFinite(requestedTuneMhz) ? requestedTuneMhz : _currentCenter())
|
||||||
|
: _currentCenter();
|
||||||
const mode = document.getElementById('wfMonitorMode')?.value || 'wfm';
|
const mode = document.getElementById('wfMonitorMode')?.value || 'wfm';
|
||||||
const squelch = parseInt(document.getElementById('wfMonitorSquelch')?.value, 10) || 0;
|
const squelch = parseInt(document.getElementById('wfMonitorSquelch')?.value, 10) || 0;
|
||||||
const sliderGain = parseInt(document.getElementById('wfMonitorGain')?.value, 10);
|
const sliderGain = parseInt(document.getElementById('wfMonitorGain')?.value, 10);
|
||||||
@@ -2768,6 +2785,8 @@ const Waterfall = (function () {
|
|||||||
|
|
||||||
if (!retuneOnly) {
|
if (!retuneOnly) {
|
||||||
_monitorFreqMhz = centerMhz;
|
_monitorFreqMhz = centerMhz;
|
||||||
|
} else if (Number.isFinite(centerMhz)) {
|
||||||
|
_monitorFreqMhz = centerMhz;
|
||||||
}
|
}
|
||||||
_drawFreqAxis();
|
_drawFreqAxis();
|
||||||
_stopSmeter();
|
_stopSmeter();
|
||||||
@@ -2787,7 +2806,7 @@ const Waterfall = (function () {
|
|||||||
// clicks that changed the VFO during the async setup are
|
// clicks that changed the VFO during the async setup are
|
||||||
// picked up rather than overridden.
|
// picked up rather than overridden.
|
||||||
let { response, payload } = await _requestAudioStart({
|
let { response, payload } = await _requestAudioStart({
|
||||||
frequency: retuneOnly ? _monitorFreqMhz : centerMhz,
|
frequency: centerMhz,
|
||||||
modulation: mode,
|
modulation: mode,
|
||||||
squelch,
|
squelch,
|
||||||
gain,
|
gain,
|
||||||
@@ -2838,6 +2857,12 @@ const Waterfall = (function () {
|
|||||||
const attach = await _attachMonitorAudio(nonce);
|
const attach = await _attachMonitorAudio(nonce);
|
||||||
if (nonce !== _audioConnectNonce) return;
|
if (nonce !== _audioConnectNonce) return;
|
||||||
_monitorSource = payload?.source === 'waterfall' ? 'waterfall' : 'process';
|
_monitorSource = payload?.source === 'waterfall' ? 'waterfall' : 'process';
|
||||||
|
if (
|
||||||
|
Number.isFinite(_pendingMonitorTuneMhz)
|
||||||
|
&& Math.abs(_pendingMonitorTuneMhz - centerMhz) < 1e-6
|
||||||
|
) {
|
||||||
|
_pendingMonitorTuneMhz = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!attach.ok) {
|
if (!attach.ok) {
|
||||||
if (attach.reason === 'autoplay_blocked') {
|
if (attach.reason === 'autoplay_blocked') {
|
||||||
@@ -2932,6 +2957,7 @@ const Waterfall = (function () {
|
|||||||
_monitorSource = 'process';
|
_monitorSource = 'process';
|
||||||
_pendingSharedMonitorRearm = false;
|
_pendingSharedMonitorRearm = false;
|
||||||
_pendingCaptureVfoMhz = null;
|
_pendingCaptureVfoMhz = null;
|
||||||
|
_pendingMonitorTuneMhz = null;
|
||||||
_syncMonitorButtons();
|
_syncMonitorButtons();
|
||||||
_setMonitorState('No audio monitor');
|
_setMonitorState('No audio monitor');
|
||||||
|
|
||||||
@@ -3125,6 +3151,7 @@ const Waterfall = (function () {
|
|||||||
_wsOpened = false;
|
_wsOpened = false;
|
||||||
_pendingSharedMonitorRearm = false;
|
_pendingSharedMonitorRearm = false;
|
||||||
_pendingCaptureVfoMhz = null;
|
_pendingCaptureVfoMhz = null;
|
||||||
|
_pendingMonitorTuneMhz = null;
|
||||||
// Reset in-flight monitor start flag so the button is not left
|
// Reset in-flight monitor start flag so the button is not left
|
||||||
// disabled after a waterfall stop/restart cycle.
|
// disabled after a waterfall stop/restart cycle.
|
||||||
if (_startingMonitor) {
|
if (_startingMonitor) {
|
||||||
@@ -3405,6 +3432,7 @@ const Waterfall = (function () {
|
|||||||
_audioUnlockRequired = false;
|
_audioUnlockRequired = false;
|
||||||
_pendingSharedMonitorRearm = false;
|
_pendingSharedMonitorRearm = false;
|
||||||
_pendingCaptureVfoMhz = null;
|
_pendingCaptureVfoMhz = null;
|
||||||
|
_pendingMonitorTuneMhz = null;
|
||||||
_sseStartConfigKey = '';
|
_sseStartConfigKey = '';
|
||||||
_sseStartPromise = null;
|
_sseStartPromise = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user