Skip to content

Commit

Permalink
feat: Add SF to mute audio amplifier on supported radios (EdgeTX#3753)
Browse files Browse the repository at this point in the history
* SF Audio amplifier mute port to 2.10

* added missing definition STR_SF_DISABLE_AUDIO_AMP

* exclude radios not able to switch audio amp off

* radio/src/storage/yaml/yaml_datastructs_128x64.cpp needs to distinguish between radios with or without switchable audio amps. Expample Zorro vs X9lites

* updated companion and radio language PL

* - added Companion and radio language SE

- removed type unfinished for translated languages

* added radio and companion language JP

* - reverted change to 128x64 yaml_datastructs.h

- moved exclusion of SF DISABLE_AUDIO_AMP based on hw capabilities to UI level

* confused FUNC_ with FUNCTION_

* confused FUNCTION_* with FUNC_*
  • Loading branch information
mha1 authored Sep 14, 2023
1 parent 16276d3 commit d30499f
Show file tree
Hide file tree
Showing 53 changed files with 148 additions and 3 deletions.
8 changes: 6 additions & 2 deletions companion/src/firmwares/customfunctiondata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ QString CustomFunctionData::funcToString(const AssignFunc func, const ModelData
return tr("Disable Touch");
else if (func == FuncSetScreen)
return tr("Set Main Screen");
else if (func == FuncDisableAudioAmp)
return tr("Audio Amp Off");
else {
return QString(CPN_STR_UNKNOWN_ITEM);
}
Expand Down Expand Up @@ -257,7 +259,8 @@ bool CustomFunctionData::isFuncAvailable(const int index, const ModelData * mode
((index >= FuncRangeCheckInternalModule && index <= FuncBindExternalModule) && !fw->getCapability(DangerousFunctions)) ||
((index >= FuncAdjustGV1 && index <= FuncAdjustGVLast) && !fw->getCapability(Gvars)) ||
((index == FuncDisableTouch) && !IS_HORUS_OR_TARANIS(fw->getBoard())) ||
((index == FuncSetScreen && !Boards::getCapability(fw->getBoard(), Board::HasColorLcd)))
((index == FuncSetScreen && !Boards::getCapability(fw->getBoard(), Board::HasColorLcd)) ||
((index == FuncDisableAudioAmp && !Boards::getCapability(fw->getBoard(), Board::HasAudioMuteGPIO))))
);
return !ret;
}
Expand Down Expand Up @@ -471,7 +474,8 @@ bool CustomFunctionData::isParamAvailable() const
FuncBindInternalModule,
FuncBindExternalModule,
FuncRacingMode,
FuncDisableTouch
FuncDisableTouch,
FuncDisableAudioAmp
};

return funcList.contains(func) ? false : true;
Expand Down
1 change: 1 addition & 0 deletions companion/src/firmwares/customfunctiondata.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ enum AssignFunc {
FuncRacingMode,
FuncDisableTouch,
FuncSetScreen,
FuncDisableAudioAmp,
FuncCount,
FuncReserve = -1
};
Expand Down
1 change: 1 addition & 0 deletions companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ static const YamlLookupTable customFnLut = {
{ FuncRacingMode, "RACING_MODE" },
{ FuncDisableTouch, "DISABLE_TOUCH" },
{ FuncSetScreen, "SET_SCREEN"},
{ FuncDisableAudioAmp, "DISABLE_AUDIO_AMP" },
};

