From 68926a72c4ac3ceb4e724c5fd46729e63ab05e99 Mon Sep 17 00:00:00 2001 From: vk7js <58905135+vk7js@users.noreply.github.com> Date: Sat, 14 May 2022 12:12:06 +1000 Subject: [PATCH] Began work on the macros screen. Toggling tone or enabling/disabling (macros 1 and 2) now supported. Added new voice prompt for tone. --- openrtx/include/core/voicePromptUtils.h | 15 ++++++++- openrtx/include/core/voicePrompts.h | 1 + openrtx/src/core/voicePromptUtils.c | 45 +++++++++++++++++++++++++ openrtx/src/ui/ui.c | 6 ++++ 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/openrtx/include/core/voicePromptUtils.h b/openrtx/include/core/voicePromptUtils.h index b5caf2f4..a1886208 100644 --- a/openrtx/include/core/voicePromptUtils.h +++ b/openrtx/include/core/voicePromptUtils.h @@ -24,6 +24,19 @@ #include "voicePrompts.h" #include "ui/UIStrings.h" #include "cps.h" + +/* +Please Note! + +Many of the functions take queue flags because sometimes messages must be +played in sequence (i.e. the announceXX functions may be called one after the +other) and thus the init must only be sent prior to the first message queued +and the play must only be invoked after the last message queued. + +When an announceXX function is called in isolation, vpqInit|vpqPlayImmediately +should be used to ensure that the message interupts the current prompt and +plays immediately. +*/ void announceVFO(); void announceChannelName(channel_t* channel, uint16_t channelIndex, VoicePromptQueueFlags_T flags); void vpQueueFrequency(freq_t freq); @@ -42,5 +55,5 @@ passed in and if so, queues it, but if not, just spells the text character by character. */ void announceText( char* text, VoicePromptQueueFlags_T flags); - +void announceCTCSS(bool rxToneEnabled, uint8_t rxTone, bool txToneEnabled, uint8_t txTone, 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 ebcc58e5..cad3d15c 100644 --- a/openrtx/include/core/voicePrompts.h +++ b/openrtx/include/core/voicePrompts.h @@ -117,6 +117,7 @@ PROMPT_SOURCE_ID, // Source ID PROMPT_DEST_ID, // Destination ID PROMPT_DMR_ID, // DMR ID PROMPT_TALKGROUP, // Talk group +PROMPT_TONE, // tone PROMPT_CHARACTER, // character PROMPT_SPACE, // space PROMPT_PERCENT, // Percent diff --git a/openrtx/src/core/voicePromptUtils.c b/openrtx/src/core/voicePromptUtils.c index 27994688..4cad125c 100644 --- a/openrtx/src/core/voicePromptUtils.c +++ b/openrtx/src/core/voicePromptUtils.c @@ -210,3 +210,48 @@ void announceText( char* text, VoicePromptQueueFlags_T flags) vpPlayIfNeeded(flags); } + +void announceCTCSS(bool rxToneEnabled, uint8_t rxTone, bool txToneEnabled, uint8_t txTone, VoicePromptQueueFlags_T flags) +{ + vpInitIfNeeded(flags); + + if (!rxToneEnabled && !txToneEnabled) + { + vpQueuePrompt(PROMPT_TONE); + vpQueueStringTableEntry(¤tLanguage->off); + vpPlayIfNeeded(flags); + return; + } + + char buffer[16] = "\0"; + + // If the rx and tx tones are the same and both are enabled, just say Tone. + if ((rxToneEnabled && txToneEnabled) && (rxTone == txTone)) + { + vpQueuePrompt(PROMPT_TONE); + snprintf(buffer, 16, "%3.1f", ctcss_tone[rxTone]/10.0f); + vpQueueString(buffer, vpqDefault); + vpQueuePrompt(PROMPT_HERTZ); + vpPlayIfNeeded(flags); + return; + } + // speak the individual rx and tx tones. + if (rxToneEnabled) + { + vpQueuePrompt(PROMPT_RECEIVE); + vpQueuePrompt(PROMPT_TONE); + snprintf(buffer, 16, "%3.1f", ctcss_tone[rxTone]/10.0f); + vpQueueString(buffer, vpqDefault); + vpQueuePrompt(PROMPT_HERTZ); + } + if (txToneEnabled) + { + vpQueuePrompt(PROMPT_TRANSMIT); + vpQueuePrompt(PROMPT_TONE); + snprintf(buffer, 16, "%3.1f", ctcss_tone[txTone]/10.0f); + vpQueueString(buffer, vpqDefault); + vpQueuePrompt(PROMPT_HERTZ); + } + + vpPlayIfNeeded(flags); +} \ No newline at end of file diff --git a/openrtx/src/ui/ui.c b/openrtx/src/ui/ui.c index 76253bcf..e13eb94d 100644 --- a/openrtx/src/ui/ui.c +++ b/openrtx/src/ui/ui.c @@ -781,6 +781,9 @@ void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx) state.channel.fm.txTone %= MAX_TONE_INDEX; state.channel.fm.rxTone = state.channel.fm.txTone; *sync_rtx = true; + announceCTCSS(state.channel.fm.rxToneEn, state.channel.fm.rxTone, + state.channel.fm.txToneEn, state.channel.fm.txTone, + (vpqInit | vpqPlayImmediately)); } break; case 2: @@ -802,6 +805,9 @@ void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx) state.channel.fm.txToneEn = tone_tx_enable; state.channel.fm.rxToneEn = tone_rx_enable; *sync_rtx = true; + announceCTCSS(state.channel.fm.rxToneEn, state.channel.fm.rxTone, + state.channel.fm.txToneEn, state.channel.fm.txTone, + (vpqInit | vpqPlayImmediately)); } break; case 4: