Got voice prompts code compiling. (certain blocks are commented out until we get codec2 decode figured out).

md1702
vk7js 2022-05-09 22:23:37 +10:00 zatwierdzone przez Silvano Seva
rodzic 901db10c87
commit fd5c5b4979
5 zmienionych plików z 46 dodań i 25 usunięć

Wyświetl plik

@ -51,6 +51,8 @@ openrtx_src = ['openrtx/src/core/state.c',
'openrtx/src/core/audio_codec.c',
'openrtx/src/core/data_conversion.c',
'openrtx/src/core/memory_profiling.cpp',
'openrtx/src/core/voicePrompts.c',
'openrtx/src/core/voicePromptUtils.c',
'openrtx/src/ui/ui.c',
'openrtx/src/ui/UIStrings.c',
'openrtx/src/ui/ui_main.c',

Wyświetl plik

@ -21,7 +21,7 @@
#ifndef VOICE_PROMPT_UTILS_H_INCLUDED
#define VOICE_PROMPT_UTILS_H_INCLUDED
#include "core/voicePrompts.h"
#include "voicePrompts.h"
#include "ui/UIStrings.h"
#include "cps.h"

Wyświetl plik

@ -18,6 +18,10 @@
***************************************************************************/
#ifndef voice_prompts_h_included
#define voice_prompts_h_included
#include <datatypes.h>
#include <stdbool.h>
/*
Please note, these prompts represent spoken words or phrases which are not in
the UI string table, for example letters of the alphabet, digits, and
@ -111,6 +115,7 @@ PROMPT_TRANSMIT, // Transmit
PROMPT_MODE, // Mode
PROMPT_DMR, // D M R
PROMPT_FM, // F M
PROMPT_CHARACTER, // character
PROMPT_SPACE, // space
PROMPT_PERCENT, // Percent
PROMPT_POINT, // POINT
@ -141,7 +146,6 @@ PROMPT_UNDERLINE, // underline
PROMPT_CARET, // caret
PROMPT_LEFT_BRACE, // left brace
NUM_VOICE_PROMPTS,
__MAKE_ENUM_16BITS = INT16_MAX
} voicePrompt_t;
// PROMPT_VOICE_NAME is always the very last prompt after the indexed prompts
@ -176,7 +180,7 @@ void vpTick(void);
void vpInit(void);
// This function appends an individual prompt item to the prompt queue.
// This can be a single letter, number, or a phrase.
void vpAppendPrompt(uint16_t prompt);
void vpQueuePrompt(uint16_t prompt);
// This function appends the spelling of a complete string to the queue.
// It is used to pronounce strings for which we do not have a recorded voice
//prompt.

Wyświetl plik

@ -17,18 +17,21 @@
* along with this program; if not, see <http://www.gnu.org/licenses/> *
***************************************************************************/
// This file contains functions for announcing radio functions using the building blocks in voicePrompts.h/c.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "core/voicePromptUtils.h"
static void vpInitIfNeeded(VoicePromptQueueFlags_T flags)
{
if (flags&vpqInit)
if (flags & vpqInit)
vpInit();
}
static void vpPlayIfNeeded(VoicePromptQueueFlags_T flags)
{
if (flags&vpqPlayImmediatley)
if (flags & vpqPlayImmediately)
vpPlay();
}
@ -51,7 +54,7 @@ VoicePromptQueueFlags_T flags)
{
vpInitIfNeeded(flags);
if (flags&vpqIncludeDescriptions)
if (flags & vpqIncludeDescriptions)
{
vpQueuePrompt(PROMPT_CHANNEL);
}
@ -59,20 +62,24 @@ VoicePromptQueueFlags_T flags)
// Only queue the name if it is not the same as the raw number.
// Otherwise the radio will say channel 1 1 for channel 1.
if (strcmp(atoi(channelIndex), channel->name) != 0)
vpQueueString(channel->name);
char numAsStr[16]="\0";
snprintf(numAsStr, 16, "%d", channelIndex);
if (strcmp(numAsStr, channel->name) != 0)
vpQueueString(channel->name, flags);
vpPlayIfNeeded(flags);
}
static void vpQueueFrequency(freq_t freq)
{
char buffer[10];
snprintf(buffer, 10, "%d.%05d", (freq / 1000000), ((freq%1000000)/10));
char buffer[16];
int mhz = (freq / 1000000);
int khz = ((freq%1000000) / 10);
snprintf(buffer, 16, "%d.%05d", mhz, khz);
removeUnnecessaryZerosFromVoicePrompts(buffer);
vpQueueString(buffer);
vpQueueString(buffer, vpAnnounceCommonSymbols);
vpQueuePrompt(PROMPT_MEGAHERTZ);
}
@ -80,7 +87,9 @@ static void vpQueueFrequency(freq_t freq)
void announceFrequencies(freq_t rx, freq_t tx, VoicePromptQueueFlags_T flags)
{
vpInitIfNeeded(flags);
if (rx==tx)
// if rx and tx frequencies differ, announce both, otherwise just announce
// one.
if (rx == tx)
vpQueueFrequency(rx);
else
{
@ -96,7 +105,7 @@ void announceRadioMode(uint8_t mode, VoicePromptQueueFlags_T flags)
{
vpInitIfNeeded(flags);
if (flags&vpqIncludeDescriptions)
if (flags & vpqIncludeDescriptions)
vpQueuePrompt(PROMPT_MODE);
switch(mode)
@ -108,7 +117,7 @@ void announceRadioMode(uint8_t mode, VoicePromptQueueFlags_T flags)
vpQueuePrompt(PROMPT_FM);
break;
case OPMODE_M17:
vpQueuePrompt(PROMPT_M17);
vpQueueStringTableEntry(&currentLanguage->m17);
break;
}
@ -123,7 +132,7 @@ VoicePromptQueueFlags_T flags)
vpInitIfNeeded(flags);
// mask off init and play because this function will handle init and play.
VoicePromptQueueFlags_T localFlags=flags&vpqIncludeDescriptions;
VoicePromptQueueFlags_T localFlags=flags & vpqIncludeDescriptions;
announceChannelName(channel, channelIndex, localFlags);
announceFrequencies(channel->rx_frequency , channel->tx_frequency, localFlags);

Wyświetl plik

@ -17,9 +17,13 @@
* You should have received a copy of the GNU General Public License *
* along with this program; if not, see <http://www.gnu.org/licenses/> *
***************************************************************************/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include "core/voicePrompts.h"
#include "ui/UIStrings.h"
const uint32_t VOICE_PROMPTS_DATA_MAGIC = 0x5056;//'VP'
const uint32_t VOICE_PROMPTS_DATA_VERSION = 0x1000; // v1000 OpenRTX
// Must match the number of voice prompts allowed by the generator script.
@ -81,7 +85,7 @@ void vpCacheInit(void)
if (vpCheckHeader((uint32_t *)&header))
{// ToDo see above
voicePromptDataIsLoaded = SPI_Flash_read(VOICE_PROMPTS_FLASH_HEADER_ADDRESS + sizeof(voicePromptsDataHeader_t), (uint8_t *)&tableOfContents, sizeof(uint32_t) * VOICE_PROMPTS_TOC_SIZE);
voicePromptDataIsLoaded = false; //SPI_Flash_read(VOICE_PROMPTS_FLASH_HEADER_ADDRESS + sizeof(voicePromptsDataHeader_t), (uint8_t *)&tableOfContents, sizeof(uint32_t) * VOICE_PROMPTS_TOC_SIZE);
vpFlashDataAddress = VOICE_PROMPTS_FLASH_HEADER_ADDRESS + sizeof(voicePromptsDataHeader_t) + sizeof(uint32_t)*VOICE_PROMPTS_TOC_SIZE ;
}
@ -96,9 +100,11 @@ bool vpCheckHeader(uint32_t *bufferAddress)
static void GetCodec2Data(int offset,int length)
{
if (length <= Codec2DataBufferSize)
if ((offset >= 0) && (length <= Codec2DataBufferSize))
{// ToDo where are we reading this from?
SPI_Flash_read(vpFlashDataAddress + offset, (uint8_t *)&Codec2Data, length);
// Just so we can build,
;
//SPI_Flash_read(vpFlashDataAddress + offset, (uint8_t *)&Codec2Data, length);
}
}
@ -144,10 +150,10 @@ void vpTick(void)
{
promptTail--;
if ((promptTail == 0) && trxCarrierDetected() && (trxGetMode() == RADIO_MODE_ANALOG))
{// ToDo disable amp.
/*if ((promptTail == 0) && trxCarrierDetected() && (trxGetMode() == RADIO_MODE_ANALOG))
{// ToDo enable amp.
//GPIO_PinWrite(GPIO_RX_audio_mux, Pin_RX_audio_mux, 1); // Set the audio path to AT1846 -> audio amp.
}
}*/
}
}
}
@ -259,7 +265,7 @@ void vpQueueString(char *promptString, VoicePromptFlags_T flags)
else // announce ASCII
{
int32_t val = *promptString;
vpQueueLanguageString(&currentLanguage->dtmf_code); // just the word "code" as we don't have character.
vpQueuePrompt(PROMPT_CHARACTER); // just the word "code" as we don't have character.
vpQueueInteger(val);
}
}
@ -276,7 +282,7 @@ void vpQueueString(char *promptString, VoicePromptFlags_T flags)
void vpQueueInteger(int32_t value)
{
char buf[12] = {0}; // min: -2147483648, max: 2147483647
itoa(value, buf, 10);
snprintf(buf, 12, "%d", value);
vpQueueString(buf, 0);
}
@ -290,7 +296,7 @@ void vpQueueStringTableEntry(const char * const *stringTableStringPtr)
{
return;
}
vpQueuePrompt(NUM_VOICE_PROMPTS + (stringTableStringPtr - currentLanguage->languageName));
vpQueuePrompt(NUM_VOICE_PROMPTS + (stringTableStringPtr - &currentLanguage->languageName));
}
void vpPlay(void)