Skip to content

Commit 0391174

Browse files
authored
fix: Lua get/setGlobalVariable not honoring flight mode setting (#1602)
When GV was set to e.g. `FM0` , `setGlobalVariable` would change it to own value. Now it works as it should
1 parent f44a8b6 commit 0391174

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

radio/src/lua/api_model.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "lua_api.h"
2626
#include "../timers.h"
2727
#include "model_init.h"
28+
#include "gvars.h"
2829

2930
#if defined(SDCARD_YAML)
3031
#include <storage/sdcard_yaml.h>
@@ -1513,7 +1514,7 @@ static int luaModelGetGlobalVariable(lua_State *L)
15131514
unsigned int idx = luaL_checkunsigned(L, 1);
15141515
unsigned int phase = luaL_checkunsigned(L, 2);
15151516
if (phase < MAX_FLIGHT_MODES && idx < MAX_GVARS)
1516-
lua_pushinteger(L, g_model.flightModeData[phase].gvars[idx]);
1517+
lua_pushinteger(L, getGVarValue(idx, phase));
15171518
else
15181519
lua_pushnil(L);
15191520
return 1;
@@ -1541,7 +1542,7 @@ static int luaModelSetGlobalVariable(lua_State *L)
15411542
unsigned int phase = luaL_checkunsigned(L, 2);
15421543
int value = luaL_checkinteger(L, 3);
15431544
if (phase < MAX_FLIGHT_MODES && idx < MAX_GVARS && value >= -GVAR_MAX && value <= GVAR_MAX) {
1544-
g_model.flightModeData[phase].gvars[idx] = value;
1545+
SET_GVAR(idx, value, phase);
15451546
storageDirty(EE_MODEL);
15461547
}
15471548
return 0;

0 commit comments

Comments
 (0)