static const YamlLookupTable trainerLut = {
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2059,6 +2059,11 @@ Do you want to import settings from a file?</source>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation>Vypnutí zesilovače zvuku</translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="216"/>
<source>Played once, not during startup</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2359,6 +2359,11 @@ Vil du indlæse indstillinger fra en fil?</translation>
<source>Set Main Screen</source>
<translation>Indstil hoved billede</translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation>Sluk audio amplifier</translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="373"/>
<source>Value</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,11 @@ Do you want to import settings from a file?</source>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation>Audio Amp AUS</translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="216"/>
<source>Played once, not during startup</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2037,6 +2037,11 @@ Do you want to import settings from a file?</source>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="216"/>
<source>Played once, not during startup</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,11 @@ Do you want to import settings from a file?</source>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="216"/>
<source>Played once, not during startup</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_fi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2060,6 +2060,11 @@ Do you want to import settings from a file?</source>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="216"/>
<source>Played once, not during startup</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2079,6 +2079,11 @@ Voulez-vous importer les paramètres depuis un fichier?</translation>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation>Désact. Ampli Audio</translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="216"/>
<source>!1x</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,11 @@ Do you want to import settings from a file?</source>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="143"/>
<source>s</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,11 @@ Do you want to import settings from a file?</source>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation>Amplificatore audio off</translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="216"/>
<source>Played once, not during startup</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2051,6 +2051,11 @@ Do you want to import settings from a file?</source>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation>オーディオアンプ OFF</translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="216"/>
<source>!1x</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,11 @@ Do you want to import settings from a file?</source>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="143"/>
<source>s</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,11 @@ Do you want to import settings from a file?</source>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation>Wycisz wzmacniacz audio</translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="216"/>
<source>Played once, not during startup</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,11 @@ Do you want to import settings from a file?</source>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="143"/>
<source>s</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2060,6 +2060,11 @@ Do you want to import settings from a file?</source>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="216"/>
<source>Played once, not during startup</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_sv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2359,6 +2359,11 @@ Vill du hämta inställningarna från en fil?</translation>
<source>Set Main Screen</source>
<translation>Ställ in huvudskärm</translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation>Audioförstärkare av</translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="371"/>
<source>Value</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,11 @@ Do you want to import settings from a file?</source>
<source>Disable Touch</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation>关闭音频功放</translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="127"/>
<source>Set Main Screen</source>
Expand Down
5 changes: 5 additions & 0 deletions companion/src/translations/companion_zh_TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,11 @@ Do you want to import settings from a file?</source>
<source>Set Main Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="129"/>
<source>Audio Amp Off</source>
<translation>關閉音頻功放</translation>
</message>
<message>
<location filename="../firmwares/customfunctiondata.cpp" line="216"/>
<source>Played once, not during startup</source>
Expand Down
1 change: 1 addition & 0 deletions radio/src/dataconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ enum Functions {
FUNC_DISABLE_TOUCH,
FUNC_SET_SCREEN,
#endif
FUNC_DISABLE_AUDIO_AMP,
#if defined(DEBUG)
FUNC_TEST, // should remain the last before MAX as not added in Companion
#endif
Expand Down
9 changes: 9 additions & 0 deletions radio/src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,11 @@ void evalFunctions(const CustomFunctionData * functions, CustomFunctionsContext
newActiveFunctions |= (1u << FUNCTION_DISABLE_TOUCH);
break;
#endif
#if defined(AUDIO_MUTE_GPIO)
case FUNC_DISABLE_AUDIO_AMP:
newActiveFunctions |= (1u << FUNCTION_DISABLE_AUDIO_AMP);
break;
#endif
#if defined(COLORLCD)
case FUNC_SET_SCREEN:
if (isRepeatDelayElapsed(functions, functionsContext, i)) {
Expand Down Expand Up @@ -533,6 +538,10 @@ const char* funcGetLabel(uint8_t func)
case FUNC_SET_SCREEN:
return STR_SF_SET_SCREEN;
#endif
#if defined(AUDIO_MUTE_GPIO)
case FUNC_DISABLE_AUDIO_AMP:
return STR_SF_DISABLE_AUDIO_AMP;
#endif
#if defined(DEBUG)
case FUNC_TEST:
return STR_SF_TEST;
Expand Down
6 changes: 5 additions & 1 deletion radio/src/gui/gui_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,11 @@ bool isAssignableFunctionAvailable(int function, CustomFunctionData * functions)
case FUNC_PLAY_SCRIPT:
return false;
#endif

case FUNC_DISABLE_AUDIO_AMP:
#if defined(AUDIO_MUTE_GPIO)
return true;
#endif
return false;
default:
return true;
}
Expand Down
3 changes: 3 additions & 0 deletions radio/src/opentx.h
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,9 @@ enum FunctionsActive {
#if defined(HARDWARE_TOUCH)
FUNCTION_DISABLE_TOUCH,
#endif
#if defined(AUDIO_MUTE_GPIO)
FUNCTION_DISABLE_AUDIO_AMP
#endif
};

#define VARIO_FREQUENCY_ZERO 700/*Hz*/
Expand Down
1 change: 1 addition & 0 deletions radio/src/storage/yaml/yaml_datastructs_128x64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_BACKLIGHT, "BACKLIGHT" },
{ FUNC_SCREENSHOT, "SCREENSHOT" },
{ FUNC_RACING_MODE, "RACING_MODE" },
{ FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
Expand Down
1 change: 1 addition & 0 deletions radio/src/storage/yaml/yaml_datastructs_nv14.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_RACING_MODE, "RACING_MODE" },
{ FUNC_DISABLE_TOUCH, "DISABLE_TOUCH" },
{ FUNC_SET_SCREEN, "SET_SCREEN" },
{ FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" },
{ 0, NULL }
};
const struct YamlIdStr enum_ZoneOptionValueEnum[] = {
Expand Down
1 change: 1 addition & 0 deletions radio/src/storage/yaml/yaml_datastructs_tpro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_BACKLIGHT, "BACKLIGHT" },
{ FUNC_SCREENSHOT, "SCREENSHOT" },
{ FUNC_RACING_MODE, "RACING_MODE" },
{ FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
Expand Down
1 change: 1 addition & 0 deletions radio/src/storage/yaml/yaml_datastructs_x10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_BACKLIGHT, "BACKLIGHT" },
{ FUNC_SCREENSHOT, "SCREENSHOT" },
{ FUNC_RACING_MODE, "RACING_MODE" },
{ FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" },
{ FUNC_DISABLE_TOUCH, "DISABLE_TOUCH" },
{ FUNC_SET_SCREEN, "SET_SCREEN" },
{ 0, NULL }
Expand Down
1 change: 1 addition & 0 deletions radio/src/storage/yaml/yaml_datastructs_x12s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_BACKLIGHT, "BACKLIGHT" },
{ FUNC_SCREENSHOT, "SCREENSHOT" },
{ FUNC_RACING_MODE, "RACING_MODE" },
{ FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" },
{ FUNC_DISABLE_TOUCH, "DISABLE_TOUCH" },
{ FUNC_SET_SCREEN, "SET_SCREEN" },
{ 0, NULL }
Expand Down
1 change: 1 addition & 0 deletions radio/src/storage/yaml/yaml_datastructs_x9d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_BACKLIGHT, "BACKLIGHT" },
{ FUNC_SCREENSHOT, "SCREENSHOT" },
{ FUNC_RACING_MODE, "RACING_MODE" },
{ FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
Expand Down
1 change: 1 addition & 0 deletions radio/src/storage/yaml/yaml_datastructs_x9e.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_BACKLIGHT, "BACKLIGHT" },
{ FUNC_SCREENSHOT, "SCREENSHOT" },
{ FUNC_RACING_MODE, "RACING_MODE" },
{ FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
Expand Down
1 change: 1 addition & 0 deletions radio/src/storage/yaml/yaml_datastructs_x9lite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_BACKLIGHT, "BACKLIGHT" },
{ FUNC_SCREENSHOT, "SCREENSHOT" },
{ FUNC_RACING_MODE, "RACING_MODE" },
{ FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
Expand Down
1 change: 1 addition & 0 deletions radio/src/storage/yaml/yaml_datastructs_xlites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const struct YamlIdStr enum_Functions[] = {
{ FUNC_BACKLIGHT, "BACKLIGHT" },
{ FUNC_SCREENSHOT, "SCREENSHOT" },
{ FUNC_RACING_MODE, "RACING_MODE" },
{ FUNC_DISABLE_AUDIO_AMP, "DISABLE_AUDIO_AMP" },
{ 0, NULL }
};
const struct YamlIdStr enum_TimerModes[] = {
Expand Down
5 changes: 5 additions & 0 deletions radio/src/targets/common/arm/stm32/audio_dac_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ void audioMute()

void audioUnmute()
{
if(isFunctionActive(FUNCTION_DISABLE_AUDIO_AMP)) {
setMutePin(true);
return;
}

#if defined(AUDIO_UNMUTE_DELAY)
// if muted
if (getMutePin()) {
Expand Down
5 changes: 5 additions & 0 deletions radio/src/targets/nv14/audio_spi_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ void audioMute()

void audioUnmute()
{
if(isFunctionActive(FUNCTION_DISABLE_AUDIO_AMP)) {
setMutePin(true);
return;
}

#if defined(AUDIO_UNMUTE_DELAY)
// if muted
if (getMutePin()) {
Expand Down
Loading

0 comments on commit d30499f

Please sign in to comment.