From cde4fea81790c6ca32412ffe4b96e44ff6c5b672 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 10 Feb 2014 16:05:32 +0100 Subject: [PATCH] getVersion added to Lua functions --- radio/src/Makefile | 6 ++---- radio/src/lua.cpp | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/radio/src/Makefile b/radio/src/Makefile index 16dfb8b04..44ce5c3ab 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -1082,13 +1082,11 @@ sym: $(TARGET).sym # Build stamp-file stamp_header: - @echo - @echo "Generate Version-stamp:" - @echo "//Automatically generated file (Makefile) - do not edit" > stamp-opentx.h + @echo "// Automatically generated file (Makefile) - do not edit" > stamp-opentx.h @echo "#define DATE_STR \"`date +%Y-%m-%d | tr -d '\r\n'`\"" >> stamp-opentx.h @echo "#define TIME_STR \"`date +%H:%M:%S | tr -d '\r\n'`\"" >> stamp-opentx.h @echo "#define VERS_STR \"$(VERSION)\"" >> stamp-opentx.h - @cat stamp-opentx.h + @echo "#define VERS_NUM $(VERSION)" >> stamp-opentx.h 9x-stamp: @echo "#define DATE_STR \"`date +%Y-%m-%d`\"" > stamp-opentx-9x.txt diff --git a/radio/src/lua.cpp b/radio/src/lua.cpp index c466a5ac9..0e18824fa 100644 --- a/radio/src/lua.cpp +++ b/radio/src/lua.cpp @@ -35,6 +35,7 @@ */ #include "opentx.h" +#include "stamp-opentx.h" #if !defined(SIMU) extern "C" { @@ -76,6 +77,12 @@ void hook(lua_State* L, lua_Debug *ar) } } +static int luaGetVersion(lua_State *L) +{ + lua_pushnumber(L, VERS_NUM); + return 1; +} + static int luaGetTime(lua_State *L) { lua_pushunsigned(L, get_tmr10ms()); @@ -507,7 +514,7 @@ static int luaModelDeleteMix(lua_State *L) return 0; } -static int luaModelGetCustomSwitch(lua_State *L) +static int luaModelGetLogicalSwitch(lua_State *L) { int idx = luaL_checkunsigned(L, 1); if (idx < NUM_CSW) { @@ -527,7 +534,7 @@ static int luaModelGetCustomSwitch(lua_State *L) return 1; } -static int luaModelSetCustomSwitch(lua_State *L) +static int luaModelSetLogicalSwitch(lua_State *L) { int idx = luaL_checkunsigned(L, 1); if (idx < NUM_CSW) { @@ -784,8 +791,8 @@ static const luaL_Reg modelLib[] = { { "getMix", luaModelGetMix }, { "insertMix", luaModelInsertMix }, { "deleteMix", luaModelDeleteMix }, - { "getCustomSwitch", luaModelGetCustomSwitch }, - { "setCustomSwitch", luaModelSetCustomSwitch }, + { "getLogicalSwitch", luaModelGetLogicalSwitch }, + { "setLogicalSwitch", luaModelSetLogicalSwitch }, { "getCustomFunction", luaModelGetCustomFunction }, { "setCustomFunction", luaModelSetCustomFunction }, { "getOutput", luaModelGetOutput }, @@ -823,6 +830,7 @@ void luaInit() // Push openTX functions lua_register(L, "getTime", luaGetTime); + lua_register(L, "getVersion", luaGetVersion); lua_register(L, "getValue", luaGetValue); lua_register(L, "playFile", luaPlayFile); lua_register(L, "popupInput", luaPopupInput);