From 0a4ed4009c552b4ee865d001881517178aace4ad Mon Sep 17 00:00:00 2001 From: vk7js <58905135+vk7js@users.noreply.github.com> Date: Thu, 19 May 2022 16:34:58 +1000 Subject: [PATCH] Added announceGPSInfo so we can read something meaningful for the GPS screen (not yet hooked up). --- openrtx/include/core/voicePromptUtils.h | 3 ++ openrtx/src/core/voicePromptUtils.c | 61 +++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/openrtx/include/core/voicePromptUtils.h b/openrtx/include/core/voicePromptUtils.h index c2b2b7eb..a4c28de9 100644 --- a/openrtx/include/core/voicePromptUtils.h +++ b/openrtx/include/core/voicePromptUtils.h @@ -66,6 +66,9 @@ void announceTimeslot(uint8_t timeslot, VoicePromptQueueFlags_T flags); void announceColorCode(uint8_t rxColorCode, uint8_t txColorCode, VoicePromptQueueFlags_T flags); void announceBank(uint16_t bank, VoicePromptQueueFlags_T flags); void announceM17Info(channel_t* channel, VoicePromptQueueFlags_T flags); +#ifdef GPS_PRESENT +void announceGPSInfo(VoicePromptQueueFlags_T flags); +#endif // GPS_PRESENT VoicePromptQueueFlags_T GetQueueFlagsForVoiceLevel(); diff --git a/openrtx/src/core/voicePromptUtils.c b/openrtx/src/core/voicePromptUtils.c index c3bc7f02..b9bfbaf0 100644 --- a/openrtx/src/core/voicePromptUtils.c +++ b/openrtx/src/core/voicePromptUtils.c @@ -447,7 +447,68 @@ void announceM17Info(channel_t* channel, VoicePromptQueueFlags_T flags) vpPlayIfNeeded(flags); } + +#ifdef GPS_PRESENT +void announceGPSInfo(VoicePromptQueueFlags_T flags) +{ + if (!state.settings.gps_enabled) + return; + vpInitIfNeeded(flags); + if (flags & vpqIncludeDescriptions) + vpQueueStringTableEntry(¤tLanguage->gps); + + switch (state.gps_data.fix_quality) + { + case 0: + vpQueueStringTableEntry(¤tLanguage->noFix); + break; + case 1: + vpQueueString("SPS", vpAnnounceCommonSymbols); + break; + case 2: + vpQueueString("DGPS", vpAnnounceCommonSymbols); + break; + case 3: + vpQueueString("PPS", vpAnnounceCommonSymbols); + break; + case 6: + vpQueueStringTableEntry(¤tLanguage->fixLost); + break; + default: + vpQueueStringTableEntry(¤tLanguage->error); + vpPlayIfNeeded(flags); + return; + } + + switch(state.gps_data.fix_type) + { + case 2: + vpQueueString("2D", vpAnnounceCommonSymbols); + break; + case 3: + vpQueueString("3D", vpAnnounceCommonSymbols); + break; + } + // lat/long + char buffer[16] = "\0"; + snprintf(buffer, 16, "%8.6f N", state.gps_data.latitude); + vpQueueString(buffer, vpAnnounceCommonSymbols); + float longitude = state.gps_data.longitude; + const char *direction = (longitude < 0) ? "W" : "E"; + longitude = (longitude < 0) ? -longitude : longitude; + snprintf(buffer, 16, "%8.6f %s", longitude, direction); + vpQueueString(buffer, vpAnnounceCommonSymbols); + // speed/altitude: + snprintf(buffer, 16, "%4.1fkm/h", state.gps_data.speed); + vpQueueString(buffer, vpAnnounceCommonSymbols); + snprintf(buffer, 16, "%4.1fm", state.gps_data.altitude); + vpQueueString(buffer, vpAnnounceCommonSymbols); + + vpPlayIfNeeded(flags); +} +#endif // GPS_PRESENT + /* there are 5 levels of verbosity: