-
Notifications
You must be signed in to change notification settings - Fork 2
/
codeOverrides.cfg
75 lines (60 loc) · 2.08 KB
/
codeOverrides.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Built-In Macro Override
[gcode_macro FW_RESTART]
gcode:
FIRMWARE_RESTART
# Built-In Macro Override
[gcode_macro EStop]
gcode:
M112
[gcode_macro PAUSE]
variable_paused_z: 0
rename_existing: PAUSE_BASE
gcode:
# Save the current G-code state
SAVE_GCODE_STATE NAME=PAUSE_state
# Move to the maximum Z height adjusted for the defined Z offset
{% set max_z = printer.configfile.config["stepper_z"].position_max|float - printer.gcode_move.homing_origin.z|float %}
G90 ; Switch to absolute positioning
G0 Z{max_z} ; Move Z to its maximum position
M5 # Stop the spindle
PAUSE_BASE
[gcode_macro RESUME]
rename_existing: RESUME_BASE
gcode:
{% set svv = printer.save_variables.variables %}
M3 S{svv.spindle_speed}
# Restore the previously saved G-code state
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=0
RESUME_BASE
[gcode_macro CANCEL_PRINT]
rename_existing: CANCEL_PRINT_BASE
gcode:
{% set max_z = printer.configfile.config["stepper_z"].position_max|float - printer.gcode_move.homing_origin.z|float %}
G90 ; Switch to absolute positioning
G0 Z{max_z} ; Move Z to its maximum position
M5 # Stop the spindle
M84 X Y Z # Turn off the motors
CANCEL_PRINT_BASE
# G28: Custom homing sequence
[gcode_macro G28]
rename_existing: G28.0
gcode:
# Define default behavior when no specific axis is requested
{% set home_all = 'X' not in params and 'Y' not in params and 'Z' not in params %}
# Home Z first if requested or if no axes are specified to avoid collisions
{% if 'Z' in params or home_all %}
G28.0 Z
{% endif %}
# Home X and Y; home both if no specific axis is mentioned
{% if 'X' in params or 'Y' in params or home_all %}
G28.0 {% if 'X' in params or home_all %}X{% endif %} {% if 'Y' in params or home_all %}Y{% endif %}
{% endif %}
# Force Absolute positioning mode
G90
# Reset kinematic positions for axes that were homed
{% if 'X' in params or home_all %}
SET_KINEMATIC_POSITION X=0 # Reset X position to zero
{% endif %}
{% if 'Y' in params or home_all %}
SET_KINEMATIC_POSITION Y=0 # Reset Y position to zero
{% endif %}