From f58ee6bbed6a87b886e97e96a3d10346f7dc168d Mon Sep 17 00:00:00 2001 From: Mitko Haralanov Date: Fri, 27 Oct 2023 10:35:57 -0700 Subject: [PATCH] Fix config file consistency and clarify GCode state command usage (#136) The PRINT_END macro in the Octopus config file contains a pair of SAVE_GCODE_STATE/RESTORE_GCODE_STATE command. The purpose of those commands is to allow the macro to perfom actions at the end of the print and then restore the printer state as it was prior to the macro's execution (restore coordinate system and speeds). However, there was some confusion as to the effect of those calls, particularly the RESTORE_GCODE_STATE. What is desired is that the printer state is restored but the toolhead position is not. To clarify the intention and prevent any issues, the "MOVE=0" argument to RESTORE_GCODE_STATE is added as to explicitly prevent any toolhead position changes and a comment is added to describe the purpose of the commands. Since having the commands in the PRINT_END macro is something that is needed, the same commands have also been added to any of the other configs which were missing it. --- .../klipper_configurations/M8P/Voron2_M8P_config.cfg | 9 +++++++++ .../Octopus/Voron2_Octopus_Config.cfg | 12 +++++++++--- .../SKR_1.3/Voron2_SKR_13_Config.cfg | 10 ++++++++-- .../SKR_1.4/Voron2_SKR_14_Config.cfg | 10 ++++++++-- .../Spider/Voron2_Spider_Config.cfg | 10 ++++++++-- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/firmware/klipper_configurations/M8P/Voron2_M8P_config.cfg b/firmware/klipper_configurations/M8P/Voron2_M8P_config.cfg index a2463348..0cb31a21 100644 --- a/firmware/klipper_configurations/M8P/Voron2_M8P_config.cfg +++ b/firmware/klipper_configurations/M8P/Voron2_M8P_config.cfg @@ -538,9 +538,12 @@ gcode: [gcode_macro PRINT_END] # Use PRINT_END for the slicer ending script - please customise for your slicer of choice gcode: + SAVE_GCODE_STATE NAME=STATE_PRINT_END + M400 ; wait for buffer to clear G92 E0 ; zero the extruder G1 E-10.0 F3600 ; retract filament + G91 ; relative positioning G0 Z1.00 X20.0 Y20.0 F20000 ; move nozzle to remove stringing TURN_OFF_HEATERS @@ -550,4 +553,10 @@ gcode: G0 X125 Y250 F3600 ; park nozzle at rear BED_MESH_CLEAR + # The purpose of the SAVE_GCODE_STATE/RESTORE_GCODE_STATE + # command pair is to restore the printer's coordinate system + # and speed settings since the commands above change them. + # However, to prevent any accidental, unintentional toolhead + # moves when restoring the state, explicitly set MOVE=0. + RESTORE_GCODE_STATE NAME=STATE_PRINT_END MOVE=0 diff --git a/firmware/klipper_configurations/Octopus/Voron2_Octopus_Config.cfg b/firmware/klipper_configurations/Octopus/Voron2_Octopus_Config.cfg index c342e4e5..b8b0b8d3 100644 --- a/firmware/klipper_configurations/Octopus/Voron2_Octopus_Config.cfg +++ b/firmware/klipper_configurations/Octopus/Voron2_Octopus_Config.cfg @@ -560,17 +560,23 @@ gcode: {% set z_safe = [th.position.z + 2, th.axis_maximum.z]|min %} SAVE_GCODE_STATE NAME=STATE_PRINT_END - + M400 ; wait for buffer to clear G92 E0 ; zero the extruder G1 E-5.0 F1800 ; retract filament TURN_OFF_HEATERS - + G90 ; absolute positioning G0 X{x_safe} Y{y_safe} Z{z_safe} F20000 ; move nozzle to remove stringing G0 X{th.axis_maximum.x//2} Y{th.axis_maximum.y - 2} F3600 ; park nozzle at rear M107 ; turn off fan BED_MESH_CLEAR - RESTORE_GCODE_STATE NAME=STATE_PRINT_END + + # The purpose of the SAVE_GCODE_STATE/RESTORE_GCODE_STATE + # command pair is to restore the printer's coordinate system + # and speed settings since the commands above change them. + # However, to prevent any accidental, unintentional toolhead + # moves when restoring the state, explicitly set MOVE=0. + RESTORE_GCODE_STATE NAME=STATE_PRINT_END MOVE=0 \ No newline at end of file diff --git a/firmware/klipper_configurations/SKR_1.3/Voron2_SKR_13_Config.cfg b/firmware/klipper_configurations/SKR_1.3/Voron2_SKR_13_Config.cfg index efb2397b..a42582e3 100644 --- a/firmware/klipper_configurations/SKR_1.3/Voron2_SKR_13_Config.cfg +++ b/firmware/klipper_configurations/SKR_1.3/Voron2_SKR_13_Config.cfg @@ -563,7 +563,7 @@ gcode: {% set z_safe = [th.position.z + 2, th.axis_maximum.z]|min %} SAVE_GCODE_STATE NAME=STATE_PRINT_END - + M400 ; wait for buffer to clear G92 E0 ; zero the extruder G1 E-5.0 F1800 ; retract filament @@ -576,4 +576,10 @@ gcode: M107 ; turn off fan BED_MESH_CLEAR - RESTORE_GCODE_STATE NAME=STATE_PRINT_END + + # The purpose of the SAVE_GCODE_STATE/RESTORE_GCODE_STATE + # command pair is to restore the printer's coordinate system + # and speed settings since the commands above change them. + # However, to prevent any accidental, unintentional toolhead + # moves when restoring the state, explicitly set MOVE=0. + RESTORE_GCODE_STATE NAME=STATE_PRINT_END MOVE=0 \ No newline at end of file diff --git a/firmware/klipper_configurations/SKR_1.4/Voron2_SKR_14_Config.cfg b/firmware/klipper_configurations/SKR_1.4/Voron2_SKR_14_Config.cfg index 2c3555c8..dff0252c 100644 --- a/firmware/klipper_configurations/SKR_1.4/Voron2_SKR_14_Config.cfg +++ b/firmware/klipper_configurations/SKR_1.4/Voron2_SKR_14_Config.cfg @@ -563,7 +563,7 @@ gcode: {% set z_safe = [th.position.z + 2, th.axis_maximum.z]|min %} SAVE_GCODE_STATE NAME=STATE_PRINT_END - + M400 ; wait for buffer to clear G92 E0 ; zero the extruder G1 E-5.0 F1800 ; retract filament @@ -576,4 +576,10 @@ gcode: M107 ; turn off fan BED_MESH_CLEAR - RESTORE_GCODE_STATE NAME=STATE_PRINT_END + + # The purpose of the SAVE_GCODE_STATE/RESTORE_GCODE_STATE + # command pair is to restore the printer's coordinate system + # and speed settings since the commands above change them. + # However, to prevent any accidental, unintentional toolhead + # moves when restoring the state, explicitly set MOVE=0. + RESTORE_GCODE_STATE NAME=STATE_PRINT_END MOVE=0 \ No newline at end of file diff --git a/firmware/klipper_configurations/Spider/Voron2_Spider_Config.cfg b/firmware/klipper_configurations/Spider/Voron2_Spider_Config.cfg index 22c564dc..f7a85fd5 100644 --- a/firmware/klipper_configurations/Spider/Voron2_Spider_Config.cfg +++ b/firmware/klipper_configurations/Spider/Voron2_Spider_Config.cfg @@ -506,7 +506,7 @@ gcode: {% set z_safe = [th.position.z + 2, th.axis_maximum.z]|min %} SAVE_GCODE_STATE NAME=STATE_PRINT_END - + M400 ; wait for buffer to clear G92 E0 ; zero the extruder G1 E-5.0 F1800 ; retract filament @@ -519,4 +519,10 @@ gcode: M107 ; turn off fan BED_MESH_CLEAR - RESTORE_GCODE_STATE NAME=STATE_PRINT_END + + # The purpose of the SAVE_GCODE_STATE/RESTORE_GCODE_STATE + # command pair is to restore the printer's coordinate system + # and speed settings since the commands above change them. + # However, to prevent any accidental, unintentional toolhead + # moves when restoring the state, explicitly set MOVE=0. + RESTORE_GCODE_STATE NAME=STATE_PRINT_END MOVE=0 \ No newline at end of file