mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 12:25:12 +03:00
Add Lua getUsage() function that returns percent of already used up i… (#5313)
* Add Lua getUsage() function that returns percent of already used up instructions in current script execution cycle. It can be used to avoid script being killed when doing long lasting tasks (like telemetry logs loading and parsing) * Compilation fixes * Doc fix * Disable Lua script instructions limit in DEBUG mode
This commit is contained in:
parent
6c7e4b5597
commit
955d5775cb
3 changed files with 34 additions and 2 deletions
|
@ -1171,6 +1171,21 @@ static int luaLoadScript(lua_State * L)
|
|||
}
|
||||
}
|
||||
|
||||
/*luadoc
|
||||
@function getUsage()
|
||||
|
||||
Get percent of already used Lua instructions in current script execution cycle.
|
||||
|
||||
@retval usage (number) a value from 0 to 100 (percent)
|
||||
|
||||
@status current Introduced in 2.2.1
|
||||
*/
|
||||
static int luaGetUsage(lua_State * L)
|
||||
{
|
||||
lua_pushinteger(L, instructionsPercent);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const luaL_Reg opentxLib[] = {
|
||||
{ "getTime", luaGetTime },
|
||||
{ "getDateTime", luaGetDateTime },
|
||||
|
@ -1193,6 +1208,7 @@ const luaL_Reg opentxLib[] = {
|
|||
{ "getRSSI", luaGetRSSI },
|
||||
{ "killEvents", luaKillEvents },
|
||||
{ "loadScript", luaLoadScript },
|
||||
{ "getUsage", luaGetUsage },
|
||||
#if LCD_DEPTH > 1 && !defined(COLORLCD)
|
||||
{ "GREY", luaGrey },
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue