1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-24 16:55:15 +03:00

Fixes #4399: problem getting/setting curve on output with Lua (#4455)

This commit is contained in:
Bertrand Songis 2017-02-15 21:25:08 +01:00 committed by Damjan Adamic
parent 27b1255584
commit 53f55f8e1d

View file

@ -984,8 +984,6 @@ static int luaModelGetOutput(lua_State *L)
lua_pushtableinteger(L, "revert", limit->revert); lua_pushtableinteger(L, "revert", limit->revert);
if (limit->curve) if (limit->curve)
lua_pushtableinteger(L, "curve", limit->curve-1); lua_pushtableinteger(L, "curve", limit->curve-1);
else
lua_pushtablenil(L, "curve");
} }
else { else {
lua_pushnil(L); lua_pushnil(L);
@ -1012,6 +1010,7 @@ static int luaModelSetOutput(lua_State *L)
unsigned int idx = luaL_checkunsigned(L, 1); unsigned int idx = luaL_checkunsigned(L, 1);
if (idx < MAX_OUTPUT_CHANNELS) { if (idx < MAX_OUTPUT_CHANNELS) {
LimitData * limit = limitAddress(idx); LimitData * limit = limitAddress(idx);
memclear(limit, sizeof(LimitData));
luaL_checktype(L, -1, LUA_TTABLE); luaL_checktype(L, -1, LUA_TTABLE);
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) { for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
luaL_checktype(L, -2, LUA_TSTRING); // key is string luaL_checktype(L, -2, LUA_TSTRING); // key is string
@ -1039,10 +1038,7 @@ static int luaModelSetOutput(lua_State *L)
limit->revert = luaL_checkinteger(L, -1); limit->revert = luaL_checkinteger(L, -1);
} }
else if (!strcmp(key, "curve")) { else if (!strcmp(key, "curve")) {
if (lua_isnil(L, -1)) limit->curve = luaL_checkinteger(L, -1) + 1;
limit->curve = 0;
else
limit->curve = luaL_checkinteger(L, -1) + 1;
} }
} }
storageDirty(EE_MODEL); storageDirty(EE_MODEL);