Added Lua function lcd.exitFullScreen()
This commit is contained in:
@@ -22,10 +22,11 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "libopenui.h"
|
#include "libopenui.h"
|
||||||
|
#include "widget.h"
|
||||||
#include "api_colorlcd.h"
|
#include "api_colorlcd.h"
|
||||||
|
|
||||||
BitmapBuffer* luaLcdBuffer = nullptr;
|
BitmapBuffer* luaLcdBuffer = nullptr;
|
||||||
|
Widget* runningFS = nullptr;
|
||||||
|
|
||||||
static int8_t getTextHorizontalOffset(LcdFlags flags)
|
static int8_t getTextHorizontalOffset(LcdFlags flags)
|
||||||
{
|
{
|
||||||
@@ -1216,6 +1217,25 @@ static int luaLcdDrawHudRectangle(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*luadoc
|
||||||
|
@function lcd.exitFullScreen()
|
||||||
|
|
||||||
|
Exit full screen widget mode.
|
||||||
|
|
||||||
|
@notice Only available on radios with color display
|
||||||
|
|
||||||
|
@status current Introduced in 2.5.0
|
||||||
|
*/
|
||||||
|
static int luaLcdExitFullScreen(lua_State *L)
|
||||||
|
{
|
||||||
|
if (runningFS) {
|
||||||
|
Widget* rfs = runningFS;
|
||||||
|
runningFS = nullptr;
|
||||||
|
rfs->setFullscreen(false);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg lcdLib[] = {
|
const luaL_Reg lcdLib[] = {
|
||||||
{ "refresh", luaLcdRefresh },
|
{ "refresh", luaLcdRefresh },
|
||||||
{ "clear", luaLcdClear },
|
{ "clear", luaLcdClear },
|
||||||
@@ -1246,5 +1266,6 @@ const luaL_Reg lcdLib[] = {
|
|||||||
{ "drawAnnulus", luaLcdDrawAnnulus },
|
{ "drawAnnulus", luaLcdDrawAnnulus },
|
||||||
{ "drawLineWithClipping", luaLcdDrawLineWithClipping },
|
{ "drawLineWithClipping", luaLcdDrawLineWithClipping },
|
||||||
{ "drawHudRectangle", luaLcdDrawHudRectangle },
|
{ "drawHudRectangle", luaLcdDrawHudRectangle },
|
||||||
|
{ "exitFullScreen", luaLcdExitFullScreen },
|
||||||
{ NULL, NULL } /* sentinel */
|
{ NULL, NULL } /* sentinel */
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -39,5 +39,6 @@ constexpr int8_t text_vertical_offset[7] {2,2,0,2,3,3,7};
|
|||||||
|
|
||||||
extern bool luaLcdAllowed;
|
extern bool luaLcdAllowed;
|
||||||
extern BitmapBuffer * luaLcdBuffer;
|
extern BitmapBuffer * luaLcdBuffer;
|
||||||
|
extern Widget * runningFS;
|
||||||
|
|
||||||
LcdFlags flagsRGB(LcdFlags flags);
|
LcdFlags flagsRGB(LcdFlags flags);
|
||||||
@@ -515,10 +515,12 @@ void LuaWidget::refresh(BitmapBuffer* dc)
|
|||||||
// This little hack is needed to not interfere with the LCD usage of preempted scripts
|
// This little hack is needed to not interfere with the LCD usage of preempted scripts
|
||||||
bool lla = luaLcdAllowed;
|
bool lla = luaLcdAllowed;
|
||||||
luaLcdAllowed = true;
|
luaLcdAllowed = true;
|
||||||
|
runningFS = this;
|
||||||
|
|
||||||
if (lua_pcall(lsWidgets, 3, 0, 0) != 0) {
|
if (lua_pcall(lsWidgets, 3, 0, 0) != 0) {
|
||||||
setErrorMessage("refresh()");
|
setErrorMessage("refresh()");
|
||||||
}
|
}
|
||||||
|
runningFS = nullptr;
|
||||||
// Remove LCD
|
// Remove LCD
|
||||||
luaLcdAllowed = lla;
|
luaLcdAllowed = lla;
|
||||||
luaLcdBuffer = nullptr;
|
luaLcdBuffer = nullptr;
|
||||||
@@ -537,9 +539,11 @@ void LuaWidget::background()
|
|||||||
if (factory->backgroundFunction) {
|
if (factory->backgroundFunction) {
|
||||||
lua_rawgeti(lsWidgets, LUA_REGISTRYINDEX, factory->backgroundFunction);
|
lua_rawgeti(lsWidgets, LUA_REGISTRYINDEX, factory->backgroundFunction);
|
||||||
lua_rawgeti(lsWidgets, LUA_REGISTRYINDEX, luaWidgetDataRef);
|
lua_rawgeti(lsWidgets, LUA_REGISTRYINDEX, luaWidgetDataRef);
|
||||||
|
runningFS = this;
|
||||||
if (lua_pcall(lsWidgets, 1, 0, 0) != 0) {
|
if (lua_pcall(lsWidgets, 1, 0, 0) != 0) {
|
||||||
setErrorMessage("background()");
|
setErrorMessage("background()");
|
||||||
}
|
}
|
||||||
|
runningFS = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user