From 46bf2cc385074f7c520faffbaf37842f9dfe018d Mon Sep 17 00:00:00 2001 From: itsrubberduck Date: Fri, 19 Jun 2026 12:40:26 +0200 Subject: [PATCH] feat(pm): mirror full COM1 panel (active + standby) from SimBridge Sync both COM_ACTIVE_FREQUENCY and COM_STANDBY_FREQUENCY from bridge telemetry into the radio, each tracked independently so they only retune on an actual sim change. Active retune still cuts in-progress ATC speech; standby has no audio side effects. Co-Authored-By: Claude Opus 4.8 --- app/pages/pm.vue | 49 ++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/app/pages/pm.vue b/app/pages/pm.vue index 7dc561f..fcd1850 100644 --- a/app/pages/pm.vue +++ b/app/pages/pm.vue @@ -4807,9 +4807,10 @@ watch(prerecEnabled, (val) => { // --- SimBridge live frequency sync ----------------------------------------- // When /pm is opened with ?token= and that bridge is actively -// posting telemetry, mirror the sim's COM1 active frequency into the radio and -// surface a "Bridge connected" indicator. The bridge counts as connected only -// while fresh telemetry keeps arriving — if it goes quiet we drop the badge. +// posting telemetry, mirror the sim's COM1 radio panel (active + standby) into +// the radio and surface a "Bridge connected" indicator. The bridge counts as +// connected only while fresh telemetry keeps arriving — if it goes quiet we +// drop the badge. const bridgeToken = computed(() => { const value = route.query.token const raw = Array.isArray(value) ? value[0] : value @@ -4821,9 +4822,10 @@ const bridgeSimActiveFreq = ref(null) const BRIDGE_TELEMETRY_STALE_MS = 12_000 const BRIDGE_POLL_INTERVAL_MS = 3_000 let bridgePoller: ReturnType | null = null -// Last sim frequency we pushed into the radio — only re-tune when the sim value -// actually changes, so manual/flow tuning isn't constantly overridden. -let lastSyncedSimFreq: string | null = null +// Last sim frequencies we pushed into the radio — only re-tune when the sim +// value actually changes, so manual/flow tuning isn't constantly overridden. +let lastSyncedSimActive: string | null = null +let lastSyncedSimStandby: string | null = null function normalizeSimFreq(value: unknown): string | null { const num = typeof value === 'number' ? value : Number(value) @@ -4844,22 +4846,32 @@ async function pollBridgeTelemetry() { bridgeConnected.value = fresh if (!fresh) { - // Bridge went quiet — drop the sync anchor so reconnecting re-tunes. - lastSyncedSimFreq = null + // Bridge went quiet — drop the sync anchors so reconnecting re-tunes. + lastSyncedSimActive = null + lastSyncedSimStandby = null bridgeSimActiveFreq.value = null return } - const simFreq = normalizeSimFreq(res.telemetry?.COM_ACTIVE_FREQUENCY) - bridgeSimActiveFreq.value = simFreq - if (simFreq && simFreq !== lastSyncedSimFreq) { - lastSyncedSimFreq = simFreq - if (frequencies.value.active !== simFreq) { - // Mirror the sim radio: tuning away cuts in-progress ATC speech on the - // old channel, same as a manual tune. + const simActive = normalizeSimFreq(res.telemetry?.COM_ACTIVE_FREQUENCY) + const simStandby = normalizeSimFreq(res.telemetry?.COM_STANDBY_FREQUENCY) + bridgeSimActiveFreq.value = simActive + + // Mirror COM1 active: tuning away cuts in-progress ATC speech on the old + // channel, same as a manual tune. + if (simActive && simActive !== lastSyncedSimActive) { + lastSyncedSimActive = simActive + if (frequencies.value.active !== simActive) { stopCurrentSpeech() - frequencies.value.standby = frequencies.value.active - frequencies.value.active = simFreq + frequencies.value.active = simActive + } + } + + // Mirror COM1 standby (no audio side effects — it's just the staged channel). + if (simStandby && simStandby !== lastSyncedSimStandby) { + lastSyncedSimStandby = simStandby + if (frequencies.value.standby !== simStandby) { + frequencies.value.standby = simStandby } } } catch { @@ -4888,7 +4900,8 @@ onMounted(() => { watch(bridgeToken, () => { bridgeConnected.value = false bridgeSimActiveFreq.value = null - lastSyncedSimFreq = null + lastSyncedSimActive = null + lastSyncedSimStandby = null startBridgeSync() })