From f8a0d5d7737476f13c0699b1b9a879df4eddd78a Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 7 Jan 2020 19:51:30 +0200 Subject: [PATCH 1/4] Fix lcd_print_stop function --- Firmware/Marlin_main.cpp | 29 ++++++++++++----------- Firmware/ultralcd.cpp | 50 ++++++++++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 26 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 507a8f83e..62bfb68da 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4692,13 +4692,13 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) // We don't know where we are! HOME! // Push the commands to the front of the message queue in the reverse order! // There shall be always enough space reserved for these commands. - if (lcd_commands_type != LcdCommands::StopPrint) { + // if (lcd_commands_type != LcdCommands::StopPrint) { repeatcommand_front(); // repeat G80 with all its parameters enquecommand_front_P((PSTR("G28 W0"))); - } - else { - mesh_bed_leveling_flag = false; - } + // } + // else { + // mesh_bed_leveling_flag = false; + // } break; } @@ -4728,23 +4728,23 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) #ifndef PINDA_THERMISTOR if (run == false && temp_cal_active == true && calibration_status_pinda() == true && target_temperature_bed >= 50) { - if (lcd_commands_type != LcdCommands::StopPrint) { + // if (lcd_commands_type != LcdCommands::StopPrint) { temp_compensation_start(); run = true; repeatcommand_front(); // repeat G80 with all its parameters enquecommand_front_P((PSTR("G28 W0"))); - } - else { - mesh_bed_leveling_flag = false; - } + // } + // else { + // mesh_bed_leveling_flag = false; + // } break; } run = false; #endif //PINDA_THERMISTOR - if (lcd_commands_type == LcdCommands::StopPrint) { - mesh_bed_leveling_flag = false; - break; - } + // if (lcd_commands_type == LcdCommands::StopPrint) { + // mesh_bed_leveling_flag = false; + // break; + // } // Save custom message state, set a new custom message state to display: Calibrating point 9. CustomMsg custom_message_type_old = custom_message_type; unsigned int custom_message_state_old = custom_message_state; @@ -8948,6 +8948,7 @@ static void wait_for_heater(long codenum, uint8_t extruder) { residencyStart = -1; /* continue to loop until we have reached the target temp _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */ + cancel_heatup = false; while ((!cancel_heatup) && ((residencyStart == -1) || (residencyStart >= 0 && (((unsigned int)(_millis() - residencyStart)) < (TEMP_RESIDENCY_TIME * 1000UL))))) { #else diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index d988e5488..d8b3e817b 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -250,7 +250,9 @@ static void fil_unload_menu(); static void lcd_disable_farm_mode(); static void lcd_set_fan_check(); static void lcd_cutter_enabled(); +#ifdef SNMM static char snmm_stop_print_menu(); +#endif //SNMM #ifdef SDCARD_SORT_ALPHA static void lcd_sort_type_set(); #endif @@ -1056,7 +1058,7 @@ static void lcd_status_screen() } if (current_click - && (lcd_commands_type != LcdCommands::StopPrint) //click is aborted unless stop print finishes + // && (lcd_commands_type != LcdCommands::StopPrint) //click is aborted unless stop print finishes && ( menu_block_entering_on_serious_errors == SERIOUS_ERR_NONE ) // or a serious error blocks entering the menu ) { @@ -1466,7 +1468,7 @@ void lcd_commands() } #endif // not SNMM - +/* if (lcd_commands_type == LcdCommands::StopPrint) /// stop print { @@ -1558,6 +1560,7 @@ void lcd_commands() lcd_commands_step = 7; } } +*/ if (lcd_commands_type == LcdCommands::FarmModeConfirm) /// farm mode confirm { @@ -6051,7 +6054,7 @@ void bowden_menu() { } } -//#ifdef SNMM +#ifdef SNMM static char snmm_stop_print_menu() { //menu for choosing which filaments will be unloaded in stop print lcd_clear(); @@ -6102,6 +6105,8 @@ static char snmm_stop_print_menu() { //menu for choosing which filaments will be } +#endif //SNMM + //! @brief Select one of numbered items //! //! Create list of items with header. Header can not be selected. @@ -7320,7 +7325,6 @@ void lcd_print_stop() // Clear any saved printing state cancel_saved_printing(); - cancel_heatup = true; // Abort the planner/queue/sd planner_abort_hard(); @@ -7331,19 +7335,41 @@ void lcd_print_stop() CRITICAL_SECTION_END; +#ifdef MESH_BED_LEVELING + mbl.active = false; //also prevents undoing the mbl compensation a second time in the second planner_abort_hard() +#endif + lcd_setstatuspgm(_T(MSG_PRINT_ABORTED)); 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_step = 0; - lcd_commands_type = LcdCommands::StopPrint; - // Turn off the print fan - SET_OUTPUT(FAN_PIN); - WRITE(FAN_PIN, 0); - fanSpeed = 0; + + lcd_commands_step = 0; + lcd_commands_type = LcdCommands::Idle; + + lcd_cooldown(); //turns off heaters and fan; goes to status screen. + cancel_heatup = true; //unroll temperature wait loop stack. + + current_position[Z_AXIS] += 10; //lift Z. + plan_buffer_line_curposXYZE(manual_feedrate[Z_AXIS] / 60, active_extruder); + + if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) //if axis are homed, move to parked position. + { + current_position[X_AXIS] = X_CANCEL_POS; + current_position[Y_AXIS] = Y_CANCEL_POS; + plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder); + } + st_synchronize(); + + if (mmu_enabled) extr_unload(); //M702 C + + finishAndDisableSteppers(); //M84 + + lcd_setstatuspgm(_T(WELCOME_MSG)); + custom_message_type = CustomMsg::Status; + + planner_abort_hard(); //needs to be done since plan_buffer_line resets waiting_inside_plan_buffer_line_print_aborted to false. Also copies current to destination. } void lcd_sdcard_stop() From 4422fc29f8c020347133e63b3fab67b4fd2cbe18 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 7 Jan 2020 20:42:21 +0200 Subject: [PATCH 2/4] Set XYZ to absolute and E to relative --- Firmware/ultralcd.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index d8b3e817b..44e9b4371 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7370,6 +7370,11 @@ void lcd_print_stop() custom_message_type = CustomMsg::Status; planner_abort_hard(); //needs to be done since plan_buffer_line resets waiting_inside_plan_buffer_line_print_aborted to false. Also copies current to destination. + + axis_relative_modes[X_AXIS] = false; + axis_relative_modes[Y_AXIS] = false; + axis_relative_modes[Z_AXIS] = false; + axis_relative_modes[E_AXIS] = true; } void lcd_sdcard_stop() From 1996fc79409789d09dcc4c8bb21b4732df920679 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 7 Jan 2020 20:43:56 +0200 Subject: [PATCH 3/4] Remove commented-out code --- Firmware/Marlin_main.cpp | 26 +++-------- Firmware/ultralcd.cpp | 94 ---------------------------------------- 2 files changed, 6 insertions(+), 114 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 62bfb68da..94dd7dba4 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4692,13 +4692,8 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) // We don't know where we are! HOME! // Push the commands to the front of the message queue in the reverse order! // There shall be always enough space reserved for these commands. - // if (lcd_commands_type != LcdCommands::StopPrint) { - repeatcommand_front(); // repeat G80 with all its parameters - enquecommand_front_P((PSTR("G28 W0"))); - // } - // else { - // mesh_bed_leveling_flag = false; - // } + repeatcommand_front(); // repeat G80 with all its parameters + enquecommand_front_P((PSTR("G28 W0"))); break; } @@ -4728,23 +4723,14 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) #ifndef PINDA_THERMISTOR if (run == false && temp_cal_active == true && calibration_status_pinda() == true && target_temperature_bed >= 50) { - // if (lcd_commands_type != LcdCommands::StopPrint) { - temp_compensation_start(); - run = true; - repeatcommand_front(); // repeat G80 with all its parameters - enquecommand_front_P((PSTR("G28 W0"))); - // } - // else { - // mesh_bed_leveling_flag = false; - // } + temp_compensation_start(); + run = true; + repeatcommand_front(); // repeat G80 with all its parameters + enquecommand_front_P((PSTR("G28 W0"))); break; } run = false; #endif //PINDA_THERMISTOR - // if (lcd_commands_type == LcdCommands::StopPrint) { - // mesh_bed_leveling_flag = false; - // break; - // } // Save custom message state, set a new custom message state to display: Calibrating point 9. CustomMsg custom_message_type_old = custom_message_type; unsigned int custom_message_state_old = custom_message_state; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 44e9b4371..75d233620 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1058,7 +1058,6 @@ static void lcd_status_screen() } if (current_click - // && (lcd_commands_type != LcdCommands::StopPrint) //click is aborted unless stop print finishes && ( menu_block_entering_on_serious_errors == SERIOUS_ERR_NONE ) // or a serious error blocks entering the menu ) { @@ -1468,99 +1467,6 @@ void lcd_commands() } #endif // not SNMM -/* - if (lcd_commands_type == LcdCommands::StopPrint) /// stop print - { - - - if (lcd_commands_step == 0) - { - lcd_commands_step = 6; - } - - if (lcd_commands_step == 1 && !blocks_queued()) - { - lcd_commands_step = 0; - lcd_commands_type = LcdCommands::Idle; - lcd_setstatuspgm(_T(WELCOME_MSG)); - custom_message_type = CustomMsg::Status; - isPrintPaused = false; - } - if (lcd_commands_step == 2 && !blocks_queued()) - { - setTargetBed(0); - enquecommand_P(PSTR("M104 S0")); //set hotend temp to 0 - - manage_heater(); - lcd_setstatuspgm(_T(WELCOME_MSG)); - cancel_heatup = false; - lcd_commands_step = 1; - } - if (lcd_commands_step == 3 && !blocks_queued()) - { - // M84: Disable steppers. - enquecommand_P(PSTR("M84")); - autotempShutdown(); - lcd_commands_step = 2; - } - if (lcd_commands_step == 4 && !blocks_queued()) - { - lcd_setstatuspgm(_T(MSG_PLEASE_WAIT)); - // G90: Absolute positioning. - enquecommand_P(PSTR("G90")); - // M83: Set extruder to relative mode. - enquecommand_P(PSTR("M83")); - #ifdef X_CANCEL_POS - enquecommand_P(PSTR("G1 X" STRINGIFY(X_CANCEL_POS) " Y" STRINGIFY(Y_CANCEL_POS) " E0 F7000")); - #else - enquecommand_P(PSTR("G1 X50 Y" STRINGIFY(Y_MAX_POS) " E0 F7000")); - #endif - lcd_ignore_click(false); - if (mmu_enabled) - lcd_commands_step = 8; - else - lcd_commands_step = 3; - } - if (lcd_commands_step == 5 && !blocks_queued()) - { - lcd_setstatuspgm(_T(MSG_PRINT_ABORTED)); - // G91: Set to relative positioning. - enquecommand_P(PSTR("G91")); - // Lift up. - enquecommand_P(PSTR("G1 Z15 F1500")); - if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) lcd_commands_step = 4; - else lcd_commands_step = 3; - } - if (lcd_commands_step == 6 && !blocks_queued()) - { - lcd_setstatuspgm(_T(MSG_PRINT_ABORTED)); - cancel_heatup = true; - setTargetBed(0); - if (mmu_enabled) - setAllTargetHotends(0); - manage_heater(); - custom_message_type = CustomMsg::FilamentLoading; - lcd_commands_step = 5; - } - if (lcd_commands_step == 7 && !blocks_queued()) - { - if (mmu_enabled) - enquecommand_P(PSTR("M702 C")); //current - else - switch(snmm_stop_print_menu()) - { - case 0: enquecommand_P(PSTR("M702")); break;//all - case 1: enquecommand_P(PSTR("M702 U")); break; //used - case 2: enquecommand_P(PSTR("M702 C")); break; //current - default: enquecommand_P(PSTR("M702")); break; - } - lcd_commands_step = 3; - } - if (lcd_commands_step == 8 && !blocks_queued()) { //step 8 is here for delay (going to next step after execution of all gcodes from step 4) - lcd_commands_step = 7; - } - } -*/ if (lcd_commands_type == LcdCommands::FarmModeConfirm) /// farm mode confirm { From d9e52835260b5780f076551ca35c1c4cb3eb5453 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 7 Jan 2020 21:02:13 +0200 Subject: [PATCH 4/4] Fix pause->stop->PrintFromSD scenario --- Firmware/ultralcd.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 75d233620..75031f46b 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7281,6 +7281,8 @@ void lcd_print_stop() axis_relative_modes[Y_AXIS] = false; axis_relative_modes[Z_AXIS] = false; axis_relative_modes[E_AXIS] = true; + + isPrintPaused = false; //clear isPrintPaused flag to allow starting next print after pause->stop scenario. } void lcd_sdcard_stop()