Created
April 8, 2023 14:31
-
-
Save rootiest/1eed5c7e8f459894d19b99e5a4446b12 to your computer and use it in GitHub Desktop.
Home if needed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[gcode_macro CG28] | |
variable_output: 116 ; Output method for status feedback | |
gcode: | |
{% set printcfg = printer['gcode_macro _printcfg'] %} ; get printcfg variables | |
{% if "x" in rawparams|string|lower %} ; if x is in rawparams | |
{% set X = True %} ; set x flag | |
{% endif %} | |
{% if "y" in rawparams|string|lower %} ; if y is in rawparams | |
{% set Y = True %} ; set y flag | |
{% endif %} | |
{% if "z" in rawparams|string|lower %} ; if z is in rawparams | |
{% set Z = True %} ; set z flag | |
{% endif %} | |
{% if rawparams|string|lower == "" %} ; if no parameters are defined | |
{% set ALL = True %} ; set all flag | |
{% set X = True %} ; set x flag | |
{% set Y = True %} ; set y flag | |
{% set Z = True %} ; set z flag | |
{% endif %} | |
{% if printer.toolhead.homed_axes != "xyz" %} ; if not homed | |
{% if "x" not in printer.toolhead.homed_axes %} ; if x is not homed | |
{% set home_x = True %} ; set home_x flag | |
{% endif %} | |
{% if "y" not in printer.toolhead.homed_axes %} ; if y is not homed | |
{% set home_y = True %} ; set home_y flag | |
{% endif %} | |
{% if "z" not in printer.toolhead.homed_axes %} ; if z is not homed | |
{% set home_z = True %} ; set home_z flag | |
{% endif %} | |
{% if home_x == True and home_y == True and home_z == True %} ; if all axes need to be homed | |
{% if ALL == True %} ; if all axes are being homed | |
M{output} Homing all axes | |
G28 ; Home all axes | |
{% else %} ; if only some axes are being homed | |
{% if X == True %} ; if x is being homed | |
M{output} Homing X axis | |
G28 X ; Home x axis | |
{% endif %} | |
{% if Y == True %} ; if y is being homed | |
M{output} Homing Y axis | |
G28 Y ; Home y axis | |
{% endif %} | |
{% if Z == True %} ; if z is being homed | |
M{output} Homing Z axis | |
G28 Z ; Home z axis | |
{% endif %} | |
{% endif %} | |
{% else %} ; if only some axes need to be homed | |
{% if home_x == True %} ; if x needs to be homed | |
{% if X == True %} ; if x is being homed | |
M{output} Homing X axis | |
G28 X ; Home x axis | |
{% endif %} | |
{% endif %} | |
{% if home_y == True %} ; if y needs to be homed | |
{% if Y == True %} ; if y is being homed | |
M{output} Homing Y axis | |
G28 Y ; Home y axis | |
{% endif %} | |
{% endif %} | |
{% if home_z == True %} ; if z needs to be homed | |
{% if Z == True %} ; if z is being homed | |
M{output} Homing Z axis | |
G28 Z ; Home z axis | |
{% endif %} | |
{% endif %} | |
{% endif %} | |
{% else %} ; if already homed | |
M{output} All axes are homed | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment