fix(fw): compilation without AUDIO (#5022)

This commit is contained in:
Raphael Coeffic
2024-05-18 14:11:20 +10:00
committed by GitHub
parent c2e7d91539
commit 6a59c580ef
14 changed files with 75 additions and 10 deletions
+32 -4
View File
@@ -566,9 +566,6 @@ void audioTask(void * pdata);
#define AUDIO_BUZZER(a, b) b
#endif
#define AUDIO_ERROR_MESSAGE(e) audioEvent(e)
#define AUDIO_TIMER_MINUTE(t) playDuration(t, 0, 0)
void onKeyError();
void audioKeyPress();
@@ -576,6 +573,11 @@ void audioKeyError();
void audioTrimPress(int value);
void audioTimerCountdown(uint8_t timer, int value);
#if defined(AUDIO)
#define AUDIO_ERROR_MESSAGE(e) audioEvent(e)
#define AUDIO_TIMER_MINUTE(t) playDuration(t, 0, 0)
#define AUDIO_KEY_PRESS() audioKeyPress()
#define AUDIO_KEY_ERROR() audioKeyError()
@@ -606,6 +608,28 @@ void audioTimerCountdown(uint8_t timer, int value);
#define AUDIO_TRAINER_LOST() audioEvent(AU_TRAINER_LOST)
#define AUDIO_TRAINER_BACK() audioEvent(AU_TRAINER_BACK)
#else // AUDIO
#include "buzzer.h"
#define AUDIO_TIMER_COUNTDOWN(idx, val)
#define AUDIO_TIMER_ELAPSED(idx)
#define AUDIO_TRIM_MIN()
#define AUDIO_TRIM_MAX()
#define AUDIO_TRIM_PRESS(val)
#define AUDIO_VARIO(fq, t, p, f)
#define AUDIO_RSSI_ORANGE()
#define AUDIO_RSSI_RED()
#define AUDIO_RAS_RED()
#define AUDIO_TELEMETRY_CONNECTED()
#define AUDIO_TELEMETRY_LOST()
#define AUDIO_TELEMETRY_BACK()
#define AUDIO_TRAINER_CONNECTED()
#define AUDIO_TRAINER_LOST()
#define AUDIO_TRAINER_BACK()
#endif
enum AutomaticPromptsCategories {
SYSTEM_AUDIO_CATEGORY,
MODEL_AUDIO_CATEGORY,
@@ -639,10 +663,13 @@ void playModelName();
#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))
#if defined(AUDIO)
#define AUDIO_RESET() audioQueue.stopAll()
#define AUDIO_FLUSH() audioQueue.flush()
#endif
#if defined(SDCARD)
#if defined(SDCARD) & defined(AUDIO)
extern tmr10ms_t timeAutomaticPromptsSilence;
void playModelEvent(uint8_t category, uint8_t index, event_t event=0);
#define PLAY_PHASE_OFF(phase) playModelEvent(PHASE_AUDIO_CATEGORY, phase, AUDIO_EVENT_OFF)
@@ -661,6 +688,7 @@ void playModelName();
#define PLAY_LOGICAL_SWITCH_ON(sw)
#define PLAY_MODEL_NAME()
#define START_SILENCE_PERIOD()
#define IS_SILENCE_PERIOD_ELAPSED() true
#endif
char * getAudioPath(char * path);
+2 -2
View File
@@ -70,7 +70,7 @@ inline void beep(uint8_t) { }
#define AUDIO_WARNING1() beep(3)
#define AUDIO_ERROR() beep(4)
#define AUDIO_MIX_WARNING(x) beep(1)
#define AUDIO_POT_MIDDLE() beep(2)
#define AUDIO_POT_MIDDLE(x) beep(2)
#define AUDIO_TIMER_COUNTDOWN(idx, val) beep(2)
#define AUDIO_TIMER_ELAPSED(idx) beep(3)
#define AUDIO_VARIO_UP() _beep(1)
@@ -95,7 +95,7 @@ inline void beep(uint8_t) { }
#define AUDIO_WARNING1()
#define AUDIO_ERROR()
#define AUDIO_MIX_WARNING(x)
#define AUDIO_POT_MIDDLE()
#define AUDIO_POT_MIDDLE(x)
#define AUDIO_TIMER_LT10(m, x)
#define AUDIO_TIMER_00(m)
#define AUDIO_VARIO_UP()
+4
View File
@@ -858,8 +858,12 @@ int cliStackInfo(const char ** argv)
cliSerialPrint("[MAIN] %d available / %d bytes", mainStackAvailable()*4, stackSize()*4);
cliSerialPrint("[MENUS] %d available / %d bytes", menusStack.available()*4, menusStack.size());
cliSerialPrint("[MIXER] %d available / %d bytes", mixerStack.available()*4, mixerStack.size());
#if defined(AUDIO)
cliSerialPrint("[AUDIO] %d available / %d bytes", audioStack.available()*4, audioStack.size());
#endif
#if defined(CLI)
cliSerialPrint("[CLI] %d available / %d bytes", cliStack.available()*4, cliStack.size());
#endif
return 0;
}
+2
View File
@@ -273,6 +273,7 @@ void evalFunctions(const CustomFunctionData * functions, CustomFunctionsContext
break;
#endif
#if defined(AUDIO)
case FUNC_VOLUME: {
getvalue_t raw = getValue(CFN_PARAM(cfn));
// only set volume if input changed more than hysteresis
@@ -284,6 +285,7 @@ void evalFunctions(const CustomFunctionData * functions, CustomFunctionsContext
2048;
break;
}
#endif
#if defined(SDCARD)
case FUNC_PLAY_SOUND:
+3
View File
@@ -50,7 +50,10 @@ extern uint8_t trimsDisplayTimer;
extern uint8_t trimsDisplayMask;
extern uint32_t maxMixerDuration;
#if defined(AUDIO)
extern uint8_t requiredSpeakerVolume;
#endif
extern uint8_t requiredBacklightBright;
enum MainRequest {
+2
View File
@@ -197,8 +197,10 @@ void menuStatisticsDebug(event_t event)
lcdDrawNumber(MENU_DEBUG_COL1_OFS, y, menusStack.available(), LEFT);
lcdDrawText(lcdLastRightPos, y, "/");
lcdDrawNumber(lcdLastRightPos, y, mixerStack.available(), LEFT);
#if defined(AUDIO)
lcdDrawText(lcdLastRightPos, y, "/");
lcdDrawNumber(lcdLastRightPos, y, audioStack.available(), LEFT);
#endif
y += FH;
#if defined(DEBUG_LATENCY)
+2
View File
@@ -191,8 +191,10 @@ void menuStatisticsDebug(event_t event)
lcdDrawNumber(lcdLastRightPos, y, menusStack.available(), LEFT);
lcdDrawText(lcdLastRightPos+2, y+1, "[X]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, y, mixerStack.available(), LEFT);
#if defined(AUDIO)
lcdDrawText(lcdLastRightPos+2, y+1, "[A]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, y, audioStack.available(), LEFT);
#endif
lcdDrawText(lcdLastRightPos+2, y+1, "[I]", SMLSIZE);
lcdDrawNumber(lcdLastRightPos, y, mainStackAvailable(), LEFT);
y += FH;
@@ -346,9 +346,11 @@ void DebugViewPage::build(Window* window)
new DebugInfoNumber<uint32_t>(
line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT},
[] { return mixerStack.available(); }, STR_STACK_MIX);
#if defined(AUDIO)
new DebugInfoNumber<uint32_t>(
line, rect_t{0, 0, DBG_B_WIDTH, DBG_B_HEIGHT},
[] { return audioStack.available(); }, STR_STACK_AUDIO);
#endif
#if defined(DEBUG_LATENCY)
line = window->newLine(grid2);
@@ -55,6 +55,7 @@ class RadioInfoWidget : public TopBarWidget
COLOR_THEME_PRIMARY2);
usbIcon->hide();
#if defined(AUDIO)
audioScale =
new StaticIcon(this, W_AUDIO_X + 15, 2, ICON_TOPMENU_VOLUME_SCALE,
COLOR_THEME_PRIMARY3);
@@ -66,6 +67,7 @@ class RadioInfoWidget : public TopBarWidget
audioVol[i]->hide();
}
audioVol[0]->show();
#endif
batteryIcon = new StaticIcon(this, W_AUDIO_X, 25, ICON_TOPMENU_TXBATT,
COLOR_THEME_PRIMARY2);
@@ -130,6 +132,7 @@ class RadioInfoWidget : public TopBarWidget
logsIcon->show(!usbPlugged() && isFunctionActive(FUNCTION_LOGS) &&
BLINK_ON_PHASE);
#if defined(AUDIO)
/* Audio volume */
uint8_t vol = 4;
if (requiredSpeakerVolume == 0 || g_eeGeneral.beepMode == e_mode_quiet)
@@ -145,6 +148,7 @@ class RadioInfoWidget : public TopBarWidget
audioVol[lastVol]->hide();
lastVol = vol;
}
#endif
#if defined(USB_CHARGER)
batteryChargeIcon->show(usbChargerLed());
@@ -193,8 +197,10 @@ class RadioInfoWidget : public TopBarWidget
uint8_t lastRSSI = 0;
StaticIcon* logsIcon;
StaticIcon* usbIcon;
#if defined(AUDIO)
StaticIcon* audioScale;
StaticIcon* audioVol[5];
#endif
StaticIcon* batteryIcon;
lv_obj_t* batteryFill = nullptr;
lv_obj_t* rssiBars[5] = {nullptr};
+5
View File
@@ -43,8 +43,11 @@
#include "lua/lua_event.h"
#endif
#if defined(AUDIO)
uint8_t currentSpeakerVolume = 255;
uint8_t requiredSpeakerVolume = 255;
#endif
uint8_t currentBacklightBright = 0;
uint8_t requiredBacklightBright = 0;
uint8_t mainRequestFlags = 0;
@@ -265,12 +268,14 @@ void handleJackConnection()
void checkSpeakerVolume()
{
#if defined(AUDIO)
if (currentSpeakerVolume != requiredSpeakerVolume) {
currentSpeakerVolume = requiredSpeakerVolume;
#if !defined(SOFTWARE_VOLUME)
setScaledVolume(currentSpeakerVolume);
#endif
}
#endif
}
#if defined(USE_HATS_AS_KEYS)
+2
View File
@@ -1126,7 +1126,9 @@ void evalMixes(uint8_t tick10ms)
// must be done after mixing because some functions use the inputs/channels values
// must be done before limits because of the applyLimit function: it checks for safety switches which would be not initialized otherwise
if (tick10ms) {
#if defined(AUDIO)
requiredSpeakerVolume = g_eeGeneral.speakerVolume + VOLUME_LEVEL_DEF;
#endif
requiredBacklightBright = g_eeGeneral.getBrightness();
+7 -3
View File
@@ -1443,12 +1443,16 @@ void edgeTxInit()
initSerialPorts();
currentSpeakerVolume = requiredSpeakerVolume = g_eeGeneral.speakerVolume + VOLUME_LEVEL_DEF;
currentBacklightBright = requiredBacklightBright = g_eeGeneral.getBrightness();
#if defined(AUDIO)
currentSpeakerVolume = requiredSpeakerVolume =
g_eeGeneral.speakerVolume + VOLUME_LEVEL_DEF;
#if !defined(SOFTWARE_VOLUME)
setScaledVolume(currentSpeakerVolume);
#endif
#endif
currentBacklightBright = requiredBacklightBright = g_eeGeneral.getBrightness();
referenceSystemAudioFiles();
audioQueue.start();
+3 -1
View File
@@ -35,8 +35,10 @@
RTOS_TASK_HANDLE menusTaskId;
RTOS_DEFINE_STACK(menusTaskId, menusStack, MENUS_STACK_SIZE);
#if defined(AUDIO)
RTOS_TASK_HANDLE audioTaskId;
RTOS_DEFINE_STACK(audioTaskId, audioStack, AUDIO_STACK_SIZE);
#endif
RTOS_MUTEX_HANDLE audioMutex;
@@ -112,7 +114,7 @@ void tasksStart()
RTOS_CREATE_TASK(menusTaskId, menusTask, "menus", menusStack,
MENUS_STACK_SIZE, MENUS_TASK_PRIO);
#if !defined(SIMU)
#if !defined(SIMU) && defined(AUDIO)
RTOS_CREATE_TASK(audioTaskId, audioTask, "audio", audioStack,
AUDIO_STACK_SIZE, AUDIO_TASK_PRIO);
#endif
+3
View File
@@ -56,7 +56,10 @@
extern TaskStack<MENUS_STACK_SIZE> menusStack;
extern TaskStack<MIXER_STACK_SIZE> mixerStack;
#if defined(AUDIO)
extern TaskStack<AUDIO_STACK_SIZE> audioStack;
#endif
#if defined(CLI)
extern TaskStack<CLI_STACK_SIZE> cliStack;