Advertisement
Guest User

gcode_macro.cfg

a guest
Jul 28th, 2024
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.86 KB | None | 0 0
  1. # K1C
  2. # CreateDate: 2023/09/05
  3.  
  4. [gcode_macro PRINTER_PARAM]
  5. variable_z_safe_pause: 0.0
  6. variable_z_safe_g28: 3.0
  7. variable_max_x_position: 220.0
  8. variable_max_y_position: 220.0
  9. variable_max_z_position: 250.0
  10. variable_fans: 3
  11. variable_auto_g29: 0
  12. variable_fan0_min: 25
  13. variable_fan1_min: 50
  14. variable_fan2_min: 180
  15. variable_fan2_speed: 0
  16. variable_hotend_temp: 0
  17. variable_e_min_current: 0.27
  18. variable_cam_off_temp: 60
  19. gcode:
  20.  
  21. [gcode_macro AUTOTUNE_SHAPERS]
  22. #variable_autotune_shapers: 'ei'
  23. gcode:
  24.  
  25. [gcode_macro LOAD_MATERIAL_CLOSE_FAN2]
  26. variable_fan2_value: 0
  27. gcode:
  28. SAVE_GCODE_STATE NAME=myMoveState
  29. {% if printer['output_pin fan2'].value > 0.0 %}
  30. SET_GCODE_VARIABLE MACRO=LOAD_MATERIAL_CLOSE_FAN2 VARIABLE=fan2_value VALUE={printer['output_pin fan2'].value}
  31. M107 P2
  32. {% endif %}
  33. RESTORE_E_CURRENT
  34.  
  35. [gcode_macro LOAD_MATERIAL_RESTORE_FAN2]
  36. gcode:
  37. {% set fan2_value = printer['gcode_macro LOAD_MATERIAL_CLOSE_FAN2'].fan2_value|float %}
  38. RESTORE_GCODE_STATE NAME=myMoveState
  39. {% if fan2_value > 0.0 %}
  40. {% set s_value = (fan2_value * 255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) * 255 / (255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) %}
  41. M106 P2 S{s_value}
  42. SET_GCODE_VARIABLE MACRO=LOAD_MATERIAL_CLOSE_FAN2 VARIABLE=fan2_value VALUE=0
  43. {% endif %}
  44. SET_E_MIN_CURRENT
  45.  
  46. [gcode_macro SET_E_MIN_CURRENT]
  47. gcode:
  48. {% set e_current = printer['gcode_macro PRINTER_PARAM'].e_min_current %}
  49. M400
  50. SET_TMC_CURRENT STEPPER=extruder CURRENT={e_current} HOLDCURRENT={e_current}
  51. G4 P2000
  52.  
  53. [gcode_macro RESTORE_E_CURRENT]
  54. gcode:
  55. {% set e_current = printer.configfile.settings['tmc2209 extruder'].run_current %}
  56. M400
  57. SET_TMC_CURRENT STEPPER=extruder CURRENT={e_current} HOLDCURRENT={e_current}
  58. G4 P2000
  59.  
  60. [gcode_macro LOAD_MATERIAL]
  61. gcode:
  62. LOAD_MATERIAL_CLOSE_FAN2
  63. M109 S{printer.custom_macro.default_extruder_temp}
  64. G91
  65. G1 E80 F180
  66. LOAD_MATERIAL_RESTORE_FAN2
  67.  
  68. [gcode_macro QUIT_MATERIAL]
  69. gcode:
  70. SAVE_GCODE_STATE NAME=myMoveState
  71. RESTORE_E_CURRENT
  72. M109 S{printer.custom_macro.default_extruder_temp}
  73. M83
  74. G1 E100 F300
  75. G1 E-15 F3000
  76. G1 E-22.4700 F2400
  77. G1 E-6.4200 F1200
  78. G1 E-3.2100 F720
  79. G1 E5.0000 F356
  80. G1 E-5.0000 F384
  81. G1 E5.0000 F412
  82. G1 E-5.0000 F440
  83. G1 E5.0000 F467
  84. G1 E-5.0000 F495
  85. G1 E5.0000 F523
  86. G1 E-5.0000 F3000
  87. G1 E-15 F3000
  88. SET_E_MIN_CURRENT
  89. RESTORE_GCODE_STATE NAME=myMoveState
  90.  
  91. [gcode_macro Qmode]
  92. variable_flag: 0
  93. variable_accel: 0
  94. variable_accel_to_decel: 0
  95. variable_velocity: 0
  96. variable_square_corner_velocity: 0
  97. variable_pressure_advance:0.0
  98. variable_fan0_value: 0.00
  99. variable_fan1_value: 0.00
  100. variable_fan2_value: 0.00
  101. variable_speed_factor: 0
  102. variable_max_accel: 2500
  103. variable_max_accel_to_decel: 2500
  104. gcode:
  105. {% set printer_state = printer.print_stats.state %}
  106. {% if printer['gcode_macro Qmode'].flag|int == 0 %}
  107. {% if printer_state == "printing" or printer_state == "paused" %}
  108. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=accel VALUE={printer.toolhead.max_accel}
  109. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=accel_to_decel VALUE={printer.toolhead.max_accel_to_decel}
  110. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=velocity VALUE={printer.toolhead.max_velocity}
  111. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=square_corner_velocity VALUE={printer.toolhead.square_corner_velocity}
  112. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=pressure_advance VALUE={printer.extruder.pressure_advance}
  113. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=speed_factor VALUE={printer.gcode_move.speed_factor}
  114. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE={printer['output_pin fan0'].value}
  115. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE={printer['output_pin fan1'].value}
  116. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE={printer['output_pin fan2'].value}
  117. SET_TMC_FIELD STEPPER=stepper_x FIELD=en_spreadcycle VALUE=0
  118. SET_TMC_FIELD STEPPER=stepper_y FIELD=en_spreadcycle VALUE=0
  119.  
  120. SET_TMC_CURRENT STEPPER=stepper_x CURRENT=1.0
  121. SET_TMC_CURRENT STEPPER=stepper_y CURRENT=1.0
  122. G4 P1000
  123.  
  124. # Set Motion Parameters
  125. SET_VELOCITY_LIMIT ACCEL=2500
  126. SET_VELOCITY_LIMIT ACCEL_TO_DECEL=2500
  127. SET_VELOCITY_LIMIT VELOCITY=150
  128. SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=5
  129. SET_PRESSURE_ADVANCE ADVANCE=0.05
  130. M220 S50
  131.  
  132. {% set tmp = printer['output_pin fan0'].value * 255 %}
  133. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE={tmp}
  134. {% if tmp - printer['gcode_macro PRINTER_PARAM'].fan0_min > (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
  135. {% set tmp = printer['gcode_macro PRINTER_PARAM'].fan0_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
  136. SET_PIN PIN=fan0 VALUE={tmp}
  137. {% endif %}
  138.  
  139. {% set tmp = printer['output_pin fan1'].value * 255 %}
  140. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE={printer['output_pin fan1'].value * 255}
  141. {% if tmp - printer['gcode_macro PRINTER_PARAM'].fan1_min > (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
  142. {% set tmp = printer['gcode_macro PRINTER_PARAM'].fan1_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
  143. SET_PIN PIN=fan1 VALUE={tmp}
  144. {% endif %}
  145.  
  146. {% set tmp = printer['output_pin fan2'].value * 255 %}
  147. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE={printer['output_pin fan2'].value * 255}
  148. {% if tmp - printer['gcode_macro PRINTER_PARAM'].fan2_min > (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
  149. {% set tmp = printer['gcode_macro PRINTER_PARAM'].fan2_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
  150. SET_PIN PIN=fan2 VALUE={tmp}
  151. {% endif %}
  152.  
  153. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=flag VALUE=1
  154. SET_QMODE_FLAG FLAG=1
  155. {% endif %}
  156. {% endif %}
  157.  
  158. [gcode_macro Qmode_exit]
  159. gcode:
  160. {% set printer_state = printer.print_stats.state %}
  161. {% if printer['gcode_macro Qmode'].flag|int == 1 %}
  162. {% if printer_state == "printing" or printer_state == "paused" %}
  163. SET_VELOCITY_LIMIT ACCEL={printer['gcode_macro Qmode'].accel}
  164. SET_VELOCITY_LIMIT ACCEL_TO_DECEL={printer['gcode_macro Qmode'].accel_to_decel}
  165. SET_VELOCITY_LIMIT VELOCITY={printer['gcode_macro Qmode'].velocity}
  166. SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={printer['gcode_macro Qmode'].square_corner_velocity}
  167. SET_PRESSURE_ADVANCE ADVANCE={printer['gcode_macro Qmode'].pressure_advance}
  168. M220 S{printer['gcode_macro Qmode'].speed_factor * 100}
  169.  
  170. {% set X_RUN_CUR = printer.configfile.settings['tmc2209 stepper_x'].run_current %}
  171. {% set Y_RUN_CUR = printer.configfile.settings['tmc2209 stepper_y'].run_current %}
  172. SET_TMC_CURRENT STEPPER=stepper_x CURRENT={X_RUN_CUR}
  173. SET_TMC_CURRENT STEPPER=stepper_y CURRENT={Y_RUN_CUR}
  174.  
  175. SET_TMC_FIELD STEPPER=stepper_x FIELD=en_spreadcycle VALUE=1
  176. SET_TMC_FIELD STEPPER=stepper_y FIELD=en_spreadcycle VALUE=1
  177. G4 P1000
  178.  
  179. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=flag VALUE=0
  180. SET_QMODE_FLAG FLAG=0
  181.  
  182. {% if printer['output_pin fan0'].value != 0 %}
  183. {action_respond_info("fan0_value = %s" % printer['gcode_macro Qmode'].fan0_value)}
  184. SET_PIN PIN=fan0 VALUE={printer['gcode_macro Qmode'].fan0_value}
  185. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE=0
  186. {% endif %}
  187. {% if printer['output_pin fan1'].value != 0 %}
  188. {action_respond_info("fan1_value = %s" % printer['gcode_macro Qmode'].fan1_value)}
  189. SET_PIN PIN=fan1 VALUE={printer['gcode_macro Qmode'].fan1_value}
  190. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE=0
  191. {% endif %}
  192. {% if printer['output_pin fan2'].value != 0 %}
  193. {action_respond_info("fan2_value = %s" % printer['gcode_macro Qmode'].fan2_value)}
  194. SET_PIN PIN=fan2 VALUE={printer['gcode_macro Qmode'].fan2_value}
  195. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE=0
  196. {% endif %}
  197. {% endif %}
  198. {% endif %}
  199.  
  200. [gcode_macro M204]
  201. rename_existing: M204.1
  202. gcode:
  203. # {% if printer['gcode_macro Qmode'].flag|int == 0 %}
  204. {% set get_params = "" %}
  205. {% set qmode_max_accel = printer['gcode_macro Qmode'].max_accel|string %}
  206. {% if 'S' in params|upper %}
  207. {% if printer['gcode_macro Qmode'].flag|int == 1 and params.S|float > qmode_max_accel|float %}
  208. {% set get_params = (get_params + ' ' + 'S' + qmode_max_accel) %}
  209. {% else %}
  210. {% set get_params = (get_params + ' ' + 'S' + params.S) %}
  211. {% endif %}
  212. {% endif %}
  213. {% if 'P' in params|upper %}
  214. {% if printer['gcode_macro Qmode'].flag|int == 1 and params.P|float > qmode_max_accel|float %}
  215. {% set get_params = (get_params + ' ' + 'P' + qmode_max_accel) %}
  216. {% else %}
  217. {% set get_params = (get_params + ' ' + 'P' + params.P) %}
  218. {% endif %}
  219. {% endif %}
  220. {% if 'T' in params|upper %}
  221. {% if printer['gcode_macro Qmode'].flag|int == 1 and params.T|float > qmode_max_accel|float %}
  222. {% set get_params = (get_params + ' ' + 'T' + qmode_max_accel) %}
  223. {% else %}
  224. {% set get_params = (get_params + ' ' + 'T' + params.T) %}
  225. {% endif %}
  226. {% endif %}
  227. M204.1 {get_params}
  228. [gcode_macro M205]
  229. gcode:
  230. {% if 'X' in params %}
  231. SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.X}
  232. {% elif 'Y' in params %}
  233. SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.Y}
  234. {% endif %}
  235.  
  236. [gcode_macro M106]
  237. gcode:
  238. {% set fans = printer["gcode_macro PRINTER_PARAM"].fans|int %}
  239. {% set fan = 0 %}
  240. {% set value = 0 %}
  241. {% if params.P is defined %}
  242. {% set tmp = params.P|int %}
  243. {% if tmp < fans %}
  244. {% set fan = tmp %}
  245. {% endif %}
  246. {% endif %}
  247. {% if params.S is defined %}
  248. {% set tmp = params.S|float %}
  249. {% else %}
  250. {% set tmp = 255 %}
  251. {% endif %}
  252. {% if tmp > 0 %}
  253. {% if fan == 0 %}
  254. {% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan0_min) / 255 * tmp %}
  255. {% if printer['gcode_macro Qmode'].flag | int == 1 %}
  256. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan0_min + value}
  257. {% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
  258. {% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
  259. {% else %}
  260. {% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + value %}
  261. {% endif %}
  262. {% else %}
  263. {% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + value %}
  264. {% endif %}
  265. {% endif %}
  266. {% if fan == 1 %}
  267. {% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan1_min) / 255 * tmp %}
  268. {% if printer['gcode_macro Qmode'].flag | int == 1 %}
  269. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan1_min + value}
  270. {% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
  271. {% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
  272. {% else %}
  273. {% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + value %}
  274. {% endif %}
  275. {% else %}
  276. {% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + value %}
  277. {% endif %}
  278. {% endif %}
  279. {% if fan == 2 %}
  280. {% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) / 255 * tmp %}
  281. {% if printer['gcode_macro Qmode'].flag | int == 1 %}
  282. SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan2_min + value}
  283. {% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
  284. {% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
  285. {% else %}
  286. {% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + value %}
  287. {% endif %}
  288. {% else %}
  289. {% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + value %}
  290. {% endif %}
  291. {% endif %}
  292. {% endif %}
  293. {% if value >= 255 %}
  294. {% set value = 255 %}
  295. {% endif %}
  296. SET_PIN PIN=fan{fan} VALUE={value}
  297.  
  298. [gcode_macro M107]
  299. gcode:
  300. {% set fans = printer["gcode_macro PRINTER_PARAM"].fans|int %}
  301. {% if params.P is defined %}
  302. {% if params.P|int < fans %}
  303. SET_PIN PIN=fan{params.P|int} VALUE=0
  304. {% else %}
  305. SET_PIN PIN=fan0 VALUE=0
  306. {% endif %}
  307. {% else %}
  308. SET_PIN PIN=fan0 VALUE=0
  309. SET_PIN PIN=fan2 VALUE=0
  310. {% endif %}
  311.  
  312. [gcode_macro M141]
  313. description: Set Chamber temperature with slicers
  314. gcode:
  315. {% if 'S' in params|upper %}
  316. {% if printer["temperature_fan chamber_fan"].speed > 0.0 %}
  317. SET_PIN PIN=fan1 VALUE=255
  318. {% else %}
  319. SET_PIN PIN=fan1 VALUE=0
  320. {% endif %}
  321. {% if params.S|int > 0 %}
  322. SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET={params.S|default(35)}
  323. {% else %}
  324. SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET=35
  325. {% if params.S|int == 0 %}
  326. SET_PIN PIN=fan1 VALUE=0
  327. {% endif %}
  328. {% endif %}
  329. {% endif %}
  330.  
  331. [gcode_macro M900]
  332. gcode:
  333. {% if 'K' in params %}
  334. {% if 'E' in params %}
  335. SET_PRESSURE_ADVANCE EXTRUDER={params.E} ADVANCE={params.K}
  336. {% else %}
  337. SET_PRESSURE_ADVANCE ADVANCE={params.K}
  338. {% endif %}
  339. {% endif %}
  340.  
  341. [delayed_gcode wait_temp]
  342. # initial_duration: 2.
  343. gcode:
  344. {% set cur_temp = printer.extruder.temperature %}
  345. {% if cur_temp|int < 40 %}
  346. WAIT_TEMP_END
  347. {% else %}
  348. UPDATE_DELAYED_GCODE ID=wait_temp DURATION=5
  349. {% endif %}
  350.  
  351. [gcode_macro WAIT_TEMP_START]
  352. gcode:
  353. {action_respond_info("wait temp start\n")}
  354. UPDATE_DELAYED_GCODE ID=wait_temp DURATION=1
  355. M106 P0 S255
  356. # M106 P2 S255
  357.  
  358. [gcode_macro WAIT_TEMP_END]
  359. gcode:
  360. {action_respond_info("wait temp end\n")}
  361. UPDATE_DELAYED_GCODE ID=wait_temp DURATION=0
  362. M106 P0 S0
  363. # M106 P2 S0
  364.  
  365. [gcode_macro PRINT_CALIBRATION]
  366. # This part of the command is replaced by the application side without passing parameters
  367. gcode:
  368. CX_PRINT_LEVELING_CALIBRATION
  369.  
  370. [gcode_macro FIRST_FLOOR_PAUSE_POSITION]
  371. gcode:
  372. {% set extruder_temp = printer.custom_macro.g28_ext_temp %}
  373. M104 S{extruder_temp}
  374. {% set y_park = printer.toolhead.axis_maximum.y/2 %}
  375. {% set x_park = printer['gcode_macro PRINTER_PARAM'].max_x_position|float + 1 %}
  376. G90
  377. G1 Z2 F600
  378. G1 X{x_park} Y{y_park} F6000
  379. G1 Z0.2 F600
  380.  
  381. [gcode_macro ACCURATE_G28]
  382. gcode:
  383. ACCURATE_HOME_Z
  384.  
  385. #[gcode_macro START_PRINT]
  386. #variable_prepare: 0
  387. #gcode:
  388. # WAIT_TEMP_END
  389. # CLEAR_PAUSE
  390. # {% set g28_extruder_temp = printer.custom_macro.g28_ext_temp %}
  391. # {% set bed_temp = printer.custom_macro.default_bed_temp %}
  392. # {% set extruder_temp = printer.custom_macro.default_extruder_temp %}
  393. # {% if 'BED_TEMP' in params|upper and (params.BED_TEMP|float) %}
  394. # {% set bed_temp = params.BED_TEMP %}
  395. # {% endif %}
  396. # {% if 'EXTRUDER_TEMP' in params|upper and (params.EXTRUDER_TEMP|float) %}
  397. # {% set extruder_temp = params.EXTRUDER_TEMP %}
  398. # {% endif %}
  399. # {% if printer['gcode_macro START_PRINT'].prepare|int == 0 %}
  400. # {action_respond_info("not prepare.\n")}
  401. # PRINT_PREPARE_CLEAR
  402. # CX_ROUGH_G28 EXTRUDER_TEMP={extruder_temp} BED_TEMP={bed_temp}
  403. # CX_NOZZLE_CLEAR
  404. # ACCURATE_G28
  405. # CX_PRINT_LEVELING_CALIBRATION
  406. # {% else %}
  407. # PRINT_PREPARE_CLEAR
  408. # {% endif %}
  409. # CX_PRINT_DRAW_ONE_LINE
  410.  
  411.  
  412. [gcode_macro PRINT_PREPARED]
  413. gcode:
  414. SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=prepare VALUE=1
  415. {action_respond_info("print prepared")}
  416.  
  417. [gcode_macro PRINT_PREPARE_CLEAR]
  418. gcode:
  419. SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=prepare VALUE=0
  420.  
  421. [gcode_macro END_PRINT_POINT_WITHOUT_LIFTING]
  422. gcode:
  423. {% if "xyz" in printer.toolhead.homed_axes %}
  424. {% set E = printer["gcode_macro PAUSE"].extrude|float %}
  425. G91
  426. {% if printer.extruder.can_extrude|lower == 'true' %}
  427. G1 E-1.0 F180
  428. G1 E-{E} F4000
  429. {% else %}
  430. {action_respond_info("Extruder not hot enough")}
  431. {% endif %}
  432. G1 Z2.0 F600
  433. G90
  434. {% set y_park = printer.toolhead.axis_maximum.y/2 %}
  435. {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
  436. G1 X{x_park} Y{y_park} F30000
  437. {% else %}
  438. {action_respond_info("end print xyz_axes is NULL\n")}
  439. {% endif %}
  440.  
  441. [gcode_macro END_PRINT_POINT]
  442. gcode:
  443. {% if "xyz" in printer.toolhead.homed_axes %}
  444. {% set E = printer["gcode_macro PAUSE"].extrude|float %}
  445. {% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
  446. {% set act_z = printer.toolhead.position.z|float %}
  447. {% set z_safe = 0.0 %}
  448. {% if act_z < (max_z / 2) %}
  449. {% set z_safe = (max_z / 2) - act_z %}
  450. {% elif act_z < max_z %}
  451. {% set z_safe = 2.0 %}
  452. {% endif %}
  453. G91
  454. {% if printer.extruder.can_extrude|lower == 'true' %}
  455. G1 E-1.0 F180
  456. G1 E-{E} F4000
  457. {% else %}
  458. {action_respond_info("Extruder not hot enough")}
  459. {% endif %}
  460. G1 Z2.0 F600
  461. G90
  462. {% set y_park = printer.toolhead.axis_maximum.y/2 %}
  463. {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
  464. G1 X{x_park} Y{y_park} F30000
  465. {% if z_safe > 2.0 %}
  466. G91
  467. {% set z_safe = z_safe - 2.0 %}
  468. G1 Z{z_safe} F600
  469. G90
  470. {% endif %}
  471. {% else %}
  472. {action_respond_info("end print xyz_axes is NULL\n")}
  473. {% endif %}
  474.  
  475. [gcode_macro END_PRINT]
  476. gcode:
  477. Qmode_exit
  478. EXCLUDE_OBJECT_RESET
  479. PRINT_PREPARE_CLEAR
  480. M220 S100
  481. SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=2500
  482. TURN_OFF_HEATERS
  483. M107 P1
  484. M107 P2
  485. END_PRINT_POINT
  486. WAIT_TEMP_START
  487. M84
  488.  
  489. [gcode_macro FIRST_FLOOR_PAUSE]
  490. description: Pause the first floor print
  491. # change this if you need more or less extrusion
  492. variable_extrude: 2.0
  493. gcode:
  494. ##### read E from pause macro #####
  495. {% set E = printer["gcode_macro FIRST_FLOOR_PAUSE"].extrude|float %}
  496. ##### set park positon for x and y #####
  497. # default is your max posion from your printer.cfg
  498. {% set y_park = printer.toolhead.axis_maximum.y/2 %}
  499. {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
  500. ##### calculate save lift position #####
  501. {% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
  502. {% set act_z = printer.toolhead.position.z|float %}
  503. {% set z_safe = 0.0 %}
  504. {% if act_z < (max_z - 2.0) %}
  505. {% set z_safe = 2.0 %}
  506. {% elif act_z < max_z %}
  507. {% set z_safe = max_z - act_z %}
  508. {% endif %}
  509. ##### end of definitions #####
  510. SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=z_safe_pause VALUE={z_safe|float}
  511. PAUSE_BASE
  512. G91
  513. {% if "xyz" in printer.toolhead.homed_axes %}
  514. {% if printer.extruder.can_extrude|lower == 'true' %}
  515. G1 E-1.0 F180
  516. G1 E-{E} F4000
  517. {% else %}
  518. {action_respond_info("Extruder not hot enough")}
  519. {% endif %}
  520. G1 Z{z_safe} F600
  521. G90
  522. G1 X{x_park} Y{y_park} F30000
  523. {% else %}
  524. {action_respond_info("Printer not homed")}
  525. {% endif %}
  526. # save fan2 value and turn off fan2
  527. SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan2_speed VALUE={printer['output_pin fan2'].value}
  528. {% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
  529. {action_respond_info("fan2_value = %s \n" % (fspeed))}
  530. # SET_PIN PIN=fan2 VALUE=0
  531. M106 P2 S0
  532. SET_E_MIN_CURRENT
  533.  
  534. [gcode_macro FIRST_FLOOR_RESUME]
  535. description: Resume the first floor print
  536. gcode:
  537. RESTORE_E_CURRENT
  538. {% if printer['gcode_macro PRINTER_PARAM'].fan2_speed > 0 %}
  539. # {% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
  540. # {action_respond_info("fan2_value2 = %s \n" % (fspeed))}
  541. # SET_PIN PIN=fan2 VALUE={(printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 + 0.5)|int}
  542. {% 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 %}
  543. M106 P2 S{s_value}
  544. {% endif %}
  545. ##### read E from pause macro #####
  546. {% set E = printer["gcode_macro FIRST_FLOOR_PAUSE"].extrude|float + 1.0 %}
  547. #### get VELOCITY parameter if specified ####
  548. {% if 'VELOCITY' in params|upper %}
  549. {% set get_params = ('VELOCITY=' + params.VELOCITY) %}
  550. {%else %}
  551. {% set get_params = "" %}
  552. {% endif %}
  553. ##### end of definitions #####
  554. {% if printer.extruder.can_extrude|lower == 'true' %}
  555. G91
  556. G1 E{E} F2100
  557. {% else %}
  558. {action_respond_info("Extruder not hot enough")}
  559. {% endif %}
  560. M400
  561. RESUME_BASE {get_params}
  562.  
  563. [gcode_macro PAUSE]
  564. description: Pause the actual running print
  565. rename_existing: PAUSE_BASE
  566. # change this if you need more or less extrusion
  567. variable_extrude: 2.0
  568. gcode:
  569. ##### read E from pause macro #####
  570. {% set E = printer["gcode_macro PAUSE"].extrude|float %}
  571. ##### set park positon for x and y #####
  572. # default is your max posion from your printer.cfg
  573. {% set y_park = printer.toolhead.axis_maximum.y/2 %}
  574. {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
  575. ##### calculate save lift position #####
  576. {% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
  577. {% set act_z = printer.toolhead.position.z|float %}
  578. {% set z_safe = 0.0 %}
  579. {% if act_z < 48.0 %}
  580. {% set z_safe = 50.0 - act_z %}
  581. {% elif act_z < (max_z - 2.0) %}
  582. {% set z_safe = 2.0 %}
  583. {% elif act_z < max_z %}
  584. {% set z_safe = max_z - act_z %}
  585. {% endif %}
  586. {action_respond_info("z_safe = %s"% (z_safe))}
  587. ##### end of definitions #####
  588. SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=z_safe_pause VALUE={z_safe|float}
  589. PAUSE_BASE
  590. G91
  591. SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE={printer.extruder.target}
  592. M104 S140
  593. {% if "xyz" in printer.toolhead.homed_axes %}
  594. {% if printer.extruder.can_extrude|lower == 'true' %}
  595. G1 E-1.0 F180
  596. G1 E-{E} F4000
  597. {% else %}
  598. {action_respond_info("Extruder not hot enough")}
  599. {% endif %}
  600. G1 Z{z_safe} F600
  601. M400
  602. G90
  603. G1 X{x_park} Y{y_park} F30000
  604. {% else %}
  605. {action_respond_info("Printer not homed")}
  606. {% endif %}
  607. # save fan2 value and turn off fan2
  608. SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan2_speed VALUE={printer['output_pin fan2'].value}
  609. {% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
  610. {action_respond_info("fan2_value = %s \n" % (fspeed))}
  611. # SET_PIN PIN=fan2 VALUE=0
  612. M106 P2 S0
  613. SET_E_MIN_CURRENT
  614.  
  615. [gcode_macro INPUTSHAPER]
  616. gcode:
  617. SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
  618. SET_FILAMENT_SENSOR SENSOR=filament_sensor_2 ENABLE=0
  619. G90
  620. G28
  621. {% set POSITION_X = printer.configfile.settings['stepper_x'].position_max/2 %}
  622. {% set POSITION_Y = printer.configfile.settings['stepper_y'].position_max/2 %}
  623. G1 X{POSITION_X} Y{POSITION_Y} F6000
  624. G1 Z10 F600
  625. SHAPER_CALIBRATE AXIS
  626. CXSAVE_CONFIG
  627. SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1
  628. SET_FILAMENT_SENSOR SENSOR=filament_sensor_2 ENABLE=1
  629.  
  630. [gcode_macro INPUT_SHAPER]
  631. description: Measure X and Y axis resonances
  632. gcode:
  633. G90
  634. {% if printer.toolhead.homed_axes != "xyz" %}
  635. G28
  636. {% endif %}
  637. SHAPER_CALIBRATE
  638. {% set y_park = printer.toolhead.axis_maximum.y/2 %}
  639. {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
  640. G1 X{x_park} Y{y_park} F20000
  641.  
  642. [gcode_macro BEDPID]
  643. gcode:
  644. PID_CALIBRATE HEATER=heater_bed TARGET=100
  645. SAVE_CONFIG
  646.  
  647. [gcode_macro TUNOFFINPUTSHAPER]
  648. gcode:
  649. SET_INPUT_SHAPER SHAPER_FREQ_X=0 SHAPER_FREQ_Y=0
  650.  
  651. #[gcode_macro RESUME]
  652. #description: Resume the actual running print
  653. #rename_existing: RESUME_BASE
  654. #gcode:
  655. # RESTORE_E_CURRENT
  656. # {% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int != 0 %}
  657. # {% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int > printer.extruder.temperature %}
  658. # M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
  659. # {% else %}
  660. # M104 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
  661. # {% endif %}
  662. # SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE=0
  663. # {% endif %}
  664. # {% if printer['gcode_macro PRINTER_PARAM'].fan2_speed > 0 %}
  665. # # {% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
  666. # # {action_respond_info("fan2_value2 = %s \n" % (fspeed))}
  667. # # SET_PIN PIN=fan2 VALUE={(printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 + 0.5)|int}
  668. # {% 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 %}
  669. # M106 P2 S{s_value}
  670. # {% endif %}
  671. # {% set z_resume_move = printer['gcode_macro PRINTER_PARAM'].z_safe_pause|int %}
  672. # {% if z_resume_move > 2 %}
  673. # {% set z_resume_move = z_resume_move - 2 %}
  674. # G91
  675. # G1 Z-{z_resume_move} F600
  676. # M400
  677. # {% endif %}
  678. # {action_respond_info("z_resume_move = %s"% (z_resume_move))}
  679. # ##### read E from pause macro #####
  680. # {% set E = printer["gcode_macro PAUSE"].extrude|float + 1.0 %}
  681. # #### get VELOCITY parameter if specified ####
  682. # {% if 'VELOCITY' in params|upper %}
  683. # {% set get_params = ('VELOCITY=' + params.VELOCITY) %}
  684. # {%else %}
  685. # {% set get_params = "" %}
  686. # {% endif %}
  687. # ##### end of definitions #####
  688. # {% if printer.extruder.can_extrude|lower == 'true' %}
  689. # G91
  690. # G1 E{E} F2100
  691. # G90
  692. # {% else %}
  693. # {action_respond_info("Extruder not hot enough")}
  694. # {% endif %}
  695. # M400
  696. # RESUME_BASE {get_params}
  697.  
  698. [gcode_macro CANCEL_PRINT]
  699. description: Cancel the actual running print
  700. rename_existing: CANCEL_PRINT_BASE
  701. gcode:
  702. END_PRINT
  703. CANCEL_PRINT_BASE
  704.  
  705. [gcode_macro G29]
  706. gcode:
  707. {% if 'PROBE_COUNT' in params|upper %}
  708. {% set get_count = ('PROBE_COUNT' + params.PROBE_COUNT) %}
  709. {%else %}
  710. {% set get_count = "" %}
  711. {% endif %}
  712.  
  713. {% set bed_temp = printer.custom_macro.default_bed_temp %}
  714. {% set extruder_temp = printer.custom_macro.g28_ext_temp %}
  715. {% set nozzle_clear_temp = printer.custom_macro.default_extruder_temp %}
  716.  
  717. {% if 'BED_TEMP' in params|upper %}
  718. {% set bed_temp = params.BED_TEMP %}
  719. {% endif %}
  720.  
  721. {% if 'EXTRUDER_TEMP' in params|upper %}
  722. {% set nozzle_clear_temp = params.EXTRUDER_TEMP %}
  723. {% endif %}
  724. SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
  725. SET_FILAMENT_SENSOR SENSOR=filament_sensor_2 ENABLE=0
  726.  
  727. G28
  728. BED_MESH_CLEAR
  729. NOZZLE_CLEAR HOT_MIN_TEMP={extruder_temp} HOT_MAX_TEMP={nozzle_clear_temp} BED_MAX_TEMP={bed_temp}
  730. ACCURATE_G28
  731. M204 S5000
  732. SET_VELOCITY_LIMIT ACCEL_TO_DECEL=5000
  733. BED_MESH_CALIBRATE {get_count}
  734. BED_MESH_OUTPUT
  735. {% set y_park = printer.toolhead.axis_maximum.y/2 %}
  736. {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
  737. G1 X{x_park} Y{y_park} F2000
  738. CXSAVE_CONFIG
  739. TURN_OFF_HEATERS
  740. SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1
  741. SET_FILAMENT_SENSOR SENSOR=filament_sensor_2 ENABLE=1
  742.  
  743. # [gcode_macro G299]
  744. # gcode:
  745. # BED_MESH_CLEAR
  746. # G28
  747. # PRTOUCH_READY
  748. # BED_MESH_CALIBRATE
  749. # BED_MESH_OUTPUT
  750.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement