From 33867ec009130592e1fb751e4cb2e22cf6a12838 Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Fri, 26 Aug 2022 16:58:43 +0200 Subject: [PATCH] Fixed speaking of voice prompt level when changing from the menu. --- openrtx/include/core/voicePromptUtils.h | 5 +++++ openrtx/include/core/voicePrompts.h | 3 +++ openrtx/src/core/voicePromptUtils.c | 25 +++++++++++++++++++++++++ openrtx/src/ui/ui.c | 12 ++++++++++++ openrtx/src/ui/ui_menu.c | 5 ++++- 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/openrtx/include/core/voicePromptUtils.h b/openrtx/include/core/voicePromptUtils.h index dcdf136f..10908fdf 100644 --- a/openrtx/include/core/voicePromptUtils.h +++ b/openrtx/include/core/voicePromptUtils.h @@ -188,6 +188,11 @@ void vp_announceRestoreScreen(); void vp_announceSettingsTimeDate(); #endif +/** + * This is called to speak voice prompt level changes. + */ +void vp_announceSettingsVoiceLevel(const vpQueueFlags_t flags); + /** * */ diff --git a/openrtx/include/core/voicePrompts.h b/openrtx/include/core/voicePrompts.h index d58797e5..55e5a644 100644 --- a/openrtx/include/core/voicePrompts.h +++ b/openrtx/include/core/voicePrompts.h @@ -180,6 +180,9 @@ typedef enum } voicePrompt_t; +// The name of the voice prompt file is always encoded as the last prompt. +#define PROMPT_VOICE_NAME (NUM_VOICE_PROMPTS + (sizeof(stringsTable_t)/sizeof(char*))) + /** * Flags controlling how vp_queueString operates. */ diff --git a/openrtx/src/core/voicePromptUtils.c b/openrtx/src/core/voicePromptUtils.c index 40010089..d5cb6d1f 100644 --- a/openrtx/src/core/voicePromptUtils.c +++ b/openrtx/src/core/voicePromptUtils.c @@ -692,6 +692,31 @@ void vp_announceSettingsTimeDate() } #endif // RTC_PRESENT +void vp_announceSettingsVoiceLevel(const vpQueueFlags_t flags) +{ + clearCurrPromptIfNeeded(flags); + switch (state.settings.vpLevel) + { + case vpNone: + vp_queueStringTableEntry(¤tLanguage->off); + break; + + case vpBeep: + vp_queueStringTableEntry(¤tLanguage->beep); + break; + + default: + if (flags & vpqIncludeDescriptions) + { + vp_queuePrompt(PROMPT_VOICE_NAME); + vp_queueStringTableEntry(¤tLanguage->level); + } + vp_queueInteger(state.settings.vpLevel-vpBeep); + break; + } + + playIfNeeded(flags); +} vpQueueFlags_t vp_getVoiceLevelQueueFlags() { diff --git a/openrtx/src/ui/ui.c b/openrtx/src/ui/ui.c index 69f40980..1d80b06c 100644 --- a/openrtx/src/ui/ui.c +++ b/openrtx/src/ui/ui.c @@ -742,6 +742,18 @@ static void _ui_changeVoiceLevel(int variation) } state.settings.vpLevel += variation; + + // Force these flags to ensure the changes are spoken for levels 1 through 3. + vpQueueFlags_t flags = vpqInit + | vpqAddSeparatingSilence + | vpqPlayImmediately; + + if (!vp_isPlaying()) + { + flags |= vpqIncludeDescriptions; + } + + vp_announceSettingsVoiceLevel(flags); } static void _ui_changePhoneticSpell(bool newVal) diff --git a/openrtx/src/ui/ui_menu.c b/openrtx/src/ui/ui_menu.c index 80883f36..69007e49 100644 --- a/openrtx/src/ui/ui_menu.c +++ b/openrtx/src/ui/ui_menu.c @@ -102,8 +102,11 @@ static void announceMenuItemIfNeeded(char* name, char* value) // e.g. when changing a value with left or right, we don't want to repeat the // prompt if arrowing rapidly. bool voicePromptWasPlaying = vp_isPlaying(); + // Stop any prompt in progress and clear the buffer. - vp_clearCurrPrompt(); + if (voicePromptWasPlaying) + vp_clearCurrPrompt(); + // If no value is supplied, or, no prompt is in progress, announce the name. if ((voicePromptWasPlaying == false) || (value == NULL) || (*value == '\0')) vp_announceText(name, vpqDefault);