From 3d24c329af5a4dd71c40bdd918caa792b179373d Mon Sep 17 00:00:00 2001 From: Thomas Moore Date: Mon, 12 Jun 2017 23:09:44 -0500 Subject: [PATCH 1/3] M600 fixes --- Marlin/Marlin_main.cpp | 78 +++++++++++++++++++++++++++++------------- Marlin/ultralcd.cpp | 15 +++++--- 2 files changed, 65 insertions(+), 28 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index a15145d31..28c6fb058 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -5866,7 +5866,7 @@ inline void gcode_M17() { idle(); heaters_heating = false; HOTEND_LOOP() { - if (thermalManager.degTargetHotend(e) && abs(thermalManager.degHotend(e) - thermalManager.degTargetHotend(e)) > 3) { + if (thermalManager.degTargetHotend(e) && abs(thermalManager.degHotend(e) - thermalManager.degTargetHotend(e)) > TEMP_HYSTERESIS) { heaters_heating = true; #if ENABLED(ULTIPANEL) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_WAIT_FOR_NOZZLES_TO_HEAT); @@ -5882,7 +5882,7 @@ inline void gcode_M17() { ) { if (move_away_flag) return false; // already paused - if (!DEBUGGING(DRYRUN) && unload_length != 0) { + if (!DEBUGGING(DRYRUN) && (unload_length != 0 || retract != 0)) { #if ENABLED(PREVENT_COLD_EXTRUSION) if (!thermalManager.allow_cold_extrude && thermalManager.degTargetHotend(active_extruder) < thermalManager.extrude_min_temp) { @@ -5919,10 +5919,11 @@ inline void gcode_M17() { COPY(resume_position, current_position); set_destination_to_current(); - // Initial retract before move to filament change position - destination[E_AXIS] += retract; - - RUNPLAN(PAUSE_PARK_RETRACT_FEEDRATE); + if (retract) { + // Initial retract before move to filament change position + destination[E_AXIS] += retract; + RUNPLAN(PAUSE_PARK_RETRACT_FEEDRATE); + } // Lift Z axis if (z_lift > 0) { @@ -5951,23 +5952,25 @@ inline void gcode_M17() { destination[E_AXIS] += unload_length; RUNPLAN(FILAMENT_CHANGE_UNLOAD_FEEDRATE); stepper.synchronize(); + } - if (show_lcd) { - #if ENABLED(ULTIPANEL) - lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INSERT); - #endif - } - - #if HAS_BUZZER - filament_change_beep(max_beep_count, true); + if (show_lcd) { + #if ENABLED(ULTIPANEL) + lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INSERT); #endif - - idle(); } - // Disable extruders steppers for manual filament changing - disable_e_steppers(); - safe_delay(100); + #if HAS_BUZZER + filament_change_beep(max_beep_count, true); + #endif + + idle(); + + // Disable extruders steppers for manual filament changing (only on boards that have separate ENABLE_PINS) + #if E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN + disable_e_steppers(); + safe_delay(100); + #endif // Start the heater idle timers const millis_t nozzle_timeout = (millis_t)(PAUSE_PARK_NOZZLE_TIMEOUT) * 1000UL; @@ -5989,14 +5992,43 @@ inline void gcode_M17() { filament_change_beep(max_beep_count); #endif + // If the nozzle has timed out, wait for the user to press the button to re-heat the nozzle, then + // re-heat the nozzle, re-show the insert screen, restart the idle timers, and start over if (!nozzle_timed_out) HOTEND_LOOP() nozzle_timed_out |= thermalManager.is_heater_idle(e); - #if ENABLED(ULTIPANEL) - if (nozzle_timed_out) + if (nozzle_timed_out) { + #if ENABLED(ULTIPANEL) lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_CLICK_TO_HEAT_NOZZLE); - #endif + #endif + + // Wait for LCD click or M108 + while (wait_for_user) idle(true); + + // Re-enable the heaters if they timed out + HOTEND_LOOP() thermalManager.reset_heater_idle_timer(e); + + // Wait for the heaters to reach the target temperatures + ensure_safe_temperature(); + + #if ENABLED(ULTIPANEL) + lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INSERT); + #endif + + // Start the heater idle timers + const millis_t nozzle_timeout = (millis_t)(PAUSE_PARK_NOZZLE_TIMEOUT) * 1000UL; + + HOTEND_LOOP() + thermalManager.start_heater_idle_timer(e, nozzle_timeout); + + wait_for_user = true; /* Wait for user to load filament */ + nozzle_timed_out = false; + + #if HAS_BUZZER + filament_change_beep(max_beep_count, true); + #endif + } idle(true); } @@ -7643,7 +7675,7 @@ inline void gcode_M18_M84() { if (parser.seen('X')) disable_X(); if (parser.seen('Y')) disable_Y(); if (parser.seen('Z')) disable_Z(); - #if ((E0_ENABLE_PIN != X_ENABLE_PIN) && (E1_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have seperate ENABLE_PINS + #if E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN // Only enable on boards that have seperate ENABLE_PINS if (parser.seen('E')) disable_e_steppers(); #endif } diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 23cdba92c..61f8ee7e9 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1107,11 +1107,16 @@ void kill_screen(const char* lcd_msg) { #if ENABLED(ADVANCED_PAUSE_FEATURE) void lcd_enqueue_filament_change() { - if (!DEBUGGING(DRYRUN) && thermalManager.tooColdToExtrude(active_extruder)) { - lcd_save_previous_screen(); - lcd_goto_screen(lcd_advanced_pause_toocold_menu); - return; - } + + #if ENABLED(PREVENT_COLD_EXTRUSION) + if (!DEBUGGING(DRYRUN) && !thermalManager.allow_cold_extrude && + thermalManager.degTargetHotend(active_extruder) < thermalManager.extrude_min_temp) { + lcd_save_previous_screen(); + lcd_goto_screen(lcd_advanced_pause_toocold_menu); + return; + } + #endif + lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT); enqueue_and_echo_commands_P(PSTR("M600 B0")); } From 4857a3ba48b8168099b78ac65c1f1613c3253bf1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 18 Jun 2017 22:58:19 -0500 Subject: [PATCH 2/3] Formatting and spelling --- Marlin/Marlin_main.cpp | 4 ++-- Marlin/mesh_bed_leveling.h | 4 ++-- Marlin/planner.cpp | 16 ++++++++-------- Marlin/ultralcd.cpp | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 28c6fb058..81d491d7e 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -6081,7 +6081,7 @@ inline void gcode_M17() { stepper.synchronize(); } - #if ENABLED(ULTIPANEL) && defined(ADVANCED_PAUSE_EXTRUDE_LENGTH) && ADVANCED_PAUSE_EXTRUDE_LENGTH > 0 + #if ENABLED(ULTIPANEL) && ADVANCED_PAUSE_EXTRUDE_LENGTH > 0 float extrude_length = initial_extrude_length; @@ -7675,7 +7675,7 @@ inline void gcode_M18_M84() { if (parser.seen('X')) disable_X(); if (parser.seen('Y')) disable_Y(); if (parser.seen('Z')) disable_Z(); - #if E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN // Only enable on boards that have seperate ENABLE_PINS + #if E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN // Only enable on boards that have separate ENABLE_PINS if (parser.seen('E')) disable_e_steppers(); #endif } diff --git a/Marlin/mesh_bed_leveling.h b/Marlin/mesh_bed_leveling.h index 41ba2677c..f7b701bf2 100644 --- a/Marlin/mesh_bed_leveling.h +++ b/Marlin/mesh_bed_leveling.h @@ -94,8 +94,8 @@ } static float calc_z0(const float &a0, const float &a1, const float &z1, const float &a2, const float &z2) { - const float delta_z = (z2 - z1) / (a2 - a1); - const float delta_a = a0 - a1; + const float delta_z = (z2 - z1) / (a2 - a1), + delta_a = a0 - a1; return z1 + delta_a * delta_z; } diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index a755db576..537f33460 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -534,10 +534,10 @@ void Planner::check_axes_activity() { if (!ubl.state.active) return; #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) // if z_fade_height enabled (nonzero) and raw_z above it, no leveling required - if ((planner.z_fade_height) && (planner.z_fade_height <= RAW_Z_POSITION(lz))) return; + if (planner.z_fade_height && planner.z_fade_height <= RAW_Z_POSITION(lz)) return; lz += ubl.state.z_offset + ubl.get_z_correction(lx, ly) * ubl.fade_scaling_factor_for_z(lz); #else // no fade - lz += ubl.state.z_offset + ubl.get_z_correction(lx,ly); + lz += ubl.state.z_offset + ubl.get_z_correction(lx, ly); #endif // FADE #endif // UBL @@ -598,10 +598,10 @@ void Planner::check_axes_activity() { if (ubl.state.active) { - const float z_physical = RAW_Z_POSITION(logical[Z_AXIS]); - const float z_ublmesh = ubl.get_z_correction(logical[X_AXIS], logical[Y_AXIS]); - const float z_virtual = z_physical - ubl.state.z_offset - z_ublmesh; - float z_logical = LOGICAL_Z_POSITION(z_virtual); + const float z_physical = RAW_Z_POSITION(logical[Z_AXIS]), + z_correct = ubl.get_z_correction(logical[X_AXIS], logical[Y_AXIS]), + z_virtual = z_physical - ubl.state.z_offset - z_correct; + float z_logical = LOGICAL_Z_POSITION(z_virtual); #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) @@ -614,10 +614,10 @@ void Planner::check_axes_activity() { // so L=(P-O-M)/(1-M/H) for L= planner.z_fade_height) z_logical = LOGICAL_Z_POSITION(z_physical - ubl.state.z_offset); + else + z_logical /= 1.0 - z_correct * planner.inverse_z_fade_height; } #endif // ENABLE_LEVELING_FADE_HEIGHT diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 61f8ee7e9..f7c75cc3d 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1018,8 +1018,8 @@ void kill_screen(const char* lcd_msg) { #if ENABLED(AUTO_BED_LEVELING_UBL) - float mesh_edit_value, mesh_edit_accumulator; // We round mesh_edit_value to 2.5 decimal places. So we keep a - // seperate value that doesn't lose precision. + float mesh_edit_value, mesh_edit_accumulator; // We round mesh_edit_value to 2.5 decimal places. So we keep a + // separate value that doesn't lose precision. static int ubl_encoderPosition = 0; static void _lcd_mesh_fine_tune(const char* msg) { From 4c3dc8bf079d27c79b8117153e0096e882603960 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 18 Jun 2017 23:00:25 -0500 Subject: [PATCH 3/3] Remove set_current_to_destination from resume_print Addressing #7057 --- Marlin/Marlin_main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 81d491d7e..61bbaa514 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -6136,8 +6136,6 @@ inline void gcode_M17() { filament_ran_out = false; #endif - set_current_to_destination(); - #if ENABLED(ULTIPANEL) // Show status screen lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_STATUS);