From 6ba4187381a7f8eedc58ba9ecdf06b0da269660b Mon Sep 17 00:00:00 2001 From: Jesper Frickmann Date: Thu, 3 Dec 2020 19:53:34 -0500 Subject: [PATCH] Added model.resetSensor(sensor) function Issue #7562 --- radio/src/lua/api_model.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/radio/src/lua/api_model.cpp b/radio/src/lua/api_model.cpp index bb543c2c4..334e1d4ca 100644 --- a/radio/src/lua/api_model.cpp +++ b/radio/src/lua/api_model.cpp @@ -1555,6 +1555,28 @@ static int luaModelGetSensor(lua_State *L) 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[] = { { "getInfo", luaModelGetInfo }, { "setInfo", luaModelSetInfo }, @@ -1588,5 +1610,6 @@ const luaL_Reg modelLib[] = { { "getGlobalVariable", luaModelGetGlobalVariable }, { "setGlobalVariable", luaModelSetGlobalVariable }, { "getSensor", luaModelGetSensor }, + { "resetSensor", luaModelResetSensor }, { NULL, NULL } /* sentinel */ };