From 43ace00a243cc221b8bfcdc4b61c2e5f16a784d4 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Thu, 12 Nov 2020 18:43:48 +0200 Subject: [PATCH] Fill the progress bar at the end and code optimizations --- Firmware/ultralcd.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 15d0d68c7..0a2236f4a 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -8786,6 +8786,7 @@ static bool check_file(const char* filename) { const uint32_t filesize = card.getFileSize(); uint32_t startPos = 0; const uint16_t bytesToCheck = min(END_FILE_SECTION, filesize); + uint8_t blocksPrinted = 0; if (filesize > END_FILE_SECTION) { startPos = filesize - END_FILE_SECTION; card.setIndex(startPos); @@ -8793,23 +8794,23 @@ static bool check_file(const char* filename) { lcd_clear(); lcd_puts_at_P(0, 1, _i("Checking file"));////c=20 r=1 + lcd_set_cursor(0, 2); 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 - } - } + for (; blocksPrinted < (((card.get_sdpos() - startPos) * LCD_WIDTH) / bytesToCheck); blocksPrinted++) + lcd_print('\xFF'); //simple progress bar card.sdprinting = true; get_command(); result = check_commands(); } + + for (; blocksPrinted < LCD_WIDTH; blocksPrinted++) + lcd_print('\xFF'); //simple progress bar + _delay(100); //for the user to see the end of the progress bar. + card.printingHasFinished(); + strncpy_P(lcd_status_message, _T(WELCOME_MSG), LCD_WIDTH); lcd_finishstatus(); return result;