[Taranis / sky9x] Specific volume for beeps/wav/vario/background
[Taranis] New alarm when TELEMETRY lost/back
This commit is contained in:
+37
-26
@@ -37,6 +37,15 @@
|
||||
#include "opentx.h"
|
||||
#include <math.h>
|
||||
|
||||
const unsigned int toneVolumes[] = {
|
||||
4000,
|
||||
8000,
|
||||
16000,
|
||||
24000,
|
||||
32000
|
||||
};
|
||||
|
||||
|
||||
#if defined(SDCARD)
|
||||
const char * audioFilenames[] = {
|
||||
"tada",
|
||||
@@ -76,11 +85,13 @@ const char * audioFilenames[] = {
|
||||
"rssi_red",
|
||||
"swr_red",
|
||||
#endif
|
||||
"telemko",
|
||||
"telemok"
|
||||
};
|
||||
|
||||
uint32_t sdAvailableSystemAudioFiles = 0;
|
||||
uint8_t sdAvailablePhaseAudioFiles[MAX_PHASES] = { 0 };
|
||||
uint8_t sdAvailableMixerAudioFiles[MAX_MIXERS] = { 0 };
|
||||
uint64_t sdAvailableSystemAudioFiles = 0;
|
||||
uint8_t sdAvailablePhaseAudioFiles[MAX_PHASES] = { 0 };
|
||||
uint8_t sdAvailableMixerAudioFiles[MAX_MIXERS] = { 0 };
|
||||
|
||||
void refreshSystemAudioFiles()
|
||||
{
|
||||
@@ -97,13 +108,13 @@ void refreshSystemAudioFiles()
|
||||
assert(sizeof(audioFilenames)==AU_FRSKY_FIRST*sizeof(char *));
|
||||
assert(sizeof(sdAvailableSystemAudioFiles)*8 >= AU_FRSKY_FIRST);
|
||||
|
||||
uint32_t availableAudioFiles = 0;
|
||||
uint64_t availableAudioFiles = 0;
|
||||
|
||||
for (uint32_t i=0; i<AU_FRSKY_FIRST; i++) {
|
||||
strcpy(filename+sizeof(SYSTEM_SOUNDS_PATH), audioFilenames[i]);
|
||||
strcat(filename+sizeof(SYSTEM_SOUNDS_PATH), SOUNDS_EXT);
|
||||
if (f_stat(filename, &info) == FR_OK)
|
||||
availableAudioFiles |= ((uint32_t)1 << i);
|
||||
availableAudioFiles |= ((uint64_t)1 << i);
|
||||
}
|
||||
|
||||
sdAvailableSystemAudioFiles = availableAudioFiles;
|
||||
@@ -163,7 +174,7 @@ bool isAudioFileAvailable(uint32_t i, char * filename)
|
||||
#endif
|
||||
|
||||
if (category == SYSTEM_AUDIO_CATEGORY) {
|
||||
if (sdAvailableSystemAudioFiles & ((uint32_t)1 << event)) {
|
||||
if (sdAvailableSystemAudioFiles & ((uint64_t)1 << event)) {
|
||||
strcpy(filename, SYSTEM_SOUNDS_PATH "/");
|
||||
strncpy(filename+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
|
||||
strcpy(filename+sizeof(SYSTEM_SOUNDS_PATH), audioFilenames[i]);
|
||||
@@ -316,7 +327,7 @@ void mix(uint16_t * result, int sample, unsigned int fade)
|
||||
#define RIFF_CHUNK_SIZE 12
|
||||
uint8_t wavBuffer[AUDIO_BUFFER_SIZE*2];
|
||||
|
||||
int AudioQueue::mixWav(AudioContext &context, AudioBuffer *buffer, unsigned int weight)
|
||||
int AudioQueue::mixWav(AudioContext &context, AudioBuffer *buffer, int volume, unsigned int fade)
|
||||
{
|
||||
FRESULT result = FR_OK;
|
||||
UINT read = 0;
|
||||
@@ -379,18 +390,18 @@ int AudioQueue::mixWav(AudioContext &context, AudioBuffer *buffer, unsigned int
|
||||
read /= 2;
|
||||
for (uint32_t i=0; i<read; i++) {
|
||||
for (uint8_t j=0; j<context.state.wav.resampleRatio; j++)
|
||||
mix(samples++, ((int16_t *)wavBuffer)[i], weight);
|
||||
mix(samples++, ((int16_t *)wavBuffer)[i], fade+2-volume);
|
||||
}
|
||||
}
|
||||
else if (context.state.wav.codec == CODEC_ID_PCM_ALAW) {
|
||||
for (uint32_t i=0; i<read; i++)
|
||||
for (uint8_t j=0; j<context.state.wav.resampleRatio; j++)
|
||||
mix(samples++, alawTable[wavBuffer[i]], weight);
|
||||
mix(samples++, alawTable[wavBuffer[i]], fade+2-volume);
|
||||
}
|
||||
else if (context.state.wav.codec == CODEC_ID_PCM_MULAW) {
|
||||
for (uint32_t i=0; i<read; i++)
|
||||
for (uint8_t j=0; j<context.state.wav.resampleRatio; j++)
|
||||
mix(samples++, ulawTable[wavBuffer[i]], weight);
|
||||
mix(samples++, ulawTable[wavBuffer[i]], fade+2-volume);
|
||||
}
|
||||
|
||||
return samples - buffer->data;
|
||||
@@ -401,13 +412,13 @@ int AudioQueue::mixWav(AudioContext &context, AudioBuffer *buffer, unsigned int
|
||||
return -result;
|
||||
}
|
||||
#else
|
||||
int AudioQueue::mixWav(AudioContext &context, AudioBuffer *buffer, unsigned int weight)
|
||||
int AudioQueue::mixWav(AudioContext &context, AudioBuffer *buffer, int volume, unsigned int fade)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int AudioQueue::mixTone(AudioContext &context, AudioBuffer *buffer, unsigned int weight)
|
||||
int AudioQueue::mixBeep(AudioContext &context, AudioBuffer *buffer, int volume, unsigned int fade)
|
||||
{
|
||||
AudioFragment & fragment = context.fragment;
|
||||
unsigned int duration = 0;
|
||||
@@ -421,7 +432,7 @@ int AudioQueue::mixTone(AudioContext &context, AudioBuffer *buffer, unsigned int
|
||||
if (context.state.tone.idx >= context.state.tone.count) context.state.tone.idx = 0;
|
||||
double t = (M_PI * 2 * periods) / context.state.tone.count;
|
||||
for (unsigned int i=0; i<context.state.tone.count; i++)
|
||||
context.state.tone.points[i] = sin(t*i) * 16000;
|
||||
context.state.tone.points[i] = sin(t*i) * (toneVolumes[2+volume]);
|
||||
}
|
||||
|
||||
if (fragment.tone.freqIncr)
|
||||
@@ -431,7 +442,7 @@ int AudioQueue::mixTone(AudioContext &context, AudioBuffer *buffer, unsigned int
|
||||
|
||||
duration = min<unsigned int>(AUDIO_BUFFER_DURATION, fragment.tone.duration);
|
||||
for (unsigned int i=0; i<duration*(AUDIO_BUFFER_SIZE/AUDIO_BUFFER_DURATION); i++) {
|
||||
mix(&buffer->data[i], context.state.tone.points[context.state.tone.idx], weight);
|
||||
mix(&buffer->data[i], context.state.tone.points[context.state.tone.idx], fade);
|
||||
context.state.tone.idx = context.state.tone.idx + 1;
|
||||
if (context.state.tone.idx >= context.state.tone.count) context.state.tone.idx = 0;
|
||||
}
|
||||
@@ -452,16 +463,16 @@ int AudioQueue::mixTone(AudioContext &context, AudioBuffer *buffer, unsigned int
|
||||
return result;
|
||||
}
|
||||
|
||||
int AudioQueue::mixAudioContext(AudioContext &context, AudioBuffer *buffer, unsigned int weight)
|
||||
int AudioQueue::mixAudioContext(AudioContext &context, AudioBuffer *buffer, int beepVolume, int wavVolume, unsigned int fade)
|
||||
{
|
||||
int result;
|
||||
AudioFragment & fragment = context.fragment;
|
||||
|
||||
if (fragment.type == FRAGMENT_FILE) {
|
||||
result = mixWav(context, buffer, weight);
|
||||
if (fragment.type == FRAGMENT_TONE) {
|
||||
result = mixBeep(context, buffer, beepVolume, fade);
|
||||
}
|
||||
else if (fragment.type == FRAGMENT_TONE) {
|
||||
result = mixTone(context, buffer, weight);
|
||||
else if (fragment.type == FRAGMENT_FILE) {
|
||||
result = mixWav(context, buffer, wavVolume, fade);
|
||||
}
|
||||
else {
|
||||
result = 0;
|
||||
@@ -475,7 +486,7 @@ void AudioQueue::wakeup()
|
||||
int result;
|
||||
AudioBuffer *buffer = getEmptyBuffer();
|
||||
if (buffer) {
|
||||
unsigned int weight = 0;
|
||||
unsigned int fade = 0;
|
||||
int size = 0;
|
||||
|
||||
// write silence in the buffer
|
||||
@@ -484,17 +495,17 @@ void AudioQueue::wakeup()
|
||||
}
|
||||
|
||||
// mix the foreground context
|
||||
result = mixAudioContext(foregroundContext, buffer, weight);
|
||||
result = mixAudioContext(foregroundContext, buffer, g_eeGeneral.beepVolume, g_eeGeneral.wavVolume, fade);
|
||||
if (result > 0) {
|
||||
size = max(size, result);
|
||||
weight += 1;
|
||||
fade += 1;
|
||||
}
|
||||
|
||||
// mix the normal context
|
||||
result = mixAudioContext(currentContext, buffer, weight);
|
||||
result = mixAudioContext(currentContext, buffer, g_eeGeneral.beepVolume, g_eeGeneral.wavVolume, fade);
|
||||
if (result > 0) {
|
||||
size = max(size, result);
|
||||
weight += 1;
|
||||
fade += 1;
|
||||
}
|
||||
else {
|
||||
CoEnterMutexSection(audioMutex);
|
||||
@@ -510,7 +521,7 @@ void AudioQueue::wakeup()
|
||||
|
||||
// mix the background context
|
||||
if (!isFunctionActive(FUNC_BACKGND_MUSIC_PAUSE)) {
|
||||
result = mixAudioContext(backgroundContext, buffer, weight);
|
||||
result = mixAudioContext(backgroundContext, buffer, g_eeGeneral.varioVolume, g_eeGeneral.backgroundVolume, fade);
|
||||
if (result > 0) {
|
||||
size = max(size, result);
|
||||
}
|
||||
@@ -530,7 +541,7 @@ inline unsigned int getToneLength(uint16_t len)
|
||||
if (g_eeGeneral.beepLength < 0) {
|
||||
result /= (1-g_eeGeneral.beepLength);
|
||||
}
|
||||
if (g_eeGeneral.beepLength > 0) {
|
||||
else if (g_eeGeneral.beepLength > 0) {
|
||||
result *= (1+g_eeGeneral.beepLength);
|
||||
}
|
||||
return result;
|
||||
|
||||
+6
-3
@@ -177,9 +177,9 @@ class AudioQueue {
|
||||
|
||||
void wakeup();
|
||||
|
||||
int mixAudioContext(AudioContext &context, AudioBuffer *buffer, unsigned int weight);
|
||||
int mixTone(AudioContext &context, AudioBuffer *buffer, unsigned int weight);
|
||||
int mixWav(AudioContext &context, AudioBuffer *buffer, unsigned int weight);
|
||||
int mixAudioContext(AudioContext &context, AudioBuffer *buffer, int beepVolume, int wavVolume, unsigned int fade);
|
||||
int mixBeep(AudioContext &context, AudioBuffer *buffer, int volume, unsigned int fade);
|
||||
int mixWav(AudioContext &context, AudioBuffer *buffer, int volume, unsigned int fade);
|
||||
|
||||
volatile bool state;
|
||||
uint8_t ridx;
|
||||
@@ -270,6 +270,9 @@ void audioStart();
|
||||
#define AUDIO_SWR_RED() audioEvent(AU_SWR_RED)
|
||||
#endif
|
||||
|
||||
#define AUDIO_TELEMETRY_LOST() audioEvent(AU_TELEMETRY_LOST)
|
||||
#define AUDIO_TELEMETRY_BACK() audioEvent(AU_TELEMETRY_BACK)
|
||||
|
||||
#define AUDIO_HEARTBEAT()
|
||||
|
||||
#define SYSTEM_AUDIO_CATEGORY 0
|
||||
|
||||
+35
-16
@@ -142,9 +142,13 @@ enum menuGeneralSetupItems {
|
||||
ITEM_SETUP_SOUND_LABEL,
|
||||
IF_AUDIO(ITEM_SETUP_BEEP_MODE)
|
||||
IF_BUZZER(ITEM_SETUP_BUZZER_MODE)
|
||||
IF_VOICE(ITEM_SETUP_SPEAKER_VOLUME)
|
||||
IF_CPUARM(ITEM_SETUP_BEEP_VOLUME)
|
||||
IF_CPUARM(ITEM_SETUP_WAV_VOLUME)
|
||||
IF_CPUARM(ITEM_SETUP_VARIO_VOLUME)
|
||||
IF_CPUARM(ITEM_SETUP_BACKGROUND_VOLUME)
|
||||
ITEM_SETUP_BEEP_LENGTH,
|
||||
IF_AUDIO(ITEM_SETUP_SPEAKER_PITCH)
|
||||
IF_VOICE(ITEM_SETUP_SPEAKER_VOLUME)
|
||||
IF_HAPTIC(ITEM_SETUP_HAPTIC_LABEL)
|
||||
IF_HAPTIC(ITEM_SETUP_HAPTIC_MODE)
|
||||
IF_HAPTIC(ITEM_SETUP_HAPTIC_LENGTH)
|
||||
@@ -201,7 +205,7 @@ void menuGeneralSetup(uint8_t event)
|
||||
}
|
||||
#endif
|
||||
|
||||
MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) IF_BATTGRAPH(1) LABEL(SOUND), IF_AUDIO(0) IF_BUZZER(0) 0, IF_AUDIO(0) IF_VOICE(0) IF_HAPTIC(LABEL(HAPTIC)) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) IF_PCBSKY9X(0) IF_9X(0) LABEL(ALARMS), 0, IF_PCBSKY9X(0) IF_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, IF_SPLASH(0) IF_GPS(0) IF_GPS(0) IF_PXX(0) IF_CPUARM(0) IF_CPUARM(0) IF_FAI_CHOICE(0) 0, LABEL(TX_MODE), CASE_PCBTARANIS(0) 1/*to force edit mode*/});
|
||||
MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) IF_BATTGRAPH(1) LABEL(SOUND), IF_AUDIO(0) IF_BUZZER(0) IF_VOICE(0) IF_CPUARM(0) IF_CPUARM(0) IF_CPUARM(0) IF_CPUARM(0) 0, IF_AUDIO(0) IF_HAPTIC(LABEL(HAPTIC)) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) IF_PCBSKY9X(0) IF_9X(0) LABEL(ALARMS), 0, IF_PCBSKY9X(0) IF_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, IF_SPLASH(0) IF_GPS(0) IF_GPS(0) IF_PXX(0) IF_CPUARM(0) IF_CPUARM(0) IF_FAI_CHOICE(0) 0, LABEL(TX_MODE), CASE_PCBTARANIS(0) 1/*to force edit mode*/});
|
||||
|
||||
uint8_t sub = m_posVert - 1;
|
||||
|
||||
@@ -321,20 +325,6 @@ void menuGeneralSetup(uint8_t event)
|
||||
break;
|
||||
#endif
|
||||
|
||||
case ITEM_SETUP_BEEP_LENGTH:
|
||||
SLIDER_5POS(y, g_eeGeneral.beepLength, STR_LENGTH, event, attr);
|
||||
break;
|
||||
|
||||
#if defined(AUDIO)
|
||||
case ITEM_SETUP_SPEAKER_PITCH:
|
||||
lcd_putsLeft( y, STR_SPKRPITCH);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.speakerPitch, attr|LEFT);
|
||||
if (attr) {
|
||||
CHECK_INCDEC_GENVAR(event, g_eeGeneral.speakerPitch, 0, 20);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(VOICE)
|
||||
case ITEM_SETUP_SPEAKER_VOLUME:
|
||||
{
|
||||
@@ -354,6 +344,35 @@ void menuGeneralSetup(uint8_t event)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
case ITEM_SETUP_BEEP_VOLUME:
|
||||
SLIDER_5POS(y, g_eeGeneral.beepVolume, STR_BEEP_VOLUME, event, attr);
|
||||
break;
|
||||
case ITEM_SETUP_WAV_VOLUME:
|
||||
SLIDER_5POS(y, g_eeGeneral.wavVolume, STR_WAV_VOLUME, event, attr);
|
||||
break;
|
||||
case ITEM_SETUP_VARIO_VOLUME:
|
||||
SLIDER_5POS(y, g_eeGeneral.varioVolume, STR_VARIO_VOLUME, event, attr);
|
||||
break;
|
||||
case ITEM_SETUP_BACKGROUND_VOLUME:
|
||||
SLIDER_5POS(y, g_eeGeneral.backgroundVolume, STR_BG_VOLUME, event, attr);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case ITEM_SETUP_BEEP_LENGTH:
|
||||
SLIDER_5POS(y, g_eeGeneral.beepLength, STR_LENGTH, event, attr);
|
||||
break;
|
||||
|
||||
#if defined(AUDIO)
|
||||
case ITEM_SETUP_SPEAKER_PITCH:
|
||||
lcd_putsLeft( y, STR_SPKRPITCH);
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.speakerPitch, attr|LEFT);
|
||||
if (attr) {
|
||||
CHECK_INCDEC_GENVAR(event, g_eeGeneral.speakerPitch, 0, 20);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(HAPTIC)
|
||||
case ITEM_SETUP_HAPTIC_LABEL:
|
||||
lcd_putsLeft(y, STR_HAPTIC_LABEL);
|
||||
|
||||
+1
-1
@@ -173,7 +173,7 @@ void writeLogs()
|
||||
#if defined(RTCLOCK)
|
||||
struct gtm utm;
|
||||
gettime(&utm);
|
||||
f_printf(&g_oLogFile, "%4d-%02d-%02d,%02d:%02d:%02d.%02d,", utm.tm_year+1900, utm.tm_mon+1, utm.tm_mday, utm.tm_hour, utm.tm_min, utm.tm_sec, g_ms100);
|
||||
f_printf(&g_oLogFile, "%4d-%02d-%02d,%02d:%02d:%02d.%02d0,", utm.tm_year+1900, utm.tm_mon+1, utm.tm_mday, utm.tm_hour, utm.tm_min, utm.tm_sec, g_ms100);
|
||||
#else
|
||||
f_printf(&g_oLogFile, "%d,", tmr10ms);
|
||||
#endif
|
||||
|
||||
+5
-1
@@ -210,7 +210,11 @@ enum BeeperMode {
|
||||
uint8_t rotarySteps; \
|
||||
uint8_t countryCode; \
|
||||
uint8_t imperial; \
|
||||
char ttsLanguage[2];
|
||||
char ttsLanguage[2]; \
|
||||
int8_t beepVolume; \
|
||||
int8_t wavVolume; \
|
||||
int8_t varioVolume; \
|
||||
int8_t backgroundVolume;
|
||||
#elif defined(PXX)
|
||||
#define EXTRA_GENERAL_FIELDS uint8_t countryCode;
|
||||
#else
|
||||
|
||||
@@ -406,6 +406,11 @@ void generalDefault()
|
||||
g_eeGeneral.inactivityTimer = 10;
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
g_eeGeneral.wavVolume = 2;
|
||||
g_eeGeneral.backgroundVolume = 1;
|
||||
#endif
|
||||
|
||||
g_eeGeneral.chkSum = 0xFFFF;
|
||||
}
|
||||
|
||||
|
||||
@@ -1304,6 +1304,10 @@ enum AUDIO_SOUNDS {
|
||||
AU_RSSI_ORANGE,
|
||||
AU_RSSI_RED,
|
||||
AU_SWR_RED,
|
||||
#endif
|
||||
#if defined(CPUARM)
|
||||
AU_TELEMETRY_LOST,
|
||||
AU_TELEMETRY_BACK,
|
||||
#endif
|
||||
AU_FRSKY_FIRST,
|
||||
AU_FRSKY_BEEP1 = AU_FRSKY_FIRST,
|
||||
|
||||
@@ -343,6 +343,10 @@ const pm_char STR_CURRENT_CALIB[] PROGMEM = TR_CURRENT_CALIB;
|
||||
const pm_char STR_UNITSSYSTEM[] PROGMEM = TR_UNITSSYSTEM;
|
||||
const pm_char STR_VOICELANG[] PROGMEM = TR_VOICELANG;
|
||||
const pm_char STR_MODELIDUSED[] PROGMEM = TR_MODELIDUSED;
|
||||
const pm_char STR_BEEP_VOLUME[] PROGMEM = INDENT "Beep Volume";
|
||||
const pm_char STR_WAV_VOLUME[] PROGMEM = INDENT "Wav Volume";
|
||||
const pm_char STR_VARIO_VOLUME[] PROGMEM = INDENT "Vario Volume";
|
||||
const pm_char STR_BG_VOLUME[] PROGMEM = INDENT "Bg Volume";
|
||||
#endif
|
||||
|
||||
#if defined(NAVIGATION_MENUS)
|
||||
|
||||
@@ -473,6 +473,10 @@ extern const pm_char STR_CURRENT[];
|
||||
extern const pm_char STR_UNITSSYSTEM[];
|
||||
extern const pm_char STR_VOICELANG[];
|
||||
extern const pm_char STR_MODELIDUSED[];
|
||||
extern const pm_char STR_BEEP_VOLUME[];
|
||||
extern const pm_char STR_WAV_VOLUME[];
|
||||
extern const pm_char STR_VARIO_VOLUME[];
|
||||
extern const pm_char STR_BG_VOLUME[];
|
||||
#else
|
||||
#define LEN_CALIB_FIELDS PSIZE(TR_BATT_CALIB)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user