This page is a reference copy of the stock Klipper configuration files that ship on the Creality K2 Plus. They normally live hidden on the printer’s internal storage, so they’re easy to lose track of after an update or a botched edit. Having them written down means you can compare against your own setup, understand what the on-printer macros actually do (handy when tuning a slicer profile), and rebuild a file from scratch if you ever corrupt one.
These were pulled from firmware identifying itself internally as F008 (the K2 Plus platform). Your version headers may differ — check the comment block at the top of each file against yours before assuming they match.
Back up before you touch anything. These files run the machine. A bad edit can cause crashes, failed homing, or damage. Always copy the originals off the printer first (see below), change one thing at a time, and keep a known-good backup you can restore.
Getting root access over SSH
To view or edit the hidden default printer files, SSH into the printer as root. First enable root access on the printer: go to Settings → General → Root Account and turn it on.
Then connect from your computer. Replace the IP below with your own printer’s address (you’ll find it under the printer’s network settings):
ssh root@192.168.1.16
cd /mnt/UDISK/printer_data/config
ls -l
(If SSH won’t connect, go to Network, forget the current connection, and reconnect.)
Back up the originals first
From a terminal on your own computer (not the SSH session), pull a full copy of the config folder down with scp so you always have the untouched originals:
scp -r root@192.168.1.16:/mnt/UDISK/printer_data/config ~/k2plus-config-backup
Or make an on-printer backup of a single file before editing it (from the SSH session):
cp printer.cfg printer.cfg.bak
Applying changes
After editing a file, Klipper has to reload it. Run FIRMWARE_RESTART from the console (Fluidd/Mainsail or the printer screen’s G-code terminal), or restart the Klipper service. Watch the console on restart — if there’s a syntax error or a renamed option, Klipper will refuse to start and tell you exactly which line is the problem. If that happens, restore your backup and try again.
What each file does
- printer.cfg — the main config. Pulls in all the others via
[include], and defines the MCUs, steppers, extruder, heaters, bed mesh, resonance tester, and theprtouch_v3strain-gauge bed probe. The auto-generatedSAVE_CONFIGblock at the bottom holds your input-shaper and bed-mesh results. - gcode_macro.cfg — the big one. Contains
START_PRINT,END_PRINT,PAUSE/RESUME, the fan overrides (M106/M107/M141), the “quiet mode” macros (Qmode), and the calibration routines (G29,INPUTSHAPER,BED_MESH_CALIBRATE_START_PRINT, Z-tilt). - box.cfg — the CFS (Creality Filament System) multi-spool box: serial link, cutter positions, and the
M8200macro that the slicer’s toolchange G-code calls. - motor_control.cfg — the closed-loop (servo-style) stepper driver tuning for X, Y, Z, Z1, and E: stall pins plus the PID/observer parameters for each axis.
- printer_params.cfg — fan-feedback pins, the default/homing temperatures (
custom_macro), and the product size/temperature limits. - sensorless.cfg — sensorless homing (StallGuard) via
homing_overrideand the per-axis_HOME_X/Y/Zhelper macros.
Default printer files
box.cfg
CFS multi-spool control: the RS-485 serial link to the box, cut/clean/extrude coordinates, and the M8200 command that the slicer’s toolchange sequence drives (pre-op, cut, retrude, extrude, waste, flush, end). The Chinese comments are from Creality and describe each position/step.
[serial_485 serial485]
serial: /dev/ttyS5
baud: 230400
[auto_addr]
[filament_rack]
not_pin: !PA5
[box]
bus:serial485
filament_sensor:filament_sensor
pre_cut_pos_x: 10 #预撞刀的位置,保证垂直撞刀
pre_cut_pos_y: 200
#cut_pos_x: -6.5
cut_pos_y: 200
Tn_retrude: -10 #切料后,使耗材退出挤出齿轮的长度
Tn_retrude_velocity: 600 #回抽速度
Tn_extrude_temp: 220 #挤出温度
Tn_extrude: 140 #如果当前温度设置温度,预加热刀120
Tn_extrude_velocity: 360 #挤出速度
buffer_empty_len: 30 #缓冲器回抽预留长度,需要挤出缓冲器预留的长度 (切断挤出机内撞刀到挤出齿轮的长度)
clean_left_pos_x: 135 #料槽吐完料摆动 左边界
clean_left_pos_y: 378
clean_right_pos_x: 160 #料槽吐完料摆动 右边界
clean_right_pos_y: 378
clean_velocity: 12000
box_need_clean_length:70
cut_velocity: 30000
extrude_pos_x: 133 #切换料吐料的位置
extrude_pos_y: 378
has_extrude_pos: 1 #有没有吐料需要 区分K1_MAX和f008
safe_pos_y: 345
safe_pos_x: 225
clean_pos_left_x: 160 #擦喷嘴 硅胶的左边界的坐标
clean_pos_right_x:170 #擦喷嘴 硅胶的右边界的坐标
clean_pos_middle_y:374 #擦喷嘴 硅胶的Y轴中间坐标
pre_cut_cal_pos_x:-5 #预切刀校准位置,减少校准时间
check_cut_pos_x_max: -5.5 #切刀校准最大值
check_cut_pos_x_min: -9.5 #切刀校准最小值
switch_pin:!nozzle_mcu:PB9
version: 1
[load_ai]
[gcode_macro BOX_LOAD_MATERIAL_HEATING]
gcode:
BOX_GO_TO_EXTRUDE_POS
BOX_SET_TEMP
[gcode_macro BOX_LOAD_MATERIAL_CUT_MATERIAL]
gcode:
BOX_CUT_MATERIAL
BOX_SAVE_FAN
[gcode_macro BOX_LOAD_MATERIAL_RETRUDE_MATERIAL]
gcode:
BOX_GO_TO_EXTRUDE_POS
BOX_SET_TEMP
BOX_MODE_WAIT
BOX_RETRUDE_MATERIAL
[gcode_macro BOX_LOAD_MATERIAL_EXTRUDE_MATERIAL]
gcode:
{% set get_tnn = "" %}
{% if 'TNN' in params|upper %}
{% set get_tnn = ('TNN=' + params.TNN) %}
{% endif %}
BOX_MODE_WAIT
BOX_EXTRUDE_MATERIAL {get_tnn}
[gcode_macro BOX_LOAD_MATERIAL_MATERIAL_FLUSH]
gcode:
{% set get_tnn = "" %}
{% if 'TNN' in params|upper %}
{% set get_tnn = ('TNN=' + params.TNN) %}
{% endif %}
BOX_EXTRUDER_EXTRUDE {get_tnn}
BOX_MATERIAL_CHANGE_FLUSH
[gcode_macro BOX_LOAD_MATERIAL_END]
gcode:
BOX_RESTORE_FAN
BOX_MOVE_TO_SAFE_POS
[gcode_macro BOX_LOAD_MATERIAL]
gcode:
BOX_LOAD_MATERIAL_HEATING
BOX_LOAD_MATERIAL_CUT_MATERIAL
BOX_LOAD_MATERIAL_RETRUDE_MATERIAL
BOX_LOAD_MATERIAL_EXTRUDE_MATERIAL
BOX_LOAD_MATERIAL_MATERIAL_FLUSH
BOX_LOAD_MATERIAL_END
[gcode_macro BOX_QUIT_MATERIAL_HEATING]
gcode:
BOX_GO_TO_EXTRUDE_POS
{% if printer["filament_switch_sensor filament_sensor"].filament_detected %}
BOX_SET_TEMP
{% endif %}
[gcode_macro BOX_QUIT_MATERIAL_CUT_MATERIAL]
gcode:
BOX_CUT_MATERIAL
[gcode_macro BOX_QUIT_MATERIAL_RETRUDE_MATERIAL]
gcode:
BOX_GO_TO_EXTRUDE_POS
{% if printer["filament_switch_sensor filament_sensor"].filament_detected %}
BOX_SET_TEMP
{% endif %}
BOX_RETRUDE_MATERIAL
[gcode_macro BOX_QUIT_MATERIAL_END]
gcode:
BOX_MOVE_TO_SAFE_POS
[gcode_macro BOX_QUIT_MATERIAL]
gcode:
BOX_QUIT_MATERIAL_HEATING
BOX_QUIT_MATERIAL_CUT_MATERIAL
BOX_QUIT_MATERIAL_RETRUDE_MATERIAL
BOX_QUIT_MATERIAL_END
# eg:
# BOX_EXTRUDE_MATERIAL TNN=T1A
# BOX_EXTRUDER_EXTRUDE TNN=T1A
# BOX_MATERIAL_FLUSH LEN=100 VELOCITY=360 TEMP=220
# BOX_RETRUDE_MATERIAL_WITH_TNN TNN=T1A
[gcode_macro BOX_INFO_REFRESH]
gcode:
BOX_SET_PRE_LOADING ADDR={params.ADDR} NUM={params.NUM} ACTION=RUN
M400
BOX_GET_RFID ADDR={params.ADDR} NUM={params.NUM}
M400
BOX_GET_REMAIN_LEN ADDR={params.ADDR} NUM={params.NUM}
M400
# CR_BOX_PRE_OPT
# CR_BOX_CUT
# CR_BOX_RETRUDE
# CR_BOX_EXTRUDE
# CR_BOX_WASTE
# CR_BOX_FLUSH
# CR_BOX_END_OPT
# CR_BOX_PRE_OPT_EXTRA
# CR_BOX_END_OPT_EXTRA
# 准备换耗材:M8200 P S[next] CR_BOX_PRE_OPT
# 切刀动作 M8200 C S0 CR_BOX_CUT
# 料盒退料动作:M8200 R I[pre] p0 CR_BOX_RETRUDE
# 料盒进料动作:M8200 L I[next] p1 CR_BOX_EXTRUDE
# 废料槽检测:M8200 W CR_BOX_WASTE
# 冲刷动作:M8200 F S[speed]L[length] CR_BOX_FLUSH
# 结束M8200 O S[next] CR_BOX_END_OPT
[gcode_macro M8200]
variable_tnn: None
gcode:
{% if params.P is defined %}
# 准备换耗材:M8200 P S[next]
CR_BOX_PRE_OPT
{% endif %}
{% if params.C is defined %}
# 切刀动作 M8200 C S0
CR_BOX_CUT
{% endif %}
{% if params.R is defined %}
# 料盒退料动作:M8200 R I[pre] p0
{% if params.E is defined %}
CR_BOX_RETRUDE LENGTH={params.E|float}
{% else %}
CR_BOX_RETRUDE
{% endif %}
{% endif %}
{% if params.L is defined %}
# 料盒进料动作:M8200 L I[next] p1
{% set I_param = params.I|int %}
{% set addr = (I_param / 4 + 1)|int|string %}
{% set num_map = ['A', 'B', 'C', 'D'] %}
{% set num = (I_param % 4)|int %}
{% set tnn = 'T' + addr + num_map[num] %}
{action_respond_info("tnn: %s" % tnn)}
CR_BOX_EXTRUDE TNN={tnn}
SET_GCODE_VARIABLE MACRO=M8200 VARIABLE=tnn VALUE='"{tnn}"'
CR_BOX_WASTE
{% endif %}
{% if params.W is defined %}
# 废料槽检测:M8200 W
CR_BOX_WASTE
{% endif %}
{% if params.F is defined %}
# 冲刷动作:M8200 F S[speed]L[length]
{% set tnn = printer['gcode_macro M8200'].tnn %}
{action_respond_info("tnn: %s" % tnn)}
CR_BOX_FLUSH TNN={tnn}
SET_GCODE_VARIABLE MACRO=M8200 VARIABLE=tnn VALUE='""'
{% endif %}
{% if params.O is defined %}
# 结束M8200 O S[next]
CR_BOX_END_OPT
{% endif %}
##### 举例T0可由以下宏命令替换 #####
# # CR_BOX_PRE_OPT
# M8200 P
# # CR_BOX_CUT
# M8200 C
# # CR_BOX_RETRUDE
# M8200 R
# # CR_BOX_EXTRUDE
# M8200 L I0
# # CR_BOX_WASTE
# M8200 W
# # CR_BOX_FLUSH
# M8200 F
# # CR_BOX_END_OPT
# M8200 O
# # T命令拆解后替换
# # 此处示例T0(假设均为同类型耗材,当前Z坐标50,已有耗材进去,当前挤出温度220,T0最大挤出温度为240)
# ## 1. 抬升Z轴,防止刮模型
# G0 Z50.4 F600
# ## 2. 预处理处理
# M8200 P
# ## 3. 移动到预切刀位置
# G0 X10 Y200 F12000
# ## 4. 设置撞刀的速度、加速度与加减速度
# SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=25000
# G0 F9000
# ## 5. 执行切刀动作
# M8200 C
# ## 6. 移动到挤出位置
# ### 先移动Y轴
# G0 Y345 F12000
# ### 6.1. 移动X轴,对准废料槽,此位置直行无碰撞风险
# G0 X139
# ### 6.2. 移动Y轴,进入废料槽
# G0 Y378
# ### 6.3. 移动X轴抬起挡板,易于接收废料,使其成型
# G0 X133
# ## 7. 耗材退到料盒
# M8200 R
# ## 8. 提前设置耗材挤出温度
# M104 S240
# ## 9. 料盒进料
# M8200 L I0
# ## 10. 冲刷(只展示一次)
# G91
# G0 E90 F600
# G90
# ### 10.1. 设置一下加速度与加减速,横擦一下,使用钢片割断耗材
# SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=5000
# G0 X160 F12000
# G0 X135
# ### 10.2 胶条上圆圈擦拭
# G0 X160 Y374 F12000
# G2 I4 J0 P1 F10000
# G0 X170 Y374 F12000
# G3 I-4 J0 P1 F10000
# ### 10.3 横擦抖动,并回到挤出位置
# G0 X160 Y378 F12000
# G0 X133 Y378 F12000
# G0 X160 Y378 F12000
# G0 X133 Y378 F12000
# G0 X160 Y378 F12000
# G0 X133 Y378 F12000
# ## 11. 移动出废料槽
# G0 X160
# G0 Y345 F12000
# ## 12. 结束处理
# M8200 O
# ## 13. 恢复Z轴(或者移动回模型后再恢复Z轴)
# G0 Z50 F600
gcode_macro.cfg
The core macro file. This is what a slicer’s START_PRINT / END_PRINT calls hand off to, and it owns homing, meshing, nozzle cleaning, pause/resume, the fan-curve overrides, and the calibration routines. If you’re wondering why a minimal slicer start G-code is enough on this printer, it’s because everything below already runs on the machine.
# F008
# CreateDate: 2023/03/21
[gcode_macro PRINTER_PARAM]
variable_z_safe_pause: 0.0
variable_z_safe_g28: 3.0
variable_max_x_position: 350.0
variable_max_y_position: 352.0
variable_max_z_position: 350.0
variable_fans: 3
variable_auto_g29: 0
variable_fan0_min: 25
variable_fan1_min: 50
variable_fan2_min: 100
variable_fan2_speed: 0
variable_fan0_speed: 0
variable_hotend_temp: 0
variable_e_min_current: 0.27
variable_bed_steady_temp: 29,60,70,100
variable_bed_steady_time: 180,60,120,600
gcode:
[gcode_macro MAINTENANCE_ITEM_PARAM]
variable_cut_calibration: 10000 # 次数
variable_shaper_calibrate: 1800000 # 秒 500小时
variable_belt_tensioning: 3600000 # 秒 1000小时
variable_motion_mechanism_lubrication: 1800000 # 秒
variable_camera_maintenance: 1800000 # 秒
variable_fan_inspection: 1800000 # 秒
variable_nozzle: 20000 # 克
variable_cut: 100000 # 次
variable_machine_teflon_tube: 3600000 # 秒
variable_wipe_mouth_strip: 1800000 # 秒
variable_air_filter: 1800000 # 秒
variable_cfs_teflon_tube: 3600000 # 秒
variable_cfs_desiccant: 1800000 # 秒
gcode:
[gcode_macro MAINTENANCE_ITEM]
gcode:
[gcode_macro AUTOTUNE_SHAPERS]
variable_autotune_shapers: 'zv','mzv','ei'
gcode:
[gcode_macro IF_NEED_HOME]
gcode:
{% set x_axes = printer.toolhead.homed_axes %}
{% if x_axes is defined and x_axes[0] is defined %}
{action_respond_info(
"x_axes: %s \n"
% (x_axes))}
{% else %}
G28
{% endif %}
[gcode_macro LOAD_MATERIAL_CLOSE_FAN2]
variable_fan2_value: 0
gcode:
SAVE_GCODE_STATE NAME=myMoveState
{% if printer['output_pin fan2'].value > 0.0 %}
SET_GCODE_VARIABLE MACRO=LOAD_MATERIAL_CLOSE_FAN2 VARIABLE=fan2_value VALUE={printer['output_pin fan2'].value}
M107 P2
{% endif %}
[gcode_macro LOAD_MATERIAL_RESTORE_FAN2]
gcode:
{% set fan2_value = printer['gcode_macro LOAD_MATERIAL_CLOSE_FAN2'].fan2_value|float %}
RESTORE_GCODE_STATE NAME=myMoveState
{% if fan2_value > 0.0 %}
{% set s_value = (fan2_value * 255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) * 255 / (255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) %}
M106 P2 S{s_value}
SET_GCODE_VARIABLE MACRO=LOAD_MATERIAL_CLOSE_FAN2 VARIABLE=fan2_value VALUE=0
{% endif %}
[gcode_macro LOAD_MATERIAL_HEATING]
gcode:
SAVE_GCODE_STATE NAME=myMoveState
BOX_GO_TO_EXTRUDE_POS
FILAMENT_RACK_SAVE_FAN
FILAMENT_RACK_PRE_FLUSH
{% if printer["filament_switch_sensor filament_sensor"].filament_detected %}
FILAMENT_RACK_SET_TEMP
{% endif %}
[gcode_macro LOAD_MATERIAL_MATERIAL_FLUSH]
gcode:
{% if printer["filament_switch_sensor filament_sensor"].filament_detected %}
FILAMENT_RACK_FLUSH
{% endif %}
[gcode_macro LOAD_MATERIAL_END]
gcode:
FILAMENT_RACK_RESTORE_FAN
SET_COOL_TEMP
BOX_MOVE_TO_SAFE_POS
RESTORE_GCODE_STATE NAME=myMoveState
[gcode_macro LOAD_MATERIAL]
gcode:
LOAD_MATERIAL_HEATING
LOAD_MATERIAL_MATERIAL_FLUSH
LOAD_MATERIAL_END
[gcode_macro QUIT_MATERIAL_HEATING]
gcode:
SAVE_GCODE_STATE NAME=myMoveState
BOX_GO_TO_EXTRUDE_POS
{% if printer["filament_switch_sensor filament_sensor"].filament_detected %}
FILAMENT_RACK_SET_TEMP
{% endif %}
[gcode_macro QUIT_MATERIAL_CUT_MATERIAL]
gcode:
BOX_MOVE_TO_CUT
M400
[gcode_macro QUIT_MATERIAL_RETRUDE_MATERIAL]
gcode:
{% if printer["filament_switch_sensor filament_sensor"].filament_detected %}
G91
G0 E-10 F360
G90
M400
{% endif %}
[gcode_macro QUIT_MATERIAL_END]
gcode:
BOX_MOVE_TO_SAFE_POS
SET_COOL_TEMP
RESTORE_GCODE_STATE NAME=myMoveState
[gcode_macro QUIT_MATERIAL]
gcode:
QUIT_MATERIAL_HEATING
QUIT_MATERIAL_CUT_MATERIAL
QUIT_MATERIAL_RETRUDE_MATERIAL
QUIT_MATERIAL_END
[gcode_macro Qmode]
variable_flag: 0
variable_accel: 0
variable_accel_to_decel: 0
variable_velocity: 0
variable_square_corner_velocity: 0
variable_pressure_advance:0.0
variable_fan0_value: 0.00
variable_fan1_value: 0.00
variable_fan2_value: 0.00
variable_speed_factor: 0
variable_max_accel: 2500
variable_max_accel_to_decel: 2500
gcode:
{% set printer_state = printer.print_stats.state %}
{% if printer['gcode_macro Qmode'].flag|int == 0 %}
{% if printer_state == "printing" or printer_state == "paused" %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=accel VALUE={printer.toolhead.max_accel}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=accel_to_decel VALUE={printer.toolhead.max_accel_to_decel}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=velocity VALUE={printer.toolhead.max_velocity}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=square_corner_velocity VALUE={printer.toolhead.square_corner_velocity}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=pressure_advance VALUE={printer.extruder.pressure_advance}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=speed_factor VALUE={printer.gcode_move.speed_factor}
# Set Motion Parameters
SET_VELOCITY_LIMIT ACCEL=2500
SET_VELOCITY_LIMIT ACCEL_TO_DECEL=2500
SET_VELOCITY_LIMIT VELOCITY=150
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=5
SET_PRESSURE_ADVANCE ADVANCE=0.05
M220 S50
{% set tmp = printer['output_pin fan0'].value * 255 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE={tmp}
{% if tmp - printer['gcode_macro PRINTER_PARAM'].fan0_min > (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
{% set tmp = printer['gcode_macro PRINTER_PARAM'].fan0_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
SET_PIN PIN=fan0 VALUE={tmp}
{% endif %}
{% set tmp = printer['output_pin fan1'].value * 255 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE={printer['output_pin fan1'].value * 255}
{% if tmp - printer['gcode_macro PRINTER_PARAM'].fan1_min > (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
{% set tmp = printer['gcode_macro PRINTER_PARAM'].fan1_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
SET_PIN PIN=fan1 VALUE={tmp}
{% endif %}
{% set tmp = printer['output_pin fan2'].value * 255 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE={printer['output_pin fan2'].value * 255}
{% if tmp - printer['gcode_macro PRINTER_PARAM'].fan2_min > (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
{% set tmp = printer['gcode_macro PRINTER_PARAM'].fan2_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
SET_PIN PIN=fan2 VALUE={tmp}
{% endif %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=flag VALUE=1
SET_QMODE_FLAG FLAG=1
{% endif %}
{% endif %}
[gcode_macro Qmode_exit]
gcode:
{% set printer_state = printer.print_stats.state %}
{% if printer['gcode_macro Qmode'].flag|int == 1 %}
{% if printer_state == "printing" or printer_state == "paused" %}
SET_VELOCITY_LIMIT ACCEL={printer['gcode_macro Qmode'].accel}
SET_VELOCITY_LIMIT ACCEL_TO_DECEL={printer['gcode_macro Qmode'].accel_to_decel}
SET_VELOCITY_LIMIT VELOCITY={printer['gcode_macro Qmode'].velocity}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={printer['gcode_macro Qmode'].square_corner_velocity}
SET_PRESSURE_ADVANCE ADVANCE={printer['gcode_macro Qmode'].pressure_advance}
M220 S{printer['gcode_macro Qmode'].speed_factor * 100}
{% if printer['output_pin fan0'].value != 0 %}
{action_respond_info("fan0_value = %s" % printer['gcode_macro Qmode'].fan0_value)}
SET_PIN PIN=fan0 VALUE={printer['gcode_macro Qmode'].fan0_value}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE=0
{% endif %}
{% if printer['output_pin fan1'].value != 0 %}
{action_respond_info("fan1_value = %s" % printer['gcode_macro Qmode'].fan1_value)}
SET_PIN PIN=fan1 VALUE={printer['gcode_macro Qmode'].fan1_value}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE=0
{% endif %}
{% if printer['output_pin fan2'].value != 0 %}
{action_respond_info("fan2_value = %s" % printer['gcode_macro Qmode'].fan2_value)}
SET_PIN PIN=fan2 VALUE={printer['gcode_macro Qmode'].fan2_value}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=flag VALUE=0
SET_QMODE_FLAG FLAG=0
{% endif %}
{% endif %}
[gcode_macro M204]
rename_existing: M204.1
gcode:
# {% if printer['gcode_macro Qmode'].flag|int == 0 %}
{% set get_params = "" %}
{% set qmode_max_accel = printer['gcode_macro Qmode'].max_accel|string %}
{% if 'S' in params|upper %}
{% if printer['gcode_macro Qmode'].flag|int == 1 and params.S|float > qmode_max_accel|float %}
{% set get_params = (get_params + ' ' + 'S' + qmode_max_accel) %}
{% else %}
{% set get_params = (get_params + ' ' + 'S' + params.S) %}
{% endif %}
{% endif %}
{% if 'P' in params|upper %}
{% if printer['gcode_macro Qmode'].flag|int == 1 and params.P|float > qmode_max_accel|float %}
{% set get_params = (get_params + ' ' + 'P' + qmode_max_accel) %}
{% else %}
{% set get_params = (get_params + ' ' + 'P' + params.P) %}
{% endif %}
{% endif %}
{% if 'T' in params|upper %}
{% if printer['gcode_macro Qmode'].flag|int == 1 and params.T|float > qmode_max_accel|float %}
{% set get_params = (get_params + ' ' + 'T' + qmode_max_accel) %}
{% else %}
{% set get_params = (get_params + ' ' + 'T' + params.T) %}
{% endif %}
{% endif %}
M204.1 {get_params}
# {% endif %}
[gcode_macro M205]
gcode:
{% if 'X' in params %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.X}
{% elif 'Y' in params %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.Y}
{% endif %}
[gcode_macro M106]
gcode:
{% set fans = printer["gcode_macro PRINTER_PARAM"].fans|int %}
{% set fan = 0 %}
{% set value = 0 %}
{% if params.P is defined %}
{% set tmp = params.P|int %}
{% if tmp < fans %}
{% set fan = tmp %}
{% endif %}
{% endif %}
{% if params.S is defined %}
{% set tmp = params.S|float %}
{% else %}
{% set tmp = 255 %}
{% endif %}
{% if tmp > 0 %}
{% if fan == 0 %}
{% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan0_min) / 255 * tmp %}
{% if printer['gcode_macro Qmode'].flag | int == 1 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan0_min + value}
{% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + value %}
{% endif %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + value %}
{% endif %}
{% endif %}
{% if fan == 1 %}
{% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan1_min) / 255 * tmp %}
{% if printer['gcode_macro Qmode'].flag | int == 1 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan1_min + value}
{% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + value %}
{% endif %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + value %}
{% endif %}
{% endif %}
{% if fan == 2 %}
{% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) / 255 * tmp %}
{% if printer['gcode_macro Qmode'].flag | int == 1 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan2_min + value}
{% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + value %}
{% endif %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + value %}
{% endif %}
{% endif %}
{% endif %}
{% if value >= 255 %}
{% set value = 255 %}
{% endif %}
SET_PIN PIN=fan{fan} VALUE={value}
[gcode_macro M107]
gcode:
{% set fans = printer["gcode_macro PRINTER_PARAM"].fans|int %}
{% if params.P is defined %}
{% if params.P|int < fans %}
SET_PIN PIN=fan{params.P|int} VALUE=0
{% else %}
SET_PIN PIN=fan0 VALUE=0
{% endif %}
{% else %}
SET_PIN PIN=fan0 VALUE=0
SET_PIN PIN=fan2 VALUE=0
{% endif %}
[gcode_macro M141]
gcode:
{% if 'S' in params|upper %}
# SET_TEMPERATURE_FAN_SWITCH TEMPERATURE_FAN=chamber_fan VALUE=1
{% if printer["temperature_fan chamber_fan"].speed > 0.0 %}
SET_PIN PIN=fan1 VALUE=255
{% else %}
SET_PIN PIN=fan1 VALUE=0
{% endif %}
{% if params.S|int > 40 %}
SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET=0
SET_PIN PIN=fan1 VALUE=0
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={params.S}
{% elif params.S|int > 0 %}
SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET={params.S|default(35)}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% else %}
SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET=35
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% if params.S|int == 0 %}
SET_PIN PIN=fan1 VALUE=0
# SET_TEMPERATURE_FAN_SWITCH TEMPERATURE_FAN=chamber_fan VALUE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M191]
gcode:
{% if 'S' in params|upper %}
# SET_TEMPERATURE_FAN_SWITCH TEMPERATURE_FAN=chamber_fan VALUE=1
{% if printer["temperature_fan chamber_fan"].speed > 0.0 %}
SET_PIN PIN=fan1 VALUE=255
{% else %}
SET_PIN PIN=fan1 VALUE=0
{% endif %}
{% if params.S|int > 40 %}
SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET=0
SET_PIN PIN=fan1 VALUE=0
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={params.S} WAIT=1
{% elif params.S|int > 0 %}
SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET={params.S|default(35)}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0 WAIT=1
{% else %}
SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET=35
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% if params.S|int == 0 %}
SET_PIN PIN=fan1 VALUE=0
# SET_TEMPERATURE_FAN_SWITCH TEMPERATURE_FAN=chamber_fan VALUE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M900]
gcode:
{% if 'K' in params %}
{% if 'E' in params %}
SET_PRESSURE_ADVANCE EXTRUDER={params.E} ADVANCE={params.K}
{% else %}
SET_PRESSURE_ADVANCE ADVANCE={params.K}
{% endif %}
{% endif %}
[delayed_gcode wait_temp]
# initial_duration: 2.
gcode:
{% set cur_temp = printer.extruder.temperature %}
{% if cur_temp|int < 40 %}
{action_respond_info("end_temp!\n")}
WAIT_TEMP_END
{% else %}
{action_respond_info("cur_temp = %s \n" % (cur_temp))}
UPDATE_DELAYED_GCODE ID=wait_temp DURATION=5
{% endif %}
[gcode_macro WAIT_TEMP_START]
gcode:
UPDATE_DELAYED_GCODE ID=wait_temp DURATION=1
M106 P0 S255
[gcode_macro WAIT_TEMP_END]
gcode:
UPDATE_DELAYED_GCODE ID=wait_temp DURATION=0
M106 P0 S0
[gcode_macro PRINT_CALIBRATION]
# This part of the command is replaced by the application side without passing parameters
gcode:
CX_PRINT_LEVELING_CALIBRATION
[gcode_macro FIRST_FLOOR_PAUSE_POSITION]
gcode:
{% set extruder_temp = printer.custom_macro.g28_ext_temp %}
M104 S{extruder_temp}
{% set y_park = printer.toolhead.axis_maximum.y/2 %}
{% set x_park = printer['gcode_macro PRINTER_PARAM'].max_x_position|float + 1 %}
G90
G1 Z2 F600
G1 X{x_park} Y{y_park} F6000
G1 Z0.2 F600
[gcode_macro ACCURATE_G28]
gcode:
ACCURATE_HOME_Z
# PRINT_TEMP_SET EXTRUDER_TEMP=130 BED_TEMP=40
# PRINT_TEMP_SET EXTRUDER_TEMP=130 BED_TEMP=40 WAIT_TEMP=1
[gcode_macro PRINT_TEMP_SET]
gcode:
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(220)|float %}
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set EXTRUDER_WAITTEMP = (140.0|float)|int %}
{% set WAIT_TEMP = params.WAIT_TEMP|default(0)|int %}
M106 S0 #需要关闭模型风扇
M140 S{BED_TEMP}
M104 S{EXTRUDER_WAITTEMP}
SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=5000
{% if WAIT_TEMP|int == 1 %}
M104 S{EXTRUDER_WAITTEMP}
M190 S{BED_TEMP}
M109 S{EXTRUDER_WAITTEMP}
{% endif %}
[gcode_macro ZDOWN_SWITCH_SET]
gcode:
ZDOWN_SWITCH ENABLE={params.VALUE}
[gcode_macro SET_CHAMBER_FAN]
gcode:
{% set temp = printer["temperature_fan chamber_fan"].temperature|int %}
{% set target = printer["temperature_fan chamber_fan"].target|int %}
{% set control = printer["configfile"]["config"]["temperature_fan chamber_fan"].control %}
{action_respond_info("temp: %s, target: %s, control: %s" % (temp, target, control))}
{% if control == "watermark" %}
{% set max_delta = printer["configfile"]["config"]["temperature_fan chamber_fan"].max_delta|int %}
{action_respond_info("max_delta: %s" % (max_delta))}
{% if temp >= target %}
{% set tmp = temp + max_delta + 1 %}
# 由于M141设置导致风扇未开启,需要恢复状态(先设置高于的温度值,再恢复)
SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET={tmp}
G4 P500
M400
SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET={target}
{% endif %}
{% endif %}
[gcode_macro START_PRINT]
variable_prepare: 0
gcode:
BOX_START_PRINT
G90
SET_GCODE_OFFSET Z=0
{% set g28_extruder_temp = printer.custom_macro.g28_ext_temp %}
{% set bed_temp = printer.custom_macro.default_bed_temp %}
{% set extruder_temp = printer.custom_macro.default_extruder_temp %}
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(220)|float %}
# {% set EXTRUDER_WAITTEMP = (EXTRUDER_TEMP/1.5|float)|int %}
{% set EXTRUDER_WAITTEMP = (140.0|float)|int %}
# {% set y_park = printer.toolhead.axis_maximum.y/2 %}
{% if printer['gcode_macro START_PRINT'].prepare|int == 0 %}
{action_respond_info("print prepared 111")}
M106 S0 #需要关闭模型风扇
M140 S{params.BED_TEMP}
M104 S{EXTRUDER_WAITTEMP}
SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=5000
G28
# 精擦嘴
NOZZLE_CLEAR
M104 S{EXTRUDER_WAITTEMP}
M190 S{params.BED_TEMP}
M109 S{EXTRUDER_WAITTEMP}
BOX_NOZZLE_CLEAN
# 精归零
NEXT_HOMEZ_NACCU
G28 Z
{% else %}
PRINT_PREPARE_CLEAR
{% endif %}
M140 S{params.BED_TEMP}
M104 S{params.EXTRUDER_TEMP}
BOX_GO_TO_EXTRUDE_POS
M190 S{params.BED_TEMP}
M109 S{params.EXTRUDER_TEMP} ;wait nozzle heating
M220 S100 ;Reset Feedrate
# M221 S100 ;Reset Flowrate
G21
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=10
M204 S5000
SET_VELOCITY_LIMIT ACCEL_TO_DECEL=5000
BOX_NOZZLE_CLEAN
G92 E0 ; Reset Extruder
SET_PIN PIN=extruder_fan VALUE=1
# SET_TEMPERATURE_FAN_SWITCH TEMPERATURE_FAN=chamber_fan VALUE=1
[gcode_macro PRINT_PREPARED]
gcode:
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=prepare VALUE=1
{action_respond_info("print prepared")}
[gcode_macro PRINT_PREPARE_CLEAR]
gcode:
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=prepare VALUE=0
[gcode_macro END_PRINT_POINT_WITHOUT_LIFTING]
gcode:
{% if "xyz" in printer.toolhead.homed_axes %}
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
{% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
{% set act_z = printer.toolhead.position.z|float %}
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-1.0 F180
G1 E-{E} F4000
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if act_z < (max_z - 5) %}
G1 Z2.0 F600
{% endif %}
G90
{% set y_park = printer.toolhead.axis_maximum.y/2 %}
{% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
G1 X{x_park} Y{y_park} F30000
{% else %}
{action_respond_info("end print xyz_axes is NULL\n")}
{% endif %}
[gcode_macro END_PRINT_Z_SAFE]
gcode:
{% if "xyz" in printer.toolhead.homed_axes %}
{% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
{% set act_z = printer.toolhead.position.z|float %}
G91
{action_respond_info("END_PRINT_Z_SAFE act_z:%s, max_z:%s \n" % (act_z, max_z))}
{% if act_z < (max_z - 5) %}
{action_respond_info("END_PRINT_Z_SAFE G1 Z2.0 F600 \n")}
G1 Z2.0 F600
{% endif %}
G90
{% else %}
{action_respond_info("end print xyz_axes is NULL\n")}
{% endif %}
[gcode_macro END_PRINT_POINT]
gcode:
{% if "xyz" in printer.toolhead.homed_axes %}
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
{% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% set z_safe = 0.0 %}
{% if act_z < (max_z / 2) %}
{% set z_safe = (max_z / 2) - act_z %}
{% elif act_z < max_z %}
{% set z_safe = 2.0 %}
{% endif %}
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-1.0 F180
G1 E-{E} F4000
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
# {action_respond_info("END_PRINT_POINT act_z:%s, max_z:%s \n" % (act_z, max_z))}
# {% if act_z < (max_z - 5) %}
# {action_respond_info("END_PRINT_POINT G1 Z2.0 F600 \n")}
# G1 Z2.0 F600
# {% endif %}
G90
# {% set y_park = printer.toolhead.axis_maximum.y/2 %}
# {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
# G1 X{x_park} Y{y_park} F30000
{% if z_safe > 2.0 %}
G91
{% set z_safe = z_safe - 2.0 %}
G1 Z{z_safe} F600
G90
{% endif %}
{% else %}
{action_respond_info("end print xyz_axes is NULL\n")}
{% endif %}
[gcode_macro END_PRINT]
gcode:
RESTORE_LIMITS
ENABLE_PRESSURE_ADVANCE VALUE=1
M400
G92 E0
END_PRINT_Z_SAFE
BOX_END
BOX_END_PRINT
Qmode_exit
EXCLUDE_OBJECT_RESET
PRINT_PREPARE_CLEAR
M220 S100
SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=5000
TURN_OFF_HEATERS
M107 P1
M107 P2
END_PRINT_POINT
WAIT_TEMP_START
M106 P0 S127
M141 S0
SET_PIN PIN=extruder_fan VALUE=0
# SET_TEMPERATURE_FAN_SWITCH TEMPERATURE_FAN=chamber_fan VALUE=0
[gcode_macro FIRST_FLOOR_PAUSE]
description: Pause the first floor print
# change this if you need more or less extrusion
variable_extrude: 2.0
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro FIRST_FLOOR_PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set y_park = printer.toolhead.axis_maximum.y/2 %}
{% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
##### calculate save lift position #####
{% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% set z_safe = 0.0 %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% elif act_z < max_z %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=z_safe_pause VALUE={z_safe|float}
PAUSE_BASE
G91
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-1.0 F180
G1 E-{E} F300
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
G1 Z{z_safe} F600
G90
G1 X{x_park} Y{y_park} F30000
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
# save fan2 value and turn off fan2
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan2_speed VALUE={printer['output_pin fan2'].value}
{% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
{action_respond_info("fan2_value = %s \n" % (fspeed))}
M106 P2 S0
M106 S0
[gcode_macro FIRST_FLOOR_RESUME]
description: Resume the first floor print
gcode:
{% if printer['gcode_macro PRINTER_PARAM'].fan2_speed > 0 %}
# {% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
# {action_respond_info("fan2_value2 = %s \n" % (fspeed))}
# SET_PIN PIN=fan2 VALUE={(printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 + 0.5)|int}
{% set s_value = (printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) * 255 / (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min)|float %}
M106 P2 S{s_value}
{% endif %}
##### read E from pause macro #####
{% set E = printer["gcode_macro FIRST_FLOOR_PAUSE"].extrude|float + 1.0 %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
G91
G1 E{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
M400
RESUME_BASE {get_params}
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
# change this if you need more or less extrusion
variable_extrude: 2.0
gcode:
{% if printer.pause_resume.is_paused|lower == 'false' %}
PAUSE_BASE
PAUSE_EXTERNAL
{% endif %}
[gcode_macro PAUSE_EXTERNAL]
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set y_park = printer.toolhead.axis_maximum.y/2 %}
{% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
##### calculate save lift position #####
{% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% set z_safe = 0.0 %}
{% if act_z < 48.0 %}
{% set z_safe = 50.0 - act_z %}
{% elif act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% elif act_z < max_z %}
{% set z_safe = max_z - act_z %}
{% endif %}
{action_respond_info("z_safe = %s"% (z_safe))}
##### end of definitions #####
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=z_safe_pause VALUE={z_safe|float}
M400
G91
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE={printer.extruder.target}
M104 S140
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-1.0 F180
G1 E-{E} F360
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
G1 Z{z_safe} F600
M400
G90
BOX_GO_TO_EXTRUDE_POS
BOX_NOZZLE_CLEAN
BOX_MOVE_TO_SAFE_POS
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
# save fan2 value and turn off fan2
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan2_speed VALUE={printer['output_pin fan2'].value}
{% set fspeed = printer['output_pin fan2'].value %}
{action_respond_info("fan2_value = %s \n" % (fspeed))}
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan0_speed VALUE={printer['output_pin fan0'].value}
{% set fspeed = printer['output_pin fan0'].value %}
{action_respond_info("fan0_value = %s \n" % (fspeed))}
M106 P2 S0
M106 P0 S0
SET_PIN PIN=extruder_fan VALUE=0
[gcode_macro CALIBRATE_CUT_POS]
gcode:
{% if "xyz" not in printer.toolhead.homed_axes %}
G28
{% endif %}
SET_LIMITS
MOTOR_SYS_PARAM NUM=1 DATA=1 ID=70 PARAMS=300 PARAMS_TYPE=float
MOTOR_CHECK_CUT_POS
M400
MOTOR_SYS_PARAM NUM=1 DATA=1 ID=70 PARAMS=100 PARAMS_TYPE=float
RESTORE_LIMITS
[gcode_macro INPUTSHAPER]
gcode:
{% set enabled = printer["filament_switch_sensor filament_sensor"].enabled %}
{% if enabled %}
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
{% endif %}
G90
{% if "xyz" not in printer.toolhead.homed_axes %}
G28
{% endif %}
{% set POSITION_X = printer.configfile.settings['stepper_x'].position_max/2 %}
{% set POSITION_Y = printer.configfile.settings['stepper_y'].position_max/2 %}
G1 X{POSITION_X} Y{POSITION_Y} F6000
G1 Z10 F600
SHAPER_CALIBRATE
CXSAVE_CONFIG
{% if enabled %}
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1
{% endif %}
M400
[gcode_macro BELT_TENSION]
gcode:
G90
{% if "xy" not in printer.toolhead.homed_axes %}
G28 X Y
{% endif %}
BED_MESH_CLEAR
BOX_MOVE_TO_SAFE_POS
M400
M84
{% if 'X' in params.AXES|upper %}
BELT_MDL_INFO MDL_NAME=mdlx
BELT_MDL_SET MDL_NAME=mdlx MDL_N=140
{% elif 'Y' in params.AXES|upper %}
BELT_MDL_INFO MDL_NAME=mdly
BELT_MDL_SET MDL_NAME=mdly MDL_N=140
{% else %}
BELT_MDL_INFO MDL_NAME=mdlx
BELT_MDL_SET MDL_NAME=mdlx MDL_N=140
BELT_MDL_INFO MDL_NAME=mdly
BELT_MDL_SET MDL_NAME=mdly MDL_N=140
{% endif %}
SET_MAINTENANCE_ITEM_VARIABLE NAME=calibrate VARIABLE=belt_tensioning VALUE=0
[gcode_macro BEDPID]
gcode:
PID_CALIBRATE HEATER=heater_bed TARGET=100
SAVE_CONFIG
[gcode_macro NOZZLE_PID]
gcode:
SET_PIN PIN=fan0 VALUE=255
PID_CALIBRATE HEATER=extruder TARGET=230
SAVE_CONFIG
SET_PIN PIN=fan0 VALUE=0
[gcode_macro NOZZLE_PID_HIGH]
gcode:
SET_PIN PIN=fan0 VALUE=255
PID_CALIBRATE HEATER=extruder TARGET=320
SAVE_CONFIG
SET_PIN PIN=fan0 VALUE=0
[gcode_macro TUNOFFINPUTSHAPER]
gcode:
SET_INPUT_SHAPER SHAPER_FREQ_X=0 SHAPER_FREQ_Y=0
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
RESUME_EXTERNAL_PROCESS
RESUME_BASE {get_params}
[gcode_macro RESUME_EXTERNAL_PROCESS]
gcode:
BOX_ERROR_RESUME_PROCESS
RESUME_EXTERNAL
[gcode_macro RESUME_EXTERNAL]
gcode:
{% if printer.pause_resume.resume_err is none or printer.pause_resume.resume_err|lower == 'false' %}
{% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int != 0 %}
{% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int > printer.extruder.temperature %}
M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
{% else %}
M104 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
{% endif %}
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE=0
{% endif %}
{% if printer['gcode_macro PRINTER_PARAM'].fan2_speed > 0 %}
SET_PIN PIN=fan2 VALUE={(printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 + 0.5)|int}
{% set s_value = (printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) * 255 / (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min)|float %}
# M106 P2 S{s_value}
{% endif %}
{% if printer['gcode_macro PRINTER_PARAM'].fan0_speed > 0 %}
SET_PIN PIN=fan0 VALUE={(printer['gcode_macro PRINTER_PARAM'].fan0_speed * 255 + 0.5)|int}
{% set s_value_0 = (printer['gcode_macro PRINTER_PARAM'].fan0_speed * 255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) * 255 / (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min)|float %}
# M106 P2 S{s_value}
{% endif %}
BOX_GO_TO_EXTRUDE_POS
{% set z_resume_move = printer['gcode_macro PRINTER_PARAM'].z_safe_pause|int %}
{% if z_resume_move > 2 %}
{% set z_resume_move = z_resume_move - 2 %}
G91
#G1 Z-{z_resume_move} F600
M400
{% endif %}
{action_respond_info("z_resume_move = %s"% (z_resume_move))}
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float + 80.0 %}
{% set E_VELOCITY = printer['filament_rack'].remain_material_velocity * 0.8 %}
{action_respond_info("velocity: %s" % (E_VELOCITY))}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'false' %}
{action_respond_info("Extruder not hot enough, SET M109 S%s" %
printer['gcode_macro PRINTER_PARAM'].hotend_temp|int)}
M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
{% else %}
M104 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
{% endif %}
G91
M106 S0
G1 E{E} F{E_VELOCITY}
G90
M106 S127
G4 P3000
BOX_NOZZLE_CLEAN
M106 P2 S{s_value}
M106 P0 S{s_value_0}
SET_LIMITS
M400
SET_PIN PIN=extruder_fan VALUE=1
{% endif %}
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
{action_respond_info("start END_PRINT")}
END_PRINT
{action_respond_info("end END_PRINT success")}
CANCEL_PRINT_BASE
{action_respond_info("CANCEL_PRINT success")}
CLEAR_EEPROM_INFO
[gcode_macro MOTOR_CANCEL_PRINT]
gcode:
Qmode_exit
EXCLUDE_OBJECT_RESET
PRINT_PREPARE_CLEAR
M220 S100
SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=5000
TURN_OFF_HEATERS
M107 P1
M107 P2
M141 S0
SET_PIN PIN=extruder_fan VALUE=0
BOX_SET_CURRENT_BOX_IDLE_MODE
CANCEL_PRINT_BASE
WAIT_TEMP_START
[gcode_macro G29]
gcode:
{% if 'PROBE_COUNT' in params|upper %}
{% set get_count = ('PROBE_COUNT' + params.PROBE_COUNT) %}
{%else %}
{% set get_count = "" %}
{% endif %}
{% set bed_temp = printer.custom_macro.default_bed_temp %}
{% set extruder_temp = printer.custom_macro.g28_ext_temp %}
{% set nozzle_clear_temp = printer.custom_macro.default_extruder_temp %}
{% if 'BED_TEMP' in params|upper and params.BED_TEMP|default(0)|int >= printer.custom_macro.default_bed_temp %}
{% set bed_temp = params.BED_TEMP %}
{% endif %}
{% if 'EXTRUDER_TEMP' in params|upper %}
{% set nozzle_clear_temp = params.EXTRUDER_TEMP %}
{% endif %}
{% set enabled = printer["filament_switch_sensor filament_sensor"].enabled %}
{% if enabled %}
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
{% endif %}
M104 S{extruder_temp}
M140 S{bed_temp}
{% if "xy" not in printer.toolhead.homed_axes %}
G28 X Y
{% endif %}
# 此处Z归位一定要下降,此次光电找平后,不恢复上次做Z_TILT_ADJUST记录的adjustments值
# 每次调平在上面的重新做Z_TILT_ADJUST,才能得到新的adjustments调整值
# 设置标志位 ZDOWN的时候 不恢复上次做Z_TILT_ADJUST记录的adjustments值
SET_G29_FLAG VALUE=1
G28 Z
BED_MESH_CLEAR
NOZZLE_CLEAR
M104 S{extruder_temp}
M190 S{bed_temp}
M109 S{extruder_temp}
# 精擦嘴后做一次光电找平获取最大Z轴高度值
ZDOWN_SWITCH ENABLE=1
G28 Z
BED_MESH_CLEAR
Z_TILT_ADJUST WAITTIME=5
NEXT_HOMEZ_NACCU
G28 Z
SET_G29_FLAG VALUE=0
M204 S5000
SET_VELOCITY_LIMIT ACCEL_TO_DECEL=5000
BED_MESH_CALIBRATE {get_count}
G1 Z175 F1200
BOX_MOVE_TO_SAFE_POS
CXSAVE_CONFIG
TURN_OFF_HEATERS
{% if enabled %}
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1
{% endif %}
[gcode_macro BED_MANUAL_CAL_START]
gcode:
{action_respond_info("bed manual calibration start")}
[gcode_macro BED_MANUAL_CAL_END]
gcode:
{action_respond_info("bed manual calibration end")}
[gcode_macro BED_MANUAL_CAL] ;手动调节热床后需要重新校准Z_MAX值
gcode:
BED_MANUAL_CAL_START
SET_G29_FLAG VALUE=1
G28 Z
BED_MESH_CLEAR
NOZZLE_CLEAR
NEXT_HOMEZ_NACCU
G28 Z
BED_MESH_CLEAR
ZDOWN_SWITCH ENABLE=1
G28 Z
SET_G29_FLAG VALUE=0
TURN_OFF_HEATERS
BED_MANUAL_CAL_END
[gcode_macro BED_MESH_CALIBRATE_START_PRINT] # 用于打印前的归位调平
gcode:
{% if 'PROBE_COUNT' in params|upper %}
{% set get_count = ('PROBE_COUNT' + params.PROBE_COUNT) %}
{%else %}
{% set get_count = "" %}
{% endif %}
{% if 'GCODE_FILE' in params|upper %}
{% set get_gcode_file = ("GCODE_FILE='"+ params.GCODE_FILE + "'") %}
{%else %}
{% set get_gcode_file = "" %}
{% endif %}
{action_respond_info("get_gcode_file = %s" % (get_gcode_file))}
{% set bed_temp = printer.custom_macro.default_bed_temp %}
{% set extruder_temp = printer.custom_macro.g28_ext_temp %}
{% set nozzle_clear_temp = printer.custom_macro.default_extruder_temp %}
{% if 'BED_TEMP' in params|upper and params.BED_TEMP|default(0)|int >= printer.custom_macro.default_bed_temp %}
{% set bed_temp = params.BED_TEMP %}
{% endif %}
{% if 'EXTRUDER_TEMP' in params|upper %}
{% set nozzle_clear_temp = params.EXTRUDER_TEMP %}
{% endif %}
{% set enabled = printer["filament_switch_sensor filament_sensor"].enabled %}
M106 S0
M104 S{extruder_temp}
M140 S{bed_temp}
{% if "z" not in printer.toolhead.homed_axes %}
G28
{% endif %}
{% if enabled %}
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
{% endif %}
M104 S{extruder_temp}
M190 S{bed_temp}
M109 S{extruder_temp}
{% if printer['gcode_macro START_PRINT'].prepare|int == 0 %}
PRINT_PREPARED
BED_MESH_CLEAR
NOZZLE_CLEAR
NEXT_HOMEZ_NACCU
G28 Z
{% endif %}
M204 S5000
SET_VELOCITY_LIMIT ACCEL_TO_DECEL=5000
BED_MESH_CALIBRATE {get_count} {get_gcode_file}
G0 Z10 F600
CXSAVE_CONFIG
{% if enabled %}
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1
{% endif %}
[gcode_macro WAIT_BED_STABLE_POS]
gcode:
{% if "xyz" not in printer.toolhead.homed_axes %}
G28
{% endif %}
BOX_MOVE_TO_SAFE_POS
G1 Z45 F1200
[gcode_macro TEST_HOME]
gcode:
{% for _ in range(100) %}
G28
{% endfor %}
[gcode_macro A_TriPress_STEP1]
gcode:
G28
G1 Z25 F600
[gcode_macro A_TriPress_STEP2]
gcode:
PROBE_ACCURACY PROBE_SPEED=5
[gcode_macro EXTRUDE_TEST]
gcode:
M104 S220
{% set times = params.TIMES|default(1)|int %}
{% for _ in range(times) %}
BOX_MOVE_TO_CUT
BOX_GO_TO_EXTRUDE_POS
G91
G0 E100 F360
G90
M400
# BOX_BLOW
SET_PIN PIN=fan0 VALUE=255
G4 P4000
SET_PIN PIN=fan0 VALUE=0
M400
BOX_NOZZLE_CLEAN
{% endfor %}
[gcode_macro A_G28_test] ;归零与重复探测精度测试
gcode:
{% set Count = params.G28_COUNT|default(3000)|int %}
{% set RECount = params.COUNT|default(1000)|int %}
M109 S140
{% for _ in range(Count) %}
G28
{% endfor %}
TEST_REPROBE C={RECount}
M104 S0
[gcode_macro START_TIMER]
variable_time: 0
gcode:
# {% for k in printer["mcu"] %}
# action_respond_info("{ k }")
# {% endfor %}
{% set ns = printer["system_stats"]["monotonic"]|default(0) %} ; 时钟sync同步精度
{action_respond_info("ns = %s " % (ns))}
SET_GCODE_VARIABLE MACRO=START_TIMER VARIABLE=time VALUE={ns}
[gcode_macro END_TIMER]
gcode:
{% set name = params.NAME|default("DefaultGcodeSeg") %}
{% set end = printer["system_stats"]["monotonic"]|default(0) %}
{% set duration = end - printer["gcode_macro START_TIMER"].time|float %}
{action_respond_info("[%s] Timer duration = %.2f seconds" % (name, duration))}
[gcode_macro Z_AXIS_CALIBRATION]
gcode:
{% set bed_temp = printer.custom_macro.default_bed_temp %}
{% set extruder_temp = printer.custom_macro.g28_ext_temp %}
{% set nozzle_clear_temp = printer.custom_macro.default_extruder_temp %}
{% if 'BED_TEMP' in params|upper and params.BED_TEMP|default(0)|int >= printer.custom_macro.default_bed_temp %}
{% set bed_temp = params.BED_TEMP %}
{% endif %}
{% if 'EXTRUDER_TEMP' in params|upper %}
{% set nozzle_clear_temp = params.EXTRUDER_TEMP %}
{% endif %}
{% set enabled = printer["filament_switch_sensor filament_sensor"].enabled %}
{% if enabled %}
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
{% endif %}
M104 S{extruder_temp}
M140 S{bed_temp}
{% if "xy" not in printer.toolhead.homed_axes %}
G28 X Y
{% endif %}
SET_G29_FLAG VALUE=1
G28 Z
BED_MESH_CLEAR
NOZZLE_CLEAR
M104 S{extruder_temp}
M190 S{bed_temp}
M109 S{extruder_temp}
ZDOWN_SWITCH ENABLE=1
G28 Z
BED_MESH_CLEAR
Z_TILT_ADJUST WAITTIME=5
NEXT_HOMEZ_NACCU
G28 Z
SET_G29_FLAG VALUE=0
G1 Z175 F600
BOX_MOVE_TO_SAFE_POS
TURN_OFF_HEATERS
{% if enabled %}
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1
{% endif %}
[gcode_macro CANCEL_CHAMBER_FAN_SWITCH]
gcode:
SET_TEMPERATURE_FAN_SWITCH TEMPERATURE_FAN=chamber_fan VALUE=1
motor_control.cfg
Closed-loop driver tuning for the servo-style steppers. The active lines set the position/speed/current PID, observer (LESO), and tracking-error protection per axis; most of the lower-level motor parameters are commented out and left at firmware defaults. Don’t change these unless you know exactly what you’re doing — bad values here can make an axis run away or fault.
# F008
# Printer_size: 350x350x350
# Version: v1.0.0
# CreateDate: 2025/08/20
# FW: mot2_023_C30-mot2_002_072.bin
[motor_control]
overcurrent_switch: 0
switch: 1
retries: 4
cut_pos_offset: 0.4 # 切刀位置补偿系数 mm
motor_closed_loop: x,y,z,z1,e
motor_x_dir: PB9,0
motor_x_step: PB10,0
motor_x_stall: PB11
motor_y_dir: !PB7,0
motor_y_step: PB8,0
motor_y_stall: PB12
motor_z_dir: PB5,0
motor_z_step: PB6,1
motor_z_stall: PB13
motor_z1_dir: PA1,1
motor_z1_step: PB15,1
motor_z1_stall: PA10
motor_e_stall: nozzle_mcu:PB12
#/*** general param */
# x_param_stall_mode: 2
# x_param_stall_cur_A: 0.70
# x_param_stall_pos_err_rad: 0.012
# x_param_ud_cal_set: 0.15
# x_param_motion_dir: 1.0
# x_param_encoder_calibtate_official_ud_cal_set: 0.15
# motor param
# x_motor_param_R: 0.78
# x_motor_param_L: 0.0014
# x_motor_param_Ke: 0.098676
# controller param
# x_controller_param_en_feedforward_idiq: 1
# x_controller_param_en_feedforward_uduq: 1
# position loop PID param
x_controller_pos_loop_pid_param_kp: 100
# speed loop PID param
x_controller_spd_loop_pid_param_kp: 0.028
x_controller_spd_loop_pid_param_ki: 6.0
# x_controller_spd_loop_pid_param_kc: 0.5
# x_controller_spd_loop_pid_fal_param_en: 0
# x_controller_spd_loop_pid_fal_param_a: 1.0
# x_controller_spd_loop_pid_fal_param_zoom: 0.1
# current loop PID param
x_controller_cur_loop_pid_param_kp: 2.5
x_controller_cur_loop_pid_param_ki: 200.0
# x_controller_cur_loop_pid_param_kc: 0.5
# x_controller_cur_loop_pid_fal_param_en: 0
# x_controller_cur_loop_pid_fal_param_a: 1.2
# x_controller_cur_loop_pid_fal_param_zoom: 0.25
# leso param
x_controller_leso_param_b0k: 1.0
x_controller_leso_param_z3k: 0
x_controller_leso_param_wp: 4000
x_controller_leso_param_ws: 4000
x_controller_leso_param_wd: 400
# fwc param
# x_controller_fwc_param_en: 1
# x_controller_fwc_param_I_max: 5.5
# x_controller_fwc_param_wm_base: 120
# current filter param
# x_controller_cur_filter_param_en: 0
# x_controller_cur_filter_param_fc: 6000
# protection param
# x_protection_param_protect_en: 1
# x_protection_param_prt_peak_cur_A: 999.0
# x_protection_param_prt_continuous_cur_A: 4.0
# x_protection_param_prt_continuous_time_s: 1.0
# x_protection_param_prt_over_speed_rad_s: 314.159271
# x_protection_param_prt_over_speed_time_s: 0.1
x_protection_param_prt_track_max_err: 0.3
x_protection_param_prt_track_err_time: 0.1
# x_protection_param_power_voltage_min: 20.0
# x_protection_param_mcu_temp_max: 115.0
# step controller param
# x_step_controller_param_subdivision: 16
# communication interface param
# x_cmd_int_param_char_cmd_support: 1
# zazen mode param
# x_zazen_param_zazen_en: 1
# x_zazen_param_zazen_trigger_time_s: 1.0
# x_zazen_param_zazen_gain_spd_kp: 0.7
# x_zazen_param_zazen_gain_spd_ki: 1.0
# x_zazen_param_zazen_gain_cur_kp: 1.0
# x_zazen_param_zazen_gain_cur_ki: 1.0
# slicer param
x_stall_pos_err_rad_for_slicer: 0.016375
#/*** general param */
# y_param_stall_mode: 2
# y_param_stall_cur_A: 0.70
# y_param_stall_pos_err_rad: 0.012
# y_param_ud_cal_set: 0.15
# y_param_motion_dir: 1.0
# y_param_encoder_calibtate_official_ud_cal_set: 0.15
# motor param
# y_motor_param_R: 0.78
# y_motor_param_L: 0.0014
# y_motor_param_Ke: 0.098676
# controller param
# y_controller_param_en_feedforward_idiq: 1
# y_controller_param_en_feedforward_uduq: 1
# position loop PID param
y_controller_pos_loop_pid_param_kp: 300
# speed loop PID param
y_controller_spd_loop_pid_param_kp: 0.028
y_controller_spd_loop_pid_param_ki: 6.0
# y_controller_spd_loop_pid_param_kc: 0.5
# y_controller_spd_loop_pid_fal_param_en: 0
# y_controller_spd_loop_pid_fal_param_a: 1.0
# y_controller_spd_loop_pid_fal_param_zoom: 0.1
# current loop PID param
y_controller_cur_loop_pid_param_kp: 2.5
y_controller_cur_loop_pid_param_ki: 200.0
# y_controller_cur_loop_pid_param_kc: 0.5
# y_controller_cur_loop_pid_fal_param_en: 0
# y_controller_cur_loop_pid_fal_param_a: 1.2
# y_controller_cur_loop_pid_fal_param_zoom: 0.25
# leso param
y_controller_leso_param_b0k: 1.0
y_controller_leso_param_z3k: 0
y_controller_leso_param_wp: 4000
y_controller_leso_param_ws: 4000
y_controller_leso_param_wd: 400
# fwc param
# y_controller_fwc_param_en: 1
# y_controller_fwc_param_I_max: 5.5
# y_controller_fwc_param_wm_base: 120
# current filter param
# y_controller_cur_filter_param_en: 0
# y_controller_cur_filter_param_fc: 6000
# protection param
# y_protection_param_protect_en: 1
# y_protection_param_prt_peak_cur_A: 999.0
# y_protection_param_prt_continuous_cur_A: 4.0
# y_protection_param_prt_continuous_time_s: 1.0
# y_protection_param_prt_over_speed_rad_s: 314.159271
# y_protection_param_prt_over_speed_time_s: 0.1
y_protection_param_prt_track_max_err: 0.3
y_protection_param_prt_track_err_time: 0.1
# y_protection_param_power_voltage_min: 20.0
# y_protection_param_mcu_temp_max: 115.0
# step controller param
# y_step_controller_param_subdivision: 16
# communication interface param
# y_cmd_int_param_char_cmd_support: 1
# zazen mode param
# y_zazen_param_zazen_en: 1
# y_zazen_param_zazen_trigger_time_s: 1.0
# y_zazen_param_zazen_gain_spd_kp: 0.7
# y_zazen_param_zazen_gain_spd_ki: 1.0
# y_zazen_param_zazen_gain_cur_kp: 1.0
# y_zazen_param_zazen_gain_cur_ki: 1.0
# slicer param
y_stall_pos_err_rad_for_slicer: 0.016375
#/*** general param */
# z_param_stall_mode: 2
# z_param_stall_cur_A: 0.70
# z_param_stall_pos_err_rad: 0.012
# z_param_ud_cal_set: 0.15
# z_param_motion_dir: 1.0
# z_param_encoder_calibtate_official_ud_cal_set: 0.15
# motor param
# z_motor_param_R: 0.78
# z_motor_param_L: 0.0014
# z_motor_param_Ke: 0.098676
# controller param
# z_controller_param_en_feedforward_idiq: 1
# z_controller_param_en_feedforward_uduq: 1
# position loop PID param
z_controller_pos_loop_pid_param_kp: 100
# speed loop PID param
z_controller_spd_loop_pid_param_kp: 0.035
z_controller_spd_loop_pid_param_ki: 2.0
# z_controller_spd_loop_pid_param_kc: 0.5
# z_controller_spd_loop_pid_fal_param_en: 0
# z_controller_spd_loop_pid_fal_param_a: 1.0
# z_controller_spd_loop_pid_fal_param_zoom: 0.1
# current loop PID param
z_controller_cur_loop_pid_param_kp: 2.5
z_controller_cur_loop_pid_param_ki: 200.0
# z_controller_cur_loop_pid_param_kc: 0.5
# z_controller_cur_loop_pid_fal_param_en: 0
# z_controller_cur_loop_pid_fal_param_a: 1.2
# z_controller_cur_loop_pid_fal_param_zoom: 0.25
# leso param
z_controller_leso_param_b0k: 1.0
z_controller_leso_param_z3k: 0
z_controller_leso_param_wp: 4000
z_controller_leso_param_ws: 4000
z_controller_leso_param_wd: 400
# fwc param
# z_controller_fwc_param_en: 1
# z_controller_fwc_param_I_max: 5.5
# z_controller_fwc_param_wm_base: 120
# current filter param
# z_controller_cur_filter_param_en: 0
# z_controller_cur_filter_param_fc: 6000
# protection param
# z_protection_param_protect_en: 1
# z_protection_param_prt_peak_cur_A: 999.0
# z_protection_param_prt_continuous_cur_A: 4.0
# z_protection_param_prt_continuous_time_s: 1.0
# z_protection_param_prt_over_speed_rad_s: 314.159271
# z_protection_param_prt_over_speed_time_s: 0.1
z_protection_param_prt_track_max_err: 0.3
z_protection_param_prt_track_err_time: 0.1
# z_protection_param_power_voltage_min: 20.0
# z_protection_param_mcu_temp_max: 115.0
# step controller param
# z_step_controller_param_subdivision: 16
# communication interface param
# z_cmd_int_param_char_cmd_support: 1
# zazen mode param
# z_zazen_param_zazen_en: 1
# z_zazen_param_zazen_trigger_time_s: 1.0
# z_zazen_param_zazen_gain_spd_kp: 0.7
# z_zazen_param_zazen_gain_spd_ki: 1.0
# z_zazen_param_zazen_gain_cur_kp: 1.0
# z_zazen_param_zazen_gain_cur_ki: 1.0
#/*** general param */
# z1_param_stall_mode: 2
# z1_param_stall_cur_A: 0.70
# z1_param_stall_pos_err_rad: 0.012
# z1_param_ud_cal_set: 0.15
# z1_param_motion_dir: 1.0
# z1_param_encoder_calibtate_official_ud_cal_set: 0.15
# motor param
# z1_motor_param_R: 0.78
# z1_motor_param_L: 0.0014
# z1_motor_param_Ke: 0.098676
# controller param
# z1_controller_param_en_feedforward_idiq: 1
# z1_controller_param_en_feedforward_uduq: 1
# position loop PID param
z1_controller_pos_loop_pid_param_kp: 100
# speed loop PID param
z1_controller_spd_loop_pid_param_kp: 0.035
z1_controller_spd_loop_pid_param_ki: 2.0
# z1_controller_spd_loop_pid_param_kc: 0.5
# z1_controller_spd_loop_pid_fal_param_en: 0
# z1_controller_spd_loop_pid_fal_param_a: 1.0
# z1_controller_spd_loop_pid_fal_param_zoom: 0.1
# current loop PID param
z1_controller_cur_loop_pid_param_kp: 2.5
z1_controller_cur_loop_pid_param_ki: 200.0
# z1_controller_cur_loop_pid_param_kc: 0.5
# z1_controller_cur_loop_pid_fal_param_en: 0
# z1_controller_cur_loop_pid_fal_param_a: 1.2
# z1_controller_cur_loop_pid_fal_param_zoom: 0.25
# leso param
z1_controller_leso_param_b0k: 1.0
z1_controller_leso_param_z3k: 0
z1_controller_leso_param_wp: 4000
z1_controller_leso_param_ws: 4000
z1_controller_leso_param_wd: 400
# fwc param
# z1_controller_fwc_param_en: 1
# z1_controller_fwc_param_I_max: 5.5
# z1_controller_fwc_param_wm_base: 120
# current filter param
# z1_controller_cur_filter_param_en: 0
# z1_controller_cur_filter_param_fc: 6000
# protection param
# z1_protection_param_protect_en: 1
# z1_protection_param_prt_peak_cur_A: 999.0
# z1_protection_param_prt_continuous_cur_A: 4.0
# z1_protection_param_prt_continuous_time_s: 1.0
# z1_protection_param_prt_over_speed_rad_s: 314.159271
# z1_protection_param_prt_over_speed_time_s: 0.1
z1_protection_param_prt_track_max_err: 0.3
z1_protection_param_prt_track_err_time: 0.1
# z1_protection_param_power_voltage_min: 20.0
# z1_protection_param_mcu_temp_max: 115.0
# step controller param
# z1_step_controller_param_subdivision: 16
# communication interface param
# z1_cmd_int_param_char_cmd_support: 1
# zazen mode param
# z1_zazen_param_zazen_en: 1
# z1_zazen_param_zazen_trigger_time_s: 1.0
# z1_zazen_param_zazen_gain_spd_kp: 0.7
# z1_zazen_param_zazen_gain_spd_ki: 1.0
# z1_zazen_param_zazen_gain_cur_kp: 1.0
# z1_zazen_param_zazen_gain_cur_ki: 1.0
printer_params.cfg
Fan-feedback pin assignments, the default and homing temperatures (custom_macro: default_bed_temp, default_extruder_temp, g28_ext_temp), and the product size/temperature limits exposed to the UI. Note the size comment here reads 300×300 but the build volume in printer.cfg is 350×350×350.
# F008
# Printer_size: 300x300x300
# Version: v1.0.0
# CreateDate: 2023/03/21
# Nozzle_mcu: chip: GD32F303CBT6
# version: K1-NOZZLE-M_V12
# Leveling_mcu: chip: GD32E230F8P6
# version: F008-L-V11
# mcu: chip: GD32F303RET6
# version: CR4CU220812S12
[fan_feedback]
fan0_pin: PC6 # PTC Fan
fan1_pin: nozzle_mcu:PA12 # 喉管散热风扇
fan2_pin: nozzle_mcu:PC13 # 模型散热风扇
print_delay_time: 3
current_delay_time: 2
[custom_macro]
default_bed_temp: 50
default_extruder_temp: 220
g28_ext_temp: 140
# 产品定义参数
[gcode_macro product_param]
# 模型成型尺寸
variable_bed_size_x: 350
variable_bed_size_y: 350
variable_bed_size_z: 350
# 支持最高温度
variable_nozzle_temp: 350
variable_bed_temp: 120
variable_chamber_temp: 60
gcode:
printer.cfg
The main config and the one most worth understanding. The [include] lines at the top pull in every other file. Below that: the two MCUs, the X/Y/Z/Z1 steppers (CoreXY), the extruder and bed heaters with their PID values, the prtouch_v3 strain-gauge probe, the 9×9 bed_mesh, and the resonance_tester. The auto-generated SAVE_CONFIG block at the very bottom holds your calibrated input-shaper frequencies and the saved bed mesh — never hand-edit that section.
# F008
# Printer_size: 350*350*350
# Version: v1.1.4
# CreateDate: 2024/03/09
# Nozzle_mcu: chip: GD32F303CBT6
# version: CR1FN200338C15
# mcu: chip: GD32F303RET6
# version: CR4FN200338C15
[include sensorless.cfg]
[include gcode_macro.cfg]
[include printer_params.cfg]
[include box.cfg]
[include motor_control.cfg]
[mcu]
serial: /dev/ttyS2
baud: 230400
restart_method: command
[mcu nozzle_mcu]
serial: /dev/ttyS3
baud: 230400
restart_method: command
[verify_heater extruder]
check_gain_time: 60
heating_gain: 1.0
[verify_heater heater_bed]
check_gain_time: 120
heating_gain: 1.0
hysteresis: 10
[mcu rpi]
serial: /tmp/klipper_host_mcu
[bl24c16f]
i2c_mcu: rpi
i2c_bus: i2c.1
i2c_speed: 400000
[idle_timeout]
timeout: 1800
[virtual_sdcard]
path: /mnt/UDISK/printer_data/gcodes
forced_leveling: true
[gcode_arcs]
resolution: 1.0
[temperature_sensor mcu_temp]
sensor_type: temperature_mcu
min_temp: -30
max_temp: 100
[stepper_x]
step_pin: PB8
dir_pin: !PB7
enable_pin: !PA9
microsteps: 16
rotation_distance: 40
endstop_pin: PB11
position_endstop: 352.5
position_min: -10
position_max: 352.5
homing_speed: 100
homing_retract_dist: 10
[stepper_y]
step_pin: PB10
dir_pin: PB9
enable_pin: !PA9
microsteps: 16
rotation_distance: 40
endstop_pin: PB12
position_endstop: -6.2
position_min: -6.2
position_max: 400
homing_speed: 100
homing_retract_dist: 10
[stepper_z]
step_pin: PB6
dir_pin: PB5
enable_pin: !PA9
microsteps: 16
rotation_distance:8
endstop_pin: probe:z_virtual_endstop
position_min: -10
position_max: 360
homing_speed: 5
second_homing_speed: 5
homing_retract_dist: 5
[stepper_z1]
step_pin: PB15
dir_pin: PA1
enable_pin: !PA9
microsteps: 16
rotation_distance:8
endstop_pin: probe:z_virtual_endstop
[z_tilt]
z_positions:
-15,175
375,175
points:
5,175
345,175
speed: 300
horizontal_move_z: 5
retries: 10
retry_tolerance: 0.1
[thermistor my_thermistor]
temperature1:25
resistance1:260000
temperature2:220
resistance2:738
temperature3:350
resistance3:98
[extruder]
max_extrude_cross_section: 100
max_extrude_only_distance:1000.0
step_pin:nozzle_mcu:PB5
dir_pin: !nozzle_mcu:PB4
enable_pin:!nozzle_mcu:PB2
microsteps:16
rotation_distance:6.9
nozzle_diameter:0.400
filament_diameter:1.750
heater_pin:nozzle_mcu:PB8
sensor_type: my_thermistor
sensor_pin:nozzle_mcu:PA0
pressure_advance: 0.038
pressure_advance_smooth_time: 0.040
control:pid
pid_kp: 14.296
pid_ki: 1.271
pid_kd: 40.206
high_temp_value: 280
pid_kp_high_temp: 16.443
pid_ki_high_temp: 1.370
pid_kd_high_temp: 49.329
min_temp:-30# 0 20240326
max_temp:390
[heater_bed]
heater_pin: PC8
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC4
control: pid
pid_Kp: 37
pid_Ki: 0.18
pid_Kd: 280
min_temp: -30
max_temp: 135
[filament_switch_sensor filament_sensor]
pause_on_runout: true
switch_pin: ^!nozzle_mcu:PA11
runout_gcode:
{% if printer.extruder.can_extrude|lower == 'true' %}
G91
G0 E30 F600
G90
{% endif %}
BOX_CHECK_MATERIAL_REFILL
[multi_pin heater_fans]
pins:nozzle_mcu:PB7,PB1
[heater_fan hotend_fan]
pin:multi_pin:heater_fans
heater:extruder
heater_temp:50.0
[static_digital_output fan0_en]
pins: nozzle_mcu: PB6
[output_pin fan0]
pin: !nozzle_mcu: PB15
pwm: True
cycle_time: 0.01
hardware_pwm: false
value: 0.00
scale: 255
shutdown_value: 0.0
[multi_pin heater_fan2]
pins:PB4,PB3
[output_pin fan2]
pin: multi_pin:heater_fan2
pwm: True
cycle_time: 0.0100
hardware_pwm: false
value: 0.00
scale: 255
shutdown_value: 0.0
[output_pin fan1]
pin: PA0
pwm: True
cycle_time: 0.0100
hardware_pwm: false
value: 0.00
scale: 255
shutdown_value: 0.0
[heater_fan chamber_fan]
pin: !PB14
enable_pin: PB2
heater:chamber_heater
is_ptc_fan: 1
heater_temp: 100 # set an unattainable temperature, ensure that the fan does not work in lower temperature
[temperature_sensor chamber_temp]
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC5
min_temp: -30
max_temp: 125
[duplicate_pin_override]
pins: PC5,PA0,PC7,PB7,PB8,PB9,PB10,PB5,PB6,PA1,PB15,PB11,PB12,PB13,PA10,PA9,PB2,PB14,PB1
[heater_generic chamber_heater]
heater_pin:PC12
max_power:1.0
sensor_type:NTC 100K MGB18-104F39050L32
sensor_pin:PC5
control: watermark
# control: pid
# pid_Kp: 37
# pid_Ki: 0.18
# pid_Kd: 280
min_temp:-30
max_temp:80
[verify_heater chamber_heater]
max_error: 80
check_gain_time:345600
hysteresis: 15
heating_gain: 1
[temperature_fan chamber_fan]
pin: PA0
cycle_time: 0.0100
hardware_pwm: false
max_power: 1
shutdown_speed: 0
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC5
min_temp: -30
max_temp: 80
control: watermark
max_delta: 0.5
target_temp: 35.0
max_speed: 1.0
min_speed: 0.0
[multi_pin LED_pin]
pins:PB0,PA12
[output_pin LED]
pin:multi_pin:LED_pin
pwm: True
cycle_time: 0.010
value: 1
[output_pin extruder_fan]
pin: nozzle_mcu: PB1
[output_pin power]
pin: PC9
[output_pin ptc_power]
pin: PB2
value: 1
# [motor_control]
# overcurrent_switch: 0
# switch: 1
# retries: 4
# cut_pos_offset: 0.4 # 切刀位置补偿系数 mm
# motor_closed_loop: x,y,z,z1,e
# motor_x_dir: PB9,0
# motor_x_step: PB10,0
# motor_x_stall: PB11
# motor_y_dir: !PB7,0
# motor_y_step: PB8,0
# motor_y_stall: PB12
# motor_z_dir: PB5,0
# motor_z_step: PB6,1
# motor_z_stall: PB13
# motor_z1_dir: PA1,1
# motor_z1_step: PB15,1
# motor_z1_stall: PA10
# motor_e_stall: nozzle_mcu:PB12
[lis2dw]
cs_pin: nozzle_mcu:PA4
spi_speed: 5000000
axes_map: x,z,y
spi_software_sclk_pin: nozzle_mcu:PA5
spi_software_mosi_pin: nozzle_mcu:PA7
spi_software_miso_pin: nozzle_mcu:PA6
[resonance_tester]
accel_chip: lis2dw
probe_points:
175,175,175
min_freq: 20
max_freq: 120
accel_per_hz: 100
[prtouch_v3]
z_offset: 0
speed: 5
quick_lift_speed:100
samples: 1
samples_result: average
samples_tolerance_retries: 5
samples_tolerance: 0.5
prth_clr_probe_pos:150,355
step_swap_pin: !PC7
pres_swap_pin: nozzle_mcu:PA15
prth_msg_show: True
#prth_dbg_ippt: 172.21.20.205
pres_cs0_pin: nozzle_mcu:PB13, nozzle_mcu:PB14
pres_tri_hold:4000, 10000, 500
# prth_tmp_comp: 26,300,0,0.135 #默认使用非线性温度补偿功能,26,300,0,0.11 使用2.5mm不削薄应变片+提高应变片激励电压方案 #26,300,0,0.135削薄应变片
enable_not_linear_comp:True #是否使能温度非线性补偿功能,True使能 False不使能(使用线性补偿)
pres_cfg_regs:60 #60(1280/128)44(640/128)56(1280/64)
# prth_gas_calr:0.001 # 高斯滤波标准差的开方,0.001 ~ 10,值越小,网床平滑滤波程序越弱,注释为关闭
prth_max_chps:8
prth_tri_zacc:1000
prth_min_fans:0.6
# regional_prtouch_switch: False # 区域调平开关,默认True开启
# regional_prtouch_percentage:0.8
high_low_temp_leveling:True
bed_mesh_fall_comp_diagonal: -0.045, -0.045, -0.025, -0.025, -0.02
bed_mesh_fall_comp_axis:-0.055, -0.055, -0.035, 0, 0, 0, -0.025, -0.025, -0.035
# bed_mesh_add_comp: 0.035, 0.020, 0
# horizontal_move_z_quick: 1 # mm 探测时的抬升高度
need_steady_regional:0.8 # 需要热床稳定区域
[bed_mesh]
speed: 100
mesh_min: 5,5
mesh_max: 345,345
probe_count:9,9
mesh_pps: 2, 2
fade_start: 5.0
fade_end: 50.0
bicubic_tension: 0.2
algorithm: bicubic
horizontal_move_z:5
split_delta_z: 0.01
move_check_distance: 1
[display_status]
[printer]
kinematics: corexy
max_velocity: 800
max_accel: 30000
max_accel_to_decel: 30000
max_z_velocity: 30
square_corner_velocity: 5
max_z_accel: 1000
[pause_resume]
[exclude_object]
[z_align]
distance_ratio: 0.85 # 向上快速运动距离的比例系数
quick_speed: 30 # mm/s 下降速度
slow_speed: 10 # mm/s 探测速度
rising_dist: 10 # mm 首次探测到光电后的上升距离
safe_dist: 40 # mm 热床倾斜偏差安全值 一侧光电触发后,另一侧允许下降的距离
filter_cnt: 10 # 连续触发限位的次数,用作滤波
timeout: 30 # s 单次探测超时时间
retries: 5 # 重试次数
retry_tolerance: 10 # 两个光电的调整允许的最大偏差 10步 步距是0.0025mm
endstop_pin_z: PA15, PA8 # 光电触发,多个光电配置方式:endstop_pin_z: PA15, PA8... 最多支持4个
zd_up: 0 # 步进电机远离限位开关的电平
zes_untrig: 1 # 限位开关未触发时的电平
zmax_safe_pox_diff: 10 # zmax_safe_pox = stepper_z中的position_max-zmax_safe_pox_diff
[belt_mdl mdlx]
ch_max_dis: 5 # 模块最大行程,单位 mm
ch_best_n: 140 # 皮带最佳受力,单位 N
ch_best_error: 0.15 #皮带检测误差值±0.15
[belt_mdl mdly]
ch_max_dis: 5 # 模块最大行程,单位 mm
ch_best_n: 140 # 皮带最佳受力,单位 N
ch_best_error: 0.15 #皮带检测误差值±0.15
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [auto_addr]
#*# mb_addr_table_uniids =
#*# 0xB8, 0x64, 0x3B, 0x4E, 0x84, 0x12, 0xB0, 0x16, 0x48, 0x31, 0x34, 0x38
#*# 0x00
#*# 0x00
#*# 0x00
#*#
#*# [box]
#*# cut_pos_x = -7.20
#*#
#*# [input_shaper]
#*# shaper_type_x = ei
#*# shaper_freq_x = 37.6
#*# shaper_type_y = mzv
#*# shaper_freq_y = 42.0
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 0.266000, 0.316000, 0.384000, 0.436000, 0.464000, 0.441000, 0.444000, 0.373000, 0.334000
#*# 0.146000, 0.194000, 0.241000, 0.296000, 0.303000, 0.306000, 0.281000, 0.204000, 0.161000
#*# 0.066000, 0.134000, 0.174000, 0.219000, 0.214000, 0.206000, 0.156000, 0.099000, 0.051000
#*# 0.044000, 0.069000, 0.116000, 0.139000, 0.164000, 0.154000, 0.119000, 0.056000, 0.038000
#*# 0.004000, 0.036000, 0.129000, 0.156000, 0.141000, 0.121000, 0.084000, 0.049000, 0.009000
#*# -0.016000, 0.049000, 0.099000, 0.122000, 0.131000, 0.121000, 0.084000, 0.041000, 0.046000
#*# -0.001000, 0.059000, 0.121000, 0.156000, 0.156000, 0.149000, 0.124000, 0.084000, 0.039000
#*# 0.054000, 0.089000, 0.178000, 0.199000, 0.216000, 0.204000, 0.199000, 0.176000, 0.101000
#*# 0.146000, 0.206000, 0.266000, 0.299000, 0.319000, 0.319000, 0.259000, 0.236000, 0.176000
#*# x_count = 9
#*# y_count = 9
#*# mesh_x_pps = 2
#*# mesh_y_pps = 2
#*# algo = bicubic
#*# tension = 0.2
#*# min_x = 5.0
#*# max_x = 345.0
#*# min_y = 5.0
#*# max_y = 345.0
sensorless.cfg
Sensorless homing. homing_override takes over G28 and calls the per-axis _HOME_X, _HOME_Y, and _HOME_Z helpers, using StallGuard (the motor_*_stall pins from motor_control.cfg) instead of physical Z endstops. The xyz_ready macro tracks which axes are already homed so re-homing one axis doesn’t force a full cycle.
# Createdate: 2023/03/08
[force_move]
enable_force_move: true
[gcode_macro xyz_ready]
variable_x_ready: 0
variable_y_ready: 0
variable_z_ready: 0
variable_xy_moved: 0
variable_z_moved: 0
variable_safe_z: 3
gcode:
[gcode_macro _IF_HOME_Z]
gcode:
M204 S100
{% if printer['gcode_macro xyz_ready'].z_ready|int == 1 %}
{% if printer.toolhead.position.z|int < 5 %}
{% set z_park = 5.0 - printer.toolhead.position.z|int %}
G91
# G1 z{z_park} F600
G90
{% endif %}
{% else %}
{% if printer['gcode_macro xyz_ready'].z_moved|int == 0 %}
{% if printer.print_stats.z_pos|float <= 20.0 or printer.print_stats.power_loss == 1 %}
# FORCE_MOVE STEPPER=stepper_z DISTANCE={printer["gcode_macro PRINTER_PARAM"].z_safe_g28} VELOCITY=10
# {% else %}
# FORCE_MOVE STEPPER=stepper_z DISTANCE=0.1 VELOCITY=10 #rock_20240120 强制移动单Z
{% endif %}
{% if printer.print_stats.power_loss == 0 %}
# STEPPER_Z_SENEORLESS
# FORCE_MOVE STEPPER=stepper_z stepper_z1 DISTANCE=-320 VELOCITY=10
{% endif %}
SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=z_moved VALUE=1
{% endif %}
{% endif %}
[gcode_macro _IF_MOVE_XY]
gcode:
M204 S2000
_IF_HOME_Z
{% if printer['gcode_macro xyz_ready'].xy_moved|int == 0 %}
SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=xy_moved VALUE=1
{% endif %}
[gcode_macro _HOME_X]
gcode:
_IF_MOVE_XY
{% if printer['gcode_macro xyz_ready'].x_ready|int == 1 %}
{% if (printer.configfile.settings['stepper_x'].position_max - printer.toolhead.position.x)|round < 10 %}
{% set x_park = (10 - (printer.configfile.settings['stepper_x'].position_max - printer.toolhead.position.x))|round %}
{% if x_park > 0 %}
G91
G1 x-{x_park} F6000
G90
{% endif %}
{% endif %}
{% endif %}
# Home
G28 X
SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=x_ready VALUE=1
# Move away
G91
G1 X-10 F3600
G90
# Wait just a second (give StallGuard registers time to clear)
# G4 P2000
[gcode_macro _HOME_Y]
gcode:
_IF_MOVE_XY
{% if printer['gcode_macro xyz_ready'].y_ready|int == 1 %}
{% if printer.toolhead.position.y|round < 8 %}
{% set y_park = 8 - printer.toolhead.position.y|round %}
{% if y_park > 0 %}
G91
G1 y{y_park} F6000
G90
# G4 P1000
{% endif %}
{% endif %}
{% endif %}
# Home
G28 Y
SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=y_ready VALUE=1
# Move away
G91
G1 Y10 F3600
G90
# Wait just a second (give StallGuard registers time to clear)
# G4 P2000
[gcode_macro _HOME_Z]
gcode:
{% if printer['gcode_macro xyz_ready'].y_ready|int == 1 %}
{% if printer['gcode_macro xyz_ready'].x_ready|int == 1 %}
_IF_HOME_Z
{% endif %}
{% endif %}
{% if printer.print_stats.z_pos|float >= 260.0 %}
# FORCE_MOVE STEPPER=stepper_z DISTANCE=-8 VELOCITY=10
{% endif %}
# 计算归零中点,根据bed_mesh参数计算,适配多种不同机器
{% set X_s = printer.configfile.settings['bed_mesh'].mesh_min[0]|int %}
{% set X_e = printer.configfile.settings['bed_mesh'].mesh_max[0]|int %}
{% set Y_s = printer.configfile.settings['bed_mesh'].mesh_min[1]|int %}
{% set Y_e = printer.configfile.settings['bed_mesh'].mesh_max[1]|int %}
{% set POSITION_X = (X_e-X_s)/2+X_s|int %}
{% set POSITION_Y = (Y_e-Y_s)/2+Y_s|int %}
G91
{% set x_park = POSITION_X - printer.toolhead.position.x|int %}
{% set y_park = POSITION_Y - printer.toolhead.position.y|int %}
{action_respond_info("x_park = %s \n" % (POSITION_X))}
{action_respond_info("y_park = %s \n" % (POSITION_Y))}
M204 S2000
G1 x{x_park} y{y_park} F12000
G90
M204 S500
G28 Z
SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=z_ready VALUE=1
G1 Z5 F600
# BED_MESH_SET_ENABLE
[gcode_macro LEAVE_FLUSH_AREA]
gcode:
FORCE_MOVE STEPPER=stepper_y DISTANCE=100 VELOCITY=50
[homing_override]
axes: xyz
# set_position_x: 0
# set_position_y: 0
# set_position_z:0
gcode:
MOTOR_STALL_MODE DATA=1
MOTOR_SYS_PARAM NUM=1 DATA=1 ID=70 PARAMS=300 PARAMS_TYPE=float
M204 S500
# BED_MESH_CLEAR
{% set x_axes = printer.toolhead.homed_axes %}
{% if x_axes is defined and x_axes[0] is defined %}
{action_respond_info(
"x_axes: %s \n"
% (x_axes))}
{% else %}
SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=x_ready VALUE=0
SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=y_ready VALUE=0
SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=z_ready VALUE=0
SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=xy_moved VALUE=0
SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=z_moved VALUE=0
{action_respond_info(
"x_axes is NULL\n")}
{% endif %}
{% if x_axes is not defined or x_axes[2] is not defined %}
BED_MESH_CLEAR
{% endif %}
{% set home_all = 'X' not in params and 'Y' not in params %}
{% if 'Z' in params and 'X' not in params and 'Y' not in params %}
{% if x_axes[0] is defined and x_axes[1] is defined %}
{% set home_all = 0 %}
{% endif %}
{% endif %}
{% if home_all or 'Y' in params %}
_HOME_Y
{% endif %}
{% if home_all or 'X' in params %}
_HOME_X
{% endif %}
{% if home_all %}
FORCE_MOVE STEPPER=stepper_y DISTANCE=-3 VELOCITY=10
{% endif %}
{% if 'X' in params and 'Y' in params %}
FORCE_MOVE STEPPER=stepper_y DISTANCE=-3 VELOCITY=10
{% endif %}
{% if 'X' in params and x_axes is defined and x_axes[0] is defined and x_axes[1] is not defined and x_axes[0] == 'y' %}
FORCE_MOVE STEPPER=stepper_y DISTANCE=-3 VELOCITY=10
{% endif %}
{% if 'Y' in params and x_axes is defined and x_axes[0] is defined and x_axes[1] is not defined and x_axes[0] == 'x'%}
FORCE_MOVE STEPPER=stepper_y DISTANCE=-3 VELOCITY=10
{% endif %}
{% if home_all or 'Z' in params %}
{% if x_axes[2] is not defined %}
BOX_GO_TO_EXTRUDE_POS
PRES_CHECK RUN=1
BOX_NOZZLE_CLEAN
PRES_CHECK RUN=0
{% endif %}
SET_PIN PIN=extruder_fan VALUE=0
_HOME_Z
{% endif %}
BED_MESH_PROFILE LOAD="default"
MOTOR_STALL_MODE DATA=2
MOTOR_CHECK_PROTECTION_AFTER_HOME DATA=11
MOTOR_SYS_PARAM NUM=1 DATA=1 ID=70 PARAMS=100 PARAMS_TYPE=float
{% set acc = printer.toolhead.max_accel %}
M204 S{acc}
Notes & gotchas
- These are firmware-specific. The version stamps in each header (and the F008 platform name) are tied to a particular Creality release — treat them as a reference, not a drop-in for a different firmware version.
- Never hand-edit the
SAVE_CONFIGblock at the bottom ofprinter.cfg. Klipper rewrites it after calibration (input shaper, bed mesh, Z offset); editing it by hand will be overwritten or cause errors. - An over-the-air firmware update can overwrite these files. If you’ve customized anything, re-pull a backup after every update and diff it against your saved copy.
- The
[include]order inprinter.cfgmatters — macros and pins defined in one file are referenced by others (for example the box and motor sections). - After any edit, run
FIRMWARE_RESTARTand read the console. A refused start almost always points to the exact bad line.
