fix(lua): Array indexes for get/setFlightMode and getCurve (#2567)

* Lua array indexes start at 1

* LUA model.setFlightMode: use array index to compute trim index

This allows for providing an incomplete table like this:
```
-- Disable T5 & T6 on FM0
modes = {}
modes[5] = 31
modes[6] = 31
t = {}
t["trimsModes"] = modes
model.setFlightMode(0, t)
```

* Remove warning & cleanup

* Fix trim value constraints in model.setFlightMode()
This commit is contained in:
Raphael Coeffic
2022-11-30 15:57:42 +10:00
committed by GitHub
parent a267520236
commit 8f3dd7f72e
2 changed files with 20 additions and 14 deletions
+2 -2
View File
@@ -1187,7 +1187,7 @@ static int luaGhostTelemetryPop(lua_State * L)
lua_newtable(L);
for (uint8_t i=0; i<length-2; i++) {
luaInputTelemetryFifo->pop(data);
lua_pushinteger(L, i+1);
lua_pushinteger(L, i + 1);
lua_pushinteger(L, data);
lua_settable(L, -3);
}
@@ -2587,7 +2587,7 @@ static int luaSources(lua_State * L)
static int luaGetOutputValue(lua_State * L)
{
mixsrc_t idx = luaL_checkinteger(L, 1);
if (idx >= 0 && idx < MAX_OUTPUT_CHANNELS) {
if (idx < MAX_OUTPUT_CHANNELS) {
lua_pushinteger(L, channelOutputs[idx]);
} else {
lua_pushinteger(L, 0);