mirror of
https://github.com/opentx/opentx.git
synced 2025-07-21 15:25:17 +03:00
Shutdown sound - bye.wav - A little bit related to #719
This commit is contained in:
parent
6839c02aba
commit
0b8963b15e
7 changed files with 52 additions and 18 deletions
|
@ -149,6 +149,7 @@ const int16_t sineValues[] =
|
|||
#if defined(SDCARD)
|
||||
const char * const audioFilenames[] = {
|
||||
"tada",
|
||||
"bye",
|
||||
"thralert",
|
||||
"swalert",
|
||||
"eebad",
|
||||
|
@ -929,31 +930,37 @@ void AudioQueue::flush()
|
|||
CoLeaveMutexSection(audioMutex);
|
||||
}
|
||||
|
||||
void audioEvent(uint8_t e, uint16_t f)
|
||||
void audioPlay(unsigned int index, uint8_t id)
|
||||
{
|
||||
#if defined(HAPTIC)
|
||||
if (e != AU_TADA) {
|
||||
// TODO could be done better, with TADA not part of errors
|
||||
haptic.event(e); //do this before audio to help sync timings
|
||||
if (g_eeGeneral.beepMode >= -1) {
|
||||
char filename[AUDIO_FILENAME_MAXLEN+1];
|
||||
if (isAudioFileReferenced(index, filename)) {
|
||||
audioQueue.playFile(filename, 0, id);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (e <= AU_ERROR || (e >= AU_WARNING1 && e < AU_FRSKY_FIRST)) {
|
||||
void audioEvent(unsigned int index, unsigned int freq)
|
||||
{
|
||||
if (index == AU_NONE)
|
||||
return;
|
||||
|
||||
if (index <= AU_ERROR || (index >= AU_WARNING1 && index < AU_FRSKY_FIRST)) {
|
||||
if (g_eeGeneral.alarmsFlash) {
|
||||
flashCounter = FLASH_DURATION;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_eeGeneral.beepMode>0 || (g_eeGeneral.beepMode==0 && e>=AU_TRIM_MOVE) || (g_eeGeneral.beepMode>=-1 && e<=AU_ERROR)) {
|
||||
if (g_eeGeneral.beepMode>0 || (g_eeGeneral.beepMode==0 && index>=AU_TRIM_MOVE) || (g_eeGeneral.beepMode>=-1 && index<=AU_ERROR)) {
|
||||
#if defined(SDCARD)
|
||||
char filename[AUDIO_FILENAME_MAXLEN+1];
|
||||
if (e < AU_FRSKY_FIRST && isAudioFileReferenced(e, filename)) {
|
||||
if (index < AU_FRSKY_FIRST && isAudioFileReferenced(index, filename)) {
|
||||
audioQueue.playFile(filename);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (e < AU_FRSKY_FIRST || audioQueue.empty()) {
|
||||
switch (e) {
|
||||
if (index < AU_FRSKY_FIRST || audioQueue.empty()) {
|
||||
switch (index) {
|
||||
// inactivity timer alert
|
||||
case AU_INACTIVITY:
|
||||
audioQueue.playTone(2250, 80, 20, PLAY_REPEAT(2));
|
||||
|
@ -996,15 +1003,15 @@ void audioEvent(uint8_t e, uint16_t f)
|
|||
break;
|
||||
// trim move
|
||||
case AU_TRIM_MOVE:
|
||||
audioQueue.playTone(f, 40, 20, PLAY_NOW);
|
||||
audioQueue.playTone(freq, 40, 20, PLAY_NOW);
|
||||
break;
|
||||
// trim center
|
||||
case AU_TRIM_MIDDLE:
|
||||
audioQueue.playTone(f, 80, 20, PLAY_NOW);
|
||||
audioQueue.playTone(freq, 80, 20, PLAY_NOW);
|
||||
break;
|
||||
// trim center
|
||||
case AU_TRIM_END:
|
||||
audioQueue.playTone(f, 80, 20, PLAY_NOW);
|
||||
audioQueue.playTone(freq, 80, 20, PLAY_NOW);
|
||||
break;
|
||||
// warning one
|
||||
case AU_WARNING1:
|
||||
|
|
|
@ -244,8 +244,14 @@ class AudioQueue {
|
|||
|
||||
extern AudioQueue audioQueue;
|
||||
|
||||
enum {
|
||||
ID_PLAY_FROM_SD_MANAGER = 254,
|
||||
ID_PLAY_BYE = 255
|
||||
};
|
||||
|
||||
void codecsInit();
|
||||
void audioEvent(uint8_t e, uint16_t f=BEEP_DEFAULT_FREQ);
|
||||
void audioEvent(unsigned int index, unsigned int freq=BEEP_DEFAULT_FREQ);
|
||||
void audioPlay(unsigned int index, uint8_t id=0);
|
||||
void audioStart();
|
||||
|
||||
#if defined(AUDIO) && defined(BUZZER)
|
||||
|
@ -264,7 +270,8 @@ void audioStart();
|
|||
#define AUDIO_TIMER_MINUTE(t) audioDefevent(AU_WARNING1)
|
||||
#endif
|
||||
|
||||
#define AUDIO_TADA() audioEvent(AU_TADA)
|
||||
#define AUDIO_TADA() audioPlay(AU_TADA)
|
||||
#define AUDIO_BYE() audioPlay(AU_BYE, ID_PLAY_BYE)
|
||||
#define AUDIO_KEYPAD_UP() AUDIO_BUZZER(audioEvent(AU_KEYPAD_UP), beep(0))
|
||||
#define AUDIO_KEYPAD_DOWN() AUDIO_BUZZER(audioEvent(AU_KEYPAD_DOWN), beep(0))
|
||||
#define AUDIO_MENUS() AUDIO_BUZZER(audioEvent(AU_MENUS), beep(0))
|
||||
|
|
|
@ -132,6 +132,7 @@ void audioDefevent(uint8_t e);
|
|||
#define AUDIO_WARNING2() AUDIO_BUZZER(audioDefevent(AU_WARNING2), beep(2))
|
||||
#define AUDIO_ERROR() AUDIO_BUZZER(audioDefevent(AU_ERROR), beep(4))
|
||||
#define AUDIO_TADA() VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_TADA),,)
|
||||
#define AUDIO_BYE()
|
||||
#define AUDIO_TX_BATTERY_LOW() VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_TX_BATTERY_LOW), audioDefevent(AU_TX_BATTERY_LOW), beep(4))
|
||||
#define AUDIO_INACTIVITY() VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT(AU_INACTIVITY), audioDefevent(AU_INACTIVITY), beep(3))
|
||||
#define AUDIO_ERROR_MESSAGE(e) VOICE_AUDIO_BUZZER(PUSH_SYSTEM_PROMPT((e)), audioDefevent(AU_ERROR), beep(4))
|
||||
|
|
|
@ -64,6 +64,7 @@ void beep(uint8_t val);
|
|||
#if !defined(AUDIO)
|
||||
#if defined(VOICE)
|
||||
#define AUDIO_TADA() PUSH_SYSTEM_PROMPT(AU_TADA)
|
||||
#define AUDIO_BYE()
|
||||
#define AUDIO_TX_BATTERY_LOW() PUSH_SYSTEM_PROMPT(AU_TX_BATTERY_LOW)
|
||||
#define AUDIO_INACTIVITY() PUSH_SYSTEM_PROMPT(AU_INACTIVITY)
|
||||
#define AUDIO_ERROR_MESSAGE(e) PUSH_SYSTEM_PROMPT((e))
|
||||
|
@ -72,6 +73,7 @@ void beep(uint8_t val);
|
|||
#define AUDIO_TIMER_20() PUSH_SYSTEM_PROMPT(AU_TIMER_20)
|
||||
#else
|
||||
#define AUDIO_TADA()
|
||||
#define AUDIO_BYE()
|
||||
#define AUDIO_TX_BATTERY_LOW() beep(4)
|
||||
#define AUDIO_INACTIVITY() beep(3)
|
||||
#define AUDIO_ERROR_MESSAGE(e) beep(4)
|
||||
|
|
|
@ -857,7 +857,7 @@ void onSdManagerMenu(const char *result)
|
|||
strcat(lfn, "/");
|
||||
strcat(lfn, reusableBuffer.sdmanager.lines[index]);
|
||||
audioQueue.stopAll();
|
||||
audioQueue.playFile(lfn, 0, 255);
|
||||
audioQueue.playFile(lfn, 0, ID_PLAY_FROM_SD_MANAGER);
|
||||
}
|
||||
#endif
|
||||
#if defined(PCBTARANIS)
|
||||
|
|
|
@ -2080,6 +2080,8 @@ void opentxStart()
|
|||
#if defined(CPUARM) || defined(CPUM2560)
|
||||
void opentxClose()
|
||||
{
|
||||
AUDIO_BYE();
|
||||
|
||||
#if defined(FRSKY)
|
||||
// TODO needed? telemetryEnd();
|
||||
#endif
|
||||
|
@ -2090,7 +2092,6 @@ void opentxClose()
|
|||
|
||||
#if defined(SDCARD)
|
||||
closeLogs();
|
||||
sdDone();
|
||||
#endif
|
||||
|
||||
#if defined(HAPTIC)
|
||||
|
@ -2130,6 +2131,18 @@ void opentxClose()
|
|||
|
||||
eeDirty(EE_GENERAL);
|
||||
eeCheck(true);
|
||||
|
||||
#if defined(CPUARM)
|
||||
while (IS_PLAYING(ID_PLAY_BYE)) {
|
||||
CoTickDelay(10);
|
||||
}
|
||||
|
||||
CoTickDelay(50);
|
||||
#endif
|
||||
|
||||
#if defined(SDCARD)
|
||||
sdDone();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1383,6 +1383,9 @@ void evalFunctions();
|
|||
/* make sure the defines below always go in numeric order */
|
||||
enum AUDIO_SOUNDS {
|
||||
AU_TADA,
|
||||
#if defined(CPUARM)
|
||||
AU_BYE,
|
||||
#endif
|
||||
#if defined(VOICE)
|
||||
AU_THROTTLE_ALERT,
|
||||
AU_SWITCH_ALERT,
|
||||
|
@ -1449,6 +1452,7 @@ enum AUDIO_SOUNDS {
|
|||
AU_TIMER_LT10,
|
||||
AU_TIMER_20,
|
||||
AU_TIMER_30,
|
||||
|
||||
AU_FRSKY_FIRST,
|
||||
AU_FRSKY_BEEP1 = AU_FRSKY_FIRST,
|
||||
AU_FRSKY_BEEP2,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue