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:
parent
ec81b078fe
commit
b77d470684
2 changed files with 11 additions and 4 deletions
|
@ -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--) {
|
||||
|
|
|
@ -1464,6 +1464,7 @@ enum AUDIO_SOUNDS {
|
|||
uint8_t reference;
|
||||
uint8_t state;
|
||||
int run;
|
||||
int background;
|
||||
uint8_t instructions;
|
||||
uint8_t memory;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue