feat: add gpws detection
This commit is contained in:
parent
9c4cf32b73
commit
8dd6edc60a
2 changed files with 23 additions and 4 deletions
|
@ -217,7 +217,7 @@ export const infotainmentBootupSequence = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!get(sequenceStore).initializationComplete) {
|
if (!get(sequenceStore).initializationComplete) {
|
||||||
const unsubscribe = sequenceStore.subscribe(data => {
|
const unsubscribe = sequenceStore.subscribe((data) => {
|
||||||
if (data.initializationComplete) {
|
if (data.initializationComplete) {
|
||||||
sequence()
|
sequence()
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
|
@ -237,7 +237,7 @@ export const infotainmentBootupSequence = async () => {
|
||||||
*/
|
*/
|
||||||
const waitForInfotainmentBootup = (sequence: () => void) => {
|
const waitForInfotainmentBootup = (sequence: () => void) => {
|
||||||
if (!get(sequenceStore).infotainmentStartedFirstTime) {
|
if (!get(sequenceStore).infotainmentStartedFirstTime) {
|
||||||
const unsubscribe = sequenceStore.subscribe(data => {
|
const unsubscribe = sequenceStore.subscribe((data) => {
|
||||||
if (data.infotainmentStartedFirstTime) {
|
if (data.infotainmentStartedFirstTime) {
|
||||||
sequence()
|
sequence()
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
|
@ -430,3 +430,13 @@ export const modeLudicrousSequence = async () => {
|
||||||
|
|
||||||
Notifications.playAudio(getVoicePath('set-acceleration-profile-ludicrous'))
|
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'),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { gpwsTriggeredSequence } from '../Sequences/sequences'
|
||||||
import { telemetryStore } from '../stores/telemetryStore'
|
import { telemetryStore } from '../stores/telemetryStore'
|
||||||
import { listen } from '@tauri-apps/api/event'
|
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') {
|
if (event.payload === 'connected') {
|
||||||
telemetryStore.set('connected', true)
|
telemetryStore.set('connected', true)
|
||||||
} else if (event.payload === 'disconnected') {
|
} 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)
|
const data = JSON.parse(event.payload as string)
|
||||||
telemetryStore.set(data['topic_name'], data['data'])
|
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 = () => {
|
const unlistenAll = () => {
|
||||||
unlistenStatus()
|
unlistenStatus()
|
||||||
unlistenTelemetry()
|
unlistenTelemetry()
|
||||||
|
unlistenGpws()
|
||||||
}
|
}
|
||||||
|
|
||||||
return unlistenAll
|
return unlistenAll
|
||||||
|
|
Loading…
Reference in a new issue