From 99270482dc3f649f690f47d4b7049c5979e68962 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 20 Feb 2022 12:43:42 +0100 Subject: [PATCH] Removed backup buffer & some LUA fixes --- radio/src/gui/colorlcd/lcd.cpp | 14 ++++-------- radio/src/gui/colorlcd/standalone_lua.cpp | 27 +++++++++-------------- radio/src/lua/api_colorlcd.cpp | 4 ++-- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/radio/src/gui/colorlcd/lcd.cpp b/radio/src/gui/colorlcd/lcd.cpp index 3cd42cc9d..7b4fd05ef 100644 --- a/radio/src/gui/colorlcd/lcd.cpp +++ b/radio/src/gui/colorlcd/lcd.cpp @@ -25,14 +25,6 @@ uint8_t LCD_FIRST_FRAME_BUFFER[DISPLAY_BUFFER_SIZE * sizeof(pixel_t)] __SDRAM; uint8_t LCD_SECOND_FRAME_BUFFER[DISPLAY_BUFFER_SIZE * sizeof(pixel_t)] __SDRAM; -//TODO: this needs to go away... -uint8_t LCD_BACKUP_FRAME_BUFFER[DISPLAY_BUFFER_SIZE * sizeof(pixel_t)] __SDRAM; - -uint16_t* lcdGetBackupBuffer() -{ - return (uint16_t*)LCD_BACKUP_FRAME_BUFFER; -} - BitmapBuffer lcdBuffer1(BMP_RGB565, LCD_W, LCD_H, (uint16_t *)LCD_FIRST_FRAME_BUFFER); BitmapBuffer lcdBuffer2(BMP_RGB565, LCD_W, LCD_H, (uint16_t *)LCD_SECOND_FRAME_BUFFER); @@ -64,6 +56,8 @@ void lcdSetFlushCb(void (*cb)(lv_disp_drv_t *, uint16_t*, const rect_t&)) lcd_flush_cb = cb; } +static lv_disp_drv_t* refr_disp = nullptr; + static void flushLcd(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) { lv_area_t refr_area; @@ -82,6 +76,7 @@ static void flushLcd(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_ refr_area.y2 - refr_area.y1 + 1}; if (lcd_flush_cb) { + refr_disp = disp_drv; lcd_flush_cb(disp_drv, (uint16_t*)color_p, copy_area); } else { lv_disp_flush_ready(disp_drv); @@ -148,8 +143,7 @@ void lcdRefresh() void lcdFlushed() { - lv_disp_t* disp = _lv_refr_get_disp_refreshing(); - lv_disp_flush_ready(disp->driver); + lv_disp_flush_ready(refr_disp); } //TODO: move this somewhere else diff --git a/radio/src/gui/colorlcd/standalone_lua.cpp b/radio/src/gui/colorlcd/standalone_lua.cpp index 1ba6913f2..60b5663d4 100644 --- a/radio/src/gui/colorlcd/standalone_lua.cpp +++ b/radio/src/gui/colorlcd/standalone_lua.cpp @@ -55,12 +55,9 @@ StandaloneLuaWindow* StandaloneLuaWindow::_instance; bool StandaloneLuaWindow::fingerDown = false; #endif -// LUA lcd buffer -uint16_t* lcdGetBackupBuffer(); - StandaloneLuaWindow::StandaloneLuaWindow() : Window(nullptr, {0, 0, LCD_W, LCD_H}, OPAQUE), - lcdBuffer(BMP_RGB565, LCD_W, LCD_H, lcdGetBackupBuffer()), + lcdBuffer(BMP_RGB565, LCD_W, LCD_H), popup({50, 73, LCD_W - 100, LCD_H - 146}) { } @@ -88,31 +85,27 @@ void StandaloneLuaWindow::attach(Window* newParent) Layer::push(this); } + setFocus(); } -void StandaloneLuaWindow::deleteLater(bool detach, bool /*trash*/) +void StandaloneLuaWindow::deleteLater(bool detach, bool trash) { - Layer::pop(this); + if (_deleted) + return; - // do not trash: we are a singleton - if (static_cast(focusWindow) == static_cast(this)) { - focusWindow = nullptr; - } + Layer::pop(this); if (prevScreen) { lv_scr_load(prevScreen); prevScreen = nullptr; } - - // detach from parent - if (detach) { - this->detach(); - } - if (closeHandler) { - closeHandler(); + if (trash) { + _instance = nullptr; } + + Window::deleteLater(detach, trash); } void StandaloneLuaWindow::paint(BitmapBuffer* dc) diff --git a/radio/src/lua/api_colorlcd.cpp b/radio/src/lua/api_colorlcd.cpp index 66fc3e271..5e602e66f 100644 --- a/radio/src/lua/api_colorlcd.cpp +++ b/radio/src/lua/api_colorlcd.cpp @@ -229,7 +229,7 @@ static void drawString(lua_State *L, const char * s, LcdFlags flags) // Draw color box int height = getFontHeight(flags & 0xFFFF) + 2 * INVERT_BOX_MARGIN; - int width = getTextWidth(s, 255, flags); + int width = getTextWidth(s, 0, flags); int ix = x - INVERT_BOX_MARGIN; if (flags & RIGHT) ix -= width; @@ -288,7 +288,7 @@ static int luaLcdSizeText(lua_State *L) { const char * s = luaL_checkstring(L, 1); LcdFlags flags = luaL_optunsigned(L, 2, 0); - lua_pushinteger(L, getTextWidth(s, 255, flags)); + lua_pushinteger(L, getTextWidth(s, 0, flags)); lua_pushinteger(L, getFontHeight(flags & 0xFFFF) + getTextVerticalOffset(flags & ~VCENTERED)); return 2; }