Renamed vp_clearCurrPrompt() to vp_flush(), added a vp_stop() function allowing to stop an in-progress voice prompt but without flushing the data buffer

md1702
Silvano Seva 2022-08-31 12:37:34 +02:00
rodzic d81a4220d1
commit cad026f902
6 zmienionych plików z 32 dodań i 21 usunięć

Wyświetl plik

@ -238,10 +238,15 @@ void vp_init();
void vp_terminate();
/**
* Clear the currently in-progress prompt, to be called before building a new
* voice prompt sequence.
* Stop an in-progress prompt and rewind data pointers to the beginning keeping
* prompt data intact. This allows to replay the prompt.
*/
void vp_clearCurrPrompt();
void vp_stop();
/**
* Stop an in-progress prompt, if present, and clear the prompt data buffer.
*/
void vp_flush();
/**
* Append an individual prompt item to the prompt queue.

Wyświetl plik

@ -34,7 +34,7 @@
static void clearCurrPromptIfNeeded(const vpQueueFlags_t flags)
{
if (flags & vpqInit)
vp_clearCurrPrompt();
vp_flush();
}
static void playIfNeeded(const vpQueueFlags_t flags)
@ -73,7 +73,7 @@ static void removeUnnecessaryZerosFromVoicePrompts(char* str)
void vp_announceVFO()
{
vp_clearCurrPrompt();
vp_flush();
vp_queuePrompt(PROMPT_VFO);
vp_play();
}
@ -204,7 +204,7 @@ void vp_announceChannelSummary(const channel_t* channel,
if (channel == NULL)
return;
vp_clearCurrPrompt();
vp_flush();
vpQueueFlags_t localFlags = vpqAddSeparatingSilence;
@ -275,7 +275,7 @@ void vp_announceInputChar(const char ch)
char buf[2] = "\0";
buf[0] = ch;
vp_clearCurrPrompt();
vp_flush();
uint8_t flags = vpAnnounceCaps
| vpAnnounceSpace
@ -301,7 +301,7 @@ void vp_announceInputReceiveOrTransmit(const bool tx, const vpQueueFlags_t flags
void vp_replayLastPrompt()
{
if (vp_isPlaying())
vp_terminate();
vp_stop();
else
vp_play();
}
@ -533,7 +533,7 @@ void vp_announceGPSInfo()
if (!state.settings.gps_enabled)
return;
vp_clearCurrPrompt();
vp_flush();
vpQueueFlags_t flags = vpqIncludeDescriptions
| vpqAddSeparatingSilence;
@ -626,7 +626,7 @@ void vp_announceGPSInfo()
void vp_announceAboutScreen()
{
vp_clearCurrPrompt();
vp_flush();
vp_queueStringTableEntry(&currentLanguage->openRTX);
@ -641,7 +641,7 @@ void vp_announceAboutScreen()
void vp_announceBackupScreen()
{
vp_clearCurrPrompt();
vp_flush();
vp_queueStringTableEntry(&currentLanguage->flashBackup);
@ -655,7 +655,7 @@ void vp_announceBackupScreen()
void vp_announceRestoreScreen()
{
vp_clearCurrPrompt();
vp_flush();
vp_queueStringTableEntry(&currentLanguage->flashRestore);
@ -670,7 +670,7 @@ void vp_announceRestoreScreen()
#ifdef RTC_PRESENT
void vp_announceSettingsTimeDate()
{
vp_clearCurrPrompt();
vp_flush();
vp_queueStringTableEntry(&currentLanguage->timeAndDate);

Wyświetl plik

@ -305,22 +305,28 @@ void vp_terminate()
#endif
}
void vp_clearCurrPrompt()
void vp_stop()
{
voicePromptActive = false;
vpCurrentSequence.length = 0;
vpCurrentSequence.pos = 0;
vpCurrentSequence.c2DataIndex = 0;
vpCurrentSequence.c2DataLength = 0;
}
void vp_flush()
{
// Stop the prompt and reset the codec data length
vp_stop();
vpCurrentSequence.length = 0;
}
void vp_queuePrompt(const uint16_t prompt)
{
if (state.settings.vpLevel < vpLow)
return;
if (voicePromptActive)
vp_clearCurrPrompt();
vp_flush();
if (vpCurrentSequence.length < VP_SEQUENCE_BUF_SIZE)
{
@ -335,7 +341,7 @@ void vp_queueString(const char* string, vpFlags_t flags)
return;
if (voicePromptActive)
vp_clearCurrPrompt();
vp_flush();
if (state.settings.vpPhoneticSpell)
flags |= vpAnnouncePhoneticRendering;

Wyświetl plik

@ -587,7 +587,7 @@ static int _ui_fsm_loadChannel(int16_t channel_index, bool *sync_rtx)
static void _ui_fsm_confirmVFOInput(bool *sync_rtx)
{
vp_clearCurrPrompt();
vp_flush();
// Switch to TX input
if(ui_state.input_set == SET_RX)
{
@ -637,7 +637,7 @@ static void _ui_fsm_insertVFONumber(kbd_msg_t msg, bool *sync_rtx)
// Advance input position
ui_state.input_position += 1;
// clear any prompts in progress.
vp_clearCurrPrompt();
vp_flush();
// Save pressed number to calculate frequency and show in GUI
ui_state.input_number = input_getPressedNumber(msg);
// queue the digit just pressed.

Wyświetl plik

@ -104,7 +104,7 @@ static void announceMenuItemIfNeeded(char* name, char* value)
bool voicePromptWasPlaying = vp_isPlaying();
// Stop any prompt in progress and/or clear the buffer.
vp_clearCurrPrompt();
vp_flush();
// If no value is supplied, or, no prompt is in progress, announce the name.
if ((voicePromptWasPlaying == false) || (value == NULL) || (*value == '\0'))

Wyświetl plik

@ -35,7 +35,7 @@ int main()
vpQueueFlags_t flags = vp_getVoiceLevelQueueFlags();
vp_init();
vp_clearCurrPrompt();
vp_flush();
vp_queueStringTableEntry(&currentLanguage->allChannels);
vp_play();
while(true)