1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-13 19:40:20 +03:00

Merge pull request #8137 from jfrickmann/2.3

Added model.resetSensor(sensor) function
This commit is contained in:
Bertrand Songis 2020-12-09 18:27:57 +01:00 committed by GitHub
commit 8a676c32c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1551,6 +1551,28 @@ static int luaModelGetSensor(lua_State *L)
return 1; return 1;
} }
/*luadoc
@function model.resetSensor(sensor)
Reset Telemetry Sensor parameters
@param sensor (unsigned number) sensor number (use 0 for sensor 1)
@retval nil
@status current Introduced in 2.3.0
*/
static int luaModelResetSensor(lua_State *L)
{
unsigned int idx = luaL_checkunsigned(L, 1);
if (idx < MAX_TELEMETRY_SENSORS) {
telemetryItems[idx].clear();
}
lua_pushnil(L);
return 1;
}
const luaL_Reg modelLib[] = { const luaL_Reg modelLib[] = {
{ "getInfo", luaModelGetInfo }, { "getInfo", luaModelGetInfo },
{ "setInfo", luaModelSetInfo }, { "setInfo", luaModelSetInfo },
@ -1584,5 +1606,6 @@ const luaL_Reg modelLib[] = {
{ "getGlobalVariable", luaModelGetGlobalVariable }, { "getGlobalVariable", luaModelGetGlobalVariable },
{ "setGlobalVariable", luaModelSetGlobalVariable }, { "setGlobalVariable", luaModelSetGlobalVariable },
{ "getSensor", luaModelGetSensor }, { "getSensor", luaModelGetSensor },
{ "resetSensor", luaModelResetSensor },
{ NULL, NULL } /* sentinel */ { NULL, NULL } /* sentinel */
}; };