diff --git a/client/src/lib/Sequences/sequences.ts b/client/src/lib/Sequences/sequences.ts index b3436f9..7479479 100644 --- a/client/src/lib/Sequences/sequences.ts +++ b/client/src/lib/Sequences/sequences.ts @@ -217,7 +217,7 @@ export const infotainmentBootupSequence = async () => { } if (!get(sequenceStore).initializationComplete) { - const unsubscribe = sequenceStore.subscribe(data => { + const unsubscribe = sequenceStore.subscribe((data) => { if (data.initializationComplete) { sequence() unsubscribe() @@ -237,7 +237,7 @@ export const infotainmentBootupSequence = async () => { */ const waitForInfotainmentBootup = (sequence: () => void) => { if (!get(sequenceStore).infotainmentStartedFirstTime) { - const unsubscribe = sequenceStore.subscribe(data => { + const unsubscribe = sequenceStore.subscribe((data) => { if (data.infotainmentStartedFirstTime) { sequence() unsubscribe() @@ -430,3 +430,13 @@ export const modeLudicrousSequence = async () => { Notifications.playAudio(getVoicePath('set-acceleration-profile-ludicrous')) } + +export const gpwsTriggeredSequence = async () => { + if (get(settingsStore).disableAnnoyances) return + await tick() + + Notifications.error('Terrain, pull up!', { + withAudio: true, + src: getVoicePath('terrain-pull-up'), + }) +} diff --git a/client/src/lib/utils/initializeTelemetry.ts b/client/src/lib/utils/initializeTelemetry.ts index 06ba0cc..155636f 100644 --- a/client/src/lib/utils/initializeTelemetry.ts +++ b/client/src/lib/utils/initializeTelemetry.ts @@ -1,3 +1,4 @@ +import { gpwsTriggeredSequence } from '../Sequences/sequences' import { telemetryStore } from '../stores/telemetryStore' import { listen } from '@tauri-apps/api/event' @@ -25,7 +26,7 @@ export const initializeTelemetry = async ( ) } - const unlistenStatus = await listen('telemetry_status', event => { + const unlistenStatus = await listen('telemetry_status', (event) => { if (event.payload === 'connected') { telemetryStore.set('connected', true) } else if (event.payload === 'disconnected') { @@ -33,14 +34,22 @@ export const initializeTelemetry = async ( } }) - const unlistenTelemetry = await listen('telemetry_data', event => { + const unlistenTelemetry = await listen('telemetry_data', (event) => { const data = JSON.parse(event.payload as string) telemetryStore.set(data['topic_name'], data['data']) }) + const unlistenGpws = await listen('telemetry_gpws', (event) => { + const data = JSON.parse(event.payload as string) as boolean + if (data) { + gpwsTriggeredSequence() + } + }) + const unlistenAll = () => { unlistenStatus() unlistenTelemetry() + unlistenGpws() } return unlistenAll