diff --git a/radio/src/lua.cpp b/radio/src/lua.cpp index f4c0c3e5f..04ea8c78a 100644 --- a/radio/src/lua.cpp +++ b/radio/src/lua.cpp @@ -1173,6 +1173,10 @@ int luaLoad(const char *filename, ScriptInternalData & sid, ScriptInputsOutputs sid.run = luaL_ref(L, LUA_REGISTRYINDEX); lua_pushnil(L); } + else if (!strcmp(key, "background")) { + sid.background = luaL_ref(L, LUA_REGISTRYINDEX); + lua_pushnil(L); + } else if (sio && !strcmp(key, "input")) { luaGetInputs(*sio); } @@ -1487,13 +1491,15 @@ void luaTask(uint8_t evt) lua_rawgeti(L, LUA_REGISTRYINDEX, sid.run); } else { - if (g_menuStack[0]!=menuTelemetryFrsky || sid.reference!=SCRIPT_TELEMETRY_FIRST+s_frsky_view) { - continue; - } #if defined(SIMU) || defined(DEBUG) filename = "[telem]"; #endif - lua_rawgeti(L, LUA_REGISTRYINDEX, sid.run); + if (g_menuStack[0]==menuTelemetryFrsky && sid.reference==SCRIPT_TELEMETRY_FIRST+s_frsky_view) { + lua_rawgeti(L, LUA_REGISTRYINDEX, sid.run); + } + 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 (sio) { diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 59b16c722..b7dfab195 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -1464,6 +1464,7 @@ enum AUDIO_SOUNDS { uint8_t reference; uint8_t state; int run; + int background; uint8_t instructions; uint8_t memory; };