Added vpQueueFrequency to speak frequency with proper handling of decimal place and addition of MHz.
This commit is contained in:
parent
88619dc682
commit
af76afb521
|
|
@ -168,6 +168,8 @@ void vpAppendPrompt(uint16_t prompt);// Append an individual prompt item. This c
|
||||||
void vpQueueString(char *promptString, VoicePromptFlags_T flags);
|
void vpQueueString(char *promptString, VoicePromptFlags_T flags);
|
||||||
void vpQueueInteger(int32_t value); // Append a signed integer
|
void vpQueueInteger(int32_t value); // Append a signed integer
|
||||||
void vpQueueStringTableEntry(const char * const *);//Append a text string from the current language e.g. currentLanguage->off
|
void vpQueueStringTableEntry(const char * const *);//Append a text string from the current language e.g. currentLanguage->off
|
||||||
|
void vpQueueFrequency(freq_t freq, bool includeMHz);
|
||||||
|
|
||||||
void vpPlay(void);// Starts prompt playback
|
void vpPlay(void);// Starts prompt playback
|
||||||
extern bool vpIsPlaying(void);
|
extern bool vpIsPlaying(void);
|
||||||
bool vpHasDataToPlay(void);
|
bool vpHasDataToPlay(void);
|
||||||
|
|
|
||||||
|
|
@ -316,3 +316,32 @@ bool vpHasDataToPlay(void)
|
||||||
return (vpCurrentSequence.Length > 0);
|
return (vpCurrentSequence.Length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void removeUnnecessaryZerosFromVoicePrompts(char *str)
|
||||||
|
{
|
||||||
|
const int NUM_DECIMAL_PLACES = 1;
|
||||||
|
int len = strlen(str);
|
||||||
|
for(int i = len; i > 2; i--)
|
||||||
|
{
|
||||||
|
if ((str[i - 1] != '0') || (str[i - (NUM_DECIMAL_PLACES + 1)] == '.'))
|
||||||
|
{
|
||||||
|
str[i] = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void vpQueueFrequency(freq_t freq, bool includeMHz)
|
||||||
|
{
|
||||||
|
char buffer[10];
|
||||||
|
|
||||||
|
snprintf(buffer, 10, "%d.%05d", (freq / 1000000), ((freq%1000000)/10));
|
||||||
|
removeUnnecessaryZerosFromVoicePrompts(buffer);
|
||||||
|
|
||||||
|
vpQueueString(buffer);
|
||||||
|
|
||||||
|
if (includeMHz)
|
||||||
|
{
|
||||||
|
vpQueuePrompt(PROMPT_MEGAHERTZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue