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

background function added to Lua scripts (used only in telemetry

scripts)
This commit is contained in:
bsongis 2014-06-18 21:59:19 +02:00
parent ec81b078fe
commit b77d470684
2 changed files with 11 additions and 4 deletions

View file

@ -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,14 +1491,16 @@ 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
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) {
for (int j=sio->outputsCount-1; j>=0; j--) {

View file

@ -1464,6 +1464,7 @@ enum AUDIO_SOUNDS {
uint8_t reference;
uint8_t state;
int run;
int background;
uint8_t instructions;
uint8_t memory;
};