From fc4cf73c897fb402147fb8a762aa0890b8ccacbc Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Sat, 26 Apr 2014 09:45:07 +0200 Subject: [PATCH] Registered OpenTX version as symbol OPENTX_VERSION in Lua Added PlayNumber() --- radio/src/lua.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/radio/src/lua.cpp b/radio/src/lua.cpp index 34b225650..0e36fe8e0 100644 --- a/radio/src/lua.cpp +++ b/radio/src/lua.cpp @@ -47,6 +47,7 @@ extern "C" { } #endif +#define lua_registernumber(L, n, i) (lua_pushnumber(L, (i)), lua_setglobal(L, (n))) #define lua_registerint(L, n, i) (lua_pushinteger(L, (i)), lua_setglobal(L, (n))) #define lua_pushtablenil(L, k) (lua_pushstring(L, (k)), lua_pushnil(L), lua_settable(L, -3)) #define lua_pushtableboolean(L, k, v) (lua_pushstring(L, (k)), lua_pushboolean(L, (v)), lua_settable(L, -3)) @@ -131,6 +132,16 @@ static int luaPlayFile(lua_State *L) return 0; } +static int luaPlayNumber(lua_State *L) +{ + int number = luaL_checkinteger(L, 1); + int unit = luaL_checkinteger(L, 2); + int att = luaL_checkinteger(L, 3); + playNumber(number, unit, att, 0); + return 0; +} + + static int luaLcdLock(lua_State *L) { lcd_locked = true; @@ -822,9 +833,11 @@ void luaInit() lua_register(L, "getVersion", luaGetVersion); lua_register(L, "getValue", luaGetValue); lua_register(L, "playFile", luaPlayFile); + lua_register(L, "playNumber", luaPlayNumber); lua_register(L, "popupInput", luaPopupInput); // Push OpenTX constants + lua_registernumber(L, "OPENTX_VERSION", VERS_NUM); lua_registerint(L, "DBLSIZE", DBLSIZE); lua_registerint(L, "MIDSIZE", MIDSIZE); lua_registerint(L, "SMLSIZE", SMLSIZE);