diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index ef20a650b..bde14bcee 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -857,6 +857,38 @@ static int luaPopupInput(lua_State * L) return 1; } +/*luadoc +@function popupWarning(title, event) + +Raises a pop-up on screen that shows a warning + +@param title (string) text to display + +@param event (number) the event variable that is passed in from the +Run function (key pressed) + +@retval "CANCEL" user pushed EXIT key + +@notice Use only from stand-alone and telemetry scripts. + +@status current Introduced in 2.2.0 +*/ +static int luaPopupWarning(lua_State * L) +{ + event_t event = luaL_checkinteger(L, 2); + warningText = luaL_checkstring(L, 1); + warningType = WARNING_TYPE_ASTERISK; + runPopupWarning(event); + if (!warningText) { + lua_pushstring(L, "CANCEL"); + } + else { + warningText = NULL; + lua_pushnil(L); + } + return 1; +} + /*luadoc @function defaultStick(channel) @@ -983,6 +1015,7 @@ const luaL_Reg opentxLib[] = { { "playTone", luaPlayTone }, { "playHaptic", luaPlayHaptic }, { "popupInput", luaPopupInput }, + { "popupWarning", luaPopupWarning }, { "defaultStick", luaDefaultStick }, { "defaultChannel", luaDefaultChannel }, { "getRSSI", luaGetRSSI },