diff --git a/radio/src/gui/colorlcd/LvglWrapper.cpp b/radio/src/gui/colorlcd/LvglWrapper.cpp index 2ae403b0c..f45c58246 100644 --- a/radio/src/gui/colorlcd/LvglWrapper.cpp +++ b/radio/src/gui/colorlcd/LvglWrapper.cpp @@ -50,10 +50,35 @@ TouchState getLastTochState() } #endif -void newLcdRefresh(uint16_t* buffer); +void newLcdRefresh(uint16_t* buffer, const rect_t& copy_area); static void flushLcd(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) { - newLcdRefresh((uint16_t*)color_p); + lv_area_t refr_area; + lv_area_copy(&refr_area, area); + +#if defined(LCD_VERTICAL_INVERT) + lv_coord_t tmp_coord; + tmp_coord = refr_area.y2; + refr_area.y2 = LCD_H - refr_area.y1 - 1; + refr_area.y1 = LCD_H - tmp_coord - 1; + tmp_coord = refr_area.x2; + refr_area.x2 = LCD_W - refr_area.x1 - 1; + refr_area.x1 = LCD_W - tmp_coord - 1; +#endif + + if (refr_area.x1 != 0 || refr_area.x2 != 479 || refr_area.y1 != 0 || + refr_area.y2 != 271) { + TRACE("partial refresh @ 0x%p {%d,%d,%d,%d}", color_p, refr_area.x1, + refr_area.y1, refr_area.x2, refr_area.y2); + } else { + TRACE("full refresh @ 0x%p", color_p); + } + + rect_t copy_area = {refr_area.x1, refr_area.y1, + refr_area.x2 - refr_area.x1 + 1, + refr_area.y2 - refr_area.y1 + 1}; + + newLcdRefresh((uint16_t*)color_p, copy_area); lv_disp_flush_ready(disp_drv); } @@ -170,9 +195,6 @@ lv_color_t makeLvColor(uint32_t colorFlags) return lv_color_make(GET_RED(color), GET_GREEN(color), GET_BLUE(color)); } -lv_obj_t * canvas=nullptr; -static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(LCD_W, LCD_H)] __SDRAM; -BitmapBuffer canBuf(BMP_RGB565, LCD_W, LCD_H, (uint16_t *)cbuf); extern BitmapBuffer * lcdFront; extern BitmapBuffer * lcd; @@ -233,15 +255,9 @@ LvglWrapper::LvglWrapper() // Create a canvas as the drawing target for libopenui as a hack. // This is going to be removed // - canvas = lv_canvas_create(lv_scr_act()); - lv_canvas_set_buffer(canvas, cbuf, LCD_W, LCD_H, LV_IMG_CF_TRUE_COLOR); - lv_obj_set_style_bg_opa(canvas, LV_OPA_MAX, LV_PART_MAIN); auto window = MainWindow::instance(); - lv_obj_set_parent(canvas, window->getLvObj()); - lv_obj_move_background(canvas); lv_scr_load(window->getLvObj()); - lv_obj_invalidate(canvas); } void LvglWrapper::run() diff --git a/radio/src/gui/colorlcd/themes/480_default.cpp b/radio/src/gui/colorlcd/themes/480_default.cpp index 2ba11066c..fab2e51fa 100644 --- a/radio/src/gui/colorlcd/themes/480_default.cpp +++ b/radio/src/gui/colorlcd/themes/480_default.cpp @@ -311,11 +311,9 @@ class Theme480: public OpenTxTheme { if (backgroundBitmap) { dc->clear(COLOR_THEME_SECONDARY3); - dc->drawBitmap(0 - dc->getOffsetX(), 0 - dc->getOffsetY(), backgroundBitmap); - } - else { - dc->drawSolidFilledRect(0 - dc->getOffsetX(), 0 - dc->getOffsetY(), - LCD_W, LCD_H, COLOR_THEME_SECONDARY3); + dc->drawBitmap(0, 0, backgroundBitmap); + } else { + dc->drawSolidFilledRect(0, 0, LCD_W, LCD_H, COLOR_THEME_SECONDARY3); } } diff --git a/radio/src/simu.cpp b/radio/src/simu.cpp index 09fcadb55..f323775b5 100644 --- a/radio/src/simu.cpp +++ b/radio/src/simu.cpp @@ -524,8 +524,6 @@ void OpenTxSim::refreshDisplay() if ((bool(isBacklightEnabled()) != lightEnabled) || simuLcdRefresh) { - simuLcdRefresh = false; - if (bool(isBacklightEnabled()) != lightEnabled) { lightEnabled = (bool)isBacklightEnabled(); TRACE("backlight %s", lightEnabled ? "ON" : "OFF"); @@ -575,6 +573,8 @@ void OpenTxSim::refreshDisplay() bmp->render(); bmf->setImage(bmp); + + simuLcdRefresh = false; } } diff --git a/radio/src/targets/simu/simulcd.cpp b/radio/src/targets/simu/simulcd.cpp index 5850e7400..9312a4ed2 100644 --- a/radio/src/targets/simu/simulcd.cpp +++ b/radio/src/targets/simu/simulcd.cpp @@ -85,22 +85,37 @@ int lcdRestoreBackupBuffer() return 1; } -void newLcdRefresh(uint16_t *buffer) +void newLcdRefresh(uint16_t *buffer, const rect_t& copy_area) { + +#if defined(LCD_VERTICAL_INVERT) + auto total = copy_area.w * copy_area.h; + auto src = buffer + total - 1; +#else + auto src = buffer; +#endif + auto dst = simuLcdBuf + copy_area.y * LCD_W + copy_area.x; + + auto y2 = copy_area.y + copy_area.h; + for (auto line = copy_area.y; line < y2; line++) { + + auto line_end = dst + copy_area.w; + while (dst != line_end) { +#if defined(LCD_VERTICAL_INVERT) + *(dst++) = *(src--); +#else + *(dst++) = *(src++); +#endif + } + + dst += LCD_W - copy_area.w; + } + // Mark screen dirty for async refresh simuLcdRefresh = true; -#if defined(LCD_VERTICAL_INVERT) - auto src = buffer + DISPLAY_BUFFER_SIZE - 1; - auto dst = simuLcdBuf; - auto end = dst + DISPLAY_BUFFER_SIZE; - - while (dst != end) { - *(dst++) = *(src--); - } -#else - memcpy(simuLcdBuf, buffer, DISPLAY_BUFFER_SIZE * sizeof(pixel_t)); -#endif + // .. and wait for refresh + while(simuLcdRefresh); } void lcdRefresh() { @@ -134,11 +149,6 @@ void lcdInit() void DMAFillRect(uint16_t *dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color) { -#if defined(LCD_VERTICAL_INVERT) && 0 - x = destw - (x + w); - y = desth - (y + h); -#endif - for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { dest[(y + i) * destw + x + j] = color; @@ -151,13 +161,6 @@ void DMACopyBitmap(uint16_t *dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h) { -#if defined(LCD_VERTICAL_INVERT) && 0 - x = destw - (x + w); - y = desth - (y + h); - srcx = srcw - (srcx + w); - srcy = srch - (srcy + h); -#endif - for (int i = 0; i < h; i++) { memcpy(dest + (y + i) * destw + x, src + (srcy + i) * srcw + srcx, 2 * w); } @@ -170,13 +173,6 @@ void DMACopyAlphaBitmap(uint16_t *dest, uint16_t destw, uint16_t desth, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h) { -#if defined(LCD_VERTICAL_INVERT) && 0 - x = destw - (x + w); - y = desth - (y + h); - srcx = srcw - (srcx + w); - srcy = srch - (srcy + h); -#endif - for (coord_t line = 0; line < h; line++) { uint16_t *p = dest + (y + line) * destw + x; const uint16_t *q = src + (srcy + line) * srcw + srcx; @@ -205,13 +201,6 @@ void DMACopyAlphaMask(uint16_t *dest, uint16_t destw, uint16_t desth, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h, uint16_t fg_color) { -#if defined(LCD_VERTICAL_INVERT) && 0 - x = destw - (x + w); - y = desth - (y + h); - srcx = srcw - (srcx + w); - srcy = srch - (srcy + h); -#endif - RGB_SPLIT(fg_color, red, green, blue); for (coord_t line = 0; line < h; line++) { diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index 9fd291d24..b0c8cf121 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit 9fd291d24d3892b28cfd771e78ad502b332e3398 +Subproject commit b0c8cf12165001a023620a9761963e90827cd11b