From c970869d74b0b60ccab0dc5f05a2ad1d20f3c2cd Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 20 Jan 2018 18:40:00 -0600 Subject: [PATCH 1/4] Add hotEnough methods --- Marlin/Marlin_main.cpp | 4 ++-- Marlin/temperature.h | 3 +++ Marlin/ultralcd.cpp | 26 +++++++++++++------------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index d84907909..da60c691f 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -6493,7 +6493,7 @@ inline void gcode_M17() { COPY(resume_position, current_position); // Initial retract before move to filament change position - if (retract && !thermalManager.tooColdToExtrude(active_extruder)) + if (retract && thermalManager.hotEnoughToExtrude(active_extruder)) do_pause_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE); // Park the nozzle by moving up by z_lift and then moving to (x_pos, y_pos) @@ -6603,7 +6603,7 @@ inline void gcode_M17() { thermalManager.reset_heater_idle_timer(e); } - if (nozzle_timed_out || !thermalManager.tooColdToExtrude(active_extruder)) { + if (nozzle_timed_out || thermalManager.hotEnoughToExtrude(active_extruder)) { // Load the new filament load_filament(load_length, extrude_length, max_beep_count, true, nozzle_timed_out); } diff --git a/Marlin/temperature.h b/Marlin/temperature.h index d8aca8a53..fbc7e9442 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -196,6 +196,9 @@ class Temperature { FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t e) { UNUSED(e); return false; } #endif + FORCE_INLINE static bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); } + FORCE_INLINE static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); } + private: #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 4b389540a..d70aa4b10 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1394,7 +1394,7 @@ void kill_screen(const char* lcd_msg) { // #if ENABLED(ADVANCED_PAUSE_FEATURE) #if E_STEPPERS == 1 && !ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - if (!thermalManager.targetTooColdToExtrude(active_extruder)) + if (thermalManager.targetHotEnoughToExtrude(active_extruder)) MENU_ITEM(gcode, MSG_FILAMENTCHANGE, PSTR("M600 B0")); else MENU_ITEM(submenu, MSG_FILAMENTCHANGE, lcd_temp_menu_e0_filament_change); @@ -2599,7 +2599,7 @@ void kill_screen(const char* lcd_msg) { #if ENABLED(ADVANCED_PAUSE_FEATURE) if (!IS_SD_FILE_OPEN) { #if E_STEPPERS == 1 && !ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - if (!thermalManager.targetTooColdToExtrude(active_extruder)) + if (thermalManager.targetHotEnoughToExtrude(active_extruder)) MENU_ITEM(gcode, MSG_FILAMENTCHANGE, PSTR("M600 B0")); else MENU_ITEM(submenu, MSG_FILAMENTCHANGE, lcd_temp_menu_e0_filament_change); @@ -4272,21 +4272,21 @@ void kill_screen(const char* lcd_msg) { // Unload filament #if E_STEPPERS == 1 - if (!thermalManager.targetTooColdToExtrude(active_extruder)) + if (thermalManager.targetHotEnoughToExtrude(active_extruder)) MENU_ITEM(gcode, MSG_FILAMENTUNLOAD, PSTR("M702")); else MENU_ITEM(submenu, MSG_FILAMENTUNLOAD, lcd_temp_menu_e0_filament_unload); #else #if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS) - if (!thermalManager.targetTooColdToExtrude(0) + if (thermalManager.targetHotEnoughToExtrude(0) #if E_STEPPERS > 1 - && !thermalManager.targetTooColdToExtrude(1) + && thermalManager.targetHotEnoughToExtrude(1) #if E_STEPPERS > 2 - && !thermalManager.targetTooColdToExtrude(2) + && thermalManager.targetHotEnoughToExtrude(2) #if E_STEPPERS > 3 - && !thermalManager.targetTooColdToExtrude(3) + && thermalManager.targetHotEnoughToExtrude(3) #if E_STEPPERS > 4 - && !thermalManager.targetTooColdToExtrude(4) + && thermalManager.targetHotEnoughToExtrude(4) #endif // E_STEPPERS > 4 #endif // E_STEPPERS > 3 #endif // E_STEPPERS > 2 @@ -4296,26 +4296,26 @@ void kill_screen(const char* lcd_msg) { else MENU_ITEM(submenu, MSG_FILAMENTUNLOAD_ALL, lcd_unload_filament_all_temp_menu); #endif - if (!thermalManager.targetTooColdToExtrude(0)) + if (thermalManager.targetHotEnoughToExtrude(0)) MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E1, PSTR("M702 T0")); else MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E1, lcd_temp_menu_e0_filament_unload); - if (!thermalManager.targetTooColdToExtrude(1)) + if (thermalManager.targetHotEnoughToExtrude(1)) MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E2, PSTR("M702 T1")); else MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E2, lcd_temp_menu_e1_filament_unload); #if E_STEPPERS > 2 - if (!thermalManager.targetTooColdToExtrude(2)) + if (thermalManager.targetHotEnoughToExtrude(2)) MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E3, PSTR("M702 T2")); else MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E3, lcd_temp_menu_e2_filament_unload); #if E_STEPPERS > 3 - if (!thermalManager.targetTooColdToExtrude(3)) + if (thermalManager.targetHotEnoughToExtrude(3)) MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E4, PSTR("M702 T3")); else MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E4, lcd_temp_menu_e3_filament_unload); #if E_STEPPERS > 4 - if (!thermalManager.targetTooColdToExtrude(4)) + if (thermalManager.targetHotEnoughToExtrude(4)) MENU_ITEM(gcode, MSG_FILAMENTUNLOAD " " MSG_E5, PSTR("M702 T4")); else MENU_ITEM(submenu, MSG_FILAMENTUNLOAD " " MSG_E5, lcd_temp_menu_e4_filament_unload); From c373afbddd39242c16071e1a1d4f5333e4a35fa3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 20 Jan 2018 10:46:56 -0600 Subject: [PATCH 2/4] Clean up and document load/unload/pause/resume --- Marlin/Marlin_main.cpp | 107 ++++++++++++++++++++++++++++++++--------- 1 file changed, 85 insertions(+), 22 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index da60c691f..14f4409f1 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -6301,6 +6301,15 @@ inline void gcode_M17() { } #endif + /** + * Ensure a safe temperature for extrusion + * + * - Fail if the TARGET temperature is too low + * - Display LCD placard with temperature status + * - Return when heating is done or aborted + * + * Returns 'true' if heating was completed, 'false' for abort + */ static bool ensure_safe_temperature(const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT) { #if ENABLED(PREVENT_COLD_EXTRUSION) @@ -6325,7 +6334,19 @@ inline void gcode_M17() { return status; } - static bool load_filament(const float &load_length=0, const float &extrude_length=0, const int8_t max_beep_count=0, + /** + * Load filament into the hotend + * + * - Fail if the a safe temperature was not reached + * - If pausing for confirmation, wait for a click or M108 + * - Show "wait for load" placard + * - Load and purge filament + * - Show "Purge more" / "Continue" menu + * - Return when "Continue" is selected + * + * Returns 'true' if load was completed, 'false' for abort + */ + static bool load_filament(const float &load_length=0, const float &purge_length=0, const int8_t max_beep_count=0, const bool show_lcd=false, const bool pause_for_user=false, const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT ) { @@ -6368,15 +6389,15 @@ inline void gcode_M17() { } #if ENABLED(ULTIPANEL) - if (show_lcd) // Show "load" message + if (show_lcd) // Show "wait for load" message lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_LOAD, mode); #endif // Load filament - do_pause_e_move(load_length, FILAMENT_CHANGE_LOAD_FEEDRATE); + if (load_length) do_pause_e_move(load_length, FILAMENT_CHANGE_LOAD_FEEDRATE); do { - if (extrude_length > 0) { + if (purge_length > 0) { // "Wait for filament purge" #if ENABLED(ULTIPANEL) if (show_lcd) @@ -6384,10 +6405,10 @@ inline void gcode_M17() { #endif // Extrude filament to get into hotend - do_pause_e_move(extrude_length, ADVANCED_PAUSE_EXTRUDE_FEEDRATE); + do_pause_e_move(purge_length, ADVANCED_PAUSE_EXTRUDE_FEEDRATE); } - // Show "Extrude More" / "Resume" menu and wait for reply + // Show "Purge More" / "Resume" menu and wait for reply #if ENABLED(ULTIPANEL) if (show_lcd) { KEEPALIVE_STATE(PAUSED_FOR_USER); @@ -6398,7 +6419,7 @@ inline void gcode_M17() { } #endif - // Keep looping if "Extrude More" was selected + // Keep looping if "Purge More" was selected } while ( #if ENABLED(ULTIPANEL) show_lcd && advanced_pause_menu_response == ADVANCED_PAUSE_RESPONSE_EXTRUDE_MORE @@ -6410,6 +6431,16 @@ inline void gcode_M17() { return true; } + /** + * Unload filament from the hotend + * + * - Fail if the a safe temperature was not reached + * - Show "wait for unload" placard + * - Retract, pause, then unload filament + * - Disable E stepper (on most machines) + * + * Returns 'true' if unload was completed, 'false' for abort + */ static bool unload_filament(const float &unload_length, const bool show_lcd=false, const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT ) { @@ -6450,6 +6481,19 @@ inline void gcode_M17() { return true; } + /** + * Pause procedure + * + * - Abort if already paused + * - Send host action for pause, if configured + * - Abort if TARGET temperature is too low + * - Display "wait for start of filament change" (if a length was specified) + * - Initial retract, if current temperature is hot enough + * - Park the nozzle at the given position + * - Call unload_filament (if a length was specified) + * + * Returns 'true' if pause was completed, 'false' for abort + */ static bool pause_print(const float &retract, const point_t &park_point, const float &unload_length=0, const bool show_lcd=false) { if (did_pause_print) return false; // already paused @@ -6457,11 +6501,6 @@ inline void gcode_M17() { SERIAL_ECHOLNPGM("//action:" ACTION_ON_PAUSE); #endif - #if ENABLED(ULTIPANEL) - if (show_lcd) // Show initial message - lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT); - #endif - if (!DEBUGGING(DRYRUN) && unload_length && thermalManager.targetTooColdToExtrude(active_extruder)) { SERIAL_ERROR_START(); SERIAL_ERRORLNPGM(MSG_HOTEND_TOO_COLD); @@ -6481,7 +6520,7 @@ inline void gcode_M17() { #if ENABLED(SDSUPPORT) if (card.sdprinting) { card.pauseSDPrint(); - ++did_pause_print; + ++did_pause_print; // Indicate SD pause also } #endif print_job_timer.pause(); @@ -6506,6 +6545,13 @@ inline void gcode_M17() { return true; } + /** + * - Show "Insert filament and press button to continue" + * - Wait for a click before returning + * - Heaters can time out, reheated before accepting a click + * + * Used by M125 and M600 + */ static void wait_for_filament_reload(const int8_t max_beep_count=0) { bool nozzle_timed_out = false; @@ -6592,12 +6638,29 @@ inline void gcode_M17() { KEEPALIVE_STATE(IN_HANDLER); } - static void resume_print(const float &load_length=0, const float &extrude_length=ADVANCED_PAUSE_EXTRUDE_LENGTH, const int8_t max_beep_count=0) { - bool nozzle_timed_out = false; - + /** + * Resume or Start print procedure + * + * - Abort if not paused + * - Reset heater idle timers + * - Load filament if specified, but only if: + * - a nozzle timed out, or + * - the nozzle is already heated. + * - Display "wait for print to resume" + * - Re-prime the nozzle... + * - FWRETRACT: Recover/prime from the prior G10. + * - !FWRETRACT: Retract by resume_position[E], if negative. + * Not sure how this logic comes into use. + * - Move the nozzle back to resume_position + * - Sync the planner E to resume_position[E] + * - Send host action for resume, if configured + * - Resume the current SD print job, if any + */ + static void resume_print(const float &load_length=0, const float &purge_length=ADVANCED_PAUSE_EXTRUDE_LENGTH, const int8_t max_beep_count=0) { if (!did_pause_print) return; // Re-enable the heaters if they timed out + bool nozzle_timed_out = false; HOTEND_LOOP() { nozzle_timed_out |= thermalManager.is_heater_idle(e); thermalManager.reset_heater_idle_timer(e); @@ -6605,7 +6668,7 @@ inline void gcode_M17() { if (nozzle_timed_out || thermalManager.hotEnoughToExtrude(active_extruder)) { // Load the new filament - load_filament(load_length, extrude_length, max_beep_count, true, nozzle_timed_out); + load_filament(load_length, purge_length, max_beep_count, true, nozzle_timed_out); } #if ENABLED(ULTIPANEL) @@ -6619,7 +6682,7 @@ inline void gcode_M17() { if (fwretract.retracted[active_extruder]) do_pause_e_move(-fwretract.retract_length, fwretract.retract_feedrate_mm_s); #else - // If resume_position negative + // If resume_position is negative if (resume_position[E_AXIS] < 0) do_pause_e_move(resume_position[E_AXIS], PAUSE_PARK_RETRACT_FEEDRATE); #endif @@ -8521,11 +8584,11 @@ inline void gcode_M121() { endstops.enable_globally(false); } inline void gcode_M125() { // Initial retract before move to filament change position - const float retract = parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0 + const float retract = -FABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0 #ifdef PAUSE_PARK_RETRACT_LENGTH - - (PAUSE_PARK_RETRACT_LENGTH) + + (PAUSE_PARK_RETRACT_LENGTH) #endif - ; + ); point_t park_point = NOZZLE_PARK_POINT; @@ -10150,7 +10213,7 @@ inline void gcode_M502() { const float load_length = FABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) : filament_change_load_length[target_extruder]); - // Show initial message + // Show initial "wait for load" message #if ENABLED(ULTIPANEL) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_LOAD, ADVANCED_PAUSE_MODE_LOAD_FILAMENT, target_extruder); #endif From c7ae531e3559edb1c42c931dab924141e2ce6e49 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 20 Jan 2018 12:25:44 -0600 Subject: [PATCH 3/4] Better LCD message when heating needed --- Marlin/Marlin_main.cpp | 11 ++++------- Marlin/language_en.h | 3 +++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 14f4409f1..1f44fdca7 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -6508,6 +6508,7 @@ inline void gcode_M17() { #if ENABLED(ULTIPANEL) if (show_lcd) // Show status screen lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS); + LCD_MESSAGEPGM(MSG_M600_TOO_COLD); #endif return false; // unable to reach safe temperature @@ -10043,15 +10044,11 @@ inline void gcode_M502() { ); // Lift Z axis - if (parser.seenval('Z')) - park_point.z = parser.linearval('Z'); + if (parser.seenval('Z')) park_point.z = parser.linearval('Z'); // Move XY axes to filament change position or given position - if (parser.seenval('X')) - park_point.x = parser.linearval('X'); - - if (parser.seenval('Y')) - park_point.y = parser.linearval('Y'); + if (parser.seenval('X')) park_point.x = parser.linearval('X'); + if (parser.seenval('Y')) park_point.y = parser.linearval('Y'); #if HOTENDS > 1 && DISABLED(DUAL_X_CARRIAGE) park_point.x += (active_extruder ? hotend_offset[X_AXIS][active_extruder] : 0); diff --git a/Marlin/language_en.h b/Marlin/language_en.h index 4303c7e54..9d44e6b77 100644 --- a/Marlin/language_en.h +++ b/Marlin/language_en.h @@ -961,6 +961,9 @@ #ifndef MSG_ERR_PROBING_FAILED #define MSG_ERR_PROBING_FAILED _UxGT("Probing failed") #endif +#ifndef MSG_M600_TOO_COLD + #define MSG_M600_TOO_COLD _UxGT("M600: Too cold") +#endif // // Filament Change screens show up to 3 lines on a 4-line display From feb6014e924a56b4335fc414cb82823207479816 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 20 Jan 2018 18:40:48 -0600 Subject: [PATCH 4/4] Don't run `M600` on filament runout if the nozzle is cold --- Marlin/Marlin_main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 1f44fdca7..7ef28de08 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -13236,7 +13236,10 @@ void disable_all_steppers() { void manage_inactivity(bool ignore_stepper_queue/*=false*/) { #if ENABLED(FILAMENT_RUNOUT_SENSOR) - if ((IS_SD_PRINTING || print_job_timer.isRunning()) && (READ(FIL_RUNOUT_PIN) == FIL_RUNOUT_INVERTING)) + if ((IS_SD_PRINTING || print_job_timer.isRunning()) + && READ(FIL_RUNOUT_PIN) == FIL_RUNOUT_INVERTING + && thermalManager.targetHotEnoughToExtrude(active_extruder) + ) handle_filament_runout(); #endif