feat(lua): Add API for overriding speaker volume (#3784)

This commit is contained in:
Michael
2023-10-13 11:37:12 +10:00
committed by GitHub
parent ff2b3ac22a
commit 7400a598a1
22 changed files with 157 additions and 67 deletions
+18 -12
View File
@@ -556,6 +556,9 @@ int WavContext::mixBuffer(AudioBuffer *buffer, int volume, unsigned int fade)
FRESULT result = FR_OK; FRESULT result = FR_OK;
UINT read = 0; UINT read = 0;
if(fragment.fragmentVolume != USE_SETTINGS_VOLUME)
volume = fragment.fragmentVolume;
if (fragment.file[1]) { if (fragment.file[1]) {
result = f_open(&state.file, fragment.file, FA_OPEN_EXISTING | FA_READ); result = f_open(&state.file, fragment.file, FA_OPEN_EXISTING | FA_READ);
fragment.file[1] = 0; fragment.file[1] = 0;
@@ -652,6 +655,9 @@ int ToneContext::mixBuffer(AudioBuffer * buffer, int volume, unsigned int fade)
int duration = 0; int duration = 0;
int result = 0; int result = 0;
if(fragment.fragmentVolume != USE_SETTINGS_VOLUME)
volume = fragment.fragmentVolume;
int remainingDuration = fragment.tone.duration - state.duration; int remainingDuration = fragment.tone.duration - state.duration;
if (remainingDuration > 0) { if (remainingDuration > 0) {
int points; int points;
@@ -837,7 +843,7 @@ bool AudioQueue::isPlaying(uint8_t id)
fragmentsFifo.hasPromptId(id); fragmentsFifo.hasPromptId(id);
} }
void AudioQueue::playTone(uint16_t freq, uint16_t len, uint16_t pause, uint8_t flags, int8_t freqIncr) void AudioQueue::playTone(uint16_t freq, uint16_t len, uint16_t pause, uint8_t flags, int8_t freqIncr, int8_t fragmentVolume)
{ {
#if defined(SIMU) && !defined(SIMU_AUDIO) #if defined(SIMU) && !defined(SIMU_AUDIO)
return; return;
@@ -848,7 +854,7 @@ void AudioQueue::playTone(uint16_t freq, uint16_t len, uint16_t pause, uint8_t f
freq = limit<uint16_t>(BEEP_MIN_FREQ, freq, BEEP_MAX_FREQ); freq = limit<uint16_t>(BEEP_MIN_FREQ, freq, BEEP_MAX_FREQ);
if (flags & PLAY_BACKGROUND) { if (flags & PLAY_BACKGROUND) {
varioContext.setFragment(freq, len, pause, 0, 0, (flags & PLAY_NOW)); varioContext.setFragment(freq, len, pause, 0, 0, (flags & PLAY_NOW), fragmentVolume);
} }
else { else {
// adjust frequency and length according to the user preferences // adjust frequency and length according to the user preferences
@@ -858,11 +864,11 @@ void AudioQueue::playTone(uint16_t freq, uint16_t len, uint16_t pause, uint8_t f
if (flags & PLAY_NOW) { if (flags & PLAY_NOW) {
if (priorityContext.isFree()) { if (priorityContext.isFree()) {
priorityContext.clear(); priorityContext.clear();
priorityContext.setFragment(freq, len, pause, flags & 0x0f, freqIncr, false); priorityContext.setFragment(freq, len, pause, flags & 0x0f, freqIncr, false, fragmentVolume);
} }
} }
else { else {
fragmentsFifo.push(AudioFragment(freq, len, pause, flags & 0x0f, freqIncr, false)); fragmentsFifo.push(AudioFragment(freq, len, pause, flags & 0x0f, freqIncr, false, fragmentVolume));
} }
} }
@@ -870,10 +876,10 @@ void AudioQueue::playTone(uint16_t freq, uint16_t len, uint16_t pause, uint8_t f
} }
#if defined(SDCARD) #if defined(SDCARD)
void AudioQueue::playFile(const char * filename, uint8_t flags, uint8_t id) void AudioQueue::playFile(const char * filename, uint8_t flags, uint8_t id, int8_t fragmentVolume)
{ {
#if defined(SIMU) #if defined(SIMU)
TRACE("playFile(\"%s\", flags=%x, id=%d)", filename, flags, id); TRACE("playFile(\"%s\", flags=%x, id=%d fragmentVolume=%d ee_general=%d)", filename, flags, id, fragmentVolume, g_eeGeneral.wavVolume);
if (strlen(filename) > AUDIO_FILENAME_MAXLEN) { if (strlen(filename) > AUDIO_FILENAME_MAXLEN) {
TRACE("file name too long! maximum length is %d characters", AUDIO_FILENAME_MAXLEN); TRACE("file name too long! maximum length is %d characters", AUDIO_FILENAME_MAXLEN);
return; return;
@@ -898,10 +904,10 @@ void AudioQueue::playFile(const char * filename, uint8_t flags, uint8_t id)
if (flags & PLAY_BACKGROUND) { if (flags & PLAY_BACKGROUND) {
backgroundContext.clear(); backgroundContext.clear();
backgroundContext.setFragment(filename, 0, id); backgroundContext.setFragment(filename, 0, fragmentVolume, id);
} }
else { else {
fragmentsFifo.push(AudioFragment(filename, flags & 0x0f, id)); fragmentsFifo.push(AudioFragment(filename, flags & 0x0f, fragmentVolume, id));
} }
RTOS_UNLOCK_MUTEX(audioMutex); RTOS_UNLOCK_MUTEX(audioMutex);
@@ -1223,14 +1229,14 @@ void audioEvent(unsigned int index)
} }
#if defined(SDCARD) #if defined(SDCARD)
void pushUnit(uint8_t unit, uint8_t idx, uint8_t id) void pushUnit(uint8_t unit, uint8_t idx, uint8_t id, uint8_t fragmentVolume)
{ {
if (unit < DIM(unitsFilenames)) { if (unit < DIM(unitsFilenames)) {
char path[AUDIO_FILENAME_MAXLEN+1]; char path[AUDIO_FILENAME_MAXLEN+1];
char * tmp = strAppendSystemAudioPath(path); char * tmp = strAppendSystemAudioPath(path);
tmp = strAppendStringWithIndex(tmp, unitsFilenames[unit], idx); tmp = strAppendStringWithIndex(tmp, unitsFilenames[unit], idx);
strcpy(tmp, SOUNDS_EXT); strcpy(tmp, SOUNDS_EXT);
audioQueue.playFile(path, 0, id); audioQueue.playFile(path, 0, id, fragmentVolume);
} }
else { else {
TRACE("pushUnit: out of bounds unit : %d", unit); // We should never get here, but given the nature of TTS files, this prevent segfault in case of bug there. TRACE("pushUnit: out of bounds unit : %d", unit); // We should never get here, but given the nature of TTS files, this prevent segfault in case of bug there.
@@ -1238,7 +1244,7 @@ void pushUnit(uint8_t unit, uint8_t idx, uint8_t id)
} }
#endif #endif
void pushPrompt(uint16_t prompt, uint8_t id) void pushPrompt(uint16_t prompt, uint8_t id, uint8_t fragmentVolume)
{ {
#if defined(SDCARD) #if defined(SDCARD)
char filename[AUDIO_FILENAME_MAXLEN+1]; char filename[AUDIO_FILENAME_MAXLEN+1];
@@ -1248,7 +1254,7 @@ void pushPrompt(uint16_t prompt, uint8_t id)
str[i] = '0' + (prompt%10); str[i] = '0' + (prompt%10);
prompt /= 10; prompt /= 10;
} }
audioQueue.playFile(filename, 0, id); audioQueue.playFile(filename, 0, id, fragmentVolume);
#endif #endif
} }
+27 -19
View File
@@ -91,6 +91,8 @@ constexpr uint8_t AUDIO_FILENAME_MAXLEN = (AUDIO_LUA_FILENAME_MAXLEN > AUDIO_MOD
#define BEEP_MAX_FREQ (15000) #define BEEP_MAX_FREQ (15000)
#define BEEP_DEFAULT_FREQ (2250) #define BEEP_DEFAULT_FREQ (2250)
#define USE_SETTINGS_VOLUME (127)
#if defined(AUDIO_DUAL_BUFFER) #if defined(AUDIO_DUAL_BUFFER)
enum AudioBufferState enum AudioBufferState
{ {
@@ -156,6 +158,7 @@ struct AudioFragment {
uint8_t type; uint8_t type;
uint8_t id; uint8_t id;
uint8_t repeat; uint8_t repeat;
int8_t fragmentVolume;
union { union {
Tone tone; Tone tone;
char file[AUDIO_FILENAME_MAXLEN+1]; char file[AUDIO_FILENAME_MAXLEN+1];
@@ -163,17 +166,19 @@ struct AudioFragment {
AudioFragment() { clear(); }; AudioFragment() { clear(); };
AudioFragment(uint16_t freq, uint16_t duration, uint16_t pause, uint8_t repeat, int8_t freqIncr, bool reset, uint8_t id=0): AudioFragment(uint16_t freq, uint16_t duration, uint16_t pause, uint8_t repeat, int8_t freqIncr, bool reset, int8_t fragmentVolume, uint8_t id=0 ):
type(FRAGMENT_TONE), type(FRAGMENT_TONE),
id(id), id(id),
repeat(repeat), repeat(repeat),
fragmentVolume(fragmentVolume),
tone(freq, duration, pause, freqIncr, reset) tone(freq, duration, pause, freqIncr, reset)
{}; {};
AudioFragment(const char * filename, uint8_t repeat, uint8_t id=0): AudioFragment(const char * filename, uint8_t repeat, int8_t fragmentVolume, uint8_t id = 0):
type(FRAGMENT_FILE), type(FRAGMENT_FILE),
id(id), id(id),
repeat(repeat) repeat(repeat),
fragmentVolume(fragmentVolume)
{ {
strcpy(file, filename); strcpy(file, filename);
} }
@@ -181,6 +186,8 @@ struct AudioFragment {
void clear() void clear()
{ {
memset(reinterpret_cast<void*>(this), 0, sizeof(AudioFragment)); memset(reinterpret_cast<void*>(this), 0, sizeof(AudioFragment));
this->fragmentVolume = USE_SETTINGS_VOLUME;
} }
}; };
@@ -190,6 +197,8 @@ class ToneContext {
inline void clear() inline void clear()
{ {
memset(reinterpret_cast<void*>(this), 0, sizeof(ToneContext)); memset(reinterpret_cast<void*>(this), 0, sizeof(ToneContext));
fragment.fragmentVolume = USE_SETTINGS_VOLUME;
} }
bool isFree() const bool isFree() const
@@ -199,9 +208,9 @@ class ToneContext {
int mixBuffer(AudioBuffer *buffer, int volume, unsigned int fade); int mixBuffer(AudioBuffer *buffer, int volume, unsigned int fade);
void setFragment(uint16_t freq, uint16_t duration, uint16_t pause, uint8_t repeat, int8_t freqIncr, bool reset, uint8_t id=0) void setFragment(uint16_t freq, uint16_t duration, uint16_t pause, uint8_t repeat, int8_t freqIncr, bool reset, int8_t fragmentVolume, uint8_t id = 0)
{ {
fragment = AudioFragment(freq, duration, pause, repeat, freqIncr, reset, id); fragment = AudioFragment(freq, duration, pause, repeat, freqIncr, reset, fragmentVolume, id);
} }
private: private:
@@ -226,9 +235,9 @@ class WavContext {
int mixBuffer(AudioBuffer *buffer, int volume, unsigned int fade); int mixBuffer(AudioBuffer *buffer, int volume, unsigned int fade);
bool hasPromptId(uint8_t id) const { return fragment.id == id; }; bool hasPromptId(uint8_t id) const { return fragment.id == id; };
void setFragment(const char * filename, uint8_t repeat, uint8_t id) void setFragment(const char * filename, uint8_t repeat, int8_t fragmentVolume, uint8_t id)
{ {
fragment = AudioFragment(filename, repeat, id); fragment = AudioFragment(filename, repeat, id, fragmentVolume);
} }
void stop(uint8_t id) void stop(uint8_t id)
@@ -294,7 +303,6 @@ class MixedContext {
ToneContext tone; ToneContext tone;
WavContext wav; WavContext wav;
}; };
}; };
class AudioBufferFifo { class AudioBufferFifo {
@@ -506,8 +514,8 @@ class AudioQueue {
public: public:
AudioQueue(); AudioQueue();
void start() { _started = true; }; void start() { _started = true; };
void playTone(uint16_t freq, uint16_t len, uint16_t pause=0, uint8_t flags=0, int8_t freqIncr=0); void playTone(uint16_t freq, uint16_t len, uint16_t pause=0, uint8_t flags=0, int8_t freqIncr=0, int8_t fragmentVolume = USE_SETTINGS_VOLUME);
void playFile(const char *filename, uint8_t flags=0, uint8_t id=0); void playFile(const char *filename, uint8_t flags=0, uint8_t id=0, int8_t fragmentVolume = USE_SETTINGS_VOLUME);
void stopPlay(uint8_t id); void stopPlay(uint8_t id);
void stopAll(); void stopAll();
void flush(); void flush();
@@ -609,15 +617,15 @@ enum AutomaticPromptsEvents {
AUDIO_EVENT_MID, AUDIO_EVENT_MID,
}; };
void pushPrompt(uint16_t prompt, uint8_t id=0); void pushPrompt(uint16_t prompt, uint8_t id=0, uint8_t fragmentVolume = USE_SETTINGS_VOLUME);
void pushUnit(uint8_t unit, uint8_t idx, uint8_t id); void pushUnit(uint8_t unit, uint8_t idx, uint8_t id, uint8_t fragmentVolume = USE_SETTINGS_VOLUME);
void playModelName(); void playModelName();
#define I18N_PLAY_FUNCTION(lng, x, ...) void lng ## _ ## x(__VA_ARGS__, uint8_t id) #define I18N_PLAY_FUNCTION(lng, x, ...) void lng ## _ ## x(__VA_ARGS__, uint8_t id, int8_t fragmentVolume = USE_SETTINGS_VOLUME)
#define PUSH_NUMBER_PROMPT(p) pushPrompt((p), id) #define PUSH_NUMBER_PROMPT(p) pushPrompt((p), id, fragmentVolume)
#define PUSH_UNIT_PROMPT(p, i) pushUnit((p), (i), id) #define PUSH_UNIT_PROMPT(p, i) pushUnit((p), (i), id, fragmentVolume)
#define PLAY_NUMBER(n, u, a) playNumber((n), (u), (a), id) #define PLAY_NUMBER(n, u, a) playNumber((n), (u), (a), id, fragmentVolume)
#define PLAY_DURATION(d, att) playDuration((d), (att), id) #define PLAY_DURATION(d, att) playDuration((d), (att), id, fragmentVolume)
#define PLAY_DURATION_ATT , uint8_t flags #define PLAY_DURATION_ATT , uint8_t flags
#define PLAY_TIME 1 #define PLAY_TIME 1
#define PLAY_LONG_TIMER 2 #define PLAY_LONG_TIMER 2
@@ -625,8 +633,8 @@ void playModelName();
#define IS_PLAY_TIME() (flags & PLAY_TIME) #define IS_PLAY_TIME() (flags & PLAY_TIME)
#define IS_PLAY_LONG_TIMER() (flags & PLAY_LONG_TIMER) #define IS_PLAY_LONG_TIMER() (flags & PLAY_LONG_TIMER)
#define IS_PLAYING(id) audioQueue.isPlaying((id)) #define IS_PLAYING(id) audioQueue.isPlaying((id))
#define PLAY_VALUE(v, id) playValue((v), (id)) #define PLAY_VALUE(v, id) playValue((v), (id), USE_SETTINGS_VOLUME)
#define PLAY_FILE(f, flags, id) audioQueue.playFile((f), (flags), (id)) #define PLAY_FILE(f, flags, id) audioQueue.playFile((f), (flags), (id), USE_SETTINGS_VOLUME)
#define STOP_PLAY(id) audioQueue.stopPlay((id)) #define STOP_PLAY(id) audioQueue.stopPlay((id))
#define AUDIO_RESET() audioQueue.stopAll() #define AUDIO_RESET() audioQueue.stopAll()
#define AUDIO_FLUSH() audioQueue.flush() #define AUDIO_FLUSH() audioQueue.flush()
+87 -14
View File
@@ -1421,35 +1421,53 @@ static int luaGetFlightMode(lua_State * L)
} }
/*luadoc /*luadoc
@function playFile(name) @function playFile(filename [, volume])
Play a file from the SD card Play a file from the SD card
@param path (string) full path to wav file (i.e. “/SOUNDS/en/system/tada.wav”) @param filename (string) full path to wav file (i.e. “/SOUNDS/en/system/tada.wav”)
Introduced in 2.1.0: If you use a relative path, the current language is appended Introduced in 2.1.0: If you use a relative path, the current language is appended
to the path (example: for English language: `/SOUNDS/en` is appended) to the path (example: for English language: `/SOUNDS/en` is appended)
@status current Introduced in 2.0.0, changed in 2.1.0 @param volume (number):
- (1..5) override radio settings Wav volume for the duration of file
- omitting the parameter uses radio settings Wav volume
@retval none
@status current Introduced in 2.0.0, changed in 2.1.0, changed in 2.10
// targets: BW, COLOR
//
// EXAMPLES:
// playFile("armed.wav", 5) -- play file armed.wav, use Wav volume 2
// playFile("armed.wav", 1) -- play file armed.wav, use Wav volume 1
// playFile("armed.wav") -- play file armed.wav, use radio settings Wav volume
*/ */
static int luaPlayFile(lua_State * L) static int luaPlayFile(lua_State * L)
{ {
const char * filename = luaL_checkstring(L, 1); const char * filename = luaL_checkstring(L, 1);
int volume = luaL_optinteger(L, 2, USE_SETTINGS_VOLUME);
if(volume != USE_SETTINGS_VOLUME)
volume = limit(-2, volume-3, 2); // (rescale 1..5) to internal format and limit to (-2..2)
if (filename[0] != '/') { if (filename[0] != '/') {
// relative sound file path - use current language dir for absolute path // relative sound file path - use current language dir for absolute path
char file[AUDIO_FILENAME_MAXLEN+1]; char file[AUDIO_FILENAME_MAXLEN+1];
char * str = getAudioPath(file); char * str = getAudioPath(file);
strncpy(str, filename, AUDIO_FILENAME_MAXLEN - (str-file)); strncpy(str, filename, AUDIO_FILENAME_MAXLEN - (str-file));
file[AUDIO_FILENAME_MAXLEN] = 0; file[AUDIO_FILENAME_MAXLEN] = 0;
PLAY_FILE(file, 0, 0); audioQueue.playFile(file, 0, 0, volume);
} }
else { else {
PLAY_FILE(filename, 0, 0); audioQueue.playFile(filename, 0, 0, volume);
} }
return 0; return 0;
} }
/*luadoc /*luadoc
@function playNumber(value, unit [, attributes]) @function playNumber(value, unit [, attributes [, volume]])
Play a numerical value (text to speech) Play a numerical value (text to speech)
@@ -1462,20 +1480,38 @@ Play a numerical value (text to speech)
* `PREC1` plays a number with one decimal place (for a number 123 it plays 12.3) * `PREC1` plays a number with one decimal place (for a number 123 it plays 12.3)
* `PREC2` plays a number with two decimal places (for a number 123 it plays 1.23) * `PREC2` plays a number with two decimal places (for a number 123 it plays 1.23)
@status current Introduced in 2.0.0 @param volume (number):
- (1..5) override radio settings Wav volume for the duration of file
- omitting the parameter uses radio settings Wav volume
@retval none
@status current Introduced in 2.0.0, changed in 2.10
// targets: BW, COLOR
//
// EXAMPLES:
// playNumber(123, 3, 0, 5) -- play number 123, unit mAh, use Wav volume 5
// playNumber(123, 3, 0, 1) -- play number 123, unit mAh, use Wav volume 1
// playNumber(123, 3, 0) -- play number 123, unit mAh, use radio settings Wav volume
*/ */
static int luaPlayNumber(lua_State * L) static int luaPlayNumber(lua_State * L)
{ {
int number = luaL_checkinteger(L, 1); int number = luaL_checkinteger(L, 1);
int unit = luaL_checkinteger(L, 2); int unit = luaL_checkinteger(L, 2);
unsigned int att = luaL_optunsigned(L, 3, 0); unsigned int att = luaL_optunsigned(L, 3, 0);
playNumber(number, unit, att, 0); int volume = luaL_optinteger(L, 4, USE_SETTINGS_VOLUME);
if(volume != USE_SETTINGS_VOLUME)
volume = limit(-2, volume-3, 2); // (rescale 1..5) to internal format and limit to (-2..2)
playNumber(number, unit, att, 0, volume);
return 0; return 0;
} }
/*luadoc /*luadoc
@function playDuration(duration [, hourFormat]) @function playDuration(duration [, hourFormat [, volume]])
Play a time value (text to speech) Play a time value (text to speech)
@@ -1484,19 +1520,38 @@ Play a time value (text to speech)
@param hourFormat (number): @param hourFormat (number):
* `0 or not present` play format: minutes and seconds. * `0 or not present` play format: minutes and seconds.
* `!= 0` play format: hours, minutes and seconds. * `!= 0` play format: hours, minutes and seconds.
*
@param volume (number):
- (1..5) override radio settings Wav volume for the duration of file
- omitting the parameter uses radio settings Wav volume
@status current Introduced in 2.1.0 @retval none
@status current Introduced in 2.1.0, changed in 2.10
// targets: BW, COLOR
//
// EXAMPLES:
// playDuration(101, 0, 5) -- play duration 101s, seconds format, use Wav volume 5
// playDuration(101, 0, 1) -- play duration 101s, seconds format, use Wav volume 1
// playDuration(101, 1) -- play duration 101s, hour format, use radio settings Wav volume
*/ */
static int luaPlayDuration(lua_State * L) static int luaPlayDuration(lua_State * L)
{ {
int duration = luaL_checkinteger(L, 1); int duration = luaL_checkinteger(L, 1);
bool playTime = (luaL_optinteger(L, 2, 0) != 0); bool playTime = (luaL_optinteger(L, 2, 0) != 0);
playDuration(duration, playTime ? PLAY_TIME : 0, 0); int volume = luaL_optinteger(L, 3, USE_SETTINGS_VOLUME);
if(volume != USE_SETTINGS_VOLUME)
volume = limit(-2, volume-3, 2); // (rescale 1..5) to internal format and limit to (-2..2)
playDuration(duration, playTime ? PLAY_TIME : 0, 0, volume);
return 0; return 0;
} }
/*luadoc /*luadoc
@function playTone(frequency, duration, pause [, flags [, freqIncr]]) @function playTone(frequency, duration, pause [, flags [, freqIncr [, volume]]])
Play a tone Play a tone
@@ -1515,7 +1570,20 @@ Play a tone
negative number decreases it. The frequency changes every 10 milliseconds, the change is `freqIncr * 10Hz`. negative number decreases it. The frequency changes every 10 milliseconds, the change is `freqIncr * 10Hz`.
The valid range is from -127 to 127. The valid range is from -127 to 127.
@status current Introduced in 2.1.0 @param volume (number):
- (1..5) override radio settings Beep volume for the duration of file
- omitting the parameter uses radio settings Beep volume
@retval none
@status current Introduced in 2.1.0, changed in 2.10
// targets: BW, COLOR
//
// EXAMPLES:
// playTone(2550, 160, 20, 3, -10, 5) -- play tone, use Beep volume 5
// playTone(2550, 160, 20, 3, -10, 1) -- play tone, use Beep volume 1
// playTone(2550, 160, 20, 3, -10) -- play tone, use radio settings Beep volume
*/ */
static int luaPlayTone(lua_State * L) static int luaPlayTone(lua_State * L)
{ {
@@ -1524,7 +1592,12 @@ static int luaPlayTone(lua_State * L)
int pause = luaL_checkinteger(L, 3); int pause = luaL_checkinteger(L, 3);
int flags = luaL_optinteger(L, 4, 0); int flags = luaL_optinteger(L, 4, 0);
int freqIncr = luaL_optinteger(L, 5, 0); int freqIncr = luaL_optinteger(L, 5, 0);
audioQueue.playTone(frequency, length, pause, flags, freqIncr); int volume = luaL_optinteger(L, 6, USE_SETTINGS_VOLUME);
if(volume != USE_SETTINGS_VOLUME)
volume = limit(-2, volume-3, 2); // (rescale 1..5) to internal format and limit to (-2..2)
audioQueue.playTone(frequency, length, pause, flags, freqIncr, volume);
return 0; return 0;
} }
+1
View File
@@ -1072,6 +1072,7 @@ void evalMixes(uint8_t tick10ms)
// must be done before limits because of the applyLimit function: it checks for safety switches which would be not initialized otherwise // must be done before limits because of the applyLimit function: it checks for safety switches which would be not initialized otherwise
if (tick10ms) { if (tick10ms) {
requiredSpeakerVolume = g_eeGeneral.speakerVolume + VOLUME_LEVEL_DEF; requiredSpeakerVolume = g_eeGeneral.speakerVolume + VOLUME_LEVEL_DEF;
requiredBacklightBright = g_eeGeneral.getBrightness(); requiredBacklightBright = g_eeGeneral.getBrightness();
if (radioGFEnabled()) { if (radioGFEnabled()) {
+6 -5
View File
@@ -25,6 +25,7 @@
#include <limits.h> #include <limits.h>
#include "opentx_types.h" #include "opentx_types.h"
#include "translations/untranslated.h" #include "translations/untranslated.h"
#include "audio.h"
#if defined(TRANSLATIONS_FR) #if defined(TRANSLATIONS_FR)
#include "translations/fr.h" #include "translations/fr.h"
@@ -884,8 +885,8 @@ extern const char STR_MODEL_MENU_TABS[];
struct LanguagePack { struct LanguagePack {
const char * id; const char * id;
const char * name; const char * name;
void (*playNumber)(getvalue_t number, uint8_t unit, uint8_t flags, uint8_t id); void (*playNumber)(getvalue_t number, uint8_t unit, uint8_t flags, uint8_t id, int8_t fragmentVolume);
void (*playDuration)(int seconds, uint8_t flags, uint8_t id); void (*playDuration)(int seconds, uint8_t flags, uint8_t id, int8_t fragmentVolume);
}; };
extern const LanguagePack * currentLanguagePack; extern const LanguagePack * currentLanguagePack;
@@ -949,14 +950,14 @@ const LanguagePack * const languagePacks[] = {
const LanguagePack* currentLanguagePack = &lng##LanguagePack; \ const LanguagePack* currentLanguagePack = &lng##LanguagePack; \
uint8_t currentLanguagePackIdx uint8_t currentLanguagePackIdx
#define PLAY_FUNCTION(x, ...) void x(__VA_ARGS__, uint8_t id) #define PLAY_FUNCTION(x, ...) void x(__VA_ARGS__, uint8_t id, int8_t fragmentVolume = USE_SETTINGS_VOLUME)
inline PLAY_FUNCTION(playNumber, getvalue_t number, uint8_t unit, uint8_t flags) { inline PLAY_FUNCTION(playNumber, getvalue_t number, uint8_t unit, uint8_t flags) {
currentLanguagePack->playNumber(number, unit, flags, id); currentLanguagePack->playNumber(number, unit, flags, id, fragmentVolume);
} }
inline PLAY_FUNCTION(playDuration, int seconds, uint8_t flags) { inline PLAY_FUNCTION(playDuration, int seconds, uint8_t flags) {
currentLanguagePack->playDuration(seconds, flags, id); currentLanguagePack->playDuration(seconds, flags, id, fragmentVolume);
} }
extern const char STR_MODELNAME[]; extern const char STR_MODELNAME[];
+1 -1
View File
@@ -34,7 +34,7 @@ enum ChinesePrompts {
}; };
#define CN_PUSH_UNIT_PROMPT(u, p) cn_pushUnitPrompt((u), (p), id) #define CN_PUSH_UNIT_PROMPT(u, p) cn_pushUnitPrompt((u), (p), id, fragmentVolume)
I18N_PLAY_FUNCTION(cn, pushUnitPrompt, uint8_t unitprompt, int16_t number) I18N_PLAY_FUNCTION(cn, pushUnitPrompt, uint8_t unitprompt, int16_t number)
{ {
+1 -1
View File
@@ -39,7 +39,7 @@ enum CzechPrompts {
}; };
#define CZ_PUSH_UNIT_PROMPT(u, p) cz_pushUnitPrompt((u), (p), id) #define CZ_PUSH_UNIT_PROMPT(u, p) cz_pushUnitPrompt((u), (p), id, fragmentVolume)
#define MALE 0x80 #define MALE 0x80
#define FEMALE 0x81 #define FEMALE 0x81
+1 -1
View File
@@ -34,7 +34,7 @@ enum DanishPrompts {
}; };
#define DA_PUSH_UNIT_PROMPT(u, p) da_pushUnitPrompt((u), (p), id) #define DA_PUSH_UNIT_PROMPT(u, p) da_pushUnitPrompt((u), (p), id, fragmentVolume)
I18N_PLAY_FUNCTION(da, pushUnitPrompt, uint8_t unitprompt, int16_t number) I18N_PLAY_FUNCTION(da, pushUnitPrompt, uint8_t unitprompt, int16_t number)
{ {
+1 -1
View File
@@ -64,7 +64,7 @@ enum GermanPrompts {
}; };
#define DE_PUSH_UNIT_PROMPT(u, p) de_pushUnitPrompt((u), (p), id) #define DE_PUSH_UNIT_PROMPT(u, p) de_pushUnitPrompt((u), (p), id, fragmentVolume)
I18N_PLAY_FUNCTION(de, pushUnitPrompt, uint8_t unitprompt, int16_t number) I18N_PLAY_FUNCTION(de, pushUnitPrompt, uint8_t unitprompt, int16_t number)
{ {
+2 -1
View File
@@ -34,7 +34,7 @@ enum EnglishPrompts {
}; };
#define EN_PUSH_UNIT_PROMPT(u, p) en_pushUnitPrompt((u), (p), id) #define EN_PUSH_UNIT_PROMPT(u, p) en_pushUnitPrompt((u), (p), id, fragmentVolume)
I18N_PLAY_FUNCTION(en, pushUnitPrompt, uint8_t unitprompt, int16_t number) I18N_PLAY_FUNCTION(en, pushUnitPrompt, uint8_t unitprompt, int16_t number)
{ {
@@ -46,6 +46,7 @@ I18N_PLAY_FUNCTION(en, pushUnitPrompt, uint8_t unitprompt, int16_t number)
I18N_PLAY_FUNCTION(en, playNumber, getvalue_t number, uint8_t unit, uint8_t att) I18N_PLAY_FUNCTION(en, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
{ {
TRACE("I18N_PLAY_FUNCTION v %d", fragmentVolume);
if (number < 0) { if (number < 0) {
PUSH_NUMBER_PROMPT(EN_PROMPT_MINUS); PUSH_NUMBER_PROMPT(EN_PROMPT_MINUS);
number = -number; number = -number;
+1 -1
View File
@@ -72,7 +72,7 @@ enum SpanishPrompts {
}; };
#define ES_PUSH_UNIT_PROMPT(u) es_pushUnitPrompt((u), id) #define ES_PUSH_UNIT_PROMPT(u) es_pushUnitPrompt((u), id, fragmentVolume)
I18N_PLAY_FUNCTION(es, pushUnitPrompt, uint8_t unitprompt) I18N_PLAY_FUNCTION(es, pushUnitPrompt, uint8_t unitprompt)
{ {
+1 -1
View File
@@ -52,7 +52,7 @@ enum FrenchPrompts {
}; };
#define FR_PUSH_UNIT_PROMPT(u) fr_pushUnitPrompt((u), id) #define FR_PUSH_UNIT_PROMPT(u) fr_pushUnitPrompt((u), id, fragmentVolume)
I18N_PLAY_FUNCTION(fr, pushUnitPrompt, uint8_t unitprompt) I18N_PLAY_FUNCTION(fr, pushUnitPrompt, uint8_t unitprompt)
{ {
+1 -1
View File
@@ -34,7 +34,7 @@ enum HebrewPrompts {
}; };
#define HE_PUSH_UNIT_PROMPT(u, p) he_pushUnitPrompt((u), (p), id) #define HE_PUSH_UNIT_PROMPT(u, p) he_pushUnitPrompt((u), (p), id, fragmentVolume)
I18N_PLAY_FUNCTION(he, pushUnitPrompt, uint8_t unitprompt, int16_t number) I18N_PLAY_FUNCTION(he, pushUnitPrompt, uint8_t unitprompt, int16_t number)
{ {
+1 -1
View File
@@ -34,7 +34,7 @@ enum HungarianPrompts {
}; };
#define HU_PUSH_UNIT_PROMPT(u, p) hu_pushUnitPrompt((u), (p), id) #define HU_PUSH_UNIT_PROMPT(u, p) hu_pushUnitPrompt((u), (p), id, fragmentVolume)
I18N_PLAY_FUNCTION(hu, pushUnitPrompt, uint8_t unitprompt, int16_t number) I18N_PLAY_FUNCTION(hu, pushUnitPrompt, uint8_t unitprompt, int16_t number)
{ {
+1 -1
View File
@@ -58,7 +58,7 @@ enum ItalianPrompts {
}; };
#define IT_PUSH_UNIT_PROMPT(u, p) it_pushUnitPrompt((u), (p), id) #define IT_PUSH_UNIT_PROMPT(u, p) it_pushUnitPrompt((u), (p), id, fragmentVolume)
I18N_PLAY_FUNCTION(it, pushUnitPrompt, uint8_t unitprompt, int16_t number) I18N_PLAY_FUNCTION(it, pushUnitPrompt, uint8_t unitprompt, int16_t number)
{ {
+1 -1
View File
@@ -34,7 +34,7 @@ enum JapanesePrompts {
}; };
#define JP_PUSH_UNIT_PROMPT(u, p) jp_pushUnitPrompt((u), (p), id) #define JP_PUSH_UNIT_PROMPT(u, p) jp_pushUnitPrompt((u), (p), id, fragmentVolume)
I18N_PLAY_FUNCTION(jp, pushUnitPrompt, uint8_t unitprompt, int16_t number) I18N_PLAY_FUNCTION(jp, pushUnitPrompt, uint8_t unitprompt, int16_t number)
{ {
+1 -1
View File
@@ -36,7 +36,7 @@ enum DutchPrompts {
}; };
#define NL_PUSH_UNIT_PROMPT(u, p) nl_pushUnitPrompt((u), (p), id) #define NL_PUSH_UNIT_PROMPT(u, p) nl_pushUnitPrompt((u), (p), id, fragmentVolume)
I18N_PLAY_FUNCTION(nl, pushUnitPrompt, uint8_t unitprompt, int16_t number) I18N_PLAY_FUNCTION(nl, pushUnitPrompt, uint8_t unitprompt, int16_t number)
{ {
+1 -1
View File
@@ -63,7 +63,7 @@ enum PolishPrompts {
}; };
#define PL_PUSH_UNIT_PROMPT(u, p) pl_pushUnitPrompt((u), (p), id) #define PL_PUSH_UNIT_PROMPT(u, p) pl_pushUnitPrompt((u), (p), id, fragmentVolume)
#define MESKI 0x80 #define MESKI 0x80
#define ZENSKI 0x81 #define ZENSKI 0x81
+1 -1
View File
@@ -67,7 +67,7 @@ enum PortuguesePrompts {
}; };
#define PT_PUSH_UNIT_PROMPT(u) pt_pushUnitPrompt((u), id) #define PT_PUSH_UNIT_PROMPT(u) pt_pushUnitPrompt((u), id, fragmentVolume)
I18N_PLAY_FUNCTION(pt, pushUnitPrompt, uint8_t unitprompt) I18N_PLAY_FUNCTION(pt, pushUnitPrompt, uint8_t unitprompt)
{ {
+1 -1
View File
@@ -42,7 +42,7 @@ enum RusPrompts {
#define RU_FEMALE_UNIT 0xFF #define RU_FEMALE_UNIT 0xFF
#define RU_PUSH_UNIT_PROMPT(u, p) ru_pushUnitPrompt((u), (p), id) #define RU_PUSH_UNIT_PROMPT(u, p) ru_pushUnitPrompt((u), (p), id, fragmentVolume)
I18N_PLAY_FUNCTION(ru, pushUnitPrompt, uint8_t unitprompt, int16_t number) I18N_PLAY_FUNCTION(ru, pushUnitPrompt, uint8_t unitprompt, int16_t number)
{ {
+1 -1
View File
@@ -34,7 +34,7 @@ enum SwedishPrompts {
}; };
#define SE_PUSH_UNIT_PROMPT(u, p) se_pushUnitPrompt((u), (p), id) #define SE_PUSH_UNIT_PROMPT(u, p) se_pushUnitPrompt((u), (p), id, fragmentVolume)
I18N_PLAY_FUNCTION(se, pushUnitPrompt, uint8_t unitprompt, int16_t number) I18N_PLAY_FUNCTION(se, pushUnitPrompt, uint8_t unitprompt, int16_t number)
{ {
+1 -1
View File
@@ -40,7 +40,7 @@ enum SlovakPrompts {
}; };
#define SK_PUSH_UNIT_PROMPT(u, p) sk_pushUnitPrompt((u), (p), id) #define SK_PUSH_UNIT_PROMPT(u, p) sk_pushUnitPrompt((u), (p), id, fragmentVolume)
#define MUZSKY 0x80 #define MUZSKY 0x80
#define ZENSKY 0x81 #define ZENSKY 0x81