Merge pull request #2573 from leptun/MK3_filecheck_progress_bar
✨Progress bar for check_file()
This commit is contained in:
commit
04bb4b5dad
|
|
@ -8781,22 +8781,35 @@ static void lcd_selftest_screen_step(int _row, int _col, int _state, const char
|
||||||
|
|
||||||
static bool check_file(const char* filename) {
|
static bool check_file(const char* filename) {
|
||||||
if (farm_mode) return true;
|
if (farm_mode) return true;
|
||||||
bool result = false;
|
|
||||||
uint32_t filesize;
|
|
||||||
card.openFile((char*)filename, true);
|
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);
|
||||||
|
uint8_t blocksPrinted = 0;
|
||||||
if (filesize > END_FILE_SECTION) {
|
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
|
||||||
|
lcd_set_cursor(0, 2);
|
||||||
|
while (!card.eof() && !result) {
|
||||||
|
for (; blocksPrinted < (((card.get_sdpos() - startPos) * LCD_WIDTH) / bytesToCheck); blocksPrinted++)
|
||||||
|
lcd_print('\xFF'); //simple progress bar
|
||||||
|
|
||||||
card.sdprinting = true;
|
card.sdprinting = true;
|
||||||
get_command();
|
get_command();
|
||||||
result = check_commands();
|
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();
|
card.printingHasFinished();
|
||||||
|
|
||||||
strncpy_P(lcd_status_message, _T(WELCOME_MSG), LCD_WIDTH);
|
strncpy_P(lcd_status_message, _T(WELCOME_MSG), LCD_WIDTH);
|
||||||
lcd_finishstatus();
|
lcd_finishstatus();
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue