From f8843b25b04723c8799ea64f07f7c2d266e1a7f7 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Wed, 1 Apr 2020 22:09:49 +0300 Subject: [PATCH] :sparkles: Progress bar for check_file() --- Firmware/ultralcd.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index daf9f017..6b140910 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -8760,20 +8760,33 @@ static void lcd_selftest_screen_step(int _row, int _col, int _state, const char static bool check_file(const char* filename) { if (farm_mode) return true; - bool result = false; - uint32_t filesize; card.openFile((char*)filename, true); - filesize = card.getFileSize(); + bool result = false; + const uint32_t filesize = card.getFileSize(); + uint32_t startPos = 0; + const uint16_t bytesToCheck = min(END_FILE_SECTION, filesize); if (filesize > END_FILE_SECTION) { - card.setIndex(filesize - END_FILE_SECTION); - + startPos = filesize - END_FILE_SECTION; + card.setIndex(startPos); } - - while (!card.eof() && !result) { + + lcd_clear(); + lcd_puts_at_P(0, 1, _i("Checking file"));////c=20 r=1 + printf_P(PSTR("startPos=%lu\n"), startPos); + while (!card.eof() && !result) { + lcd_set_cursor(0, 2); + for (int column = 0; column < 20; column++) { + const int8_t percent = ((card.get_sdpos() - startPos) * 100) / bytesToCheck; + if (column < (percent / 5)) + { + lcd_set_cursor(column, 2); + lcd_print('\xFF'); //simple progress bar + } + } + card.sdprinting = true; get_command(); result = check_commands(); - } card.printingHasFinished(); strncpy_P(lcd_status_message, _T(WELCOME_MSG), LCD_WIDTH);