Insert voice prompt utility function in UI code
Began calling voice prompt utility functions from places such as: 1. arrowing up and down in VFO mode (read new frequencies) 2. up and down in memory mode: read new channel name. 3. up and down in VFO input mode: announce receive or transmit, 4. when starting to enter a frequency: announce receive and the first digit.
This commit is contained in:
parent
27d1329ac7
commit
d68f01ffbc
|
|
@ -24,11 +24,14 @@
|
||||||
#include "voicePrompts.h"
|
#include "voicePrompts.h"
|
||||||
#include "ui/UIStrings.h"
|
#include "ui/UIStrings.h"
|
||||||
#include "cps.h"
|
#include "cps.h"
|
||||||
|
void announceVFO();
|
||||||
void announceChannelName(channel_t* channel, uint16_t channelIndex, VoicePromptQueueFlags_T flags);
|
void announceChannelName(channel_t* channel, uint16_t channelIndex, VoicePromptQueueFlags_T flags);
|
||||||
void announceFrequencies(freq_t rx, freq_t tx, VoicePromptQueueFlags_T flags);
|
void announceFrequencies(freq_t rx, freq_t tx, VoicePromptQueueFlags_T flags);
|
||||||
void announceRadioMode(uint8_t mode, VoicePromptQueueFlags_T flags);
|
void announceRadioMode(uint8_t mode, VoicePromptQueueFlags_T flags);
|
||||||
void announceChannelSummary(channel_t* channel, uint16_t channelIndex,
|
void announceChannelSummary(channel_t* channel, uint16_t channelIndex,
|
||||||
VoicePromptQueueFlags_T flags);
|
VoicePromptQueueFlags_T flags);
|
||||||
|
void AnnounceInputChar(char ch);
|
||||||
|
void announceInputReceiveOrTransmit(bool tx, VoicePromptQueueFlags_T flags);
|
||||||
|
void ReplayLastPrompt();
|
||||||
|
void announceError();
|
||||||
#endif //VOICE_PROMPT_UTILS_H_INCLUDED
|
#endif //VOICE_PROMPT_UTILS_H_INCLUDED
|
||||||
|
|
@ -48,6 +48,14 @@ static void removeUnnecessaryZerosFromVoicePrompts(char *str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void announceVFO()
|
||||||
|
{
|
||||||
|
vpInit();
|
||||||
|
|
||||||
|
vpQueuePrompt(PROMPT_VFO);
|
||||||
|
|
||||||
|
vpPlay();
|
||||||
|
}
|
||||||
|
|
||||||
void announceChannelName(channel_t* channel, uint16_t channelIndex,
|
void announceChannelName(channel_t* channel, uint16_t channelIndex,
|
||||||
VoicePromptQueueFlags_T flags)
|
VoicePromptQueueFlags_T flags)
|
||||||
|
|
@ -111,10 +119,10 @@ void announceRadioMode(uint8_t mode, VoicePromptQueueFlags_T flags)
|
||||||
switch(mode)
|
switch(mode)
|
||||||
{
|
{
|
||||||
case OPMODE_DMR:
|
case OPMODE_DMR:
|
||||||
vpQueueStringTableEntry(currentLanguage->dmr);
|
vpQueueStringTableEntry(¤tLanguage->dmr);
|
||||||
break;
|
break;
|
||||||
case OPMODE_FM:
|
case OPMODE_FM:
|
||||||
vpQueueStringTableEntry(currentLanguage->fm);
|
vpQueueStringTableEntry(¤tLanguage->fm);
|
||||||
break;
|
break;
|
||||||
case OPMODE_M17:
|
case OPMODE_M17:
|
||||||
vpQueueStringTableEntry(¤tLanguage->m17);
|
vpQueueStringTableEntry(¤tLanguage->m17);
|
||||||
|
|
@ -141,3 +149,45 @@ VoicePromptQueueFlags_T flags)
|
||||||
vpPlayIfNeeded(flags);
|
vpPlayIfNeeded(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnnounceInputChar(char ch)
|
||||||
|
{
|
||||||
|
char buf[2] = "\0";
|
||||||
|
buf[0] = ch;
|
||||||
|
|
||||||
|
vpInit();
|
||||||
|
|
||||||
|
uint8_t flags = vpAnnounceCaps | vpAnnounceSpace | vpAnnounceCommonSymbols | vpAnnounceLessCommonSymbols;
|
||||||
|
|
||||||
|
vpQueueString(buf, flags);
|
||||||
|
|
||||||
|
vpPlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void announceInputReceiveOrTransmit(bool tx, VoicePromptQueueFlags_T flags)
|
||||||
|
{
|
||||||
|
vpInitIfNeeded(flags);
|
||||||
|
|
||||||
|
if (tx)
|
||||||
|
vpQueuePrompt(PROMPT_TRANSMIT);
|
||||||
|
else
|
||||||
|
vpQueuePrompt(PROMPT_RECEIVE);
|
||||||
|
|
||||||
|
vpPlayIfNeeded(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReplayLastPrompt()
|
||||||
|
{
|
||||||
|
if (vpIsPlaying())
|
||||||
|
vpTerminate();
|
||||||
|
else
|
||||||
|
vpPlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
void announceError()
|
||||||
|
{
|
||||||
|
vpInit();
|
||||||
|
|
||||||
|
vpQueueStringTableEntry(¤tLanguage->error);
|
||||||
|
|
||||||
|
vpPlay();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@
|
||||||
#include <battery.h>
|
#include <battery.h>
|
||||||
#include <input.h>
|
#include <input.h>
|
||||||
#include <hwconfig.h>
|
#include <hwconfig.h>
|
||||||
|
#include "core/voicePromptUtils.h"
|
||||||
|
|
||||||
/* UI main screen functions, their implementation is in "ui_main.c" */
|
/* UI main screen functions, their implementation is in "ui_main.c" */
|
||||||
extern void _ui_drawMainBackground();
|
extern void _ui_drawMainBackground();
|
||||||
|
|
@ -575,6 +576,7 @@ void _ui_fsm_confirmVFOInput(bool *sync_rtx)
|
||||||
ui_state.input_set = SET_TX;
|
ui_state.input_set = SET_TX;
|
||||||
// Reset input position
|
// Reset input position
|
||||||
ui_state.input_position = 0;
|
ui_state.input_position = 0;
|
||||||
|
announceInputReceiveOrTransmit(true, (vpqInit | vpqPlayImmediately));
|
||||||
}
|
}
|
||||||
else if(ui_state.input_set == SET_TX)
|
else if(ui_state.input_set == SET_TX)
|
||||||
{
|
{
|
||||||
|
|
@ -591,7 +593,10 @@ void _ui_fsm_confirmVFOInput(bool *sync_rtx)
|
||||||
state.channel.rx_frequency = ui_state.new_rx_frequency;
|
state.channel.rx_frequency = ui_state.new_rx_frequency;
|
||||||
state.channel.tx_frequency = ui_state.new_tx_frequency;
|
state.channel.tx_frequency = ui_state.new_tx_frequency;
|
||||||
*sync_rtx = true;
|
*sync_rtx = true;
|
||||||
|
announceFrequencies(state.channel.rx_frequency, state.channel.tx_frequency, (vpqInit | vpqPlayImmediately));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
announceError();
|
||||||
state.ui_screen = MAIN_VFO;
|
state.ui_screen = MAIN_VFO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -906,7 +911,7 @@ void _ui_textInputKeypad(char *buf, uint8_t max_len, kbd_msg_t msg, bool callsig
|
||||||
{
|
{
|
||||||
ui_state.input_set = (ui_state.input_set + 1) % num_symbols;
|
ui_state.input_set = (ui_state.input_set + 1) % num_symbols;
|
||||||
}
|
}
|
||||||
// Differnt key pressed: save current char and change key
|
// Different key pressed: save current char and change key
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui_state.input_position += 1;
|
ui_state.input_position += 1;
|
||||||
|
|
@ -917,7 +922,11 @@ void _ui_textInputKeypad(char *buf, uint8_t max_len, kbd_msg_t msg, bool callsig
|
||||||
if(callsign)
|
if(callsign)
|
||||||
buf[ui_state.input_position] = symbols_ITU_T_E161_callsign[num_key][ui_state.input_set];
|
buf[ui_state.input_position] = symbols_ITU_T_E161_callsign[num_key][ui_state.input_set];
|
||||||
else
|
else
|
||||||
|
{
|
||||||
buf[ui_state.input_position] = symbols_ITU_T_E161[num_key][ui_state.input_set];
|
buf[ui_state.input_position] = symbols_ITU_T_E161[num_key][ui_state.input_set];
|
||||||
|
}
|
||||||
|
// Announce the character
|
||||||
|
AnnounceInputChar(buf[ui_state.input_position]);
|
||||||
// Update reference values
|
// Update reference values
|
||||||
ui_state.input_number = num_key;
|
ui_state.input_number = num_key;
|
||||||
ui_state.last_keypress = now;
|
ui_state.last_keypress = now;
|
||||||
|
|
@ -933,8 +942,11 @@ void _ui_textInputDel(char *buf)
|
||||||
buf[ui_state.input_position] = '\0';
|
buf[ui_state.input_position] = '\0';
|
||||||
// Move back input cursor
|
// Move back input cursor
|
||||||
if(ui_state.input_position > 0)
|
if(ui_state.input_position > 0)
|
||||||
|
{
|
||||||
ui_state.input_position--;
|
ui_state.input_position--;
|
||||||
|
AnnounceInputChar(buf[ui_state.input_position]);
|
||||||
// If we deleted the initial character, reset starting condition
|
// If we deleted the initial character, reset starting condition
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ui_state.last_keypress = 0;
|
ui_state.last_keypress = 0;
|
||||||
ui_state.input_set = 0;
|
ui_state.input_set = 0;
|
||||||
|
|
@ -1053,6 +1065,8 @@ void ui_updateFSM(bool *sync_rtx)
|
||||||
{
|
{
|
||||||
// Switch to MEM screen
|
// Switch to MEM screen
|
||||||
state.ui_screen = MAIN_MEM;
|
state.ui_screen = MAIN_MEM;
|
||||||
|
// Anounce the active channel name.
|
||||||
|
announceChannelName(&state.channel, state.channel_index, (vpqInit | vpqPlayImmediately));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(msg.keys & KEY_HASH)
|
else if(msg.keys & KEY_HASH)
|
||||||
|
|
@ -1071,6 +1085,7 @@ void ui_updateFSM(bool *sync_rtx)
|
||||||
state.channel.rx_frequency += 12500;
|
state.channel.rx_frequency += 12500;
|
||||||
state.channel.tx_frequency += 12500;
|
state.channel.tx_frequency += 12500;
|
||||||
*sync_rtx = true;
|
*sync_rtx = true;
|
||||||
|
announceFrequencies(state.channel.rx_frequency, state.channel.tx_frequency, (vpqInit | vpqPlayImmediately));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(msg.keys & KEY_DOWN || msg.keys & KNOB_LEFT)
|
else if(msg.keys & KEY_DOWN || msg.keys & KNOB_LEFT)
|
||||||
|
|
@ -1082,6 +1097,7 @@ void ui_updateFSM(bool *sync_rtx)
|
||||||
state.channel.rx_frequency -= 12500;
|
state.channel.rx_frequency -= 12500;
|
||||||
state.channel.tx_frequency -= 12500;
|
state.channel.tx_frequency -= 12500;
|
||||||
*sync_rtx = true;
|
*sync_rtx = true;
|
||||||
|
announceFrequencies(state.channel.rx_frequency, state.channel.tx_frequency, (vpqInit | vpqPlayImmediately));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(input_isNumberPressed(msg))
|
else if(input_isNumberPressed(msg))
|
||||||
|
|
@ -1091,13 +1107,17 @@ void ui_updateFSM(bool *sync_rtx)
|
||||||
// Reset input position and selection
|
// Reset input position and selection
|
||||||
ui_state.input_position = 1;
|
ui_state.input_position = 1;
|
||||||
ui_state.input_set = SET_RX;
|
ui_state.input_set = SET_RX;
|
||||||
|
// do not play because we will also announce the number just entered.
|
||||||
|
announceInputReceiveOrTransmit(false, vpqInit);
|
||||||
ui_state.new_rx_frequency = 0;
|
ui_state.new_rx_frequency = 0;
|
||||||
ui_state.new_tx_frequency = 0;
|
ui_state.new_tx_frequency = 0;
|
||||||
// Save pressed number to calculare frequency and show in GUI
|
// Save pressed number to calculare frequency and show in GUI
|
||||||
ui_state.input_number = input_getPressedNumber(msg);
|
ui_state.input_number = input_getPressedNumber(msg);
|
||||||
|
vpQueueInteger(ui_state.input_number);
|
||||||
|
vpPlay();
|
||||||
// Calculate portion of the new frequency
|
// Calculate portion of the new frequency
|
||||||
ui_state.new_rx_frequency = _ui_freq_add_digit(ui_state.new_rx_frequency,
|
ui_state.new_rx_frequency = _ui_freq_add_digit(ui_state.new_rx_frequency,
|
||||||
ui_state.input_position, ui_state.input_number);
|
ui_state.input_position, ui_state.input_number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -1115,9 +1135,15 @@ void ui_updateFSM(bool *sync_rtx)
|
||||||
else if(msg.keys & KEY_UP || msg.keys & KEY_DOWN)
|
else if(msg.keys & KEY_UP || msg.keys & KEY_DOWN)
|
||||||
{
|
{
|
||||||
if(ui_state.input_set == SET_RX)
|
if(ui_state.input_set == SET_RX)
|
||||||
|
{
|
||||||
ui_state.input_set = SET_TX;
|
ui_state.input_set = SET_TX;
|
||||||
|
announceInputReceiveOrTransmit(true, (vpqInit | vpqPlayImmediately));
|
||||||
|
}
|
||||||
else if(ui_state.input_set == SET_TX)
|
else if(ui_state.input_set == SET_TX)
|
||||||
|
{
|
||||||
ui_state.input_set = SET_RX;
|
ui_state.input_set = SET_RX;
|
||||||
|
announceInputReceiveOrTransmit(false, (vpqInit | vpqPlayImmediately));
|
||||||
|
}
|
||||||
// Reset input position
|
// Reset input position
|
||||||
ui_state.input_position = 0;
|
ui_state.input_position = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1176,6 +1202,7 @@ void ui_updateFSM(bool *sync_rtx)
|
||||||
*sync_rtx = true;
|
*sync_rtx = true;
|
||||||
// Switch to VFO screen
|
// Switch to VFO screen
|
||||||
state.ui_screen = MAIN_VFO;
|
state.ui_screen = MAIN_VFO;
|
||||||
|
announceVFO();
|
||||||
}
|
}
|
||||||
else if(msg.keys & KEY_HASH)
|
else if(msg.keys & KEY_HASH)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue