diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 6970cabb0..620819daa 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -456,27 +456,35 @@ void checkFanSpeed() if ((fan_speed_errors[1] > 15) && fans_check_enabled) fanSpeedError(1); //print fan } +extern void stop_and_save_print_to_ram(float z_move, float e_move); +extern void restore_print_from_ram_and_continue(float e_move); + void fanSpeedError(unsigned char _fan) { if (card.sdprinting) { - card.pauseSDPrint(); + if(heating_status != 0) lcd_print_stop(); + else lcd_sdcard_pause(); } setTargetHotend0(0); - /*lcd_update(); + + //lcd_update(); WRITE(BEEPER, HIGH); - delayMicroseconds(500); + delayMicroseconds(2000); WRITE(BEEPER, LOW); - delayMicroseconds(100);*/ + delayMicroseconds(100); SERIAL_ERROR_START; switch (_fan) { case 0: + fanSpeed = 255; + //lcd_print_stop(); SERIAL_ERRORLNPGM("ERROR: Extruder fan speed is lower then expected"); LCD_ALERTMESSAGEPGM("Err: EXTR. FAN ERROR"); break; case 1: + //stop_and_save_print_to_ram(0, 0); SERIAL_ERRORLNPGM("ERROR: Print fan speed is lower then expected"); LCD_ALERTMESSAGEPGM("Err: PRINT FAN ERROR"); break; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 9959cd5de..4c0acb63e 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -820,7 +820,7 @@ static void lcd_return_to_status() { } -static void lcd_sdcard_pause() { +void lcd_sdcard_pause() { lcd_return_to_status(); lcd_commands_type = LCD_COMMAND_LONG_PAUSE; @@ -4140,6 +4140,39 @@ 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; + + // Turn off the print fan + SET_OUTPUT(FAN_PIN); + WRITE(FAN_PIN, 0); + fanSpeed = 0; +} void lcd_sdcard_stop() { @@ -4167,37 +4200,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; - - // 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 6276abf34..9b749a337 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -26,6 +26,8 @@ void lcd_loading_color(); void lcd_force_language_selection(); void lcd_sdcard_stop(); + void lcd_sdcard_pause(); + void lcd_print_stop(); void prusa_statistics(int _message); void lcd_confirm_print(); void lcd_mylang();