diff --git a/radio/src/gui/colorlcd/LvglWrapper.cpp b/radio/src/gui/colorlcd/LvglWrapper.cpp index de044c642..2eb38a6a8 100644 --- a/radio/src/gui/colorlcd/LvglWrapper.cpp +++ b/radio/src/gui/colorlcd/LvglWrapper.cpp @@ -146,7 +146,8 @@ lv_indev_state_t encoderState = LV_INDEV_STATE_RELEASED; void lvglPushEncoderEvent(event_t& evt) { - if(evt != EVT_KEY_FIRST(KEY_ENTER) && evt != EVT_KEY_BREAK(KEY_ENTER) && evt != EVT_ROTARY_LEFT && evt != EVT_ROTARY_RIGHT) + if (evt != EVT_KEY_FIRST(KEY_ENTER) && evt != EVT_KEY_BREAK(KEY_ENTER) && + evt != EVT_ROTARY_LEFT && evt != EVT_ROTARY_RIGHT) return; encoderEvent = evt; diff --git a/radio/src/gui/colorlcd/LvglWrapper.h b/radio/src/gui/colorlcd/LvglWrapper.h index 847c7f1d5..2057303fd 100644 --- a/radio/src/gui/colorlcd/LvglWrapper.h +++ b/radio/src/gui/colorlcd/LvglWrapper.h @@ -22,8 +22,8 @@ #ifndef _LVGLWRAPPER_H_ #define _LVGLWRAPPER_H_ +#include #include "opentx_types.h" -#include "lvgl/lvgl.h" extern lv_color_t makeLvColor(uint32_t colorFlags); #if defined(HARDWARE_TOUCH) diff --git a/radio/src/gui/colorlcd/fonts.cpp b/radio/src/gui/colorlcd/fonts.cpp index 3f6aed05f..b3231fc2f 100644 --- a/radio/src/gui/colorlcd/fonts.cpp +++ b/radio/src/gui/colorlcd/fonts.cpp @@ -21,183 +21,39 @@ #include "opentx.h" -const uint16_t font_xxs_specs[] = { -#include "font_9.specs" -}; - -const unsigned char font_xxs[] = { -#include "font_9.lbm" -}; - -#if LCD_H > 272 - -#if defined(BOOT) -const uint16_t font_std_en_specs[] = { -#include "font_17en.specs" -}; - -const unsigned char font_std_en[] = { -#include "font_17en.lbm" -}; +static const lv_font_t* lvglFontTable[FONTS_COUNT] = { + LV_FONT_DEFAULT, // FONT_STD_INDEX +#if !defined(BOOT) + &lv_font_roboto_bold_16, // FONT_BOLD_INDEX + &lv_font_roboto_9, // FONT_XXS_INDEX + &lv_font_roboto_13, // FONT_XS_INDEX + &lv_font_roboto_24, // FONT_L_INDEX + &lv_font_roboto_bold_32, // FONT_XL_INDEX + &lv_font_roboto_bold_64, // FONT_XXL_INDEX #endif - -const uint16_t font_xs_specs[] = { -#include "font_15.specs" }; -const unsigned char font_xs[] = { -#include "font_15.lbm" -}; - -const uint16_t font_std_specs[] = { -#include "font_17.specs" -}; - -const unsigned char font_std[] = { -#include "font_17.lbm" -}; - -const uint16_t font_bold_specs[] = { -#include "font_bold17.specs" -}; - -const unsigned char font_bold[] = { -#include "font_bold17.lbm" -}; - -#else // LCD_H <= 272 - -#if defined(BOOT) -const uint16_t font_std_en_specs[] = { -#include "font_16en.specs" -}; - -const unsigned char font_std_en[] = { -#include "font_16en.lbm" -}; -#endif - -const uint16_t font_xs_specs[] = { -#include "font_13.specs" -}; - -const unsigned char font_xs[] = { -#include "font_13.lbm" -}; - -const uint16_t font_std_specs[] = { -#include "font_16.specs" -}; - -const unsigned char font_std[] = { -#include "font_16.lbm" -}; - -const uint16_t font_bold_specs[] = { -#include "font_bold16.specs" -}; - -const unsigned char font_bold[] = { -#include "font_bold16.lbm" -}; - -#endif // LCD_H > 272 - -const uint16_t font_l_specs[] = { -#include "font_24.specs" -}; - -const unsigned char font_l[] = { -#include "font_24.lbm" -}; - -const uint16_t font_xl_specs[] = { -#include "font_32.specs" -}; - -const unsigned char font_xl[] = { -#include "font_32.lbm" -}; - -const uint16_t font_xxl_specs[] = { -#include "font_64.specs" -}; - -const unsigned char font_xxl[] = { -#include "font_64.lbm" -}; - -#if defined(BOOT) -// -2 for: overall length and last boundary -const uint16_t fontCharactersTable[FONTS_COUNT] = { sizeof(font_std_en_specs)/2-2 }; -const uint16_t * const fontspecsTable[FONTS_COUNT] = { font_std_en_specs }; -const uint8_t * fontsTable[FONTS_COUNT] = { font_std_en }; -const int fontsSizeTable[FONTS_COUNT] = { sizeof(font_std_en) }; -#else -// -2 for: overall length and last boundary -const uint16_t fontCharactersTable[FONTS_COUNT] = { - sizeof(font_std_specs)/2-2, sizeof(font_bold_specs)/2-2, sizeof(font_xxs_specs)/2-2, - sizeof(font_xs_specs)/2-2, sizeof(font_l_specs)/2-2, sizeof(font_xl_specs)/2-2, - sizeof(font_xxl_specs)/2-2 -}; -const uint16_t *const fontspecsTable[FONTS_COUNT] = { - font_std_specs, font_bold_specs, font_xxs_specs, font_xs_specs, - font_l_specs, font_xl_specs, font_xxl_specs -}; -const uint8_t *fontsTable[FONTS_COUNT] = { - font_std, font_bold, font_xxs, font_xs, font_l, font_xl, font_xxl -}; -const int fontsSizeTable[FONTS_COUNT] = { - sizeof(font_std), sizeof(font_bold), sizeof(font_xxs), - sizeof(font_xs), sizeof(font_l), sizeof(font_xl), - sizeof(font_xxl) -}; -#endif - -uint8_t * decompressFont(const uint8_t * font, unsigned len) +const lv_font_t* getFont(LcdFlags flags) { - int width = 0; - int height = 0; - - uint8_t* raw_font = BitmapBuffer::loadFont(font, len, width, height); - if (!raw_font) { - return nullptr; - } - - size_t font_size = width * height; - uint8_t * buf = (uint8_t *)malloc(font_size + 4); - - ((uint16_t*)buf)[0] = (uint16_t)width; - ((uint16_t*)buf)[1] = (uint16_t)height; - -#if defined(LCD_VERTICAL_INVERT) && 0 - uint8_t* src = raw_font + font_size - 1; - for(uint8_t* dst = buf + 4; src >= raw_font; --src, ++dst) { - *dst = 0xFF - *src; - } +#if defined(BOOT) + return LV_FONT_DEFAULT; #else - uint8_t* src = raw_font; - for(uint8_t* dst = buf + 4; src != raw_font + font_size; ++src, ++dst) { - *dst = 0xFF - *src; - } + auto fontIndex = FONT_INDEX(flags); + if (fontIndex >= FONTS_COUNT) return LV_FONT_DEFAULT; + return lvglFontTable[fontIndex]; #endif - - return buf; } -void loadFonts() +uint8_t getFontHeight(LcdFlags flags) { - static bool fontsLoaded = false; - if (fontsLoaded) - return; + auto font = getFont(flags); + return lv_font_get_line_height(font); +} -#if defined(BOOT) - fontsTable[0] = decompressFont(fontsTable[0], fontsSizeTable[0]); -#else - for (int i = 0; i < FONTS_COUNT; i++) { - fontsTable[i] = decompressFont(fontsTable[i], fontsSizeTable[i]); - } -#endif - - fontsLoaded = true; +int getTextWidth(const char * s, int len, LcdFlags flags) +{ + auto font = getFont(flags); + lv_coord_t letter_space = 0; + if (!len) len = strlen(s); + return lv_txt_get_width(s, len, font, letter_space, LV_TEXT_FLAG_EXPAND); } diff --git a/radio/src/gui/colorlcd/fonts.h b/radio/src/gui/colorlcd/fonts.h deleted file mode 100644 index 405fc136d..000000000 --- a/radio/src/gui/colorlcd/fonts.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * opentx - https://github.com/opentx/opentx - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#pragma once - -void loadFonts(); diff --git a/radio/src/gui/colorlcd/layouts/layout_factory_impl.cpp b/radio/src/gui/colorlcd/layouts/layout_factory_impl.cpp index 41f9fd0c8..44bcebbc1 100644 --- a/radio/src/gui/colorlcd/layouts/layout_factory_impl.cpp +++ b/radio/src/gui/colorlcd/layouts/layout_factory_impl.cpp @@ -57,15 +57,14 @@ void Layout::checkEvents() LayoutBase::checkEvents(); adjustLayout(); - uint32_t now = RTOS_GET_MS(); - if (now - lastRefresh >= LAYOUT_REFRESH) { - lastRefresh = now; - invalidate(); - -#if defined(DEBUG_WINDOWS) - TRACE_WINDOWS("# %s refresh: %s", factory->getId(), getWindowDebugString().c_str()); -#endif - } +// uint32_t now = RTOS_GET_MS(); +// if (now - lastRefresh >= LAYOUT_REFRESH) { +// lastRefresh = now; +// invalidate(); +// #if defined(DEBUG_WINDOWS) +// TRACE_WINDOWS("# %s refresh: %s", factory->getId(), getWindowDebugString().c_str()); +// #endif +// } } void Layout::setTrimsVisible(bool visible) diff --git a/radio/src/gui/colorlcd/lcd.cpp b/radio/src/gui/colorlcd/lcd.cpp index 0e93f4695..f92860886 100644 --- a/radio/src/gui/colorlcd/lcd.cpp +++ b/radio/src/gui/colorlcd/lcd.cpp @@ -22,64 +22,6 @@ #include "lcd.h" #include "opentx.h" -uint8_t getMappedChar(uint8_t c) -{ - uint8_t result; - - result = c - 0x20; - -// TRACE("getMappedChar '%c' (0x%x) = %d", c, c, result); - - return result; -} - -int getFontPatternWidth(const uint16_t * spec, int index) -{ - return spec[index + 2] - spec[index + 1]; -} - -int getCharWidth(uint8_t c, const uint16_t * spec) -{ - return getFontPatternWidth(spec, getMappedChar(c)); -} - -uint8_t getFontHeight(LcdFlags flags) -{ - uint32_t fontindex = FONT_INDEX(flags); - return fontspecsTable[fontindex][0]; -} - -int getTextWidth(const char * s, int len, LcdFlags flags) -{ - const uint16_t * specs = fontspecsTable[FONT_INDEX(flags)]; - - int result = 0; - for (int i = 0; len == 0 || i < len; ++i) { - unsigned c = uint8_t(*s); - if (!c) { - break; - } - else if (c >= 0xFE) { // CJK marker - s++; - c = uint8_t(*s) + ((c & 0x01) << 8) - 1; - if (c >= 0x100) - c -= 1; - c += CJK_FIRST_LETTER_INDEX; - result += getFontPatternWidth(specs, c) + 1; - } - else if ((c >= 0x20u) && (c < fontCharactersTable[FONT_INDEX(flags)] + 0x20u)) { - result += getCharWidth(c, specs); - } - else { - TRACE("char out-of bound: 0x%X", c); - } - - ++s; - } - - return result; -} - void lcdSetContrast() { lcdSetRefVolt(g_eeGeneral.contrast); diff --git a/radio/src/gui/colorlcd/lcd.h b/radio/src/gui/colorlcd/lcd.h index d3f4e0ba1..1535825e4 100644 --- a/radio/src/gui/colorlcd/lcd.h +++ b/radio/src/gui/colorlcd/lcd.h @@ -24,7 +24,6 @@ #include "bitmapbuffer.h" #include "opentx_types.h" -#include "libopenui_globals.h" #if LCD_W >= 480 #define LCD_COLS 40 diff --git a/radio/src/gui/colorlcd/select_fab_button.cpp b/radio/src/gui/colorlcd/select_fab_button.cpp index 40392048d..7bd8d89b8 100644 --- a/radio/src/gui/colorlcd/select_fab_button.cpp +++ b/radio/src/gui/colorlcd/select_fab_button.cpp @@ -40,19 +40,10 @@ SelectFabButton::SelectFabButton(FormGroup* parent, coord_t x, coord_t y, void SelectFabButton::paint(BitmapBuffer* dc) { FabButton::paint(dc); - auto pos = title.find('\n'); - auto y_pos = FAB_BUTTON_SIZE; - - dc->drawSizedText(width() / 2, y_pos, - title.c_str(), pos, - COLOR2FLAGS(WHITE) | CENTERED | VCENTERED); - - if (pos != std::string::npos) { - y_pos += PAGE_LINE_HEIGHT; - dc->drawSizedText(width() / 2, y_pos, title.substr(pos+1).c_str(), - 255, COLOR2FLAGS(WHITE) | CENTERED | VCENTERED); - } + dc->drawSizedText(width() / 2, FAB_BUTTON_SIZE, + title.c_str(), title.size(), + COLOR2FLAGS(WHITE) | CENTERED); if (hasFocus()) { dc->drawSolidRect(0, 0, width(), height(), 2, COLOR2FLAGS(WHITE)); diff --git a/radio/src/lv_conf.h b/radio/src/lv_conf.h index 36f395a92..c8b586e91 100644 --- a/radio/src/lv_conf.h +++ b/radio/src/lv_conf.h @@ -369,21 +369,22 @@ /*Optionally declare custom fonts here. *You can use these fonts as default font too and they will be available globally. *E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/ -#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(lv_font_roboto_14) \ - LV_FONT_DECLARE(lv_font_roboto_13) \ - LV_FONT_DECLARE(lv_font_roboto_15) \ - LV_FONT_DECLARE(lv_font_roboto_16) \ - LV_FONT_DECLARE(lv_font_roboto_17) \ - LV_FONT_DECLARE(lv_font_roboto_24) \ - LV_FONT_DECLARE(lv_font_roboto_64) \ - LV_FONT_DECLARE(lv_font_roboto_9) \ - LV_FONT_DECLARE(lv_font_roboto_bold_16) \ - LV_FONT_DECLARE(lv_font_roboto_bold_17) \ - LV_FONT_DECLARE(lv_font_roboto_bold_32) \ - LV_FONT_DECLARE(lv_font_roboto_bold_64) +#define LV_FONT_CUSTOM_DECLARE \ + LV_FONT_DECLARE(lv_font_roboto_9) \ + LV_FONT_DECLARE(lv_font_roboto_14) \ + LV_FONT_DECLARE(lv_font_roboto_13) \ + LV_FONT_DECLARE(lv_font_roboto_15) \ + LV_FONT_DECLARE(lv_font_roboto_16) \ + LV_FONT_DECLARE(lv_font_roboto_17) \ + LV_FONT_DECLARE(lv_font_roboto_24) \ + LV_FONT_DECLARE(lv_font_roboto_64) \ + LV_FONT_DECLARE(lv_font_roboto_bold_16) \ + LV_FONT_DECLARE(lv_font_roboto_bold_17) \ + LV_FONT_DECLARE(lv_font_roboto_bold_32) \ + LV_FONT_DECLARE(lv_font_roboto_bold_64) /*Always set a default font*/ -#define LV_FONT_DEFAULT &lv_font_roboto_14 +#define LV_FONT_DEFAULT &lv_font_roboto_16 /*Enable handling large font and/or fonts with a lot of characters. *The limit depends on the font size, font face and bpp. diff --git a/radio/src/model_init.cpp b/radio/src/model_init.cpp index ce3b3cf7b..1308f08be 100644 --- a/radio/src/model_init.cpp +++ b/radio/src/model_init.cpp @@ -122,8 +122,10 @@ void applyDefaultTemplate() #endif #if defined(COLORLCD) - //TODO: not sure yet we need it here + +#if !defined(GTESTS) loadDefaultLayout(); +#endif // enable switch warnings for (int i = 0; i < NUM_SWITCHES; i++) { diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index d357b341c..c7dc7fe4d 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1981,11 +1981,6 @@ int main() boardInit(); -#if defined(COLORLCD) - extern void loadFonts(); // TODO ? - loadFonts(); -#endif - #if !defined(SIMU) stackPaint(); #endif diff --git a/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt b/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt index 525bc1e37..d2a119164 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt +++ b/radio/src/targets/common/arm/stm32/bootloader/CMakeLists.txt @@ -115,7 +115,6 @@ if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14) ../../../../../gui/colorlcd/fonts.cpp ../../../../../gui/colorlcd/colors.cpp ../../../../../thirdparty/libopenui/src/bitmapbuffer.cpp - ../../../../../thirdparty/libopenui/src/libopenui_globals.cpp ../../../../../targets/${TARGET_DIR}/sdram_driver.c ../../../../../targets/common/arm/stm32/sdio_sd.c ../../../../../targets/common/arm/stm32/rtc_driver.cpp diff --git a/radio/src/targets/horus/bootloader/boot_menu.cpp b/radio/src/targets/horus/bootloader/boot_menu.cpp index 089bb3868..b346ec024 100644 --- a/radio/src/targets/horus/bootloader/boot_menu.cpp +++ b/radio/src/targets/horus/bootloader/boot_menu.cpp @@ -72,10 +72,7 @@ const uint8_t LBM_OK[] = { void bootloaderInitScreen() { backlightEnable(BACKLIGHT_LEVEL_MAX); - - // TODO: load/decompress bitmaps - extern void loadFonts(); - loadFonts(); + // TODO: init LVGL } static void bootloaderDrawTitle(unsigned int x, const char* text) diff --git a/radio/src/targets/nv14/bootloader/boot_menu.cpp b/radio/src/targets/nv14/bootloader/boot_menu.cpp index af6d49cee..50193a90b 100644 --- a/radio/src/targets/nv14/bootloader/boot_menu.cpp +++ b/radio/src/targets/nv14/bootloader/boot_menu.cpp @@ -76,11 +76,7 @@ const uint8_t LBM_OK[] = { void bootloaderInitScreen() { backlightEnable(BACKLIGHT_LEVEL_MAX); - - // TODO: load/decompress bitmaps - extern void loadFonts(); - loadFonts(); - + // TODO: init LVGL } static void bootloaderDrawTitle(const char* text) diff --git a/radio/src/targets/nv14/lcd_driver.cpp b/radio/src/targets/nv14/lcd_driver.cpp index 8478eef17..3f4c8f896 100644 --- a/radio/src/targets/nv14/lcd_driver.cpp +++ b/radio/src/targets/nv14/lcd_driver.cpp @@ -1286,7 +1286,6 @@ void LCD_LayerInit() { LTDC_DitherCmd(ENABLE); } -extern void loadFonts(); const char* boardLcdType = ""; void LCD_SetLayer(uint32_t layer) @@ -1302,15 +1301,17 @@ void LCD_SetLayer(uint32_t layer) currentLayer = layer; } -void lcdInit(void) { +void lcdInit(void) +{ // Clear buffers first memset(LCD_FIRST_FRAME_BUFFER, 0, sizeof(LCD_FIRST_FRAME_BUFFER)); memset(LCD_SECOND_FRAME_BUFFER, 0, sizeof(LCD_SECOND_FRAME_BUFFER)); - loadFonts(); /* Configure the LCD SPI+RESET pins */ lcdSpiConfig(); + // TODO: init lVGL + /* Reset the LCD --------------------------------------------------------*/ lcdReset(); diff --git a/radio/src/tests/conversions.cpp b/radio/src/tests/conversions.cpp index 957ba5fdd..675b66c68 100644 --- a/radio/src/tests/conversions.cpp +++ b/radio/src/tests/conversions.cpp @@ -308,7 +308,7 @@ TEST(Conversions, ConversionX10From23) char modelname[] = "model1.bin"; convertBinModelData(modelname, 219); - loadModel(modelname); + EXPECT_EQ(nullptr, readModel(modelname,(uint8_t*)&g_model, sizeof(g_model))); EXPECT_EQ(100, g_eeGeneral.calib[CALIBRATED_SLIDER_REAR_LEFT].spanNeg); EXPECT_EQ(500, g_eeGeneral.calib[CALIBRATED_SLIDER_REAR_LEFT].mid); @@ -380,7 +380,7 @@ TEST(Conversions, ConversionX12SFrom23) char modelname[] = "model1.bin"; convertBinModelData(modelname, 219); - loadModel(modelname); + EXPECT_EQ(nullptr, readModel(modelname,(uint8_t*)&g_model, sizeof(g_model))); EXPECT_EQ(-30, g_eeGeneral.vBatMin); EXPECT_EQ(8, g_eeGeneral.speakerVolume); @@ -444,7 +444,7 @@ TEST(Conversions, ConversionTX16SFrom25) char modelname[] = "model1.bin"; convertBinModelData(modelname, 220); - loadModel(modelname); + EXPECT_EQ(nullptr, readModel(modelname,(uint8_t*)&g_model, sizeof(g_model))); EXPECT_EQ(-23, g_eeGeneral.vBatMin); EXPECT_EQ(0, g_eeGeneral.speakerVolume); @@ -484,9 +484,9 @@ TEST(Conversions, ConversionTX16SFrom25) char modelname2[] = "model2.bin"; convertBinModelData(modelname2, 220); - loadModel(modelname2); + EXPECT_EQ(nullptr, readModel(modelname2,(uint8_t*)&g_model, sizeof(g_model))); writeModelYaml(modelname2); - loadModel(modelname2); + EXPECT_EQ(nullptr, readModel(modelname2,(uint8_t*)&g_model, sizeof(g_model))); constexpr swarnstate_t swWarnState = (0x01) |// SA up diff --git a/radio/src/tests/lcd_480x272.cpp b/radio/src/tests/lcd_480x272.cpp index 600d71f69..38a40fb50 100644 --- a/radio/src/tests/lcd_480x272.cpp +++ b/radio/src/tests/lcd_480x272.cpp @@ -32,7 +32,7 @@ #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" -/* + void convert_RGB565_to_RGB888(uint8_t * dst, const BitmapBuffer * src, coord_t w, coord_t h) { for(int y = 0; y < src->height(); y++) { @@ -91,6 +91,38 @@ bool checkScreenshot_colorlcd(const BitmapBuffer* dc, const char* test) return true; } +#include "lvgl/src/draw/sw/lv_draw_sw.h" + +static lv_disp_t fake_disp; +static lv_disp_drv_t fake_drv; +static lv_area_t fake_draw_area = { 0, 0, LCD_W-1, LCD_H-1 }; +static lv_draw_ctx_t* draw_ctx = nullptr; + +static void init_fake_disp(BitmapBuffer* dc) +{ + if (!draw_ctx) { + lv_init(); + lv_memset_00(&fake_disp, sizeof(lv_disp_t)); + fake_disp.driver = &fake_drv; + + lv_disp_drv_init(fake_disp.driver); + fake_disp.driver->hor_res = LCD_W; + fake_disp.driver->ver_res = LCD_H; + + draw_ctx = (lv_draw_ctx_t*)lv_mem_alloc(sizeof(lv_draw_sw_ctx_t)); + LV_ASSERT_MALLOC(draw_ctx); + if(draw_ctx == NULL) return; + lv_draw_sw_init_ctx(&fake_drv, draw_ctx); + fake_disp.driver->draw_ctx = draw_ctx; + draw_ctx->clip_area = &fake_draw_area; + draw_ctx->buf_area = &fake_draw_area; + } + + _lv_refr_set_disp_refreshing(&fake_disp); + draw_ctx->buf = (void *)dc->getData(); + dc->setDrawCtx(draw_ctx); +} + TEST(Lcd_colorlcd, lines) { BitmapBuffer dc(BMP_RGB565, LCD_W, LCD_H); @@ -111,8 +143,6 @@ TEST(Lcd_colorlcd, lines) TEST(Lcd_colorlcd, vline) { - loadFonts(); - BitmapBuffer dc(BMP_RGB565, LCD_W, LCD_H); dc.clear(COLOR_THEME_SECONDARY3); @@ -124,9 +154,9 @@ TEST(Lcd_colorlcd, vline) TEST(Lcd_colorlcd, primitives) { - loadFonts(); - BitmapBuffer dc(BMP_RGB565, LCD_W, LCD_H); + init_fake_disp(&dc); + dc.clear(COLOR_THEME_SECONDARY3); dc.drawText(8, 8, "The quick brown fox jumps over the lazy dog", COLOR_THEME_DISABLED); @@ -155,14 +185,12 @@ TEST(Lcd_colorlcd, primitives) TEST(Lcd_colorlcd, transparency) { - loadFonts(); - BitmapBuffer dc(BMP_RGB565, LCD_W, LCD_H); + init_fake_disp(&dc); + dc.clear(COLOR_THEME_SECONDARY3); - // , OPACITY(4) dc.drawText(8, 8, "The quick brown fox jumps over the lazy dog", COLOR_THEME_SECONDARY1); - // , OPACITY(12) dc.drawText(5, 5, "The quick brown fox jumps over the lazy dog", COLOR_THEME_SECONDARY1); dc.drawFilledRect(10, 30, 30, 30, SOLID, COLOR_THEME_SECONDARY1, OPACITY(8)); @@ -204,16 +232,13 @@ TEST(Lcd_colorlcd, transparency) #if 0 TEST(Lcd_colorlcd, fonts) { - loadFonts(); - BitmapBuffer dc(BMP_RGB565, LCD_W, LCD_H); + init_fake_disp(&dc); + dc.clear(COLOR_THEME_SECONDARY3); - dc.drawText(8, 8, "The quick brown fox jumps over the lazy dog", COLOR_THEME_SECONDARY1|OPACITY(4)); - dc.drawText(5, 5, "The quick brown fox jumps over the lazy dog", COLOR_THEME_SECONDARY1|OPACITY(12)); - - dc.drawText(10, 200, "The quick", COLOR_THEME_SECONDARY1|VERTICAL); - dc.drawText(30, 200, "The quick brown fox", COLOR_THEME_SECONDARY1|VERTICAL); + dc.drawText(8, 8, "The quick brown fox jumps over the lazy dog", COLOR_THEME_SECONDARY1); + dc.drawText(5, 5, "The quick brown fox jumps over the lazy dog", COLOR_THEME_SECONDARY1); dc.drawText(50, 25, "The quick", COLOR_THEME_SECONDARY1 | FONT(XXS)); dc.drawText(50, 40, "The quick", COLOR_THEME_SECONDARY1 | FONT(XS)); @@ -221,8 +246,8 @@ TEST(Lcd_colorlcd, fonts) dc.drawText(50, 80, "The quick", COLOR_THEME_SECONDARY1 | FONT(XL)); dc.drawText(50, 120, "The quick", COLOR_THEME_SECONDARY1 | FONT(XXL)); - dc.drawText(8, 208, "The quick brown fox jumps over the lazy dog", COLOR_THEME_SECONDARY1|OPACITY(4)); - dc.drawText(5, 205, "The quick brown fox jumps over the lazy dog", COLOR_THEME_SECONDARY1|OPACITY(12)); + dc.drawText(8, 208, "The quick brown fox jumps over the lazy dog", COLOR_THEME_SECONDARY1); + dc.drawText(5, 205, "The quick brown fox jumps over the lazy dog", COLOR_THEME_SECONDARY1); EXPECT_TRUE(checkScreenshot_colorlcd(&dc, "fonts_" TRANSLATIONS)); } @@ -230,8 +255,6 @@ TEST(Lcd_colorlcd, fonts) TEST(Lcd_colorlcd, clipping) { - loadFonts(); - BitmapBuffer dc(BMP_RGB565, LCD_W, LCD_H); dc.clear(COLOR_THEME_SECONDARY3); @@ -286,6 +309,7 @@ TEST(Lcd_colorlcd, masks) EXPECT_TRUE(checkScreenshot_colorlcd(&dc, "masks")); } +#if 0 constexpr coord_t LBM_USB_PLUGGED_W = 211; constexpr coord_t LBM_USB_PLUGGED_H = 110; @@ -307,5 +331,5 @@ TEST(Lcd_colorlcd, darkmode) EXPECT_TRUE(checkScreenshot_colorlcd(&dc, "darkmode_" TRANSLATIONS)); } -*/ +#endif #endif diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index e1b35d747..7e03db94c 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit e1b35d747a99c9e9ec219139272d0f210faa4099 +Subproject commit 7e03db94cdc1f684e028fad2b211dca0d94c675d