Skip to content

Commit

Permalink
Disable all model Special Functions when the feature is turned off.
Browse files Browse the repository at this point in the history
Fix issue where GF that runs a Lua script is not disabled when GF feature is turned off.
  • Loading branch information
philmoz committed Sep 27, 2023
1 parent 74ed83a commit 483ba4e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 8 additions & 2 deletions radio/src/lua/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,12 @@ static bool luaLoadFunctionScript(uint8_t ref)
CustomFunctionData * fn;

if (ref <= SCRIPT_FUNC_LAST) {
idx = ref - SCRIPT_FUNC_FIRST;
fn = &g_model.customFn[idx];
if (modelSFEnabled()) {
idx = ref - SCRIPT_FUNC_FIRST;
fn = &g_model.customFn[idx];
} else {
return false;
}
}
else if (radioGFEnabled()) {
idx = ref - SCRIPT_GFUNC_FIRST;
Expand Down Expand Up @@ -1101,10 +1105,12 @@ static bool resumeLua(bool init, bool allowLcdUsage)
CustomFunctionsContext * functionsContext;

if (ref <= SCRIPT_FUNC_LAST) {
if (!modelSFEnabled()) continue;
idx = ref - SCRIPT_FUNC_FIRST;
fn = &g_model.customFn[idx];
functionsContext = &modelFunctionsContext;
} else {
if (!radioGFEnabled()) continue;
idx = ref - SCRIPT_GFUNC_FIRST;
fn = &g_eeGeneral.customFn[idx];
functionsContext = &globalFunctionsContext;
Expand Down
6 changes: 5 additions & 1 deletion radio/src/mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,11 @@ void evalMixes(uint8_t tick10ms)
} else {
globalFunctionsContext.reset();
}
evalFunctions(g_model.customFn, modelFunctionsContext);
if (modelSFEnabled()) {
evalFunctions(g_model.customFn, modelFunctionsContext);
} else {
modelFunctionsContext.reset();
}
}

//========== LIMITS ===============
Expand Down

0 comments on commit 483ba4e

Please sign in to comment.