diff --git a/config/machine.cfg b/config/machine.cfg index 0f239a2a6..734cb60f5 100644 --- a/config/machine.cfg +++ b/config/machine.cfg @@ -1,13 +1,18 @@ [virtual_sdcard] path: ~/printer_data/gcodes on_error_gcode: - {% if printer["gcode_macro _USER_VARIABLES"].status_leds_enabled %} - STATUS_LEDS COLOR="ERROR" - {% endif %} - {% if printer["gcode_macro _USER_VARIABLES"].probe_type_enabled == "dockable" %} - _PROBE_ON_ERROR_ACTION - {% endif %} - PARK + {% if printer["gcode_macro _USER_VARIABLES"].status_leds_enabled %} + STATUS_LEDS COLOR="ERROR" + {% endif %} + {% if printer["gcode_macro _USER_VARIABLES"].probe_type_enabled == "dockable" or printer["gcode_macro _USER_VARIABLES"].probe_type_enabled == "dockable_virtual" %} + _PROBE_ON_ERROR_ACTION + {% endif %} + + # Park only if printer is homed + {% if "xyz" in printer.toolhead.homed_axes %} + PARK + {% endif %} + [idle_timeout] timeout: 1800 diff --git a/macros/base/park.cfg b/macros/base/park.cfg index 4374a096b..504676e34 100644 --- a/macros/base/park.cfg +++ b/macros/base/park.cfg @@ -2,8 +2,7 @@ description: Park the toolhead at the back and retract some filament if the nozzle is hot gcode: {% set verbose = printer["gcode_macro _USER_VARIABLES"].verbose %} - {% set E = params.E|default(1.7)|float|abs %} - {% set MATERIAL = printer['gcode_macro START_PRINT'].material %} + {% set material = printer['gcode_macro START_PRINT'].material %} {% set Px, Py = printer["gcode_macro _USER_VARIABLES"].park_position_xy|map('float') %} {% set Px = params.X|default(Px)|float %} @@ -27,21 +26,36 @@ gcode: {% if printer.toolhead.homed_axes != "xyz" %} {action_raise_error("Cannot park the toolhead because axis are not homed!")} {% endif %} + + SAVE_GCODE_STATE NAME=PARK {% if printer.extruder.can_extrude %} - {% if firmware_retraction_enabled %} # use firmware_retraction parameter for retract (in case firmware retraction is selected in printer.cfg) - {% if verbose %} - RESPOND MSG="Firmware retraction enabled, Extruder retraction = {printer.firmware_retraction.retract_length}" - {% endif %} - G10 - {% else %} # otherwise: - {% if MATERIAL != "XXX" %} # use material parameter if available for retract, otherwise use default value - {% set material = printer["gcode_macro _USER_VARIABLES"].material_parameters[MATERIAL] %} - {% set E = material.retract_length %} - {% endif %} + {% if params.E is defined %} + {% set E = params.E|float|abs %} + {% if verbose %} - RESPOND MSG="Firmware retraction disabled, Extruder retraction = {E}" + RESPOND MSG="Retraction overrided with parameter, Extruder retraction = {E}" + {% endif %} + {% else %} + {% if firmware_retraction_enabled %} # use firmware_retraction parameter for retract (in case firmware retraction is selected in printer.cfg) + {% if verbose %} + RESPOND MSG="Firmware retraction enabled, Extruder retraction = {printer.firmware_retraction.retract_length}" + {% endif %} + G10 + {% else %} # otherwise: + {% if printer["gcode_macro _USER_VARIABLES"].material_parameters[material] is defined %} # use material parameter if available for retract, otherwise use default value + {% set E = printer["gcode_macro _USER_VARIABLES"].material_parameters[material].retract_length|default(1.7) %} + {% else %} + {% set E = 1.7 %} + {% endif %} + + {% if verbose %} + RESPOND MSG="Firmware retraction disabled, Extruder retraction = {E}" + {% endif %} {% endif %} + {% endif %} + + {% if E is defined and E > 0 %} G92 E0 G1 E-{E} F2100 {% endif %} @@ -50,7 +64,8 @@ gcode: G90 G1 Z{z_safe} F{Sz} G0 X{Px} Y{Py} F{St} - + + RESTORE_GCODE_STATE NAME=PARK [gcode_macro PARK_FRONT] description: Park the toolhead on the front of the printer for maintenance @@ -63,7 +78,9 @@ gcode: {% endif %} SAVE_GCODE_STATE NAME=PARK_FRONT + G90 ; absolute positioning G0 Z{printer.toolhead.axis_maximum.z/3*2} F{Sz} G0 X{printer.toolhead.axis_maximum.x/2} Y{printer.toolhead.axis_minimum.y+10} F{St} + RESTORE_GCODE_STATE NAME=PARK_FRONT