Browse Source

add lcd_print_stop() function

PavelSindler 5 years ago
parent
commit
6615717fd4
2 changed files with 37 additions and 31 deletions
  1. 36 31
      Firmware/ultralcd.cpp
  2. 1 0
      Firmware/ultralcd.h

+ 36 - 31
Firmware/ultralcd.cpp

@@ -4872,6 +4872,41 @@ static void lcd_sd_updir()
   currentMenuViewOffset = 0;
 }
 
+void lcd_print_stop() {
+		cancel_heatup = true;
+#ifdef MESH_BED_LEVELING
+		mbl.active = false;
+#endif
+		// Stop the stoppers, update the position from the stoppers.
+		if (mesh_bed_leveling_flag == false && homing_flag == false) {
+			planner_abort_hard();
+			// Because the planner_abort_hard() initialized current_position[Z] from the stepper,
+			// Z baystep is no more applied. Reset it.
+			babystep_reset();
+		}
+		// Clean the input command queue.
+		cmdqueue_reset();
+		lcd_setstatuspgm(MSG_PRINT_ABORTED);
+		lcd_update(2);
+		card.sdprinting = false;
+		card.closefile();
+
+		stoptime = millis();
+		unsigned long t = (stoptime - starttime - pause_time) / 1000; //time in s
+		pause_time = 0;
+		save_statistics(total_filament_used, t);
+		lcd_return_to_status();
+		lcd_ignore_click(true);
+		lcd_commands_type = LCD_COMMAND_STOP_PRINT;
+		if (farm_mode) prusa_statistics(7);
+		// Turn off the print fan
+		SET_OUTPUT(FAN_PIN);
+		WRITE(FAN_PIN, 0);
+		fanSpeed=0;
+}
+
+
+
 
 void lcd_sdcard_stop()
 {
@@ -4899,37 +4934,7 @@ void lcd_sdcard_stop()
 		}
 		if ((int32_t)encoderPosition == 2)
 		{
-		cancel_heatup = true;
-        #ifdef MESH_BED_LEVELING
-        mbl.active = false;
-        #endif
-        // Stop the stoppers, update the position from the stoppers.
-		if (mesh_bed_leveling_flag == false && homing_flag == false) {
-			planner_abort_hard();
-			// Because the planner_abort_hard() initialized current_position[Z] from the stepper,
-			// Z baystep is no more applied. Reset it.
-			babystep_reset();
-		}
-        // Clean the input command queue.
-        cmdqueue_reset();
-				lcd_setstatuspgm(MSG_PRINT_ABORTED);
-				lcd_update(2);
-				card.sdprinting = false;
-				card.closefile();
-
-				stoptime = millis();
-				unsigned long t = (stoptime - starttime - pause_time) / 1000; //time in s
-				pause_time = 0;
-				save_statistics(total_filament_used, t);
-
-				lcd_return_to_status();
-				lcd_ignore_click(true);
-				lcd_commands_type = LCD_COMMAND_STOP_PRINT;
-				if (farm_mode) prusa_statistics(7);
-                // Turn off the print fan
-                SET_OUTPUT(FAN_PIN);
-                WRITE(FAN_PIN, 0);
-                fanSpeed=0;
+			lcd_print_stop();
 		}
 	}
 

+ 1 - 0
Firmware/ultralcd.h

@@ -31,6 +31,7 @@
   unsigned char lcd_choose_color();
   void lcd_mylang();
   bool lcd_detected(void);
+  void lcd_print_stop();
 
   
   void lcd_menu_statistics();