Skip to content

Commit

Permalink
Merge pull request #528 from Frix-x/develop
Browse files Browse the repository at this point in the history
new version
  • Loading branch information
Frix-x authored Mar 4, 2024
2 parents bad68da + 36137d5 commit ecfbd43
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 21 deletions.
19 changes: 12 additions & 7 deletions config/machine.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand Down
45 changes: 31 additions & 14 deletions macros/base/park.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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 %}
Expand All @@ -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
Expand All @@ -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

0 comments on commit ecfbd43

Please sign in to comment.