From 8527b8a6ef4485f83e17ce0f207e7db3fd981e83 Mon Sep 17 00:00:00 2001 From: vk7js <58905135+vk7js@users.noreply.github.com> Date: Thu, 19 May 2022 20:29:24 +1000 Subject: [PATCH] Add GPS voiceprompts announcing Removed flag parameters from summary and GPSInfo, hooked up the GPS info so that if the GPS screen is active, long hold f1 will read the GPS summary and f1 will repeat the last voice prompt like on the VFO and channel screens. --- openrtx/include/core/voicePromptUtils.h | 5 ++- openrtx/src/core/voicePromptUtils.c | 23 +++++++------ openrtx/src/ui/ui.c | 43 ++++++++++++++----------- 3 files changed, 40 insertions(+), 31 deletions(-) diff --git a/openrtx/include/core/voicePromptUtils.h b/openrtx/include/core/voicePromptUtils.h index a4c28de9..261681da 100644 --- a/openrtx/include/core/voicePromptUtils.h +++ b/openrtx/include/core/voicePromptUtils.h @@ -43,8 +43,7 @@ void vpQueueFrequency(freq_t freq); void announceFrequencies(freq_t rx, freq_t tx, VoicePromptQueueFlags_T flags); void announceRadioMode(uint8_t mode, VoicePromptQueueFlags_T flags); void announceBandwidth(uint8_t bandwidth, VoicePromptQueueFlags_T flags); -void announceChannelSummary(channel_t* channel, uint16_t channelIndex, -VoicePromptQueueFlags_T flags); +void announceChannelSummary(channel_t* channel, uint16_t channelIndex, uint16_t bank); void AnnounceInputChar(char ch); void announceInputReceiveOrTransmit(bool tx, VoicePromptQueueFlags_T flags); void ReplayLastPrompt(); @@ -67,7 +66,7 @@ void announceColorCode(uint8_t rxColorCode, uint8_t txColorCode, VoicePromptQue void announceBank(uint16_t bank, VoicePromptQueueFlags_T flags); void announceM17Info(channel_t* channel, VoicePromptQueueFlags_T flags); #ifdef GPS_PRESENT -void announceGPSInfo(VoicePromptQueueFlags_T flags); +void announceGPSInfo(); #endif // GPS_PRESENT VoicePromptQueueFlags_T GetQueueFlagsForVoiceLevel(); diff --git a/openrtx/src/core/voicePromptUtils.c b/openrtx/src/core/voicePromptUtils.c index 697d112a..62e39875 100644 --- a/openrtx/src/core/voicePromptUtils.c +++ b/openrtx/src/core/voicePromptUtils.c @@ -179,15 +179,14 @@ void anouncePower(float power, VoicePromptQueueFlags_T flags) vpPlayIfNeeded(flags); } -void announceChannelSummary(channel_t* channel, uint16_t channelIndex, -VoicePromptQueueFlags_T flags) +void announceChannelSummary(channel_t* channel, uint16_t channelIndex, uint16_t bank) { if (!channel) return; - vpInitIfNeeded(flags); + vpInit(); // mask off init and play because this function will handle init and play. - VoicePromptQueueFlags_T localFlags=flags & ~(vpqInit | vpqPlayImmediately); + VoicePromptQueueFlags_T localFlags= vpqAddSeparatingSilence; // Force on the descriptions for level 3. if (state.settings.vpLevel == vpHigh) localFlags |= vpqIncludeDescriptions; @@ -235,7 +234,7 @@ VoicePromptQueueFlags_T flags) if (channelIndex > 0) // i.e. not called from VFO. announceBank(bank, localFlags); - vpPlayIfNeeded(flags); + vpPlay(); } void AnnounceInputChar(char ch) @@ -466,13 +465,14 @@ void announceM17Info(channel_t* channel, VoicePromptQueueFlags_T flags) } #ifdef GPS_PRESENT -void announceGPSInfo(VoicePromptQueueFlags_T flags) +void announceGPSInfo() { if (!state.settings.gps_enabled) return; - vpInitIfNeeded(flags); - if (flags & vpqIncludeDescriptions) + vpInit(); + VoicePromptQueueFlags_T flags = vpqIncludeDescriptions | vpqAddSeparatingSilence; + vpQueueStringTableEntry(¤tLanguage->gps); switch (state.gps_data.fix_quality) @@ -494,9 +494,12 @@ void announceGPSInfo(VoicePromptQueueFlags_T flags) break; default: vpQueueStringTableEntry(¤tLanguage->error); - vpPlayIfNeeded(flags); + + vpPlay(); + return; } + addSilenceIfNeeded(flags); switch(state.gps_data.fix_type) { @@ -540,7 +543,7 @@ void announceGPSInfo(VoicePromptQueueFlags_T flags) vpQueuePrompt(PROMPT_SATELLITES); vpQueueInteger(__builtin_popcount(state.gps_data.active_sats)); - vpPlayIfNeeded(flags); + vpPlay(); } #endif // GPS_PRESENT diff --git a/openrtx/src/ui/ui.c b/openrtx/src/ui/ui.c index a2655451..a17ad05a 100644 --- a/openrtx/src/ui/ui.c +++ b/openrtx/src/ui/ui.c @@ -1167,14 +1167,14 @@ void ui_updateFSM(bool *sync_rtx) } else if(msg.keys & KEY_F1) { - if (state.settings.vpLevel > vpBeep) - {// quick press repeat vp, long press summary. - if (msg.long_press) - announceChannelSummary(&state.channel, 0, (vpqInit | vpqPlayImmediately)); - else - ReplayLastPrompt(); - f1Handled = true; - } + if (state.settings.vpLevel > vpBeep) + {// quick press repeat vp, long press summary. + if (msg.long_press) + announceChannelSummary(&state.channel, 0, state.bank); + else + ReplayLastPrompt(); + f1Handled = true; + } } else if(input_isNumberPressed(msg)) { @@ -1253,15 +1253,14 @@ void ui_updateFSM(bool *sync_rtx) ui_state.edit_mode = false; else if(msg.keys & KEY_F1) { - if (state.settings.vpLevel > vpBeep) - {// quick press repeat vp, long press summary. - if (msg.long_press) - announceChannelSummary(&state.channel, state.channel_index, - (vpqInit|vpqPlayImmediately)); - else - ReplayLastPrompt(); - f1Handled=true; - } + if (state.settings.vpLevel > vpBeep) + {// quick press repeat vp, long press summary. + if (msg.long_press) + announceChannelSummary(&state.channel, state.channel_index, state.bank); + else + ReplayLastPrompt(); + f1Handled=true; + } } else if(msg.keys & KEY_UP || msg.keys & KEY_DOWN || msg.keys & KEY_LEFT || msg.keys & KEY_RIGHT) @@ -1436,7 +1435,15 @@ void ui_updateFSM(bool *sync_rtx) #ifdef GPS_PRESENT // GPS menu screen case MENU_GPS: - if(msg.keys & KEY_ESC) + if ((msg.keys & KEY_F1) && (state.settings.vpLevel > vpBeep)) + {// quick press repeat vp, long press summary. + if (msg.long_press) + announceGPSInfo(); + else + ReplayLastPrompt(); + f1Handled = true; + } + else if(msg.keys & KEY_ESC) _ui_menuBack(MENU_TOP); break; #endif