Skip to content
3 changes: 3 additions & 0 deletions companion/src/firmwares/customfunctiondata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ QString CustomFunctionData::funcToString(const AssignFunc func, const ModelData
return tr("Racing Mode");
else if (func == FuncDisableTouch)
return tr("Disable Touch");
else if (func == FuncDisableKeys)
return tr("Disable Keys");
else if (func == FuncSetScreen)
return tr("Set Main Screen");
else if (func == FuncDisableAudioAmp)
Expand Down Expand Up @@ -491,6 +493,7 @@ bool CustomFunctionData::isParamAvailable() const
FuncBindExternalModule,
FuncRacingMode,
FuncDisableTouch,
FuncDisableKeys,
FuncDisableAudioAmp
};

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 @@ -68,6 +68,7 @@ enum AssignFunc {
FuncBindExternalModule,
FuncRacingMode,
FuncDisableTouch,
FuncDisableKeys,
FuncSetScreen,
FuncDisableAudioAmp,
FuncRGBLed,
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 @@ -64,6 +64,7 @@ static const YamlLookupTable customFnLut = {
{ FuncRGBLed, "RGB_LED" },
{ FuncLCDtoVideo, "LCD_TO_VIDEO" },
{ FuncPushCustomSwitch1, "PUSH_CUST_SWITCH" },
{ FuncDisableKeys, "DISABLE_KEYS" },
};

static const YamlLookupTable trainerLut = {
Expand Down
58 changes: 58 additions & 0 deletions radio/src/cfn_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// This file is auto-generated via cfn_sorter.sh. Do not edit.

#include "dataconstants.h"
#include "hal_keys_lock.h"

Functions cfn_sorted[] = {
#if defined(TRANSLATIONS_CN)
Expand Down Expand Up @@ -62,6 +63,9 @@ Functions cfn_sorted[] = {
/* 暂停背景音乐 */ FUNC_BACKGND_MUSIC_PAUSE,
/* 振动 */ FUNC_HAPTIC,
/* LUA脚本 */ FUNC_PLAY_SCRIPT,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
#if defined(FUNCTION_SWITCHES)
/* Push CS */ FUNC_PUSH_CUST_SWITCH,
#endif
Expand Down Expand Up @@ -89,6 +93,9 @@ Functions cfn_sorted[] = {
/* ModuleBind */ FUNC_BIND,
/* Nastav */ FUNC_ADJUST_GVAR,
/* Nastavit Failsafe */ FUNC_SET_FAILSAFE,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
#if !OLED_SCREEN
/* Podsvětlení */ FUNC_BACKLIGHT,
#endif
Expand Down Expand Up @@ -129,6 +136,9 @@ Functions cfn_sorted[] = {
/* Lua skript */ FUNC_PLAY_SCRIPT,
/* Lydstyrke */ FUNC_VOLUME,
/* Modul tilslut */ FUNC_BIND,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
/* Nulstil */ FUNC_RESET,
/* Overskriv */ FUNC_OVERRIDE_CHANNEL,
/* RGB lys */ FUNC_RGB_LED,
Expand Down Expand Up @@ -179,6 +189,9 @@ Functions cfn_sorted[] = {
#endif
/* Lua-Skript */ FUNC_PLAY_SCRIPT,
/* ModuleBind */ FUNC_BIND,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
/* RacingMode */ FUNC_RACING_MODE,
/* RangeCheck */ FUNC_RANGECHECK,
/* RGB LED */ FUNC_RGB_LED,
Expand Down Expand Up @@ -219,6 +232,9 @@ Functions cfn_sorted[] = {
#if !OLED_SCREEN
/* Luz Fondo */ FUNC_BACKLIGHT,
#endif
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
#if defined(COLORLCD)
/* No Touch */ FUNC_DISABLE_TOUCH,
#endif
Expand Down Expand Up @@ -257,6 +273,9 @@ Functions cfn_sorted[] = {
#endif
/* Lua Script */ FUNC_PLAY_SCRIPT,
/* ModuleBind */ FUNC_BIND,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
#if defined(COLORLCD)
/* No Touch */ FUNC_DISABLE_TOUCH,
#endif
Expand Down Expand Up @@ -301,6 +320,9 @@ Functions cfn_sorted[] = {
/* Luminosité */ FUNC_BACKLIGHT,
#endif
/* Musique */ FUNC_BACKGND_MUSIC,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
#if defined(COLORLCD)
/* Non Tactile */ FUNC_DISABLE_TOUCH,
#endif
Expand Down Expand Up @@ -336,6 +358,9 @@ Functions cfn_sorted[] = {
#endif
/* Lua Script */ FUNC_PLAY_SCRIPT,
/* ModuleBind */ FUNC_BIND,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
/* Override */ FUNC_OVERRIDE_CHANNEL,
/* Play Track */ FUNC_PLAY_TRACK,
/* Play Value */ FUNC_PLAY_VALUE,
Expand Down Expand Up @@ -390,6 +415,9 @@ Functions cfn_sorted[] = {
/* Modo Racing */ FUNC_RACING_MODE,
/* Musica Sf */ FUNC_BACKGND_MUSIC,
/* Musica Sf || */ FUNC_BACKGND_MUSIC_PAUSE,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
#if defined(FUNCTION_SWITCHES)
/* Premi CS */ FUNC_PUSH_CUST_SWITCH,
#endif
Expand Down Expand Up @@ -421,6 +449,9 @@ Functions cfn_sorted[] = {
/* LCD to Video */ FUNC_LCD_TO_VIDEO,
#endif
/* LUAスクリプト */ FUNC_PLAY_SCRIPT,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
#if defined(FUNCTION_SWITCHES)
/* Push CS */ FUNC_PUSH_CUST_SWITCH,
#endif
Expand Down Expand Up @@ -459,6 +490,9 @@ Functions cfn_sorted[] = {
/* LCD -> 비디오 출력 */ FUNC_LCD_TO_VIDEO,
#endif
/* Lua 스크립트 실행 */ FUNC_PLAY_SCRIPT,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
/* RGB LED */ FUNC_RGB_LED,
/* SD 로그 저장 */ FUNC_LOGS,
/* 값 재생 */ FUNC_PLAY_VALUE,
Expand Down Expand Up @@ -515,6 +549,9 @@ Functions cfn_sorted[] = {
#endif
/* Lua Script */ FUNC_PLAY_SCRIPT,
/* ModuleBind */ FUNC_BIND,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
#if defined(COLORLCD)
/* No Touch */ FUNC_DISABLE_TOUCH,
#endif
Expand Down Expand Up @@ -557,6 +594,9 @@ Functions cfn_sorted[] = {
/* ModuleBind */ FUNC_BIND,
/* Muz. tła */ FUNC_BACKGND_MUSIC,
/* Muz. tła || */ FUNC_BACKGND_MUSIC_PAUSE,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
#if defined(COLORLCD)
/* No Touch */ FUNC_DISABLE_TOUCH,
#endif
Expand Down Expand Up @@ -605,6 +645,9 @@ Functions cfn_sorted[] = {
/* LuzFundo */ FUNC_BACKLIGHT,
#endif
/* ModCorrida */ FUNC_RACING_MODE,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
#if defined(COLORLCD)
/* No Touch */ FUNC_DISABLE_TOUCH,
#endif
Expand Down Expand Up @@ -632,6 +675,9 @@ Functions cfn_sorted[] = {
/* LCD в видео */ FUNC_LCD_TO_VIDEO,
#endif
/* Lua скрипт */ FUNC_PLAY_SCRIPT,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
/* Play Value */ FUNC_PLAY_VALUE,
/* RGB подсветка */ FUNC_RGB_LED,
/* SD логи */ FUNC_LOGS,
Expand Down Expand Up @@ -690,6 +736,9 @@ Functions cfn_sorted[] = {
/* Lås */ FUNC_OVERRIDE_CHANNEL,
/* Lärare */ FUNC_TRAINER,
/* Musik */ FUNC_BACKGND_MUSIC,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
/* Parkoppla modul */ FUNC_BIND,
/* Pausa musik */ FUNC_BACKGND_MUSIC_PAUSE,
/* Range check */ FUNC_RANGECHECK,
Expand All @@ -714,6 +763,9 @@ Functions cfn_sorted[] = {
/* Återställ */ FUNC_RESET,
#elif defined(TRANSLATIONS_TW)
/* Lua腳本 */ FUNC_PLAY_SCRIPT,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
#if defined(FUNCTION_SWITCHES)
/* Push CS */ FUNC_PUSH_CUST_SWITCH,
#endif
Expand Down Expand Up @@ -793,6 +845,9 @@ Functions cfn_sorted[] = {
/* LCD to Video */ FUNC_LCD_TO_VIDEO,
#endif
/* Lua Скрипт */ FUNC_PLAY_SCRIPT,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
#if defined(FUNCTION_SWITCHES)
/* Push CS */ FUNC_PUSH_CUST_SWITCH,
#endif
Expand All @@ -816,6 +871,9 @@ Functions cfn_sorted[] = {
#endif
/* Lua Script */ FUNC_PLAY_SCRIPT,
/* ModuleBind */ FUNC_BIND,
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
/* No Keys */ FUNC_DISABLE_KEYS,
#endif
#if defined(COLORLCD)
/* No Touch */ FUNC_DISABLE_TOUCH,
#endif
Expand Down
1 change: 1 addition & 0 deletions radio/src/dataconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ enum Functions {
#if defined(FUNCTION_SWITCHES) || defined(CFN_ONLY)
FUNC_PUSH_CUST_SWITCH,
#endif
FUNC_DISABLE_KEYS,
FUNC_TEST, // MUST remain last
#if defined(DEBUG)
FUNC_MAX SKIP
Expand Down
12 changes: 10 additions & 2 deletions radio/src/edgetx.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,19 @@ void memswap(void * a, void * b, uint8_t size);

struct CustomFunctionsContext {
MASK_FUNC_TYPE activeFunctions;
MASK_FUNC_TYPE activeUIFunctions;
MASK_CFN_TYPE activeSwitches;
MASK_CFN_TYPE activeUISwitches;
tmr10ms_t lastFunctionTime[MAX_SPECIAL_FUNCTIONS];

inline bool isFunctionActive(uint8_t func)
{
return activeFunctions & ((MASK_FUNC_TYPE)1 << func);
return (activeFunctions | activeUIFunctions) & ((MASK_FUNC_TYPE)1 << func);
}

inline bool isFunctionSwitchActive(uint8_t functionIdx)
{
return (activeSwitches | activeUISwitches) & ((MASK_CFN_TYPE)1 << functionIdx);
}

void reset()
Expand Down Expand Up @@ -421,7 +428,6 @@ inline bool isMixActive(uint8_t mix)
enum FunctionsActive {
FUNCTION_TRAINER_STICK1,
FUNCTION_TRAINER_CHANNELS = FUNCTION_TRAINER_STICK1 + MAX_STICKS,
FUNCTION_INSTANT_TRIM,
FUNCTION_VARIO,
FUNCTION_LOGS,
FUNCTION_BACKGND_MUSIC,
Expand All @@ -431,6 +437,7 @@ enum FunctionsActive {
FUNCTION_DISABLE_TOUCH,
FUNCTION_DISABLE_AUDIO_AMP,
FUNCTION_VOLUME,
FUNCTION_DISABLE_KEYS,
};

#define VARIO_FREQUENCY_ZERO 700/*Hz*/
Expand All @@ -445,6 +452,7 @@ inline bool isFunctionActive(uint8_t func)
return globalFunctionsContext.isFunctionActive(func) || modelFunctionsContext.isFunctionActive(func);
}
void evalFunctions(CustomFunctionData * functions, CustomFunctionsContext & functionsContext);
void evalUIFunctions(CustomFunctionData * functions, CustomFunctionsContext & functionsContext);
inline void customFunctionsReset()
{
globalFunctionsContext.reset();
Expand Down
Loading
Loading