From b83f95ed1abc6fc1eef9e8b367aaf8163cfe2fee Mon Sep 17 00:00:00 2001 From: bsongis Date: Wed, 18 Jun 2014 22:41:03 +0200 Subject: [PATCH] Events are transmitted to the Lua telemetry screens. Menus are displayed over those screens (needed at least for Reset Telemetry/Flight) --- radio/src/lua.cpp | 6 +++++- radio/src/opentx.cpp | 14 +++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/radio/src/lua.cpp b/radio/src/lua.cpp index 04ea8c78a..f465589c3 100644 --- a/radio/src/lua.cpp +++ b/radio/src/lua.cpp @@ -1462,6 +1462,7 @@ void luaTask(uint8_t evt) if (sid.state == SCRIPT_OK) { uint8_t prev_mem = lua_gc(L, LUA_GCCOUNT, 0); SET_LUA_INSTRUCTIONS_COUNT(PERMANENT_SCRIPTS_MAX_INSTRUCTIONS); + int inputsCount = 0; #if defined(SIMU) || defined(DEBUG) const char *filename; #endif @@ -1469,6 +1470,7 @@ void luaTask(uint8_t evt) if (sid.reference >= SCRIPT_MIX_FIRST && sid.reference <= SCRIPT_MIX_LAST) { ScriptData & sd = g_model.scriptsData[sid.reference-SCRIPT_MIX_FIRST]; sio = &scriptInputsOutputs[sid.reference-SCRIPT_MIX_FIRST]; + inputsCount = sio->inputsCount; #if defined(SIMU) || defined(DEBUG) filename = sd.file; #endif @@ -1496,12 +1498,14 @@ void luaTask(uint8_t evt) #endif if (g_menuStack[0]==menuTelemetryFrsky && sid.reference==SCRIPT_TELEMETRY_FIRST+s_frsky_view) { lua_rawgeti(L, LUA_REGISTRYINDEX, sid.run); + lua_pushinteger(L, evt); + inputsCount = 1; } else if (sid.background) { lua_rawgeti(L, LUA_REGISTRYINDEX, sid.background); } } - if (lua_pcall(L, sio ? sio->inputsCount : 0, sio ? sio->outputsCount : 0, 0) == 0) { + if (lua_pcall(L, inputsCount, sio ? sio->outputsCount : 0, 0) == 0) { if (sio) { for (int j=sio->outputsCount-1; j>=0; j--) { if (!lua_isnumber(L, -1)) { diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 3c13156e8..39a513e88 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -2760,6 +2760,13 @@ void perMain() if (!LCD_LOCKED()) { lcd_clear(); g_menuStack[g_menuStackPtr]((warn || menu) ? 0 : evt); + } + +#if defined(LUA) + luaTask(evt); +#endif + + if (!LCD_LOCKED()) { if (warn) DISPLAY_WARNING(evt); #if defined(NAVIGATION_MENUS) if (menu) { @@ -2769,16 +2776,9 @@ void perMain() putEvent(EVT_MENU_UP); } } -#endif -#if defined(LUA) - evt = 0; #endif } -#if defined(LUA) - luaTask(evt); -#endif - drawStatusLine(); lcdRefresh();