From 8fab0b1e8cbb728fbbbb6bef0a865e24d4ad6d64 Mon Sep 17 00:00:00 2001 From: vk7js <58905135+vk7js@users.noreply.github.com> Date: Tue, 17 May 2022 20:34:04 +1000 Subject: [PATCH] Added vpLevel and vpPhoneticSpell to settings. These take up 4 bits with 4 bits reserved for on the fly voice rate. Not yet hooked up to menus. --- openrtx/include/core/settings.h | 9 ++++++++- openrtx/include/core/voicePrompts.h | 7 +------ openrtx/src/core/voicePromptUtils.c | 5 +++-- openrtx/src/core/voicePrompts.c | 18 ++++++++++-------- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/openrtx/include/core/settings.h b/openrtx/include/core/settings.h index 69a266f4..7a42ae9a 100644 --- a/openrtx/include/core/settings.h +++ b/openrtx/include/core/settings.h @@ -56,6 +56,10 @@ typedef struct char callsign[10]; // Plaintext callsign, for future use uint8_t display_timer : 4, // Standby timer not_in_use : 4; + uint8_t vpLevel : 3, + vpPhoneticSpell : 1, + vpReserved : 4; // reserved for voice rate on the fly. + } __attribute__((packed)) settings_t; @@ -74,7 +78,10 @@ static const settings_t default_settings = false, // GPS enabled "", // Empty callsign TIMER_30S, // 30 seconds - 0 // not in use + 0, // not in use + 0, // vpOff, + 0, // phonetic spell off, + 0 // not in use. }; #endif /* SETTINGS_H */ diff --git a/openrtx/include/core/voicePrompts.h b/openrtx/include/core/voicePrompts.h index 8cfedec1..b6fb6b64 100644 --- a/openrtx/include/core/voicePrompts.h +++ b/openrtx/include/core/voicePrompts.h @@ -200,12 +200,7 @@ typedef enum vpqPlayImmediately=0x02, // call play after queue. vpqIncludeDescriptions=0x04 } VoicePromptQueueFlags_T; -/* -These values correspond to prompts in the wordlistXX.csv file in the -voicePromptGenerator subproject. -They must not be reordered. -They correspond to prompts for which there are no string table entries. -*/ + typedef enum { vpNone=0, diff --git a/openrtx/src/core/voicePromptUtils.c b/openrtx/src/core/voicePromptUtils.c index 95ab7b4d..ed70b101 100644 --- a/openrtx/src/core/voicePromptUtils.c +++ b/openrtx/src/core/voicePromptUtils.c @@ -20,7 +20,8 @@ #include #include #include - + #include + #include "core/voicePromptUtils.h" static void vpInitIfNeeded(VoicePromptQueueFlags_T flags) @@ -174,7 +175,7 @@ VoicePromptQueueFlags_T flags) // mask off init and play because this function will handle init and play. VoicePromptQueueFlags_T localFlags=flags & ~(vpqInit | vpqPlayImmediately); - if (vpLevel == vpHigh) + if (state.settings.vpLevel == vpHigh) localFlags |= vpqIncludeDescriptions; announceChannelName(channel, channelIndex, localFlags); diff --git a/openrtx/src/core/voicePrompts.c b/openrtx/src/core/voicePrompts.c index 63344462..c7b57775 100644 --- a/openrtx/src/core/voicePrompts.c +++ b/openrtx/src/core/voicePrompts.c @@ -23,6 +23,7 @@ #include #include "core/voicePrompts.h" #include "ui/UIStrings.h" +#include const uint32_t VOICE_PROMPTS_DATA_MAGIC = 0x5056;//'VP' const uint32_t VOICE_PROMPTS_DATA_VERSION = 0x1000; // v1000 OpenRTX @@ -49,8 +50,7 @@ static uint32_t vpFlashDataAddress;// = VOICE_PROMPTS_FLASH_HEADER_ADDRESS + siz #define Codec2DataBufferSize 2052 bool vpDataIsLoaded = false; - VoicePromptVerbosity_T vpLevel = vpHigh; - + static bool voicePromptIsActive = false; // Uninitialized is -1. static int promptDataPosition = -1; @@ -105,7 +105,7 @@ void vpCacheInit(void) vpFlashDataAddress = VOICE_PROMPTS_FLASH_HEADER_ADDRESS + sizeof(voicePromptsDataHeader_t) + sizeof(uint32_t)*VOICE_PROMPTS_TOC_SIZE ; } if (!vpDataIsLoaded) - vpLevel = vpNone; + state.settings.vpLevel = vpNone; } bool vpCheckHeader(uint32_t *bufferAddress) @@ -203,7 +203,7 @@ void vpInit(void) void vpQueuePrompt(uint16_t prompt) { - if (vpLevel < vpLow) + if (state.settings.vpLevel < vpLow) return; if (voicePromptIsActive) @@ -262,7 +262,7 @@ VoicePromptFlags_T flags, voicePrompt_t* vp) // This function spells out a string letter by letter. void vpQueueString(char *promptString, VoicePromptFlags_T flags) { - if (vpLevel < vpLow) + if (state.settings.vpLevel < vpLow) return; if (voicePromptIsActive) @@ -270,6 +270,8 @@ void vpQueueString(char *promptString, VoicePromptFlags_T flags) vpInit(); } + if (state.settings.vpPhoneticSpell) + flags|=vpAnnouncePhoneticRendering; while (*promptString != 0) { int advanceBy=0; @@ -327,7 +329,7 @@ void vpQueueString(char *promptString, VoicePromptFlags_T flags) void vpQueueInteger(int32_t value) { - if (vpLevel < vpLow) + if (state.settings.vpLevel < vpLow) return; char buf[12] = {0}; // min: -2147483648, max: 2147483647 @@ -341,7 +343,7 @@ void vpQueueInteger(int32_t value) // NUM_VOICE_PROMPTS + (stringTableStringPtr - currentLanguage->languageName) void vpQueueStringTableEntry(const char * const *stringTableStringPtr) { - if (vpLevel < vpLow) + if (state.settings.vpLevel < vpLow) return; if (stringTableStringPtr == NULL) @@ -353,7 +355,7 @@ void vpQueueStringTableEntry(const char * const *stringTableStringPtr) void vpPlay(void) { - if (vpLevel < vpLow) + if (state.settings.vpLevel < vpLow) return; if ((voicePromptIsActive == false) && (vpCurrentSequence.Length > 0))