Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
57 changes: 57 additions & 0 deletions radio/src/cfn_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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 +92,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 +135,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 +188,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 +231,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 +272,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 +319,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 +357,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 +414,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 +448,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 +489,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 +548,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 +593,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 +644,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 +674,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 +735,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 +762,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 +844,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 +870,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
4 changes: 4 additions & 0 deletions radio/src/dataconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "board.h"
#include "storage/yaml/yaml_defs.h"
#include "gvars.h"
#include "hal_keys_lock.h"

#if defined(EXPORT)
#define LUA_EXPORT(...) LEXP(__VA_ARGS__)
Expand Down Expand Up @@ -737,6 +738,9 @@ enum Functions {
#endif
#if defined(FUNCTION_SWITCHES) || defined(CFN_ONLY)
FUNC_PUSH_CUST_SWITCH,
#endif
#if (defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)) || defined(CFN_ONLY)
FUNC_DISABLE_KEYS,
#endif
FUNC_TEST, // MUST remain last
#if defined(DEBUG)
Expand Down
1 change: 1 addition & 0 deletions radio/src/edgetx.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ enum FunctionsActive {
FUNCTION_DISABLE_TOUCH,
FUNCTION_DISABLE_AUDIO_AMP,
FUNCTION_VOLUME,
FUNCTION_DISABLE_KEYS,
};

#define VARIO_FREQUENCY_ZERO 700/*Hz*/
Expand Down
20 changes: 18 additions & 2 deletions radio/src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void switchToRadio() {};
void switchToVideo() {};
#endif
#endif
CustomFunctionsContext modelFunctionsContext = { 0 };

CustomFunctionsContext modelFunctionsContext = { 0 };
CustomFunctionsContext globalFunctionsContext = { 0 };

#if defined(DEBUG)
Expand Down Expand Up @@ -195,8 +195,20 @@ void evalFunctions(CustomFunctionData * functions, CustomFunctionsContext & func
MASK_CFN_TYPE switch_mask = ((MASK_CFN_TYPE)1 << i);

bool active = getSwitch(swtch, IS_PLAY_FUNC(CFN_FUNC(cfn)) ? GETSWITCH_MIDPOS_DELAY : 0);
if (CFN_ACTIVE(cfn) == 0)
if (CFN_ACTIVE(cfn) == 0) {
active = false;
} else {
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
// 'No Keys' function checks both switch states
if (CFN_FUNC(cfn) == FUNC_DISABLE_KEYS) {
bool locked = isFunctionActive(FUNCTION_DISABLE_KEYS);
if (active != locked)
setKeyLockedState(active);
if (active)
newActiveFunctions |= (1u << FUNCTION_DISABLE_KEYS);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Synchronize the lock from the aggregate function transition.

This block is never reached when an active “No Keys” row is disabled, cleared, or changed to another function, leaving s_keys_locked enabled after newActiveFunctions clears. Multiple rows are also order-dependent because each compares against the previous aggregate state. Compute the previous/new aggregate state once, including global and model functions, and call setKeyLockedState() only for that transition.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@radio/src/functions.cpp` around lines 198 - 209, Update the aggregate
active-function processing around CFN_FUNC(cfn) and setKeyLockedState: compute
the previous and new aggregate states once across global and model functions,
then synchronize the lock from that transition even when a No Keys row is
disabled, cleared, or replaced. Remove per-row comparisons that depend on
iteration order, while preserving newActiveFunctions updates for
FUNCTION_DISABLE_KEYS.

#endif
}

if (active) {
switch (CFN_FUNC(cfn)) {
Expand Down Expand Up @@ -570,6 +582,10 @@ const char* funcGetLabel(uint8_t func)
#if defined(COLORLCD)
case FUNC_DISABLE_TOUCH:
return STR_SF_DISABLE_TOUCH;
#endif
#if defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)
case FUNC_DISABLE_KEYS:
return STR_SF_DISABLE_KEYS;
#endif
case FUNC_SET_SCREEN:
return STR_SF_SET_SCREEN;
Expand Down
Loading
Loading