From 7825fc63a0b098f9d5a80b3ee5014549b4ce1c88 Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Tue, 13 Oct 2020 20:12:34 -0300 Subject: [PATCH] Watchdog Refresh for LVGL Asset Load (#19724) --- Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp | 17 +++++++++++++++-- .../extui/lib/mks_ui/tft_lvgl_configuration.cpp | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp index d6f5fbf8b5..07ac563802 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp @@ -266,19 +266,24 @@ void spiFlashErase_PIC() { W25QXX.init(SPI_QUARTER_SPEED); //erase 0x001000 -64K for (pic_sectorcnt = 0; pic_sectorcnt < (64 - 4) / 4; pic_sectorcnt++) { + watchdog_refresh(); W25QXX.SPI_FLASH_SectorErase(PICINFOADDR + pic_sectorcnt * 4 * 1024); } //erase 64K -- 6M - for (pic_sectorcnt = 0; pic_sectorcnt < (PIC_SIZE_xM * 1024 / 64 - 1); pic_sectorcnt++) + for (pic_sectorcnt = 0; pic_sectorcnt < (PIC_SIZE_xM * 1024 / 64 - 1); pic_sectorcnt++) { + watchdog_refresh(); W25QXX.SPI_FLASH_BlockErase((pic_sectorcnt + 1) * 64 * 1024); + } } #if HAS_SPI_FLASH_FONT void spiFlashErase_FONT() { volatile uint32_t Font_sectorcnt = 0; W25QXX.init(SPI_QUARTER_SPEED); - for (Font_sectorcnt = 0; Font_sectorcnt < 32-1; Font_sectorcnt++) + for (Font_sectorcnt = 0; Font_sectorcnt < 32-1; Font_sectorcnt++) { + watchdog_refresh(); W25QXX.SPI_FLASH_BlockErase(FONTINFOADDR + Font_sectorcnt * 64 * 1024); + } } #endif @@ -410,6 +415,7 @@ uint8_t public_buf[512]; return; } + watchdog_refresh(); disp_assets_update_progress(fn); W25QXX.init(SPI_QUARTER_SPEED); @@ -422,18 +428,21 @@ uint8_t public_buf[512]; totalSizeLoaded += pfileSize; if (assetType == ASSET_TYPE_LOGO) { do { + watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); Pic_Logo_Write((uint8_t *)fn, public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); } else if (assetType == ASSET_TYPE_TITLE_LOGO) { do { + watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); Pic_TitleLogo_Write((uint8_t *)fn, public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); } else if (assetType == ASSET_TYPE_G_PREVIEW) { do { + watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); default_view_Write(public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); @@ -443,6 +452,7 @@ uint8_t public_buf[512]; SPIFlash.beginWrite(Pic_Write_Addr); #if HAS_SPI_FLASH_COMPRESSION do { + watchdog_refresh(); pbr = file.read(public_buf, SPI_FLASH_PageSize); TERN_(MARLIN_DEV_MODE, totalSizes += pbr); SPIFlash.writeData(public_buf, SPI_FLASH_PageSize); @@ -463,6 +473,7 @@ uint8_t public_buf[512]; else if (assetType == ASSET_TYPE_FONT) { Pic_Write_Addr = UNIGBK_FLASH_ADDR; do { + watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); W25QXX.SPI_FLASH_BufferWrite(public_buf, Pic_Write_Addr, pbr); Pic_Write_Addr += pbr; @@ -482,9 +493,11 @@ uint8_t public_buf[512]; disp_assets_update(); disp_assets_update_progress("Erasing pics..."); + watchdog_refresh(); spiFlashErase_PIC(); #if HAS_SPI_FLASH_FONT disp_assets_update_progress("Erasing fonts..."); + watchdog_refresh(); spiFlashErase_FONT(); #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp index ccb6a8e4dc..c0cd14d70d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp @@ -123,8 +123,11 @@ void tft_lvgl_init() { //spi_flash_read_test(); #if ENABLED(SDSUPPORT) + watchdog_refresh(); UpdateAssets(); #endif + + watchdog_refresh(); mks_test_get(); touch.Init();