Explorar el Código

Factory reset and check_file progress bar

Alex Voinea hace 3 años
padre
commit
204da1cc3f
Se han modificado 2 ficheros con 10 adiciones y 32 borrados
  1. 6 20
      Firmware/Marlin_main.cpp
  2. 4 12
      Firmware/ultralcd.cpp

+ 6 - 20
Firmware/Marlin_main.cpp

@@ -710,7 +710,6 @@ void softReset()
 // Factory reset function
 // This function is used to erase parts or whole EEPROM memory which is used for storing calibration and and so on.
 // Level input parameter sets depth of reset
-int  er_progress = 0;
 static void factory_reset(char level)
 {	
 	lcd_clear();
@@ -790,28 +789,15 @@ static void factory_reset(char level)
 			// Level 3: erase everything, whole EEPROM will be set to 0xFF
 
 		case 3:
-			lcd_puts_P(PSTR("Factory RESET"));
-			lcd_puts_at_P(1, 2, PSTR("ERASING all data"));
-
-      Sound_MakeCustom(100,0,false);
-			er_progress = 0;
-			lcd_puts_at_P(3, 3, PSTR("      "));
-			lcd_set_cursor(3, 3);
-			lcd_print(er_progress);
-
+			menu_progressbar_init(EEPROM_TOP, PSTR("ERASING all data"));
+			Sound_MakeCustom(100,0,false);
+			
 			// Erase EEPROM
-			for (int i = 0; i < 4096; i++) {
+			for (uint16_t i = 0; i < EEPROM_TOP; i++) {
 				eeprom_update_byte((uint8_t*)i, 0xFF);
-
-				if (i % 41 == 0) {
-					er_progress++;
-					lcd_puts_at_P(3, 3, PSTR("      "));
-					lcd_set_cursor(3, 3);
-					lcd_print(er_progress);
-					lcd_puts_P(PSTR("%"));
-				}
-
+				menu_progressbar_update(i);
 			}
+			menu_progressbar_finish();
 			softReset();
 
 

+ 4 - 12
Firmware/ultralcd.cpp

@@ -8403,7 +8403,6 @@ 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);
@@ -8411,22 +8410,15 @@ static bool check_file(const char* filename) {
 	cmdqueue_reset();
 	cmdqueue_serial_disabled = true;
 
-	lcd_clear();
-	lcd_puts_at_P(0, 1, _i("Checking file"));////c=20 r=1
-	lcd_set_cursor(0, 2);
+	menu_progressbar_init(bytesToCheck, _i("Checking file"));
 	while (!card.eof() && !result) {
-		for (; blocksPrinted < (((card.get_sdpos() - startPos) * LCD_WIDTH) / bytesToCheck); blocksPrinted++)
-			lcd_print('\xFF'); //simple progress bar
-
+		menu_progressbar_update(card.get_sdpos() - startPos);
 		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.
-
+	
+	menu_progressbar_finish();
 	
 	cmdqueue_serial_disabled = false;
 	card.printingHasFinished();