-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathworkspaceMacro.cfg
83 lines (69 loc) · 3.15 KB
/
workspaceMacro.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
76
77
78
79
80
81
82
83
[gcode_macro SAVE_OFFSETS]
gcode:
SAVE_VARIABLE VARIABLE=x_offset VALUE='{printer.gcode_move.homing_origin.x}'
SAVE_VARIABLE VARIABLE=y_offset VALUE='{printer.gcode_move.homing_origin.y}'
SAVE_VARIABLE VARIABLE=z_offset VALUE='{printer.gcode_move.homing_origin.z}'
[gcode_macro LOAD_OFFSETS]
gcode:
{% set svv = printer.save_variables.variables %}
SET_GCODE_OFFSET X={svv.x_offset} Y={svv.y_offset} Z={svv.z_offset}
RESPOND PREFIX="info" MSG="Loaded offsets: X={svv.x_offset} Y={svv.y_offset} Z={svv.z_offset}"
[gcode_macro CHECK_OFFSET_XYZ]
gcode:
# Print out the offsets
RESPOND PREFIX="info" MSG="Current Workspace Offsets - X: {printer.gcode_move.homing_origin.x}, Y: {printer.gcode_move.homing_origin.y}, Z: {printer.gcode_move.homing_origin.z}"
[gcode_macro SET_OFFSETS_FROM_TOOL]
gcode:
# Get the current position of the toolhead
{% set current_x = printer.toolhead.position.x %}
{% set current_y = printer.toolhead.position.y %}
{% set current_z = printer.toolhead.position.z %}
# Set the current position as offsets
SET_GCODE_OFFSET X={current_x} Y={current_y} Z={current_z}
# Optional: Respond with the new offsets
RESPOND PREFIX="info" MSG="New offsets set: X={current_x} Y={current_y} Z={current_z}"
[gcode_macro UPDATE_OFFSETS_XYZ]
gcode:
# Calculate current offsets from homing positions and effective G-code positions
{% set current_x_offset = printer.gcode_move.homing_origin.x %}
{% set current_y_offset = printer.gcode_move.homing_origin.y %}
{% set current_z_offset = printer.gcode_move.homing_origin.z %}
# Check if the user has provided new offset values and update accordingly
# Offsets must be >= 0 or they will be reset to 0
{% if params.X is defined %}
{% set new_x_offset = params.X|float %}
{% if new_x_offset >= 0 %}
{% set current_x_offset = new_x_offset%}
{% else %}
RESPOND PREFIX="error" MSG="X Offset is negative and will be set to 0"
{% set current_x_offset = 0%}
{%endif%}
{% endif %}
{% if params.Y is defined %}
{% set new_y_offset = params.Y|float %}
{% if new_y_offset >= 0 %}
{% set current_y_offset = new_y_offset %}
{% else %}
RESPOND PREFIX="error" MSG="Y Offset is negative and will be set to 0"
{% set current_y_offset = 0 %}
{%endif%}
{% endif %}
{% if params.Z is defined %}
{% set new_z_offset = params.Z|float %}
{% if new_z_offset >= 0 %}
{% set current_z_offset = new_z_offset %}
{% else %}
RESPOND PREFIX="error" MSG="Z Offset is negative and will be set to 0"
{% set current_z_offset = 0 %}
{%endif%}
{% endif %}
# Update the G-code offsets
SET_GCODE_OFFSET X={current_x_offset} Y={current_y_offset} Z={current_z_offset}
# Optional: Respond with the new offset values
RESPOND PREFIX="info" MSG="Updated Workspace Offsets - X: {current_x_offset}, Y: {current_y_offset}, Z: {current_z_offset}"
[gcode_macro ZERO_OFFSETS_XYZ]
gcode:
# Reset the G-code offsets to zero
SET_GCODE_OFFSET X=0 Y=0 Z=0
# Optional: Respond to confirm the offsets have been cleared
RESPOND PREFIX="info" MSG="Workspace offsets cleared. X, Y, Z offsets set to 0."