feat(lua): Add API for overriding speaker volume (#3784)
This commit is contained in:
+18
-12
@@ -556,6 +556,9 @@ int WavContext::mixBuffer(AudioBuffer *buffer, int volume, unsigned int fade)
|
||||
FRESULT result = FR_OK;
|
||||
UINT read = 0;
|
||||
|
||||
if(fragment.fragmentVolume != USE_SETTINGS_VOLUME)
|
||||
volume = fragment.fragmentVolume;
|
||||
|
||||
if (fragment.file[1]) {
|
||||
result = f_open(&state.file, fragment.file, FA_OPEN_EXISTING | FA_READ);
|
||||
fragment.file[1] = 0;
|
||||
@@ -652,6 +655,9 @@ int ToneContext::mixBuffer(AudioBuffer * buffer, int volume, unsigned int fade)
|
||||
int duration = 0;
|
||||
int result = 0;
|
||||
|
||||
if(fragment.fragmentVolume != USE_SETTINGS_VOLUME)
|
||||
volume = fragment.fragmentVolume;
|
||||
|
||||
int remainingDuration = fragment.tone.duration - state.duration;
|
||||
if (remainingDuration > 0) {
|
||||
int points;
|
||||
@@ -837,7 +843,7 @@ bool AudioQueue::isPlaying(uint8_t 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)
|
||||
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);
|
||||
|
||||
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 {
|
||||
// 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 (priorityContext.isFree()) {
|
||||
priorityContext.clear();
|
||||
priorityContext.setFragment(freq, len, pause, flags & 0x0f, freqIncr, false);
|
||||
priorityContext.setFragment(freq, len, pause, flags & 0x0f, freqIncr, false, fragmentVolume);
|
||||
}
|
||||
}
|
||||
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)
|
||||
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)
|
||||
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) {
|
||||
TRACE("file name too long! maximum length is %d characters", AUDIO_FILENAME_MAXLEN);
|
||||
return;
|
||||
@@ -898,10 +904,10 @@ void AudioQueue::playFile(const char * filename, uint8_t flags, uint8_t id)
|
||||
|
||||
if (flags & PLAY_BACKGROUND) {
|
||||
backgroundContext.clear();
|
||||
backgroundContext.setFragment(filename, 0, id);
|
||||
backgroundContext.setFragment(filename, 0, fragmentVolume, id);
|
||||
}
|
||||
else {
|
||||
fragmentsFifo.push(AudioFragment(filename, flags & 0x0f, id));
|
||||
fragmentsFifo.push(AudioFragment(filename, flags & 0x0f, fragmentVolume, id));
|
||||
}
|
||||
|
||||
RTOS_UNLOCK_MUTEX(audioMutex);
|
||||
@@ -1223,14 +1229,14 @@ void audioEvent(unsigned int index)
|
||||
}
|
||||
|
||||
#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)) {
|
||||
char path[AUDIO_FILENAME_MAXLEN+1];
|
||||
char * tmp = strAppendSystemAudioPath(path);
|
||||
tmp = strAppendStringWithIndex(tmp, unitsFilenames[unit], idx);
|
||||
strcpy(tmp, SOUNDS_EXT);
|
||||
audioQueue.playFile(path, 0, id);
|
||||
audioQueue.playFile(path, 0, id, fragmentVolume);
|
||||
}
|
||||
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.
|
||||
@@ -1238,7 +1244,7 @@ void pushUnit(uint8_t unit, uint8_t idx, uint8_t id)
|
||||
}
|
||||
#endif
|
||||
|
||||
void pushPrompt(uint16_t prompt, uint8_t id)
|
||||
void pushPrompt(uint16_t prompt, uint8_t id, uint8_t fragmentVolume)
|
||||
{
|
||||
#if defined(SDCARD)
|
||||
char filename[AUDIO_FILENAME_MAXLEN+1];
|
||||
@@ -1248,7 +1254,7 @@ void pushPrompt(uint16_t prompt, uint8_t id)
|
||||
str[i] = '0' + (prompt%10);
|
||||
prompt /= 10;
|
||||
}
|
||||
audioQueue.playFile(filename, 0, id);
|
||||
audioQueue.playFile(filename, 0, id, fragmentVolume);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+27
-19
@@ -91,6 +91,8 @@ constexpr uint8_t AUDIO_FILENAME_MAXLEN = (AUDIO_LUA_FILENAME_MAXLEN > AUDIO_MOD
|
||||
#define BEEP_MAX_FREQ (15000)
|
||||
#define BEEP_DEFAULT_FREQ (2250)
|
||||
|
||||
#define USE_SETTINGS_VOLUME (127)
|
||||
|
||||
#if defined(AUDIO_DUAL_BUFFER)
|
||||
enum AudioBufferState
|
||||
{
|
||||
@@ -156,6 +158,7 @@ struct AudioFragment {
|
||||
uint8_t type;
|
||||
uint8_t id;
|
||||
uint8_t repeat;
|
||||
int8_t fragmentVolume;
|
||||
union {
|
||||
Tone tone;
|
||||
char file[AUDIO_FILENAME_MAXLEN+1];
|
||||
@@ -163,17 +166,19 @@ struct AudioFragment {
|
||||
|
||||
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),
|
||||
id(id),
|
||||
repeat(repeat),
|
||||
fragmentVolume(fragmentVolume),
|
||||
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),
|
||||
id(id),
|
||||
repeat(repeat)
|
||||
repeat(repeat),
|
||||
fragmentVolume(fragmentVolume)
|
||||
{
|
||||
strcpy(file, filename);
|
||||
}
|
||||
@@ -181,6 +186,8 @@ struct AudioFragment {
|
||||
void clear()
|
||||
{
|
||||
memset(reinterpret_cast<void*>(this), 0, sizeof(AudioFragment));
|
||||
|
||||
this->fragmentVolume = USE_SETTINGS_VOLUME;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -190,6 +197,8 @@ class ToneContext {
|
||||
inline void clear()
|
||||
{
|
||||
memset(reinterpret_cast<void*>(this), 0, sizeof(ToneContext));
|
||||
|
||||
fragment.fragmentVolume = USE_SETTINGS_VOLUME;
|
||||
}
|
||||
|
||||
bool isFree() const
|
||||
@@ -199,9 +208,9 @@ class ToneContext {
|
||||
|
||||
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:
|
||||
@@ -226,9 +235,9 @@ class WavContext {
|
||||
int mixBuffer(AudioBuffer *buffer, int volume, unsigned int fade);
|
||||
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)
|
||||
@@ -294,7 +303,6 @@ class MixedContext {
|
||||
ToneContext tone;
|
||||
WavContext wav;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
class AudioBufferFifo {
|
||||
@@ -506,8 +514,8 @@ class AudioQueue {
|
||||
public:
|
||||
AudioQueue();
|
||||
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 playFile(const char *filename, uint8_t flags=0, uint8_t id=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, int8_t fragmentVolume = USE_SETTINGS_VOLUME);
|
||||
void stopPlay(uint8_t id);
|
||||
void stopAll();
|
||||
void flush();
|
||||
@@ -609,15 +617,15 @@ enum AutomaticPromptsEvents {
|
||||
AUDIO_EVENT_MID,
|
||||
};
|
||||
|
||||
void pushPrompt(uint16_t prompt, uint8_t id=0);
|
||||
void pushUnit(uint8_t unit, uint8_t idx, uint8_t id);
|
||||
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, uint8_t fragmentVolume = USE_SETTINGS_VOLUME);
|
||||
void playModelName();
|
||||
|
||||
#define I18N_PLAY_FUNCTION(lng, x, ...) void lng ## _ ## x(__VA_ARGS__, uint8_t id)
|
||||
#define PUSH_NUMBER_PROMPT(p) pushPrompt((p), id)
|
||||
#define PUSH_UNIT_PROMPT(p, i) pushUnit((p), (i), id)
|
||||
#define PLAY_NUMBER(n, u, a) playNumber((n), (u), (a), id)
|
||||
#define PLAY_DURATION(d, att) playDuration((d), (att), 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, fragmentVolume)
|
||||
#define PUSH_UNIT_PROMPT(p, i) pushUnit((p), (i), id, fragmentVolume)
|
||||
#define PLAY_NUMBER(n, u, a) playNumber((n), (u), (a), id, fragmentVolume)
|
||||
#define PLAY_DURATION(d, att) playDuration((d), (att), id, fragmentVolume)
|
||||
#define PLAY_DURATION_ATT , uint8_t flags
|
||||
#define PLAY_TIME 1
|
||||
#define PLAY_LONG_TIMER 2
|
||||
@@ -625,8 +633,8 @@ void playModelName();
|
||||
#define IS_PLAY_TIME() (flags & PLAY_TIME)
|
||||
#define IS_PLAY_LONG_TIMER() (flags & PLAY_LONG_TIMER)
|
||||
#define IS_PLAYING(id) audioQueue.isPlaying((id))
|
||||
#define PLAY_VALUE(v, id) playValue((v), (id))
|
||||
#define PLAY_FILE(f, flags, id) audioQueue.playFile((f), (flags), (id))
|
||||
#define PLAY_VALUE(v, id) playValue((v), (id), USE_SETTINGS_VOLUME)
|
||||
#define PLAY_FILE(f, flags, id) audioQueue.playFile((f), (flags), (id), USE_SETTINGS_VOLUME)
|
||||
#define STOP_PLAY(id) audioQueue.stopPlay((id))
|
||||
#define AUDIO_RESET() audioQueue.stopAll()
|
||||
#define AUDIO_FLUSH() audioQueue.flush()
|
||||
|
||||
@@ -1421,35 +1421,53 @@ static int luaGetFlightMode(lua_State * L)
|
||||
}
|
||||
|
||||
/*luadoc
|
||||
@function playFile(name)
|
||||
@function playFile(filename [, volume])
|
||||
|
||||
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
|
||||
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)
|
||||
{
|
||||
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] != '/') {
|
||||
// relative sound file path - use current language dir for absolute path
|
||||
char file[AUDIO_FILENAME_MAXLEN+1];
|
||||
char * str = getAudioPath(file);
|
||||
strncpy(str, filename, AUDIO_FILENAME_MAXLEN - (str-file));
|
||||
file[AUDIO_FILENAME_MAXLEN] = 0;
|
||||
PLAY_FILE(file, 0, 0);
|
||||
audioQueue.playFile(file, 0, 0, volume);
|
||||
}
|
||||
else {
|
||||
PLAY_FILE(filename, 0, 0);
|
||||
audioQueue.playFile(filename, 0, 0, volume);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*luadoc
|
||||
@function playNumber(value, unit [, attributes])
|
||||
@function playNumber(value, unit [, attributes [, volume]])
|
||||
|
||||
Play a numerical value (text to speech)
|
||||
|
||||
@@ -1461,21 +1479,39 @@ Play a numerical value (text to speech)
|
||||
* `0 or not present` plays integral part of the number (for a number 123 it plays 123)
|
||||
* `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)
|
||||
|
||||
@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.0.0
|
||||
@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)
|
||||
{
|
||||
int number = luaL_checkinteger(L, 1);
|
||||
int unit = luaL_checkinteger(L, 2);
|
||||
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;
|
||||
}
|
||||
|
||||
/*luadoc
|
||||
@function playDuration(duration [, hourFormat])
|
||||
@function playDuration(duration [, hourFormat [, volume]])
|
||||
|
||||
Play a time value (text to speech)
|
||||
|
||||
@@ -1484,19 +1520,38 @@ Play a time value (text to speech)
|
||||
@param hourFormat (number):
|
||||
* `0 or not present` play format: 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)
|
||||
{
|
||||
int duration = luaL_checkinteger(L, 1);
|
||||
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;
|
||||
}
|
||||
|
||||
/*luadoc
|
||||
@function playTone(frequency, duration, pause [, flags [, freqIncr]])
|
||||
@function playTone(frequency, duration, pause [, flags [, freqIncr [, volume]]])
|
||||
|
||||
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`.
|
||||
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)
|
||||
{
|
||||
@@ -1524,7 +1592,12 @@ static int luaPlayTone(lua_State * L)
|
||||
int pause = luaL_checkinteger(L, 3);
|
||||
int flags = luaL_optinteger(L, 4, 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
if (tick10ms) {
|
||||
requiredSpeakerVolume = g_eeGeneral.speakerVolume + VOLUME_LEVEL_DEF;
|
||||
|
||||
requiredBacklightBright = g_eeGeneral.getBrightness();
|
||||
|
||||
if (radioGFEnabled()) {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <limits.h>
|
||||
#include "opentx_types.h"
|
||||
#include "translations/untranslated.h"
|
||||
#include "audio.h"
|
||||
|
||||
#if defined(TRANSLATIONS_FR)
|
||||
#include "translations/fr.h"
|
||||
@@ -884,8 +885,8 @@ extern const char STR_MODEL_MENU_TABS[];
|
||||
struct LanguagePack {
|
||||
const char * id;
|
||||
const char * name;
|
||||
void (*playNumber)(getvalue_t number, uint8_t unit, uint8_t flags, uint8_t id);
|
||||
void (*playDuration)(int seconds, 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, int8_t fragmentVolume);
|
||||
};
|
||||
|
||||
extern const LanguagePack * currentLanguagePack;
|
||||
@@ -949,14 +950,14 @@ const LanguagePack * const languagePacks[] = {
|
||||
const LanguagePack* currentLanguagePack = &lng##LanguagePack; \
|
||||
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) {
|
||||
currentLanguagePack->playNumber(number, unit, flags, id);
|
||||
currentLanguagePack->playNumber(number, unit, flags, id, fragmentVolume);
|
||||
}
|
||||
|
||||
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[];
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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 FEMALE 0x81
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
@@ -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)
|
||||
{
|
||||
TRACE("I18N_PLAY_FUNCTION v %d", fragmentVolume);
|
||||
if (number < 0) {
|
||||
PUSH_NUMBER_PROMPT(EN_PROMPT_MINUS);
|
||||
number = -number;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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 ZENSKI 0x81
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ enum RusPrompts {
|
||||
#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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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 ZENSKY 0x81
|
||||
|
||||
Reference in New Issue
Block a user