diff --git a/openrtx/include/core/voicePromptUtils.h b/openrtx/include/core/voicePromptUtils.h index f0c9294f..249b3c35 100644 --- a/openrtx/include/core/voicePromptUtils.h +++ b/openrtx/include/core/voicePromptUtils.h @@ -26,6 +26,7 @@ #include "cps.h" void announceVFO(); void announceChannelName(channel_t* channel, uint16_t channelIndex, VoicePromptQueueFlags_T flags); +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 announceChannelSummary(channel_t* channel, uint16_t channelIndex, @@ -33,5 +34,5 @@ VoicePromptQueueFlags_T flags); void AnnounceInputChar(char ch); void announceInputReceiveOrTransmit(bool tx, VoicePromptQueueFlags_T flags); void ReplayLastPrompt(); -void announceError(); +void announceError(VoicePromptQueueFlags_T flags); #endif //VOICE_PROMPT_UTILS_H_INCLUDED \ No newline at end of file diff --git a/openrtx/include/core/voicePrompts.h b/openrtx/include/core/voicePrompts.h index 2e7b3c98..ebcc58e5 100644 --- a/openrtx/include/core/voicePrompts.h +++ b/openrtx/include/core/voicePrompts.h @@ -167,6 +167,7 @@ typedef enum typedef enum { + vpqDefault = 0, vpqInit=0x01, // stop any voice prompts already in progress. vpqPlayImmediately=0x02, // call play after queue. vpqIncludeDescriptions=0x04 diff --git a/openrtx/src/core/voicePromptUtils.c b/openrtx/src/core/voicePromptUtils.c index 9fda3656..df94e036 100644 --- a/openrtx/src/core/voicePromptUtils.c +++ b/openrtx/src/core/voicePromptUtils.c @@ -78,7 +78,7 @@ VoicePromptQueueFlags_T flags) vpPlayIfNeeded(flags); } -static void vpQueueFrequency(freq_t freq) +void vpQueueFrequency(freq_t freq) { char buffer[16]; int mhz = (freq / 1000000); @@ -185,11 +185,11 @@ void ReplayLastPrompt() vpPlay(); } -void announceError() +void announceError(VoicePromptQueueFlags_T flags) { - vpInit(); + vpInitIfNeeded(flags); vpQueueStringTableEntry(¤tLanguage->error); - vpPlay(); + vpPlayIfNeeded(flags); } diff --git a/openrtx/src/ui/ui.c b/openrtx/src/ui/ui.c index 53ccc2ae..c88e67b9 100644 --- a/openrtx/src/ui/ui.c +++ b/openrtx/src/ui/ui.c @@ -570,13 +570,18 @@ int _ui_fsm_loadChannel(int16_t channel_index, bool *sync_rtx) { void _ui_fsm_confirmVFOInput(bool *sync_rtx) { + vpInit(); // Switch to TX input if(ui_state.input_set == SET_RX) { ui_state.input_set = SET_TX; // Reset input position ui_state.input_position = 0; - announceInputReceiveOrTransmit(true, (vpqInit | vpqPlayImmediately)); + // announce the rx frequency just confirmed with Enter. + vpQueueFrequency(ui_state.new_rx_frequency); + // defer playing till the end. + // indicate that the user has moved to the tx freq field. + announceInputReceiveOrTransmit(true, vpqDefault); } else if(ui_state.input_set == SET_TX) { @@ -593,20 +598,32 @@ 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)); + // force init to clear any prompts in progress. + // defer play because play is called at the end of the function + //due to above freq queuing. + announceFrequencies(state.channel.rx_frequency, state.channel.tx_frequency, vpqInit); } else - announceError(); + announceError(vpqInit); state.ui_screen = MAIN_VFO; } + vpPlay(); } void _ui_fsm_insertVFONumber(kbd_msg_t msg, bool *sync_rtx) { // Advance input position ui_state.input_position += 1; + // clear any prompts in progress. + vpInit(); // Save pressed number to calculate frequency and show in GUI ui_state.input_number = input_getPressedNumber(msg); + // queue the digit just pressed. + vpQueueInteger(ui_state.input_number); + // queue point if user has entered three digits. + if (ui_state.input_position==3) + vpQueuePrompt(PROMPT_POINT); + if(ui_state.input_set == SET_RX) { if(ui_state.input_position == 1) @@ -615,7 +632,10 @@ void _ui_fsm_insertVFONumber(kbd_msg_t msg, bool *sync_rtx) ui_state.new_rx_frequency = _ui_freq_add_digit(ui_state.new_rx_frequency, ui_state.input_position, ui_state.input_number); if(ui_state.input_position >= FREQ_DIGITS) - { + {// queue the rx freq just completed. + vpQueueFrequency(ui_state.new_rx_frequency); + /// now queue tx as user has changed fields. + vpQueuePrompt(PROMPT_TRANSMIT); // Switch to TX input ui_state.input_set = SET_TX; // Reset input position @@ -640,10 +660,13 @@ void _ui_fsm_insertVFONumber(kbd_msg_t msg, bool *sync_rtx) state.channel.rx_frequency = ui_state.new_rx_frequency; state.channel.tx_frequency = ui_state.new_tx_frequency; *sync_rtx = true; + // play is called at end. + announceFrequencies(state.channel.rx_frequency, state.channel.tx_frequency, vpqInit); } state.ui_screen = MAIN_VFO; } } + vpPlay(); } void _ui_changeBrightness(int variation) @@ -1113,11 +1136,9 @@ void ui_updateFSM(bool *sync_rtx) 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;