From d68f01ffbc38e213a77a32b82980e00c6e5a7f90 Mon Sep 17 00:00:00 2001 From: vk7js <58905135+vk7js@users.noreply.github.com> Date: Tue, 10 May 2022 22:20:06 +1000 Subject: [PATCH] Insert voice prompt utility function in UI code Began calling voice prompt utility functions from places such as: 1. arrowing up and down in VFO mode (read new frequencies) 2. up and down in memory mode: read new channel name. 3. up and down in VFO input mode: announce receive or transmit, 4. when starting to enter a frequency: announce receive and the first digit. --- openrtx/include/core/voicePromptUtils.h | 7 +++- openrtx/src/core/voicePromptUtils.c | 54 ++++++++++++++++++++++++- openrtx/src/ui/ui.c | 31 +++++++++++++- 3 files changed, 86 insertions(+), 6 deletions(-) diff --git a/openrtx/include/core/voicePromptUtils.h b/openrtx/include/core/voicePromptUtils.h index 8eaff794..f0c9294f 100644 --- a/openrtx/include/core/voicePromptUtils.h +++ b/openrtx/include/core/voicePromptUtils.h @@ -24,11 +24,14 @@ #include "voicePrompts.h" #include "ui/UIStrings.h" #include "cps.h" - +void announceVFO(); void announceChannelName(channel_t* channel, uint16_t channelIndex, VoicePromptQueueFlags_T flags); void announceFrequencies(freq_t rx, freq_t tx, VoicePromptQueueFlags_T flags); void announceRadioMode(uint8_t mode, VoicePromptQueueFlags_T flags); void announceChannelSummary(channel_t* channel, uint16_t channelIndex, VoicePromptQueueFlags_T flags); - +void AnnounceInputChar(char ch); +void announceInputReceiveOrTransmit(bool tx, VoicePromptQueueFlags_T flags); +void ReplayLastPrompt(); +void announceError(); #endif //VOICE_PROMPT_UTILS_H_INCLUDED \ No newline at end of file diff --git a/openrtx/src/core/voicePromptUtils.c b/openrtx/src/core/voicePromptUtils.c index af7fc837..8db7d764 100644 --- a/openrtx/src/core/voicePromptUtils.c +++ b/openrtx/src/core/voicePromptUtils.c @@ -48,6 +48,14 @@ static void removeUnnecessaryZerosFromVoicePrompts(char *str) } } } +void announceVFO() +{ + vpInit(); + + vpQueuePrompt(PROMPT_VFO); + + vpPlay(); +} void announceChannelName(channel_t* channel, uint16_t channelIndex, VoicePromptQueueFlags_T flags) @@ -111,10 +119,10 @@ void announceRadioMode(uint8_t mode, VoicePromptQueueFlags_T flags) switch(mode) { case OPMODE_DMR: - vpQueueStringTableEntry(currentLanguage->dmr); + vpQueueStringTableEntry(¤tLanguage->dmr); break; case OPMODE_FM: - vpQueueStringTableEntry(currentLanguage->fm); + vpQueueStringTableEntry(¤tLanguage->fm); break; case OPMODE_M17: vpQueueStringTableEntry(¤tLanguage->m17); @@ -141,3 +149,45 @@ VoicePromptQueueFlags_T flags) vpPlayIfNeeded(flags); } +void AnnounceInputChar(char ch) +{ + char buf[2] = "\0"; + buf[0] = ch; + + vpInit(); + + uint8_t flags = vpAnnounceCaps | vpAnnounceSpace | vpAnnounceCommonSymbols | vpAnnounceLessCommonSymbols; + + vpQueueString(buf, flags); + + vpPlay(); +} + +void announceInputReceiveOrTransmit(bool tx, VoicePromptQueueFlags_T flags) +{ + vpInitIfNeeded(flags); + + if (tx) + vpQueuePrompt(PROMPT_TRANSMIT); + else + vpQueuePrompt(PROMPT_RECEIVE); + + vpPlayIfNeeded(flags); +} + +void ReplayLastPrompt() +{ + if (vpIsPlaying()) + vpTerminate(); + else + vpPlay(); +} + +void announceError() +{ + vpInit(); + + vpQueueStringTableEntry(¤tLanguage->error); + + vpPlay(); +} diff --git a/openrtx/src/ui/ui.c b/openrtx/src/ui/ui.c index 6f2db86c..53ccc2ae 100644 --- a/openrtx/src/ui/ui.c +++ b/openrtx/src/ui/ui.c @@ -77,6 +77,7 @@ #include #include #include +#include "core/voicePromptUtils.h" /* UI main screen functions, their implementation is in "ui_main.c" */ extern void _ui_drawMainBackground(); @@ -575,6 +576,7 @@ void _ui_fsm_confirmVFOInput(bool *sync_rtx) ui_state.input_set = SET_TX; // Reset input position ui_state.input_position = 0; + announceInputReceiveOrTransmit(true, (vpqInit | vpqPlayImmediately)); } else if(ui_state.input_set == SET_TX) { @@ -591,7 +593,10 @@ void _ui_fsm_confirmVFOInput(bool *sync_rtx) state.channel.rx_frequency = ui_state.new_rx_frequency; state.channel.tx_frequency = ui_state.new_tx_frequency; *sync_rtx = true; + announceFrequencies(state.channel.rx_frequency, state.channel.tx_frequency, (vpqInit | vpqPlayImmediately)); } + else + announceError(); state.ui_screen = MAIN_VFO; } } @@ -906,7 +911,7 @@ void _ui_textInputKeypad(char *buf, uint8_t max_len, kbd_msg_t msg, bool callsig { ui_state.input_set = (ui_state.input_set + 1) % num_symbols; } - // Differnt key pressed: save current char and change key + // Different key pressed: save current char and change key else { ui_state.input_position += 1; @@ -917,7 +922,11 @@ void _ui_textInputKeypad(char *buf, uint8_t max_len, kbd_msg_t msg, bool callsig if(callsign) buf[ui_state.input_position] = symbols_ITU_T_E161_callsign[num_key][ui_state.input_set]; else + { buf[ui_state.input_position] = symbols_ITU_T_E161[num_key][ui_state.input_set]; + } + // Announce the character + AnnounceInputChar(buf[ui_state.input_position]); // Update reference values ui_state.input_number = num_key; ui_state.last_keypress = now; @@ -933,8 +942,11 @@ void _ui_textInputDel(char *buf) buf[ui_state.input_position] = '\0'; // Move back input cursor if(ui_state.input_position > 0) + { ui_state.input_position--; + AnnounceInputChar(buf[ui_state.input_position]); // If we deleted the initial character, reset starting condition + } else ui_state.last_keypress = 0; ui_state.input_set = 0; @@ -1053,6 +1065,8 @@ void ui_updateFSM(bool *sync_rtx) { // Switch to MEM screen state.ui_screen = MAIN_MEM; + // Anounce the active channel name. + announceChannelName(&state.channel, state.channel_index, (vpqInit | vpqPlayImmediately)); } } else if(msg.keys & KEY_HASH) @@ -1071,6 +1085,7 @@ void ui_updateFSM(bool *sync_rtx) state.channel.rx_frequency += 12500; state.channel.tx_frequency += 12500; *sync_rtx = true; + announceFrequencies(state.channel.rx_frequency, state.channel.tx_frequency, (vpqInit | vpqPlayImmediately)); } } else if(msg.keys & KEY_DOWN || msg.keys & KNOB_LEFT) @@ -1082,6 +1097,7 @@ void ui_updateFSM(bool *sync_rtx) state.channel.rx_frequency -= 12500; state.channel.tx_frequency -= 12500; *sync_rtx = true; + announceFrequencies(state.channel.rx_frequency, state.channel.tx_frequency, (vpqInit | vpqPlayImmediately)); } } else if(input_isNumberPressed(msg)) @@ -1091,13 +1107,17 @@ void ui_updateFSM(bool *sync_rtx) // Reset input position and selection ui_state.input_position = 1; ui_state.input_set = SET_RX; + // do not play because we will also announce the number just entered. + announceInputReceiveOrTransmit(false, vpqInit); ui_state.new_rx_frequency = 0; ui_state.new_tx_frequency = 0; // Save pressed number to calculare frequency and show in GUI ui_state.input_number = input_getPressedNumber(msg); + vpQueueInteger(ui_state.input_number); + vpPlay(); // Calculate portion of the new frequency ui_state.new_rx_frequency = _ui_freq_add_digit(ui_state.new_rx_frequency, - ui_state.input_position, ui_state.input_number); + ui_state.input_position, ui_state.input_number); } } break; @@ -1115,9 +1135,15 @@ void ui_updateFSM(bool *sync_rtx) else if(msg.keys & KEY_UP || msg.keys & KEY_DOWN) { if(ui_state.input_set == SET_RX) + { ui_state.input_set = SET_TX; + announceInputReceiveOrTransmit(true, (vpqInit | vpqPlayImmediately)); + } else if(ui_state.input_set == SET_TX) + { ui_state.input_set = SET_RX; + announceInputReceiveOrTransmit(false, (vpqInit | vpqPlayImmediately)); + } // Reset input position ui_state.input_position = 0; } @@ -1176,6 +1202,7 @@ void ui_updateFSM(bool *sync_rtx) *sync_rtx = true; // Switch to VFO screen state.ui_screen = MAIN_VFO; + announceVFO(); } else if(msg.keys & KEY_HASH) {