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: