Cat triggering dxwaterfall

This commit is contained in:
Szymon Porwolik
2025-11-28 20:09:54 +01:00
parent 4029ca9a9c
commit b510bd7fe1
2 changed files with 23 additions and 25 deletions

View File

@@ -819,8 +819,8 @@ $(document).ready(function() {
}
// Notify DX Waterfall of mode change for sideband display update
// Only refresh if mode actually changed (not on initial undefined → value transition)
if (modeChanged && typeof dxWaterfall !== 'undefined' && dxWaterfall.refresh) {
// Only refresh if mode actually changed AND waterfall is active (has canvas)
if (modeChanged && typeof dxWaterfall !== 'undefined' && dxWaterfall.canvas && dxWaterfall.refresh) {
// Update virtual CAT state
if (typeof window.catState !== 'undefined' && window.catState !== null) {
window.catState.mode = newMode;

View File

@@ -32,7 +32,7 @@ var DX_WATERFALL_CONSTANTS = {
VERSION: '0.9.6', // DX Waterfall version (keep in sync with @version in file header)
// Debug and logging
DEBUG_MODE: false, // Set to true for verbose logging, false for production
DEBUG_MODE: true, // Set to true for verbose logging, false for production
// Timing and debouncing
DEBOUNCE: {
@@ -4659,12 +4659,9 @@ var dxWaterfall = {
// Update last refresh time
this.lastRefreshTime = Date.now();
// Ensure canvas is initialized
// Ensure canvas is initialized - don't auto-init, just return
if (!this.canvas) {
this.init();
if (!this.canvas) {
return; // Canvas not available, abort
}
return; // Canvas not available, user must click power button
}
// Check if canvas is visible in DOM
@@ -6307,22 +6304,7 @@ function setFrequency(frequencyInKHz, fromWaterfall) {
// Canvas found, but DON'T auto-initialize
// Wait for user to click the power button
// Clear any existing timer before creating new one
if (autoRefreshTimer) {
clearInterval(autoRefreshTimer);
autoRefreshTimer = null;
DX_WATERFALL_UTILS.log.debug('[DX Waterfall] Cleared existing auto-refresh timer');
}
// Set up DX spots fetching at regular intervals (only when initialized)
autoRefreshTimer = setInterval(function() {
if (dxWaterfall.canvas) { // Only fetch if waterfall has been initialized
dxWaterfall.fetchDxSpots(true, false); // Background fetch - NOT user-initiated
}
}, DX_WATERFALL_CONSTANTS.DEBOUNCE.DX_SPOTS_FETCH_INTERVAL_MS);
DX_WATERFALL_UTILS.log.debug('[DX Waterfall] Auto-refresh timer created with interval: ' + DX_WATERFALL_CONSTANTS.DEBOUNCE.DX_SPOTS_FETCH_INTERVAL_MS + 'ms');
// Auto-refresh timer will be created when waterfall is turned on
} else {
// Canvas not found, try again in 100ms
@@ -6895,13 +6877,23 @@ function setFrequency(frequencyInKHz, fromWaterfall) {
// Show waiting message
dxWaterfall.displayWaitingMessage(lang_dxwaterfall_please_wait);
// Set up periodic refresh interval
// Set up periodic refresh interval for visual updates
waterfallRefreshInterval = setInterval(function() {
if (dxWaterfall.canvas) {
dxWaterfall.refresh();
}
}, DX_WATERFALL_CONSTANTS.VISUAL.STATIC_NOISE_REFRESH_MS);
// Set up DX spots fetching at regular intervals
if (autoRefreshTimer) {
clearInterval(autoRefreshTimer);
}
autoRefreshTimer = setInterval(function() {
if (dxWaterfall.canvas) {
dxWaterfall.fetchDxSpots(true, false); // Background fetch
}
}, DX_WATERFALL_CONSTANTS.DEBOUNCE.DX_SPOTS_FETCH_INTERVAL_MS);
// Add 3 second delay before initializing (allows page to stabilize)
initializationDelayTimer = setTimeout(function() {
if (DXWaterfallStateMachine.getState() === DX_WATERFALL_CONSTANTS.STATES.INITIALIZING) {
@@ -6953,6 +6945,12 @@ function setFrequency(frequencyInKHz, fromWaterfall) {
waterfallRefreshInterval = null;
}
// Stop the auto-refresh timer for DX spots
if (autoRefreshTimer) {
clearInterval(autoRefreshTimer);
autoRefreshTimer = null;
}
// Destroy the waterfall component (handles cleanup of memory, timers, event handlers, and DOM refs)
if (typeof dxWaterfall !== 'undefined' && dxWaterfall.canvas) {
dxWaterfall.destroy();