Initial beep implementation.
Function latch will play high beep when latched and low beep when latch times out. Menus will play a high beep when you arrow through them and a low beep when you reach the first item. All keys should play a generic beep sound but this has not been implemented yet.
This commit is contained in:
parent
95b7707d87
commit
c9ce41a999
|
|
@ -217,5 +217,6 @@ void vp_announceDisplayTimer();
|
|||
*
|
||||
*/
|
||||
vpQueueFlags_t vp_getVoiceLevelQueueFlags();
|
||||
void vp_playMenuBeepIfNeeded(bool firstItem);
|
||||
|
||||
#endif // VOICE_PROMPT_UTILS_H
|
||||
|
|
|
|||
|
|
@ -300,4 +300,8 @@ bool vp_isPlaying();
|
|||
*/
|
||||
bool vp_sequenceNotEmpty();
|
||||
|
||||
/**
|
||||
* play a beep at a given frequency for a given duration.
|
||||
*/
|
||||
void vp_beep(uint16_t freq, uint16_t duration);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -878,3 +878,13 @@ vpQueueFlags_t vp_getVoiceLevelQueueFlags()
|
|||
return flags;
|
||||
}
|
||||
|
||||
void vp_playMenuBeepIfNeeded(bool firstItem)
|
||||
{
|
||||
if (state.settings.vpLevel < vpBeep)
|
||||
return;
|
||||
if (firstItem)
|
||||
vp_beep(500, 250);
|
||||
else
|
||||
vp_beep(1000, 250);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
static const uint32_t VOICE_PROMPTS_DATA_MAGIC = 0x5056; //'VP'
|
||||
static const uint32_t VOICE_PROMPTS_DATA_VERSION = 0x1000; // v1000 OpenRTX
|
||||
static uint16_t currentBeepDuration=0;
|
||||
|
||||
#define VOICE_PROMPTS_TOC_SIZE 350
|
||||
#define CODEC2_HEADER_SIZE 7
|
||||
|
|
@ -311,6 +312,9 @@ void vp_stop()
|
|||
vpCurrentSequence.pos = 0;
|
||||
vpCurrentSequence.c2DataIndex = 0;
|
||||
vpCurrentSequence.c2DataLength = 0;
|
||||
// If any beep is playing, immediately stop it.
|
||||
if (currentBeepDuration > 0)
|
||||
platform_beepStop();
|
||||
}
|
||||
|
||||
void vp_flush()
|
||||
|
|
@ -456,6 +460,16 @@ void vp_play()
|
|||
audio_enableAmp();
|
||||
}
|
||||
|
||||
void BeepTick()
|
||||
{
|
||||
if (currentBeepDuration > 0)
|
||||
{
|
||||
currentBeepDuration--;
|
||||
if (currentBeepDuration==0)
|
||||
platform_beepStop();
|
||||
}
|
||||
}
|
||||
|
||||
void vp_tick()
|
||||
{
|
||||
if (voicePromptActive == false)
|
||||
|
|
@ -502,6 +516,7 @@ void vp_tick()
|
|||
vpCurrentSequence.c2DataIndex = 0;
|
||||
vpCurrentSequence.c2DataLength = 0;
|
||||
}
|
||||
BeepTick();
|
||||
}
|
||||
|
||||
bool vp_isPlaying()
|
||||
|
|
@ -513,3 +528,22 @@ bool vp_sequenceNotEmpty()
|
|||
{
|
||||
return (vpCurrentSequence.length > 0);
|
||||
}
|
||||
|
||||
void vp_beep(uint16_t freq, uint16_t duration)
|
||||
{
|
||||
if (state.settings.vpLevel < vpBeep)
|
||||
return;
|
||||
|
||||
// Do not play a new one if one is playing.
|
||||
if (currentBeepDuration)
|
||||
return ;
|
||||
// avoid extra long beeps!
|
||||
if (duration > 2000)
|
||||
duration=2000;
|
||||
|
||||
currentBeepDuration=duration;
|
||||
|
||||
platform_beepStart(freq);
|
||||
// See BeepTick for termination.
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -279,13 +279,13 @@ static void ReleaseFunctionLatchIfNeeded()
|
|||
return;
|
||||
|
||||
functionLatchTimer = 0;
|
||||
// Play beep for function latch release.
|
||||
vp_beep(200, 500);
|
||||
}
|
||||
|
||||
static void SetFunctionLatchTimer()
|
||||
{
|
||||
functionLatchTimer= getTick() + FUNCTION_LATCH_TIMEOUT;
|
||||
// Play beep for set function latch.
|
||||
vp_beep(800, 500);
|
||||
}
|
||||
|
||||
static bool FunctionKeyIsLatched()
|
||||
|
|
@ -980,6 +980,7 @@ static void _ui_menuUp(uint8_t menu_entries)
|
|||
ui_state.menu_selected -= 1;
|
||||
else
|
||||
ui_state.menu_selected = menu_entries - 1;
|
||||
vp_playMenuBeepIfNeeded(ui_state.menu_selected==0);
|
||||
}
|
||||
|
||||
static void _ui_menuDown(uint8_t menu_entries)
|
||||
|
|
@ -988,6 +989,7 @@ static void _ui_menuDown(uint8_t menu_entries)
|
|||
ui_state.menu_selected += 1;
|
||||
else
|
||||
ui_state.menu_selected = 0;
|
||||
vp_playMenuBeepIfNeeded(ui_state.menu_selected==0);
|
||||
}
|
||||
|
||||
static void _ui_menuBack(uint8_t prev_state)
|
||||
|
|
@ -1002,6 +1004,7 @@ static void _ui_menuBack(uint8_t prev_state)
|
|||
state.ui_screen = prev_state;
|
||||
// Reset menu selection
|
||||
ui_state.menu_selected = 0;
|
||||
vp_playMenuBeepIfNeeded(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue