1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-14 03:49:52 +03:00

Add name handling to LUA timer functions (#7358)

Add timer name to LUA timer functions
This commit is contained in:
3djc 2020-02-06 14:36:21 +01:00 committed by GitHub
parent 4c94dd3ba0
commit 40d57a8853
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -182,8 +182,9 @@ Get model timer parameters
* `countdownBeep` (number) countdown beep (0­ = silent, 1 =­ beeps, 2­ = voice)
* `minuteBeep` (boolean) minute beep
* `persistent` (number) persistent timer
* `name` (string) timer name
@status current Introduced in 2.0.0
@status current Introduced in 2.0.0, name added in 2.3.6
*/
static int luaModelGetTimer(lua_State *L)
{
@ -197,6 +198,7 @@ static int luaModelGetTimer(lua_State *L)
lua_pushtableinteger(L, "countdownBeep", timer.countdownBeep);
lua_pushtableboolean(L, "minuteBeep", timer.minuteBeep);
lua_pushtableinteger(L, "persistent", timer.persistent);
lua_pushtablezstring(L, "name", timer.name);
}
else {
lua_pushnil(L);
@ -216,7 +218,7 @@ Set model timer parameters
@notice If a parameter is missing from the value, then
that parameter remains unchanged.
@status current Introduced in 2.0.0
@status current Introduced in 2.0.0, name added in 2.3.6
*/
static int luaModelSetTimer(lua_State *L)
{
@ -246,6 +248,10 @@ static int luaModelSetTimer(lua_State *L)
else if (!strcmp(key, "persistent")) {
timer.persistent = luaL_checkinteger(L, -1);
}
if (!strcmp(key, "name")) {
const char * name = luaL_checkstring(L, -1);
str2zchar(timer.name, name, sizeof(timer.name));
}
}
storageDirty(EE_MODEL);
}