From 6615717fd4b290f186bae8b58c4c9008023c5fcd Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 8 Apr 2019 18:24:18 +0200 Subject: [PATCH] add lcd_print_stop() function --- Firmware/ultralcd.cpp | 67 +++++++++++++++++++++++-------------------- Firmware/ultralcd.h | 1 + 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 7776b79d2..8a86b2c15 100644 --- a/Firmware/ultralcd.cpp +++ b/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(); } } diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 511ba6ae1..060848ecb 100644 --- a/Firmware/ultralcd.h +++ b/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();