Skip to content

Commit

Permalink
Watchdog Refresh for LVGL Asset Load (MarlinFirmware#19724)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhapsodyv authored and thinkyhead committed Oct 16, 2020
1 parent fd8d83b commit f7f1224
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -410,6 +415,7 @@ uint8_t public_buf[512];
return;
}

watchdog_refresh();
disp_assets_update_progress(fn);

W25QXX.init(SPI_QUARTER_SPEED);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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

Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f7f1224

Please sign in to comment.