1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-15 12:25:12 +03:00

Add gtimer support to LUA (#5669)

* Add gtimer support to LUA

* Copy/paste issue
This commit is contained in:
3djc 2018-02-11 23:25:04 +01:00 committed by Andre Bernet
parent 073e1a8462
commit d3951235bd

View file

@ -903,9 +903,10 @@ Returns (some of) the general radio settings
IMPERIAL units
* `language` (string) radio language (used for menus)
* `voice` (string) voice language (used for speech)
* `gtimer` (number) radio global timer in seconds (does not include current session)
@status current Introduced in 2.0.6, `imperial` added in TODO,
`language` and `voice` added in 2.2.0.
`language` and `voice` added in 2.2.0, gtimer added in 2.2.2.
*/
static int luaGetGeneralSettings(lua_State * L)
@ -917,6 +918,7 @@ static int luaGetGeneralSettings(lua_State * L)
lua_pushtableinteger(L, "imperial", g_eeGeneral.imperial);
lua_pushtablestring(L, "language", TRANSLATIONS);
lua_pushtablestring(L, "voice", currentLanguagePack->id);
lua_pushtableinteger(L, "gtimer", g_eeGeneral.globalTimer);
return 1;
}
@ -1258,6 +1260,20 @@ static int luaGetUsage(lua_State * L)
return 1;
}
/*luadoc
@function resetGlobalTimer()
Resets the radio global timer to 0.
@status current Introduced in 2.2.2
*/
static int luaResetGlobalTimer(lua_State * L)
{
g_eeGeneral.globalTimer = 0;
storageDirty(EE_GENERAL);
return 0;
}
const luaL_Reg opentxLib[] = {
{ "getTime", luaGetTime },
{ "getDateTime", luaGetDateTime },
@ -1285,6 +1301,7 @@ const luaL_Reg opentxLib[] = {
{ "killEvents", luaKillEvents },
{ "loadScript", luaLoadScript },
{ "getUsage", luaGetUsage },
{ "resetGlobalTimer", luaResetGlobalTimer },
#if LCD_DEPTH > 1 && !defined(COLORLCD)
{ "GREY", luaGrey },
#endif