Advertisement
khisanthax

klippylog

Oct 12th, 2024
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 59.99 KB | None | 0 0
  1. [INFO] 2024-10-12 04:17:46,365 [root] [statistics:generate_stats:68] Stats 48750.5: gcodein=0 mcu: mcu_awake=0.001 mcu_task_avg=0.000005 mcu_task_stddev=0.000004 bytes_write=20600005 bytes_read=6739119 bytes_retransmit=129 bytes_invalid=8 send_seq=405045 receive_seq=405045 retransmit_seq=352811 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=11 stalled_bytes=0 freq=119996793 nozzle_mcu: mcu_awake=0.000 mcu_task_avg=0.000004 mcu_task_stddev=0.000003 bytes_write=3518325 bytes_read=2795807 bytes_retransmit=35622 bytes_invalid=0 send_seq=96321 receive_seq=96321 retransmit_seq=58974 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 stalled_bytes=0 freq=119999390 adj=120002583 leveling_mcu: mcu_awake=0.000 mcu_task_avg=0.000003 mcu_task_stddev=0.000002 bytes_write=214319 bytes_read=741845 bytes_retransmit=105 bytes_invalid=0 send_seq=35056 receive_seq=35056 retransmit_seq=1437 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 stalled_bytes=0 freq=119999696 adj=120002893 rpi: mcu_awake=0.000 mcu_task_avg=0.000008 mcu_task_stddev=0.000008 bytes_write=221204 bytes_read=650829 bytes_retransmit=27 bytes_invalid=0 send_seq=35690 receive_seq=35690 retransmit_seq=2567 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 stalled_bytes=0 freq=49999049 adj=50000364 heater_bed: target=55 temp=23.0 pwm=1.000 sysload=0.34 cputime=2369.552 memavail=125572 print_time=3993.901 buffer_time=0.000 print_stall=0 extruder: target=220 temp=24.6 pwm=1.000
  2. [INFO] 2024-10-12 04:17:47,089 [root] [mcu:_restart_via_command:940] Attempting MCU 'mcu' reset command
  3. [INFO] 2024-10-12 04:17:47,112 [root] [mcu:_restart_via_command:940] Attempting MCU 'nozzle_mcu' reset command
  4. [INFO] 2024-10-12 04:17:47,129 [root] [mcu:_restart_via_command:940] Attempting MCU 'leveling_mcu' reset command
  5. [INFO] 2024-10-12 04:17:47,150 [root] [mcu:_restart_via_command:933] Attempting MCU 'rpi' config_reset command
  6. [INFO] 2024-10-12 04:17:47,153 [root] [serialhdl:handle_output:308] mcu 'rpi': #output: allocMax=4096 usedMax=0
  7. [ERROR] 2024-10-12 04:17:47,188 [root] [__init__:logging_callback:259] b'Got EOF when reading from device'
  8. [INFO] 2024-10-12 04:17:47,199 [root] [webhooks:set_client_info:202] webhooks client 1976471312: Disconnected
  9. [INFO] 2024-10-12 04:17:47,200 [root] [webhooks:set_client_info:202] webhooks client 1965832944: Disconnected
  10. [INFO] 2024-10-12 04:18:00,237 [root] [klippy:main:414] Starting Klippy...
  11. [INFO] 2024-10-12 04:18:00,239 [root] [klippy:main:423] Args: ['/usr/share/klipper/klippy/klippy.py', '/usr/data/printer_data/config/printer.cfg', '-l', '/usr/data/printer_data/logs/klippy.log', '-a', '/tmp/klippy_uds']
  12. Git version: '09faed31-dirty'
  13. CPU: 2 core ?
  14. Python: '3.8.2 (default, May 15 2024, 15:39:50) \n[GCC 7.2.0]'
  15. [INFO] 2024-10-12 04:18:01,441 [root] [klippy:run:265] Start printer at Sat Oct 12 04:18:01 2024 (1728724681.4 48765.6)
  16. [INFO] 2024-10-12 04:18:01,443 [root] [reactor:_dispatch_loop:340] _dispatch_loop current nice = 0
  17. [INFO] 2024-10-12 04:18:01,444 [root] [reactor:_dispatch_loop:342] _dispatch_loop new nice = -10
  18. [INFO] 2024-10-12 04:18:02,102 [root] [klippy:set_rollover_info:293] ===== Config file =====
  19. [virtual_pins]
  20.  
  21. [force_move]
  22. enable_force_move = true
  23.  
  24. [gcode_macro xyz_ready]
  25. variable_x_ready = 0
  26. variable_y_ready = 0
  27. variable_z_ready = 0
  28. variable_xy_moved = 0
  29. variable_z_moved = 0
  30. variable_safe_z = 3
  31. gcode =
  32.  
  33. [gcode_macro _IF_HOME_Z]
  34. gcode =
  35. {% if printer['gcode_macro xyz_ready'].z_ready|int == 1 %}
  36. {% if printer.toolhead.position.z|int < 5 %}
  37. {% set z_park = 5.0 - printer.toolhead.position.z|int %}
  38. G91
  39. G1 z{z_park} F600
  40. G90
  41. {% endif %}
  42. {% else %}
  43. {% if printer['gcode_macro xyz_ready'].z_moved|int == 0 %}
  44.  
  45. {% if printer.print_stats.power_loss == 1 %}
  46.  
  47.  
  48.  
  49.  
  50.  
  51. {% else %}
  52.  
  53.  
  54.  
  55.  
  56.  
  57. {% endif %}
  58. SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=z_moved VALUE=1
  59. {% endif %}
  60. {% endif %}
  61.  
  62. [gcode_macro _IF_MOVE_XY]
  63. gcode =
  64. _IF_HOME_Z
  65. {% if printer['gcode_macro xyz_ready'].xy_moved|int == 0 %}
  66. SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=xy_moved VALUE=1
  67.  
  68. {% endif %}
  69.  
  70. [gcode_macro _HOME_X]
  71. gcode =
  72. _IF_MOVE_XY
  73. {% if printer['gcode_macro xyz_ready'].x_ready|int == 1 %}
  74. {% if (printer.toolhead.position.x)|int < 10 %}
  75. G91
  76. G1 x10 F3600
  77. G90
  78. G4 P2000
  79. {% endif %}
  80. {% endif %}
  81.  
  82. G28 X
  83. G91
  84. G1 x10 F3600
  85. M400
  86. G90
  87. G4 P500
  88.  
  89. SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=x_ready VALUE=1
  90.  
  91. [gcode_macro _HOME_Y]
  92. gcode =
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99. {% if printer['gcode_macro xyz_ready'].y_ready|int == 1 %}
  100. {% if (printer.toolhead.position.y)|int < 10 %}
  101. G91
  102. G1 y10 F3600
  103. G90
  104. G4 P2000
  105. {% endif %}
  106. {% endif %}
  107.  
  108.  
  109.  
  110. SOFTY_G28
  111. SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=y_ready VALUE=1
  112.  
  113. [gcode_macro _HOME_Z]
  114. gcode =
  115. {% if printer['gcode_macro xyz_ready'].y_ready|int == 1 %}
  116. {% if printer['gcode_macro xyz_ready'].x_ready|int == 1 %}
  117. _IF_HOME_Z
  118. {% endif %}
  119. {% endif %}
  120.  
  121. {% set POSITION_X = printer.configfile.settings['stepper_x'].position_max/2 %}
  122. {% set POSITION_Y = printer.configfile.settings['stepper_y'].position_max/2 %}
  123. G91
  124. {% set x_park = POSITION_X - printer.toolhead.position.x|int %}
  125. {% set y_park = POSITION_Y - printer.toolhead.position.y|int %}
  126. {action_respond_info("x_park = %s \n" % (x_park))}
  127. {action_respond_info("y_park = %s \n" % (y_park))}
  128. G1 x{x_park} y{y_park} F3600
  129. G90
  130. M400
  131.  
  132. G28 Z
  133. SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=z_ready VALUE=1
  134.  
  135. [homing_override]
  136. axes = xyz
  137. gcode =
  138. M220 S100
  139. SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=2500
  140. BED_MESH_CLEAR
  141. {% set x_axes = printer.toolhead.homed_axes %}
  142. {% if x_axes is defined and x_axes[0] is defined %}
  143. {action_respond_info(
  144. "x_axes: %s \n"
  145. % (x_axes))}
  146. {% else %}
  147. SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=x_ready VALUE=0
  148. SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=y_ready VALUE=0
  149. SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=z_ready VALUE=0
  150. SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=xy_moved VALUE=0
  151. SET_GCODE_VARIABLE MACRO=xyz_ready VARIABLE=z_moved VALUE=0
  152. {action_respond_info(
  153. "x_axes is NULL\n")}
  154. {% endif %}
  155.  
  156. {% if x_axes is defined and x_axes[0] is defined and x_axes[1] is defined %}
  157. {action_respond_info("x_axes: %s \n"% (x_axes))}
  158. {% set position_y = printer.toolhead.position.y|int %}
  159. {% set max_y_position = printer["gcode_macro PRINTER_PARAM"].max_y_position|int %}
  160. {% if position_y >= max_y_position %}
  161. G91
  162. G0 Y-10 F3600
  163. G90
  164. {% endif %}
  165. {% endif %}
  166.  
  167. {% set home_all = 'X' not in params and 'Y' not in params %}
  168. {% if 'Z' in params and 'X' not in params and 'Y' not in params %}
  169. {% if x_axes[0] is defined and x_axes[1] is defined %}
  170. {% set home_all = 0 %}
  171. {% endif %}
  172. {% endif %}
  173.  
  174. {% if home_all or 'X' in params %}
  175. {% if printer.print_stats.power_loss == 0 %}
  176. SET_KINEMATIC_POSITION
  177. G91
  178. G1 X3 F1200
  179. M400
  180. G90
  181. {% endif %}
  182. STEPPER_Z_SENEORLESS
  183. M400
  184. _HOME_X
  185. {% if printer.print_stats.power_loss == 0 %}
  186. SET_KINEMATIC_POSITION
  187. {% set retract_z = printer.configfile.settings['prtouch_v2'].retract_z_dist %}
  188. {% set retract_speed = printer.configfile.settings['prtouch_v2'].retract_z_speed %}
  189. G91
  190. G1 Z-{retract_z} F{retract_speed}
  191. M400
  192. G90
  193. G4 P500
  194. {% endif %}
  195. {% endif %}
  196.  
  197. {% if home_all or 'Y' in params %}
  198. {% if printer.print_stats.power_loss == 1 %}
  199. SOFT_CHECK_ERROR FLAG=1
  200. {% endif %}
  201. _HOME_Y
  202.  
  203. SOFT_CHECK_ERROR FLAG=0
  204. {% endif %}
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214. {% if home_all or 'Z' in params %}
  215. _HOME_Z
  216. BED_MESH_PROFILE LOAD="default"
  217. {% endif %}
  218. G4 P500
  219.  
  220. [gcode_macro PRINTER_PARAM]
  221. variable_z_safe_pause = 0.0
  222. variable_z_safe_g28 = 3.0
  223. variable_max_x_position = 300.0
  224. variable_max_y_position = 300.0
  225. variable_max_z_position = 330.0
  226. variable_fans = 3
  227. variable_auto_g29 = 0
  228. variable_fan0_min = 90
  229. variable_fan1_min = 50
  230. variable_fan2_min = 50
  231. variable_fan2_speed = 0
  232. variable_hotend_temp = 0
  233. variable_e_min_current = 0.27
  234. variable_z_coefficient = 0.9995
  235. variable_z_pwl_offset = -0.05
  236. gcode =
  237.  
  238. [gcode_macro STRUCTURE_PARAM]
  239. variable_bed_length = 300.0
  240. variable_bed_width = 300.0
  241. variable_bed_hight = 330.0
  242. gcode =
  243.  
  244. [gcode_macro AUTOTUNE_SHAPERS]
  245. gcode =
  246.  
  247. [gcode_macro LOAD_MATERIAL_CLOSE_FAN2]
  248. variable_fan2_value = 0
  249. gcode =
  250. SAVE_GCODE_STATE NAME=myMoveState
  251. {% if printer['output_pin fan2'].value > 0.0 %}
  252. SET_GCODE_VARIABLE MACRO=LOAD_MATERIAL_CLOSE_FAN2 VARIABLE=fan2_value VALUE={printer['output_pin fan2'].value}
  253. M107 P2
  254. {% endif %}
  255. RESTORE_E_CURRENT
  256.  
  257. [gcode_macro LOAD_MATERIAL_RESTORE_FAN2]
  258. gcode =
  259. {% set fan2_value = printer['gcode_macro LOAD_MATERIAL_CLOSE_FAN2'].fan2_value|float %}
  260. RESTORE_GCODE_STATE NAME=myMoveState
  261. {% if fan2_value > 0.0 %}
  262. {% set s_value = (fan2_value * 255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) * 255 / (255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) %}
  263. M106 P2 S{s_value} G1
  264. SET_GCODE_VARIABLE MACRO=LOAD_MATERIAL_CLOSE_FAN2 VARIABLE=fan2_value VALUE=0
  265. {% endif %}
  266. SET_E_MIN_CURRENT
  267.  
  268. [gcode_macro SET_E_MIN_CURRENT]
  269. gcode =
  270. {% set e_current = printer['gcode_macro PRINTER_PARAM'].e_min_current %}
  271. M400
  272. SET_TMC_CURRENT STEPPER=extruder CURRENT={e_current} HOLDCURRENT={e_current}
  273. G4 P2000
  274.  
  275. [gcode_macro RESTORE_E_CURRENT]
  276. gcode =
  277. {% set e_current = printer.configfile.settings['tmc2209 extruder'].run_current %}
  278. M400
  279. SET_TMC_CURRENT STEPPER=extruder CURRENT={e_current} HOLDCURRENT={e_current}
  280. G4 P2000
  281.  
  282. [gcode_macro LOAD_MATERIAL]
  283. gcode =
  284. LOAD_MATERIAL_CLOSE_FAN2
  285. M109 S{printer.custom_macro.default_extruder_temp}
  286. G91
  287. G1 E160 F180
  288. LOAD_MATERIAL_RESTORE_FAN2
  289.  
  290. [gcode_macro QUIT_MATERIAL]
  291. gcode =
  292. SAVE_GCODE_STATE NAME=myMoveState
  293. RESTORE_E_CURRENT
  294. M109 S{printer.custom_macro.default_extruder_temp}
  295. M83
  296. G1 E100 F300
  297. G1 E-15 F3000
  298. G1 E-22.4700 F2400
  299. G1 E-6.4200 F1200
  300. G1 E-3.2100 F720
  301. G1 E5.0000 F356
  302. G1 E-5.0000 F384
  303. G1 E5.0000 F412
  304. G1 E-5.0000 F440
  305. G1 E5.0000 F467
  306. G1 E-5.0000 F495
  307. G1 E5.0000 F523
  308. G1 E-5.0000 F3000
  309. G1 E-15 F3000
  310. SET_E_MIN_CURRENT
  311. RESTORE_GCODE_STATE NAME=myMoveState
  312.  
  313. [gcode_macro Qmode]
  314. variable_flag = 0
  315. variable_accel = 0
  316. variable_accel_to_decel = 0
  317. variable_velocity = 0
  318. variable_square_corner_velocity = 0
  319. variable_pressure_advance = 0.0
  320. variable_fan0_value = 0.00
  321. variable_fan1_value = 0.00
  322. variable_fan2_value = 0.00
  323. variable_speed_factor = 0
  324. variable_max_accel = 800
  325. variable_max_accel_to_decel = 800
  326. gcode =
  327. {% set printer_state = printer.print_stats.state %}
  328. {% if printer['gcode_macro Qmode'].flag|int == 0 %}
  329. {% if printer_state == "printing" or printer_state == "paused" %}
  330. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=accel VALUE={printer.toolhead.max_accel}
  331. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=accel_to_decel VALUE={printer.toolhead.max_accel_to_decel}
  332. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=velocity VALUE={printer.toolhead.max_velocity}
  333. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=square_corner_velocity VALUE={printer.toolhead.square_corner_velocity}
  334. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=pressure_advance VALUE={printer.extruder.pressure_advance}
  335. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=speed_factor VALUE={printer.gcode_move.speed_factor}
  336. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE={printer['output_pin fan0'].value}
  337. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE={printer['output_pin fan1'].value}
  338. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE={printer['output_pin fan2'].value}
  339. SET_TMC_FIELD STEPPER=stepper_x FIELD=en_spreadcycle VALUE=0
  340. SET_TMC_FIELD STEPPER=stepper_y FIELD=en_spreadcycle VALUE=0
  341.  
  342. SET_TMC_CURRENT STEPPER=stepper_x CURRENT=0.9
  343. SET_TMC_CURRENT STEPPER=stepper_y CURRENT=0.9
  344. G4 P500
  345.  
  346.  
  347. SET_VELOCITY_LIMIT ACCEL=800
  348. SET_VELOCITY_LIMIT ACCEL_TO_DECEL=800
  349. SET_VELOCITY_LIMIT VELOCITY=40
  350. SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=5
  351. SET_PRESSURE_ADVANCE ADVANCE=0.05
  352. M220 S40
  353.  
  354. {% set tmp = printer['output_pin fan0'].value * 255 %}
  355. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE={tmp}
  356. {% if tmp - printer['gcode_macro PRINTER_PARAM'].fan0_min > (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
  357. {% set tmp = printer['gcode_macro PRINTER_PARAM'].fan0_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
  358. SET_PIN PIN=fan0 VALUE={tmp}
  359. {% endif %}
  360.  
  361. {% set tmp = printer['output_pin fan1'].value * 255 %}
  362. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE={printer['output_pin fan1'].value * 255}
  363. {% if tmp - printer['gcode_macro PRINTER_PARAM'].fan1_min > (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
  364. {% set tmp = printer['gcode_macro PRINTER_PARAM'].fan1_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
  365. SET_PIN PIN=fan1 VALUE={tmp}
  366. {% endif %}
  367.  
  368. {% set tmp = printer['output_pin fan2'].value * 255 %}
  369. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE={printer['output_pin fan2'].value * 255}
  370. {% if tmp - printer['gcode_macro PRINTER_PARAM'].fan2_min > (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
  371. {% set tmp = printer['gcode_macro PRINTER_PARAM'].fan2_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
  372. SET_PIN PIN=fan2 VALUE={tmp}
  373. {% endif %}
  374.  
  375. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=flag VALUE=1
  376. SET_QMODE_FLAG FLAG=1
  377. {% endif %}
  378. {% endif %}
  379.  
  380. [gcode_macro Qmode_exit]
  381. gcode =
  382. {% set printer_state = printer.print_stats.state %}
  383. {% if printer['gcode_macro Qmode'].flag|int == 1 %}
  384. {% if printer_state == "printing" or printer_state == "paused" %}
  385. SET_VELOCITY_LIMIT ACCEL={printer['gcode_macro Qmode'].accel}
  386. SET_VELOCITY_LIMIT ACCEL_TO_DECEL={printer['gcode_macro Qmode'].accel_to_decel}
  387. SET_VELOCITY_LIMIT VELOCITY={printer['gcode_macro Qmode'].velocity}
  388. SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={printer['gcode_macro Qmode'].square_corner_velocity}
  389. SET_PRESSURE_ADVANCE ADVANCE={printer['gcode_macro Qmode'].pressure_advance}
  390. M220 S{printer['gcode_macro Qmode'].speed_factor * 100}
  391.  
  392. {% set X_RUN_CUR = printer.configfile.settings['tmc2209 stepper_x'].run_current %}
  393. {% set Y_RUN_CUR = printer.configfile.settings['tmc2209 stepper_y'].run_current %}
  394. SET_TMC_CURRENT STEPPER=stepper_x CURRENT={X_RUN_CUR}
  395. SET_TMC_CURRENT STEPPER=stepper_y CURRENT={Y_RUN_CUR}
  396.  
  397. SET_TMC_FIELD STEPPER=stepper_x FIELD=en_spreadcycle VALUE=1
  398. SET_TMC_FIELD STEPPER=stepper_y FIELD=en_spreadcycle VALUE=1
  399. G4 P500
  400.  
  401. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=flag VALUE=0
  402. SET_QMODE_FLAG FLAG=0
  403.  
  404. {% if printer['output_pin fan0'].value != 0 %}
  405. {action_respond_info("fan0_value = %s" % printer['gcode_macro Qmode'].fan0_value)}
  406. SET_PIN PIN=fan0 VALUE={printer['gcode_macro Qmode'].fan0_value}
  407. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE=0
  408. {% endif %}
  409. {% if printer['output_pin fan1'].value != 0 %}
  410. {action_respond_info("fan1_value = %s" % printer['gcode_macro Qmode'].fan1_value)}
  411. SET_PIN PIN=fan1 VALUE={printer['gcode_macro Qmode'].fan1_value}
  412. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE=0
  413. {% endif %}
  414. {% if printer['output_pin fan2'].value != 0 %}
  415. {action_respond_info("fan2_value = %s" % printer['gcode_macro Qmode'].fan2_value)}
  416. SET_PIN PIN=fan2 VALUE={printer['gcode_macro Qmode'].fan2_value}
  417. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE=0
  418. {% endif %}
  419. {% endif %}
  420. {% endif %}
  421.  
  422. [gcode_macro M204]
  423. rename_existing = M204.1
  424. gcode =
  425.  
  426. {% set get_params = "" %}
  427. {% set qmode_max_accel = printer['gcode_macro Qmode'].max_accel|string %}
  428. {% if 'S' in params|upper %}
  429. {% if printer['gcode_macro Qmode'].flag|int == 1 and params.S|float > qmode_max_accel|float %}
  430. {% set get_params = (get_params + ' ' + 'S' + qmode_max_accel) %}
  431. {% else %}
  432. {% set get_params = (get_params + ' ' + 'S' + params.S) %}
  433. {% endif %}
  434. {% endif %}
  435. {% if 'P' in params|upper %}
  436. {% if printer['gcode_macro Qmode'].flag|int == 1 and params.P|float > qmode_max_accel|float %}
  437. {% set get_params = (get_params + ' ' + 'P' + qmode_max_accel) %}
  438. {% else %}
  439. {% set get_params = (get_params + ' ' + 'P' + params.P) %}
  440. {% endif %}
  441. {% endif %}
  442. {% if 'T' in params|upper %}
  443. {% if printer['gcode_macro Qmode'].flag|int == 1 and params.T|float > qmode_max_accel|float %}
  444. {% set get_params = (get_params + ' ' + 'T' + qmode_max_accel) %}
  445. {% else %}
  446. {% set get_params = (get_params + ' ' + 'T' + params.T) %}
  447. {% endif %}
  448. {% endif %}
  449. M204.1 {get_params}
  450.  
  451. [gcode_macro M205]
  452. gcode =
  453. {% if 'X' in params %}
  454. SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.X}
  455. {% elif 'Y' in params %}
  456. SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.Y}
  457. {% endif %}
  458.  
  459. [gcode_macro M106]
  460. variable_user_flag = 0
  461. gcode =
  462.  
  463. {% if (params.U is defined and params.U|int == 1) or (params.U is not defined and printer["gcode_macro M106"].user_flag|int == 0) or (params.G is defined)%}
  464. {% if (params.U is defined and params.U|int == 1) %}
  465. SET_GCODE_VARIABLE MACRO=M106 VARIABLE=user_flag VALUE={params.U|int}
  466. {% endif %}
  467.  
  468.  
  469. {% set fans = printer["gcode_macro PRINTER_PARAM"].fans|int %}
  470. {% set fan = 0 %}
  471. {% set value = 0 %}
  472. {% if params.P is defined %}
  473. {% set tmp = params.P|int %}
  474. {% if tmp < fans %}
  475. {% set fan = tmp %}
  476. {% endif %}
  477. {% endif %}
  478. {% if params.S is defined %}
  479. {% set tmp = params.S|float %}
  480. {% else %}
  481. {% set tmp = 255 %}
  482. {% endif %}
  483. {% if tmp > 0 %}
  484. {% if fan == 0 %}
  485. {% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan0_min) / 255 * tmp %}
  486. {% if printer['gcode_macro Qmode'].flag | int == 1 %}
  487. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan0_min + value}
  488. {% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
  489. {% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
  490. {% else %}
  491. {% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + value %}
  492. {% endif %}
  493. {% else %}
  494. {% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + value %}
  495. {% endif %}
  496. {% endif %}
  497. {% if fan == 1 %}
  498. {% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan1_min) / 255 * tmp %}
  499. {% if printer['gcode_macro Qmode'].flag | int == 1 %}
  500. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan1_min + value}
  501. {% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
  502. {% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
  503. {% else %}
  504. {% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + value %}
  505. {% endif %}
  506. {% else %}
  507. {% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + value %}
  508. {% endif %}
  509. {% endif %}
  510. {% if fan == 2 %}
  511. {% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) / 255 * tmp %}
  512. {% if printer['gcode_macro Qmode'].flag | int == 1 %}
  513. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan2_min + value}
  514. {% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
  515. {% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
  516. {% else %}
  517. {% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + value %}
  518. {% endif %}
  519. {% else %}
  520. {% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + value %}
  521. {% endif %}
  522. {% endif %}
  523. {% endif %}
  524. {% if value >= 255 %}
  525. {% set value = 255 %}
  526. {% endif %}
  527. SET_PIN PIN=fan{fan} VALUE={value}
  528. {% endif %}
  529.  
  530. [gcode_macro M107]
  531. gcode =
  532. {% set fans = printer["gcode_macro PRINTER_PARAM"].fans|int %}
  533. {% if params.P is defined %}
  534. {% if params.P|int < fans %}
  535. SET_PIN PIN=fan{params.P|int} VALUE=0
  536. {% else %}
  537. SET_PIN PIN=fan0 VALUE=0
  538. {% endif %}
  539. {% else %}
  540. SET_PIN PIN=fan0 VALUE=0
  541. SET_PIN PIN=fan2 VALUE=0
  542. {% endif %}
  543.  
  544. [gcode_macro M900]
  545. gcode =
  546. {% if 'K' in params %}
  547. {% if 'E' in params %}
  548. SET_PRESSURE_ADVANCE EXTRUDER={params.E} ADVANCE={params.K}
  549. {% else %}
  550. SET_PRESSURE_ADVANCE ADVANCE={params.K}
  551. {% endif %}
  552. {% endif %}
  553.  
  554. [delayed_gcode wait_temp]
  555. gcode =
  556. {% set cur_temp = printer.extruder.temperature %}
  557. {% if cur_temp|int < 40 %}
  558.  
  559. WAIT_TEMP_END
  560. {% else %}
  561.  
  562. UPDATE_DELAYED_GCODE ID=wait_temp DURATION=5
  563. {% endif %}
  564.  
  565. [gcode_macro WAIT_TEMP_START]
  566. gcode =
  567. UPDATE_DELAYED_GCODE ID=wait_temp DURATION=1
  568.  
  569. M106 P2 S127 G1
  570.  
  571. [gcode_macro WAIT_TEMP_END]
  572. gcode =
  573. UPDATE_DELAYED_GCODE ID=wait_temp DURATION=0
  574. M106 P0 S0 G1
  575. M106 P2 S0 G1
  576.  
  577. [gcode_macro PRINT_CALIBRATION]
  578. gcode =
  579. CX_PRINT_LEVELING_CALIBRATION
  580.  
  581. [gcode_macro FIRST_FLOOR_PAUSE_POSITION]
  582. gcode =
  583. {% set extruder_temp = printer.custom_macro.g28_ext_temp %}
  584. M104 S{extruder_temp}
  585. {% set y_park = 5 %}
  586. {% set x_park = 5 %}
  587. G90
  588. G1 Z2 F600
  589. G1 X{x_park} Y{y_park} F6000
  590. G1 Z0.2 F600
  591.  
  592. [gcode_macro ACCURATE_G28]
  593. gcode =
  594. {% if printer['gcode_macro START_PRINT'].z_sensorless|int == 1 %}
  595. G4 P1000
  596. STEPPER_Z_SENEORLESS
  597. M400
  598. G4 P500
  599. SET_KINEMATIC_POSITION
  600. {% set retract_z = printer.configfile.settings['prtouch_v2'].retract_z_dist %}
  601. {% set retract_speed = printer.configfile.settings['prtouch_v2'].retract_z_speed %}
  602. G91
  603. G1 Z-{retract_z} F{retract_speed}
  604. M400
  605. G90
  606. G4 P1000
  607. {action_respond_info("STEPPER_Z_SENEORLESS \n")}
  608. Z_SENSORLESS_CLEAR
  609. {% endif %}
  610. ACCURATE_HOME_Z
  611.  
  612. [gcode_macro Z_SENSORLESS_SET]
  613. gcode =
  614. SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=z_sensorless VALUE=1
  615. {action_respond_info("set z_sensorless")}
  616.  
  617. [gcode_macro Z_SENSORLESS_CLEAR]
  618. gcode =
  619. SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=z_sensorless VALUE=0
  620. {action_respond_info("clear z_sensorless")}
  621.  
  622. [gcode_macro PRINT_PREPARED]
  623. gcode =
  624. SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=prepare VALUE=1
  625. {action_respond_info("print prepared")}
  626.  
  627. [gcode_macro PRINT_PREPARE_CLEAR]
  628. gcode =
  629. SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=prepare VALUE=0
  630.  
  631. [gcode_macro END_PRINT_POINT_WITHOUT_LIFTING]
  632. gcode =
  633. {% if "xyz" in printer.toolhead.homed_axes %}
  634. {% set E = printer["gcode_macro PAUSE"].extrude|float %}
  635. G91
  636. {% if printer.extruder.can_extrude|lower == 'true' %}
  637. G1 E-1.0 F180
  638. G1 E-{E} F4000
  639. {% else %}
  640. {action_respond_info("Extruder not hot enough")}
  641. {% endif %}
  642. G1 Z2.0 F600
  643. G90
  644. {% set y_park = printer.toolhead.axis_maximum.y/2 %}
  645. {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
  646. G1 X{x_park} Y{y_park} F12000
  647. {% else %}
  648. {action_respond_info("end print xyz_axes is NULL\n")}
  649. {% endif %}
  650.  
  651. [gcode_macro END_PRINT_POINT]
  652. gcode =
  653. {% if "xyz" in printer.toolhead.homed_axes %}
  654. {% set E = printer["gcode_macro PAUSE"].extrude|float %}
  655. {% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
  656. {% set act_z = printer.toolhead.position.z|float %}
  657. {% set z_safe = 0.0 %}
  658. {% if act_z < (max_z / 2) %}
  659. {% set z_safe = (max_z / 2) - act_z %}
  660. {% elif act_z < max_z %}
  661. {% set z_safe = 2.0 %}
  662. {% endif %}
  663. G91
  664. {% if printer.extruder.can_extrude|lower == 'true' %}
  665. G1 E-1.0 F180
  666. G1 E-{E} F4000
  667. {% else %}
  668. {action_respond_info("Extruder not hot enough")}
  669. {% endif %}
  670. G1 Z2.0 F1200
  671. G90
  672. {% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
  673. {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
  674. {% set x_park = 10.0 %}
  675. G1 X{x_park} Y{y_park} F6000
  676. {% if z_safe > 2.0 %}
  677. G91
  678. {% set z_safe = z_safe - 2.0 %}
  679. G1 Z{z_safe} F1200
  680. G90
  681. {% endif %}
  682. {% else %}
  683. {action_respond_info("end print xyz_axes is NULL\n")}
  684. {% endif %}
  685.  
  686. [gcode_macro END_SELF_TEST_POINT]
  687. gcode =
  688. {% if "xyz" in printer.toolhead.homed_axes %}
  689. {% set E = printer["gcode_macro PAUSE"].extrude|float %}
  690. {% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
  691. {% set act_z = printer.toolhead.position.z|float %}
  692. {% set z_safe = 0.0 %}
  693. {% if act_z < (max_z ) %}
  694. {% set z_safe = (max_z ) - act_z %}
  695. {% elif act_z < max_z %}
  696. {% set z_safe = 2.0 %}
  697. {% endif %}
  698. G91
  699. G1 Z2.0 F1200
  700. G90
  701.  
  702. {% if z_safe > 2.0 %}
  703. G91
  704. {% set z_safe = z_safe - 2.0 %}
  705. G1 Z{z_safe} F1200
  706. G90
  707. {% endif %}
  708. {% else %}
  709. {action_respond_info("end print xyz_axes is NULL\n")}
  710. {% endif %}
  711.  
  712. [gcode_macro END_PRINT]
  713. gcode =
  714. SET_GCODE_VARIABLE MACRO=M106 VARIABLE=user_flag VALUE=0
  715. Qmode_exit
  716. EXCLUDE_OBJECT_RESET
  717. PRINT_PREPARE_CLEAR
  718. M220 S100
  719. SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=2500
  720. TURN_OFF_HEATERS
  721. M107 P1
  722. M107 P2
  723. END_PRINT_POINT
  724. WAIT_TEMP_START
  725. M84
  726. SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=45
  727.  
  728. [gcode_macro END_SELF_TEST]
  729. gcode =
  730. Qmode_exit
  731. EXCLUDE_OBJECT_RESET
  732. PRINT_PREPARE_CLEAR
  733. M220 S100
  734. SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=2500
  735. TURN_OFF_HEATERS
  736. M107 P1
  737. M107 P2
  738. END_SELF_TEST_POINT
  739. WAIT_TEMP_START
  740. M84
  741. SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=45
  742.  
  743. [gcode_macro FIRST_FLOOR_PAUSE]
  744. description = Pause the first floor print
  745. variable_extrude = 2.0
  746. gcode =
  747.  
  748. {% set E = printer["gcode_macro FIRST_FLOOR_PAUSE"].extrude|float %}
  749.  
  750.  
  751. {% set y_park = 5 %}
  752. {% set x_park = 5 %}
  753.  
  754. {% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
  755. {% set act_z = printer.toolhead.position.z|float %}
  756. {% set z_safe = 0.0 %}
  757. {% if act_z < (max_z - 2.0) %}
  758. {% set z_safe = 2.0 %}
  759. {% elif act_z < max_z %}
  760. {% set z_safe = max_z - act_z %}
  761. {% endif %}
  762.  
  763. SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=z_safe_pause VALUE={z_safe|float}
  764. PAUSE_BASE
  765. G91
  766. {% if "xyz" in printer.toolhead.homed_axes %}
  767. {% if printer.extruder.can_extrude|lower == 'true' %}
  768. G1 E-1.0 F180
  769. G1 E-{E} F4000
  770. {% else %}
  771. {action_respond_info("Extruder not hot enough")}
  772. {% endif %}
  773. G1 Z{z_safe} F600
  774. G90
  775. G1 X{x_park} Y{y_park} F12000
  776. {% else %}
  777. {action_respond_info("Printer not homed")}
  778. {% endif %}
  779.  
  780. SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan2_speed VALUE={printer['output_pin fan2'].value}
  781. {% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
  782. {action_respond_info("fan2_value = %s \n" % (fspeed))}
  783.  
  784. M106 P2 S0 G1
  785. SET_E_MIN_CURRENT
  786.  
  787. [gcode_macro FIRST_FLOOR_RESUME]
  788. description = Resume the first floor print
  789. gcode =
  790. RESTORE_E_CURRENT
  791. {% if printer['gcode_macro PRINTER_PARAM'].fan2_speed > 0 %}
  792.  
  793.  
  794.  
  795. {% 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 %}
  796. M106 P2 S{s_value} G1
  797. {% endif %}
  798.  
  799. {% set E = printer["gcode_macro FIRST_FLOOR_PAUSE"].extrude|float + 1.0 %}
  800.  
  801. {% if 'VELOCITY' in params|upper %}
  802. {% set get_params = ('VELOCITY=' + params.VELOCITY) %}
  803. {%else %}
  804. {% set get_params = "" %}
  805. {% endif %}
  806.  
  807. {% if printer.extruder.can_extrude|lower == 'true' %}
  808. G91
  809. G1 E{E} F2100
  810. {% else %}
  811. {action_respond_info("Extruder not hot enough")}
  812. {% endif %}
  813. M400
  814. RESUME_BASE {get_params}
  815.  
  816. [gcode_macro PAUSE]
  817. description = Pause the actual running print
  818. rename_existing = PAUSE_BASE
  819. variable_extrude = 2.0
  820. gcode =
  821.  
  822. {% set E = printer["gcode_macro PAUSE"].extrude|float %}
  823.  
  824.  
  825. {% set y_park = printer.toolhead.axis_maximum.y/2 %}
  826. {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
  827.  
  828. {% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
  829. {% set act_z = printer.toolhead.position.z|float %}
  830. {% set z_safe = 0.0 %}
  831. {% if act_z < 48.0 %}
  832. {% set z_safe = 50.0 - act_z %}
  833. {% elif act_z < (max_z - 2.0) %}
  834. {% set z_safe = 2.0 %}
  835. {% elif act_z < max_z %}
  836. {% set z_safe = max_z - act_z %}
  837. {% endif %}
  838. {action_respond_info("z_safe = %s"% (z_safe))}
  839.  
  840. SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=z_safe_pause VALUE={z_safe|float}
  841. PAUSE_BASE
  842. G91
  843. SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE={printer.extruder.target}
  844. M104 S140
  845. {% if "xyz" in printer.toolhead.homed_axes %}
  846. {% if printer.extruder.can_extrude|lower == 'true' %}
  847. G1 E-1.0 F180
  848. G1 E-{E} F4000
  849. {% else %}
  850. {action_respond_info("Extruder not hot enough")}
  851. {% endif %}
  852. G1 Z{z_safe} F600
  853. M400
  854. G90
  855. G1 X{x_park} Y{y_park} F12000
  856. {% else %}
  857. {action_respond_info("Printer not homed")}
  858. {% endif %}
  859.  
  860. SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan2_speed VALUE={printer['output_pin fan2'].value}
  861. {% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
  862. {action_respond_info("fan2_value = %s \n" % (fspeed))}
  863.  
  864. M106 P2 S0 G1
  865. SET_E_MIN_CURRENT
  866.  
  867. [gcode_macro INPUTSHAPER]
  868. gcode =
  869. SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
  870.  
  871. SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=5
  872. G90
  873. G28
  874. {% set POSITION_X = printer.configfile.settings['stepper_x'].position_max/2 %}
  875. {% set POSITION_Y = printer.configfile.settings['stepper_y'].position_max/2 %}
  876. G1 X{POSITION_X} Y{POSITION_Y} F6000
  877. G1 Z20 F1200
  878. SHAPER_CALIBRATE
  879. CXSAVE_CONFIG
  880. SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=45
  881. SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1
  882.  
  883. [gcode_macro BEDPID]
  884. gcode =
  885. PID_CALIBRATE HEATER=heater_bed TARGET=100
  886. SAVE_CONFIG
  887.  
  888. [gcode_macro TUNOFFINPUTSHAPER]
  889. gcode =
  890. SET_INPUT_SHAPER SHAPER_FREQ_X=0 SHAPER_FREQ_Y=0
  891.  
  892. [gcode_macro RESUME]
  893. description = Resume the actual running print
  894. rename_existing = RESUME_BASE
  895. gcode =
  896. RESTORE_E_CURRENT
  897. {% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int != 0 %}
  898. {% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int > printer.extruder.temperature %}
  899. M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
  900. {% else %}
  901. M104 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
  902. {% endif %}
  903. SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE=0
  904. {% endif %}
  905. {% if printer['gcode_macro PRINTER_PARAM'].fan2_speed > 0 %}
  906.  
  907.  
  908.  
  909. {% 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 %}
  910. M106 P2 S{s_value} G1
  911. {% endif %}
  912. {% set z_resume_move = printer['gcode_macro PRINTER_PARAM'].z_safe_pause|int %}
  913. {% if z_resume_move > 2 %}
  914. {% set z_resume_move = z_resume_move - 2 %}
  915. G91
  916. G1 Z-{z_resume_move} F600
  917. M400
  918. {% endif %}
  919. {action_respond_info("z_resume_move = %s"% (z_resume_move))}
  920.  
  921. {% set E = printer["gcode_macro PAUSE"].extrude|float + 1.0 %}
  922.  
  923. {% if 'VELOCITY' in params|upper %}
  924. {% set get_params = ('VELOCITY=' + params.VELOCITY) %}
  925. {%else %}
  926. {% set get_params = "" %}
  927. {% endif %}
  928.  
  929. {% if printer.extruder.can_extrude|lower == 'true' %}
  930. G91
  931. G1 E{E} F2100
  932. G90
  933. {% else %}
  934. {action_respond_info("Extruder not hot enough")}
  935. {% endif %}
  936. M400
  937. RESUME_BASE {get_params}
  938.  
  939. [gcode_macro CANCEL_PRINT]
  940. description = Cancel the actual running print
  941. rename_existing = CANCEL_PRINT_BASE
  942. gcode =
  943. END_PRINT
  944. CANCEL_PRINT_BASE
  945.  
  946. [gcode_macro G29]
  947. gcode =
  948. {% if 'PROBE_COUNT' in params|upper %}
  949. {% set get_count = ('PROBE_COUNT' + params.PROBE_COUNT) %}
  950. {%else %}
  951. {% set get_count = "" %}
  952. {% endif %}
  953.  
  954. {% set bed_temp = printer.custom_macro.default_bed_temp %}
  955. {% set extruder_temp = printer.custom_macro.g28_ext_temp %}
  956. {% set nozzle_clear_temp = printer.custom_macro.default_extruder_temp %}
  957.  
  958. {% if 'BED_TEMP' in params|upper %}
  959. {% set bed_temp = params.BED_TEMP %}
  960. {% endif %}
  961.  
  962. {% if 'EXTRUDER_TEMP' in params|upper %}
  963. {% set nozzle_clear_temp = params.EXTRUDER_TEMP %}
  964. {% endif %}
  965. SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
  966.  
  967. SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=5
  968. M109 S140
  969. G28
  970. BED_MESH_CLEAR
  971. NOZZLE_CLEAR HOT_MIN_TEMP={extruder_temp} HOT_MAX_TEMP={nozzle_clear_temp} BED_MAX_TEMP={bed_temp}
  972. M204 S5000
  973. SET_VELOCITY_LIMIT ACCEL_TO_DECEL=5000
  974. BED_MESH_CALIBRATE {get_count}
  975. BED_MESH_OUTPUT
  976. {% set y_park = printer.toolhead.axis_maximum.y/2 %}
  977. {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
  978. G1 Z50 F3600
  979. CXSAVE_CONFIG
  980. TURN_OFF_HEATERS
  981. SET_TEMPERATURE_FAN_TARGET temperature_fan=soc_fan target=45
  982. SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1
  983.  
  984. [fan_feedback]
  985. fan0_pin = PC6
  986. print_delay_time = 5
  987. current_delay_time = 2
  988.  
  989. [custom_macro]
  990. default_bed_temp = 60
  991. default_extruder_temp = 240
  992. g28_ext_temp = 140
  993.  
  994. [respond]
  995.  
  996. [calibrate_shaper_config]
  997.  
  998. [gcode_shell_command resonance_graph]
  999. command = /usr/data/printer_data/config/Helper-Script/improved-shapers/scripts/calibrate_shaper.py
  1000. timeout = 600.0
  1001. verbose = False
  1002.  
  1003. [gcode_shell_command belts_graph]
  1004. command = /usr/data/printer_data/config/Helper-Script/improved-shapers/scripts/graph_belts.py
  1005. timeout = 600.0
  1006. verbose = False
  1007.  
  1008. [gcode_shell_command delete_graph]
  1009. command = sh /usr/data/helper-script/files/improved-shapers/delete_graph.sh
  1010. timeout = 600.0
  1011. verbose = False
  1012.  
  1013. [gcode_shell_command delete_csv]
  1014. command = sh /usr/data/helper-script/files/improved-shapers/delete_csv.sh
  1015. timeout = 600.0
  1016. verbose = False
  1017.  
  1018. [gcode_macro INPUT_SHAPER_CALIBRATION]
  1019. description = Measure X and Y Axis Resonances and Save values
  1020. gcode =
  1021. {% if printer["configfile"].config["temperature_fan soc_fan"] %}
  1022. SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=30
  1023. {% endif %}
  1024. {% if printer.toolhead.homed_axes != "xyz" %}
  1025. RESPOND TYPE=command MSG="Homing..."
  1026. G28
  1027. {% endif %}
  1028. RESPOND TYPE=command MSG="Measuring X and Y Resonances..."
  1029. SHAPER_CALIBRATE
  1030. M400
  1031. {% if printer["configfile"].config["temperature_fan soc_fan"] %}
  1032. SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=45
  1033. {% endif %}
  1034. RUN_SHELL_COMMAND CMD=delete_csv
  1035. RESPOND TYPE=command MSG="Input Shaper Calibration complete!"
  1036. SAVE_CONFIG
  1037.  
  1038. [gcode_macro TEST_RESONANCES_GRAPHS]
  1039. description = Test X and Y Axis Resonances and Generate Graphs
  1040. gcode =
  1041. RUN_SHELL_COMMAND CMD=delete_graph
  1042. {% set x_png = params.X_PNG|default("/usr/data/printer_data/config/Helper-Script/improved-shapers/resonances_x.png") %}
  1043. {% set y_png = params.Y_PNG|default("/usr/data/printer_data/config/Helper-Script/improved-shapers/resonances_y.png") %}
  1044. {% if printer["configfile"].config["temperature_fan soc_fan"] %}
  1045. SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=30
  1046. {% endif %}
  1047. {% if printer.toolhead.homed_axes != "xyz" %}
  1048. RESPOND TYPE=command MSG="Homing..."
  1049. G28
  1050. {% endif %}
  1051. RESPOND TYPE=command MSG="Testing X Resonances..."
  1052. TEST_RESONANCES AXIS=X NAME=x
  1053. M400
  1054. RESPOND TYPE=command MSG="Generating X Graph... This may take some time."
  1055. RUN_SHELL_COMMAND CMD=resonance_graph PARAMS="/tmp/resonances_x_x.csv -o {x_png}"
  1056. RESPOND TYPE=command MSG="X Graph (resonances_x.png) is now available in /Helper-Script/improved-shapers folder."
  1057. RESPOND TYPE=command MSG="Testing Y Resonances..."
  1058. TEST_RESONANCES AXIS=Y NAME=y
  1059. M400
  1060. RESPOND TYPE=command MSG="Generating Y Graph... This may take some time."
  1061. RUN_SHELL_COMMAND CMD=resonance_graph PARAMS="/tmp/resonances_y_y.csv -o {y_png}"
  1062. RESPOND TYPE=command MSG="Y Graph (resonances_y.png) is now available in /Helper-Script/improved-shapers folder."
  1063. {% if printer["configfile"].config["temperature_fan soc_fan"] %}
  1064. SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=45
  1065. {% endif %}
  1066. RUN_SHELL_COMMAND CMD=delete_csv
  1067. RESPOND TYPE=command MSG="Resonances Test complete!"
  1068.  
  1069. [gcode_macro BELTS_SHAPER_CALIBRATION]
  1070. description = Perform a custom half-axis test to analyze and compare the frequency profiles of individual belts on CoreXY printers
  1071. gcode =
  1072. RUN_SHELL_COMMAND CMD=delete_graph
  1073. {% set min_freq = params.FREQ_START|default(5)|float %}
  1074. {% set max_freq = params.FREQ_END|default(133.33)|float %}
  1075. {% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
  1076. {% set png_width = params.PNG_WIDTH|default(8)|float %}
  1077. {% set png_height = params.PNG_HEIGHT|default(4.8)|float %}
  1078. {% set png_out_path = params.PNG_OUT_PATH|default("/usr/data/printer_data/config/Helper-Script/improved-shapers/belts_calibration.png") %}
  1079. {% if printer["configfile"].config["temperature_fan soc_fan"] %}
  1080. SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=30
  1081. {% endif %}
  1082. {% if printer.toolhead.homed_axes != "xyz" %}
  1083. RESPOND TYPE=command MSG="Homing..."
  1084. G28
  1085. {% endif %}
  1086. TEST_RESONANCES AXIS=1,1 OUTPUT=raw_data NAME=b FREQ_START={min_freq} FREQ_END={max_freq} HZ_PER_SEC={hz_per_sec}
  1087. M400
  1088. TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=a FREQ_START={min_freq} FREQ_END={max_freq} HZ_PER_SEC={hz_per_sec}
  1089. M400
  1090. RESPOND TYPE=command MSG="Generating Belts Frequency Profiles Graph... This may take some time."
  1091. RUN_SHELL_COMMAND CMD=belts_graph PARAMS="-w {png_width} -l {png_height} -n -o {png_out_path} -k /usr/share/klipper /tmp/raw_data_axis=1.000,-1.000_a.csv /tmp/raw_data_axis=1.000,1.000_b.csv"
  1092. RESPOND TYPE=command MSG="Graph (belts_calibration.png) is now available in /Helper-Script/improved-shapers folder."
  1093. {% if printer["configfile"].config["temperature_fan soc_fan"] %}
  1094. SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=45
  1095. {% endif %}
  1096. RUN_SHELL_COMMAND CMD=delete_csv
  1097. RESPOND TYPE=command MSG="Belts Shaper Calibration complete!"
  1098.  
  1099. [gcode_macro EXCITATE_AXIS_AT_FREQ]
  1100. description = Maintain a specified excitation frequency for a period of time to diagnose and locate a vibration source
  1101. gcode =
  1102. {% set frequency = params.FREQUENCY|default(25)|int %}
  1103. {% set time = params.TIME|default(10)|int %}
  1104. {% set axis = params.AXIS|default("x")|string|lower %}
  1105. {% if axis not in ["x", "y", "a", "b"] %}
  1106. { action_raise_error("AXIS selection is invalid. Should be either x, y, a or b!") }
  1107. {% endif %}
  1108. {% if axis == "a" %}
  1109. {% set axis = "1,-1" %}
  1110. {% elif axis == "b" %}
  1111. {% set axis = "1,1" %}
  1112. {% endif %}
  1113. {% if printer.toolhead.homed_axes != "xyz" %}
  1114. RESPOND TYPE=command MSG="Homing..."
  1115. G28
  1116. {% endif %}
  1117. TEST_RESONANCES OUTPUT=raw_data AXIS={axis} FREQ_START={frequency-1} FREQ_END={frequency+1} HZ_PER_SEC={1/(time/3)}
  1118. M400
  1119.  
  1120. [output_pin ADAPTIVE_BED_MESH]
  1121. pin = virtual_pin:ADAPTIVE_BED_MESH_pin
  1122. value = 1
  1123.  
  1124. [output_pin FULL_BED_MESH]
  1125. pin = virtual_pin:FULL_BED_MESH_pin
  1126. value = 0
  1127.  
  1128. [output_pin ADAPTIVE_PURGE_LINE]
  1129. pin = virtual_pin:ADAPTIVE_PURGE_LINE_pin
  1130. value = 1
  1131.  
  1132. [gcode_macro _ADAPTIVE_BED_MESH_ON]
  1133. description = Enable Adaptive Bed Mesh and Disable Full Bed Mesh
  1134. gcode =
  1135. SET_PIN PIN=ADAPTIVE_BED_MESH VALUE=1
  1136. SET_PIN PIN=FULL_BED_MESH VALUE=0
  1137. RESPOND TYPE=command MSG="action:prompt_end"
  1138.  
  1139. [gcode_macro _FULL_BED_MESH_ON]
  1140. description = Disable Adaptive Bed Mesh and Enable Full Bed Mesh
  1141. gcode =
  1142. SET_PIN PIN=ADAPTIVE_BED_MESH VALUE=0
  1143. SET_PIN PIN=FULL_BED_MESH VALUE=1
  1144. RESPOND TYPE=command MSG="action:prompt_end"
  1145.  
  1146. [gcode_macro _BED_MESH_OFF]
  1147. description = Disable Adaptive Bed Mesh and Enable Full Bed Mesh
  1148. gcode =
  1149. SET_PIN PIN=ADAPTIVE_BED_MESH VALUE=0
  1150. SET_PIN PIN=FULL_BED_MESH VALUE=0
  1151. RESPOND TYPE=command MSG="action:prompt_end"
  1152.  
  1153. [gcode_macro _ADAPTIVE_PURGE_LINE_ON]
  1154. description = Enable Adaptive Purge Line
  1155. gcode =
  1156. SET_PIN PIN=ADAPTIVE_PURGE_LINE VALUE=1
  1157. RESPOND TYPE=command MSG="action:prompt_end"
  1158.  
  1159. [gcode_macro _ADAPTIVE_PURGE_LINE_OFF]
  1160. description = Disable Adaptive Purge Line
  1161. gcode =
  1162. SET_PIN PIN=ADAPTIVE_PURGE_LINE VALUE=0
  1163. RESPOND TYPE=command MSG="action:prompt_end"
  1164.  
  1165. [gcode_macro KAMP_BED_MESH_SETTINGS]
  1166. description = Configure Bed Mesh type
  1167. gcode =
  1168. RESPOND TYPE=command MSG="action:prompt_begin Bed Mesh Settings"
  1169. RESPOND TYPE=command MSG="action:prompt_text What type of bed mesh do you want to use when you start printing?"
  1170. RESPOND TYPE=command MSG="action:prompt_button ADAPTIVE BED MESH|_ADAPTIVE_BED_MESH_ON|primary"
  1171. RESPOND TYPE=command MSG="action:prompt_button FULL BED MESH|_FULL_BED_MESH_ON|primary"
  1172. RESPOND TYPE=command MSG="action:prompt_button NONE|_BED_MESH_OFF|primary"
  1173. RESPOND TYPE=command MSG="action:prompt_show"
  1174.  
  1175. [gcode_macro KAMP_PURGE_LINE_SETTINGS]
  1176. description = Configure Purge Line type
  1177. gcode =
  1178. RESPOND TYPE=command MSG="action:prompt_begin Purge Line Settings"
  1179. RESPOND TYPE=command MSG="action:prompt_text What type of purge line do you want to use when you start printing?"
  1180. RESPOND TYPE=command MSG="action:prompt_button ADAPTIVE PURGE LINE|_ADAPTIVE_PURGE_LINE_ON|primary"
  1181. RESPOND TYPE=command MSG="action:prompt_button CLASSIC PURGE LINE|_ADAPTIVE_PURGE_LINE_OFF|primary"
  1182. RESPOND TYPE=command MSG="action:prompt_show"
  1183.  
  1184. [gcode_macro START_PRINT]
  1185. variable_prepare = 0
  1186. variable_z_sensorless = 0
  1187. gcode =
  1188. SET_GCODE_VARIABLE MACRO=M106 VARIABLE=user_flag VALUE=0
  1189. WAIT_TEMP_END
  1190. CLEAR_PAUSE
  1191. SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=30
  1192. {% set g28_extruder_temp = printer.custom_macro.g28_ext_temp %}
  1193. {% set bed_temp = printer.custom_macro.default_bed_temp %}
  1194. {% set extruder_temp = printer.custom_macro.default_extruder_temp %}
  1195. {% if 'BED_TEMP' in params|upper and (params.BED_TEMP|float) %}
  1196. {% set bed_temp = params.BED_TEMP %}
  1197. {% endif %}
  1198. {% if 'EXTRUDER_TEMP' in params|upper and (params.EXTRUDER_TEMP|float) %}
  1199. {% set extruder_temp = params.EXTRUDER_TEMP %}
  1200. {% endif %}
  1201. {% if printer['gcode_macro START_PRINT'].prepare|int == 0 %}
  1202. {action_respond_info("not prepare.\n")}
  1203. PRINT_PREPARE_CLEAR
  1204. CX_ROUGH_G28 EXTRUDER_TEMP={extruder_temp} BED_TEMP={bed_temp}
  1205. CX_NOZZLE_CLEAR
  1206. Z_SENSORLESS_SET
  1207. ACCURATE_G28
  1208. {% if printer['output_pin ADAPTIVE_BED_MESH'].value == 1 %}
  1209. RESPOND TYPE=command MSG="Starting Adaptative Bed Mesh..."
  1210. BED_MESH_CLEAR
  1211. BED_MESH_CALIBRATE
  1212. BED_MESH_PROFILE SAVE=adaptive
  1213. BED_MESH_PROFILE LOAD=adaptive
  1214. {% else %}
  1215. {% if printer['output_pin FULL_BED_MESH'].value == 0 and (not printer['bed_mesh'].profile_name) %}
  1216. RESPOND TYPE=command MSG="No bed mesh found. Starting Full Bed Mesh..."
  1217. CX_PRINT_LEVELING_CALIBRATION
  1218. {% endif %}
  1219. {% if printer['output_pin FULL_BED_MESH'].value == 1 %}
  1220. RESPOND TYPE=command MSG="Starting Full Bed Mesh..."
  1221. CX_PRINT_LEVELING_CALIBRATION
  1222. {% endif %}
  1223. BED_MESH_PROFILE LOAD=default
  1224. {% endif %}
  1225. {% else %}
  1226. PRINT_PREPARE_CLEAR
  1227. {% endif %}
  1228. {% if printer['output_pin ADAPTIVE_PURGE_LINE'].value == 1 %}
  1229. _SMART_PARK
  1230. M109 S{extruder_temp}
  1231. M190 S{bed_temp}
  1232. RESPOND TYPE=command MSG="Starting Adaptive Purge Line..."
  1233. _LINE_PURGE
  1234. {% else %}
  1235. RESPOND TYPE=command MSG="Starting Classic Purge Line..."
  1236. CX_PRINT_DRAW_ONE_LINE
  1237. {% endif %}
  1238. SET_VELOCITY_LIMIT ACCEL={printer.configfile.settings.printer.max_accel}
  1239.  
  1240. [gcode_macro BED_MESH_CALIBRATE]
  1241. rename_existing = _BED_MESH_CALIBRATE
  1242. gcode =
  1243. {% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %}
  1244. {% set bed_mesh_min = printer.configfile.settings.bed_mesh.mesh_min %}
  1245. {% set bed_mesh_max = printer.configfile.settings.bed_mesh.mesh_max %}
  1246. {% set probe_count = printer.configfile.settings.bed_mesh.probe_count %}
  1247. {% set kamp_settings = printer["gcode_macro _KAMP_Settings"] %}
  1248. {% set verbose_enable = kamp_settings.verbose_enable | abs %}
  1249. {% set mesh_margin = kamp_settings.mesh_margin | float %}
  1250. {% set fuzz_amount = kamp_settings.fuzz_amount | float %}
  1251. {% set probe_count = probe_count if probe_count|length > 1 else probe_count * 2 %}
  1252. {% set max_probe_point_distance_x = ( bed_mesh_max[0] - bed_mesh_min[0] ) / (probe_count[0] - 1) %}
  1253. {% set max_probe_point_distance_y = ( bed_mesh_max[1] - bed_mesh_min[1] ) / (probe_count[1] - 1) %}
  1254. {% set x_min = all_points | map(attribute=0) | min | default(bed_mesh_min[0]) %}
  1255. {% set y_min = all_points | map(attribute=1) | min | default(bed_mesh_min[1]) %}
  1256. {% set x_max = all_points | map(attribute=0) | max | default(bed_mesh_max[0]) %}
  1257. {% set y_max = all_points | map(attribute=1) | max | default(bed_mesh_max[1]) %}
  1258. {% set fuzz_range = range((0) | int, (fuzz_amount * 100) | int + 1) %}
  1259. {% set adapted_x_min = x_min - mesh_margin - (fuzz_range | random / 100.0) %}
  1260. {% set adapted_y_min = y_min - mesh_margin - (fuzz_range | random / 100.0) %}
  1261. {% set adapted_x_max = x_max + mesh_margin + (fuzz_range | random / 100.0) %}
  1262. {% set adapted_y_max = y_max + mesh_margin + (fuzz_range | random / 100.0) %}
  1263. {% set adapted_x_min = [adapted_x_min , bed_mesh_min[0]] | max %}
  1264. {% set adapted_y_min = [adapted_y_min , bed_mesh_min[1]] | max %}
  1265. {% set adapted_x_max = [adapted_x_max , bed_mesh_max[0]] | min %}
  1266. {% set adapted_y_max = [adapted_y_max , bed_mesh_max[1]] | min %}
  1267. {% set points_x = (((adapted_x_max - adapted_x_min) / max_probe_point_distance_x) | round(method='ceil') | int) + 1 %}
  1268. {% set points_y = (((adapted_y_max - adapted_y_min) / max_probe_point_distance_y) | round(method='ceil') | int) + 1 %}
  1269. {% if (points_x > points_y) %}
  1270. {% set points_y = points_x %}
  1271. {% endif %}
  1272. {% if (points_x < points_y) %}
  1273. {% set points_x = points_y %}
  1274. {% endif %}
  1275. {% if (([points_x, points_y]|max) > 6) %}
  1276. {% set algorithm = "bicubic" %}
  1277. {% set min_points = 4 %}
  1278. {% else %}
  1279. {% set algorithm = "lagrange" %}
  1280. {% set min_points = 3 %}
  1281. {% endif %}
  1282. {% set points_x = [points_x , min_points]|max %}
  1283. {% set points_y = [points_y , min_points]|max %}
  1284. {% set points_x = [points_x , probe_count[0]]|min %}
  1285. {% set points_y = [points_y , probe_count[1]]|min %}
  1286.  
  1287. {% if verbose_enable == True %}
  1288. {% if printer.exclude_object.objects != [] %}
  1289. RESPOND TYPE=command MSG="Algorithm: {algorithm}"
  1290. RESPOND TYPE=command MSG="Default probe count: {probe_count[0]},{probe_count[1]}"
  1291. RESPOND TYPE=command MSG="Adapted probe count: {points_x},{points_y}"
  1292. RESPOND TYPE=command MSG="Default mesh bounds: {bed_mesh_min[0]},{bed_mesh_min[1]}, {bed_mesh_max[0]},{bed_mesh_max[1]}"
  1293. {% if mesh_margin > 0 %}
  1294. RESPOND TYPE=command MSG="Mesh margin is {mesh_margin}, mesh bounds extended by {mesh_margin}mm."
  1295. {% else %}
  1296. RESPOND TYPE=command MSG="Mesh margin is 0, margin not increased."
  1297. {% endif %}
  1298. {% if fuzz_amount > 0 %}
  1299. RESPOND TYPE=command MSG="Mesh point fuzzing enabled, points fuzzed up to {fuzz_amount}mm"
  1300. {% else %}
  1301. RESPOND TYPE=command MSG="Fuzz amount is 0, mesh points not fuzzed."
  1302. {% endif %}
  1303. RESPOND TYPE=command MSG="Adapted mesh bounds: {adapted_x_min},{adapted_y_min}, {adapted_x_max},{adapted_y_max}"
  1304. RESPOND TYPE=command MSG="KAMP adjustments successful. Happy KAMPing!"
  1305. {% else %}
  1306. RESPOND TYPE=command MSG="No object detected! Make sure you have enabled Exclude Objets setting in your slicer. Using Full Bed Mesh."
  1307. G4 P5000
  1308. {% endif %}
  1309. {% endif %}
  1310. _BED_MESH_CALIBRATE mesh_min={adapted_x_min},{adapted_y_min} mesh_max={adapted_x_max},{adapted_y_max} ALGORITHM={algorithm} PROBE_COUNT={points_x},{points_y}
  1311.  
  1312. [gcode_macro _LINE_PURGE]
  1313. description = A purge macro that adapts to be near your actual printed objects
  1314. gcode =
  1315. {% set travel_speed = (printer.toolhead.max_velocity) * 60 | float %}
  1316. {% set cross_section = printer.configfile.settings.extruder.max_extrude_cross_section | float %}
  1317. {% if printer.firmware_retraction is defined %}
  1318. {% set RETRACT = G10 | string %}
  1319. {% set UNRETRACT = G11 | string %}
  1320. {% else %}
  1321. {% set RETRACT = 'G1 E-0.5 F2400' | string %}
  1322. {% set UNRETRACT = 'G1 E0.5 F2400' | string %}
  1323. {% endif %}
  1324. {% set bed_x_max = printer["gcode_macro PRINTER_PARAM"].max_x_position | float %}
  1325. {% set bed_y_max = printer["gcode_macro PRINTER_PARAM"].max_y_position | float %}
  1326. {% set verbose_enable = printer["gcode_macro _KAMP_Settings"].verbose_enable | abs %}
  1327. {% set purge_height = printer["gcode_macro _KAMP_Settings"].purge_height | float %}
  1328. {% set tip_distance = printer["gcode_macro _KAMP_Settings"].tip_distance | float %}
  1329. {% set purge_margin = printer["gcode_macro _KAMP_Settings"].purge_margin | float %}
  1330. {% set purge_amount = printer["gcode_macro _KAMP_Settings"].purge_amount | float %}
  1331. {% set flow_rate = printer["gcode_macro _KAMP_Settings"].flow_rate | float %}
  1332. {% set rapid_move = 10 %}
  1333. {% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %}
  1334. {% set purge_x_min = (all_points | map(attribute=0) | min | default(0)) %}
  1335. {% set purge_x_max = (all_points | map(attribute=0) | max | default(0)) %}
  1336. {% set purge_y_min = (all_points | map(attribute=1) | min | default(0)) %}
  1337. {% set purge_y_max = (all_points | map(attribute=1) | max | default(0)) %}
  1338. {% set detect_object = purge_x_min + purge_x_max + purge_y_min + purge_y_max %}
  1339. {% set purge_x_center = ([((purge_x_max + purge_x_min) / 2) - (purge_amount / 2), 0] | max) %}
  1340. {% set purge_y_center = ([((purge_y_max + purge_y_min) / 2) - (purge_amount / 2), 0] | max) %}
  1341. {% if (purge_x_center + purge_amount + rapid_move) > bed_x_max %}
  1342. {% set purge_x_center = (bed_x_max - (purge_amount + rapid_move)) %}
  1343. {% endif %}
  1344. {% if (purge_y_center + purge_amount + rapid_move) > bed_y_max %}
  1345. {% set purge_y_center = (bed_y_max - (purge_amount + rapid_move)) %}
  1346. {% endif %}
  1347. {% set purge_x_origin_low = (purge_x_min - purge_margin) %}
  1348. {% set purge_x_origin_high = (purge_x_max + purge_margin) %}
  1349. {% set purge_y_origin_low = (purge_y_min - purge_margin) %}
  1350. {% set purge_y_origin_high = (purge_y_max + purge_margin) %}
  1351. {% set purge_move_speed = (flow_rate / 5.0) * 60 | float %}
  1352.  
  1353. {% if cross_section < 5 %}
  1354. RESPOND TYPE=command MSG="[Extruder] max_extrude_cross_section is insufficient for line purge, please set it to 5 or greater. Purge skipped."
  1355. {% else %}
  1356. {% if verbose_enable == True %}
  1357. RESPOND TYPE=command MSG="Moving filament tip {tip_distance}mm"
  1358. {% endif %}
  1359. {% if detect_object == 0 %}
  1360. RESPOND TYPE=command MSG="No object detected! Using classic purge line."
  1361. {% elif purge_y_origin_low > 0 %}
  1362. RESPOND TYPE=command MSG="KAMP line purge starting at {purge_x_center}, {purge_y_origin_low} and purging {purge_amount}mm of filament, requested flow rate is {flow_rate}mm3/s."
  1363. {% elif purge_x_origin_low > 0 %}
  1364. RESPOND TYPE=command MSG="KAMP line purge starting at {purge_x_origin_low}, {purge_y_center} and purging {purge_amount}mm of filament, requested flow rate is {flow_rate}mm3/s."
  1365. {% elif purge_y_origin_high < bed_y_max %}
  1366. RESPOND TYPE=command MSG="KAMP line purge starting at {purge_x_center}, {purge_y_origin_high} and purging {purge_amount}mm of filament, requested flow rate is {flow_rate}mm3/s."
  1367. {% elif purge_x_origin_high < bed_x_max %}
  1368. RESPOND TYPE=command MSG="KAMP line purge starting at {purge_x_origin_high}, {purge_y_center} and purging {purge_amount}mm of filament, requested flow rate is {flow_rate}mm3/s."
  1369. {% else %}
  1370. RESPOND TYPE=command MSG="No space for purge line! Using classic purge line."
  1371. {% endif %}
  1372. SAVE_GCODE_STATE NAME=Prepurge_State
  1373. {% if detect_object == 0 %}
  1374. CX_PRINT_DRAW_ONE_LINE
  1375. {% elif purge_y_origin_low > 0 %}
  1376. G92 E0
  1377. G0 F{travel_speed}
  1378. G90
  1379. G0 X{purge_x_center} Y{purge_y_origin_low}
  1380. G0 Z{purge_height}
  1381. M83
  1382. G1 E{tip_distance} F{purge_move_speed}
  1383. G1 X{purge_x_center + purge_amount} E{purge_amount} F{purge_move_speed}
  1384. {RETRACT}
  1385. G0 X{purge_x_center + purge_amount + rapid_move} F{travel_speed}
  1386. G92 E0
  1387. M82
  1388. G0 Z{purge_height * 2} F{travel_speed}
  1389. {% elif purge_x_origin_low > 0 %}
  1390. G92 E0
  1391. G0 F{travel_speed}
  1392. G90
  1393. G0 X{purge_x_origin_low} Y{purge_y_center}
  1394. G0 Z{purge_height}
  1395. M83
  1396. G1 E{tip_distance} F{purge_move_speed}
  1397. G1 Y{purge_y_center + purge_amount} E{purge_amount} F{purge_move_speed}
  1398. {RETRACT}
  1399. G0 Y{purge_y_center + purge_amount + rapid_move} F{travel_speed}
  1400. G92 E0
  1401. M82
  1402. G0 Z{purge_height * 2} F{travel_speed}
  1403. {% elif purge_y_origin_high < bed_y_max %}
  1404. G92 E0
  1405. G0 F{travel_speed}
  1406. G90
  1407. G0 X{purge_x_center} Y{purge_y_origin_high}
  1408. G0 Z{purge_height}
  1409. M83
  1410. G1 E{tip_distance} F{purge_move_speed}
  1411. G1 X{purge_x_center + purge_amount} E{purge_amount} F{purge_move_speed}
  1412. {RETRACT}
  1413. G0 X{purge_x_center + purge_amount + rapid_move} F{travel_speed}
  1414. G92 E0
  1415. M82
  1416. G0 Z{purge_height * 2} F{travel_speed}
  1417. {% elif purge_x_origin_high < bed_x_max %}
  1418. G92 E0
  1419. G0 F{travel_speed}
  1420. G90
  1421. G0 X{purge_x_origin_high} Y{purge_y_center}
  1422. G0 Z{purge_height}
  1423. M83
  1424. G1 E{tip_distance} F{purge_move_speed}
  1425. G1 Y{purge_y_center + purge_amount} E{purge_amount} F{purge_move_speed}
  1426. {RETRACT}
  1427. G0 Y{purge_y_center + purge_amount + rapid_move} F{travel_speed}
  1428. G92 E0
  1429. M82
  1430. G0 Z{purge_height * 2} F{travel_speed}
  1431. {% else %}
  1432. CX_PRINT_DRAW_ONE_LINE
  1433. {% endif %}
  1434. RESTORE_GCODE_STATE NAME=Prepurge_State
  1435. {% endif %}
  1436.  
  1437. [gcode_macro _SMART_PARK]
  1438. description = Parks your printhead near the print area for pre-print hotend heating.
  1439. gcode =
  1440. {% set kamp_settings = printer["gcode_macro _KAMP_Settings"] %}
  1441. {% set bed_x_max = printer["gcode_macro PRINTER_PARAM"].max_x_position | float %}
  1442. {% set bed_y_max = printer["gcode_macro PRINTER_PARAM"].max_y_position | float %}
  1443. {% set z_height = kamp_settings.smart_park_height | float %}
  1444. {% set purge_margin = kamp_settings.purge_margin | float %}
  1445. {% set purge_amount = kamp_settings.purge_amount | float %}
  1446. {% set verbose_enable = kamp_settings.verbose_enable | abs %}
  1447. {% set center_x = bed_x_max / 2 %}
  1448. {% set center_y = bed_y_max / 2 %}
  1449. {% set axis_minimum_x = printer.toolhead.axis_minimum.x | float %}
  1450. {% set axis_minimum_y = printer.toolhead.axis_minimum.y | float %}
  1451. {% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %}
  1452. {% set x_min = (all_points | map(attribute=0) | min | default(0)) %}
  1453. {% set x_max = (all_points | map(attribute=0) | max | default(0)) %}
  1454. {% set y_min = (all_points | map(attribute=1) | min | default(0)) %}
  1455. {% set y_max = (all_points | map(attribute=1) | max | default(0)) %}
  1456. {% set travel_speed = (printer.toolhead.max_velocity) * 60 | float %}
  1457. {% set rapid_move = 10 %}
  1458. {% set park_x_center = ([((x_max + x_min) / 2) - (purge_amount / 2), 0] | max) %}
  1459. {% set park_y_center = ([((y_max + y_min) / 2) - (purge_amount / 2), 0] | max) %}
  1460. {% if (park_x_center + purge_amount + rapid_move) > bed_x_max %}
  1461. {% set park_x_center = (bed_x_max - (purge_amount + rapid_move)) %}
  1462. {% endif %}
  1463. {% if (park_y_center + purge_amount + rapid_move) > bed_y_max %}
  1464. {% set park_y_center = (bed_y_max - (purge_amount + rapid_move)) %}
  1465. {% endif %}
  1466. {% set park_x_origin_low = (x_min - purge_margin) %}
  1467. {% set park_x_origin_high = (x_max + purge_margin) %}
  1468. {% set park_y_origin_low = (y_min - purge_margin) %}
  1469. {% set park_y_origin_high = (y_max + purge_margin) %}
  1470. {% set detect_object = (x_min + x_max + y_min + y_max) %}
  1471. {% if detect_object == 0 %}
  1472. {% set x_min = 10 %}
  1473. {% set y_min = 10 %}
  1474. {% set z_height = 2 %}
  1475. {% elif park_y_origin_low > 0 %}
  1476. {% set x_min = park_x_center %}
  1477. {% set y_min = park_y_origin_low %}
  1478. {% elif park_x_origin_low > 0 %}
  1479. {% set x_min = park_x_origin_low %}
  1480. {% set y_min = park_y_center %}
  1481. {% elif park_y_origin_high < bed_y_max %}
  1482. {% set x_min = park_x_center %}
  1483. {% set y_min = park_y_origin_high %}
  1484. {% elif park_x_origin_high < bed_x_max %}
  1485. {% set x_min = park_x_origin_high %}
  1486. {% set y_min = park_y_center %}
  1487. {% else %}
  1488. {% set x_min = 10 %}
  1489. {% set y_min = 10 %}
  1490. {% set z_height = 2 %}
  1491. {% endif %}
  1492.  
  1493. {% if verbose_enable == True %}
  1494. RESPOND TYPE=command MSG="Smart Park location: {x_min},{y_min}"
  1495. {% endif %}
  1496. SAVE_GCODE_STATE NAME=Presmartpark_State
  1497. G90
  1498. {% if printer.toolhead.position.z < z_height %}
  1499. G0 Z{z_height}
  1500. {% endif %}
  1501. G0 X{x_min} Y{y_min} F{travel_speed}
  1502. G0 Z{z_height}
  1503. RESTORE_GCODE_STATE NAME=Presmartpark_State
  1504.  
  1505. [gcode_macro DEFINE_OBJECT]
  1506. description = Needed macro for Exclude Objects
  1507. gcode =
  1508. EXCLUDE_OBJECT_DEFINE {rawparams}
  1509.  
  1510. [gcode_macro START_CURRENT_OBJECT]
  1511. description = Needed macro for Exclude Objects
  1512. gcode =
  1513. EXCLUDE_OBJECT_START NAME={params.NAME}
  1514.  
  1515. [gcode_macro END_CURRENT_OBJECT]
  1516. description = Needed macro for Exclude Objects
  1517. gcode =
  1518. EXCLUDE_OBJECT_END {% if params.NAME %}NAME={params.NAME}{% endif %}
  1519.  
  1520. [gcode_macro LIST_OBJECTS]
  1521. description = Needed macro for Exclude Objects
  1522. gcode =
  1523. EXCLUDE_OBJECT_DEFINE
  1524.  
  1525. [gcode_macro LIST_EXCLUDED_OBJECTS]
  1526. description = Needed macro for Exclude Objects
  1527. gcode =
  1528. EXCLUDE_OBJECT
  1529.  
  1530. [gcode_macro REMOVE_ALL_EXCLUDED]
  1531. description = Needed macro for Exclude Objects
  1532. gcode =
  1533. EXCLUDE_OBJECT RESET=1
  1534.  
  1535. [gcode_macro _KAMP_Settings]
  1536. description = This macro contains all adjustable settings for KAMP
  1537. variable_verbose_enable = True
  1538. variable_mesh_margin = 0
  1539. variable_fuzz_amount = 0
  1540. variable_purge_height = 0.8
  1541. variable_tip_distance = 0
  1542. variable_purge_margin = 10
  1543. variable_purge_amount = 50
  1544. variable_flow_rate = 12
  1545. variable_smart_park_height = 10
  1546. gcode =
  1547. RESPOND TYPE=command MSG="Running the _KAMP_Settings macro does nothing, it's only used for storing KAMP settings."
  1548.  
  1549. [gcode_shell_command Klipper_Backup]
  1550. command = sh /usr/data/helper-script/files/scripts/useful_macros.sh -backup_klipper
  1551. timeout = 600.0
  1552. verbose = true
  1553.  
  1554. [gcode_shell_command Klipper_Restore]
  1555. command = sh /usr/data/helper-script/files/scripts/useful_macros.sh -restore_klipper
  1556. timeout = 600.0
  1557. verbose = true
  1558.  
  1559. [gcode_shell_command Moonraker_Backup]
  1560. command = sh /usr/data/helper-script/files/scripts/useful_macros.sh -backup_moonraker
  1561. timeout = 600.0
  1562. verbose = true
  1563.  
  1564. [gcode_shell_command Moonraker_Restore]
  1565. command = sh /usr/data/helper-script/files/scripts/useful_macros.sh -restore_moonraker
  1566. timeout = 600.0
  1567. verbose = true
  1568.  
  1569. [gcode_shell_command Reload_Camera]
  1570. command = sh /usr/data/helper-script/files/scripts/useful_macros.sh -reload_camera
  1571. timeout = 600.0
  1572. verbose = true
  1573.  
  1574. [gcode_macro _KLIPPER_BACKUP]
  1575. gcode =
  1576. RUN_SHELL_COMMAND CMD=Klipper_Backup
  1577. RESPOND TYPE=command MSG="action:prompt_end"
  1578.  
  1579. [gcode_macro _KLIPPER_RESTORE]
  1580. gcode =
  1581. RUN_SHELL_COMMAND CMD=Klipper_Restore
  1582. RESPOND TYPE=command MSG="action:prompt_end"
  1583.  
  1584. [gcode_macro _MOONRAKER_BACKUP]
  1585. gcode =
  1586. RUN_SHELL_COMMAND CMD=Moonraker_Backup
  1587. RESPOND TYPE=command MSG="action:prompt_end"
  1588.  
  1589. [gcode_macro _MOONRAKER_RESTORE]
  1590. gcode =
  1591. RUN_SHELL_COMMAND CMD=Moonraker_Restore
  1592. RESPOND TYPE=command MSG="action:prompt_end"
  1593.  
  1594. [gcode_macro KLIPPER_BACKUP_CONFIG]
  1595. description = Backup Klipper configuration files
  1596. gcode =
  1597. RESPOND TYPE=command MSG="action:prompt_begin Backup Klipper configuration files"
  1598. RESPOND TYPE=command MSG="action:prompt_text Do you want to backup Klipper configuration files?"
  1599. RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RESPOND TYPE=command MSG="action:prompt_end"|error"
  1600. RESPOND TYPE=command MSG="action:prompt_footer_button BACKUP|_KLIPPER_BACKUP|primary"
  1601. RESPOND TYPE=command MSG="action:prompt_show"
  1602.  
  1603. [gcode_macro KLIPPER_RESTORE_CONFIG]
  1604. description = Restore Klipper configuration files
  1605. gcode =
  1606. RESPOND TYPE=command MSG="action:prompt_begin Restore Klipper configuration files"
  1607. RESPOND TYPE=command MSG="action:prompt_text Do you want to restore Klipper configuration files?"
  1608. RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RESPOND TYPE=command MSG="action:prompt_end"|error"
  1609. RESPOND TYPE=command MSG="action:prompt_footer_button RESTORE|_KLIPPER_RESTORE|primary"
  1610. RESPOND TYPE=command MSG="action:prompt_show"
  1611.  
  1612. [gcode_macro MOONRAKER_BACKUP_DATABASE]
  1613. description = Backup Moonraker database
  1614. gcode =
  1615. RESPOND TYPE=command MSG="action:prompt_begin Backup Moonraker database"
  1616. RESPOND TYPE=command MSG="action:prompt_text Do you want to backup Moonraker database?"
  1617. RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RESPOND TYPE=command MSG="action:prompt_end"|error"
  1618. RESPOND TYPE=command MSG="action:prompt_footer_button BACKUP|_MOONRAKER_BACKUP|primary"
  1619. RESPOND TYPE=command MSG="action:prompt_show"
  1620.  
  1621. [gcode_macro MOONRAKER_RESTORE_DATABASE]
  1622. description = Restore Moonraker database
  1623. gcode =
  1624. RESPOND TYPE=command MSG="action:prompt_begin Restore Moonraker database"
  1625. RESPOND TYPE=command MSG="action:prompt_text Do you want to restore Moonraker database?"
  1626. RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|RESPOND TYPE=command MSG="action:prompt_end"|error"
  1627. RESPOND TYPE=command MSG="action:prompt_footer_button RESTORE|_MOONRAKER_RESTORE|primary"
  1628. RESPOND TYPE=command MSG="action:prompt_show"
  1629.  
  1630. [gcode_macro RELOAD_CAMERA]
  1631. description = Reload camera service
  1632. gcode =
  1633. RUN_SHELL_COMMAND CMD=Reload_Camera
  1634.  
  1635. [gcode_macro BED_LEVELING]
  1636. description = Start Bed Leveling
  1637. gcode =
  1638. {% if 'PROBE_COUNT' in params|upper %}
  1639. {% set get_count = ('PROBE_COUNT=' + params.PROBE_COUNT) %}
  1640. {%else %}
  1641. {% set get_count = "" %}
  1642. {% endif %}
  1643. {% set bed_temp = printer.custom_macro.default_bed_temp %}
  1644. {% set extruder_temp = printer.custom_macro.g28_ext_temp %}
  1645. {% set nozzle_clear_temp = printer.custom_macro.default_extruder_temp %}
  1646. {% if 'BED_TEMP' in params|upper %}
  1647. {% set bed_temp = params.BED_TEMP %}
  1648. {% endif %}
  1649. {% if 'EXTRUDER_TEMP' in params|upper %}
  1650. {% set nozzle_clear_temp = params.EXTRUDER_TEMP %}
  1651. {% endif %}
  1652. SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
  1653. SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=soc_fan TARGET=30
  1654. M109 S140
  1655. {% if printer.toolhead.homed_axes != "xyz" %}
  1656. G28
  1657. {% endif %}
  1658. BED_MESH_CLEAR
  1659. NOZZLE_CLEAR HOT_MIN_TEMP={hotend_temp} HOT_MAX_TEMP={nozzle_clear_temp} BED_MAX_TEMP={bed_temp}
  1660. M204 S5000
  1661. SET_VELOCITY_LIMIT ACCEL_TO_DECEL=5000
  1662. BED_MESH_CALIBRATE {get_count}
  1663. BED_MESH_OUTPUT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement