kewlhotrod

custom.cfg

Jul 31st, 2026
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.61 KB | None | 0 0
  1. #____________________________________________INSTRUCTIONS AND SNIPPETS TO PASTE________________________________________________
  2.  
  3. #paste [include custom.cfg] at THE END of "printer.cfg" just above ## <--------------------- SA\/E_CONFIG --------------------->
  4. #paste [skew_correction] anywhere in "printer.cfg" (for Calilantern or other skew correction; not absolutely necessary)
  5.  
  6. ##paste and uncomment in "moonraker.conf":
  7. #[timelapse]
  8. #output_path: ~/printer_data/timelapse/
  9. #frame_path: /tmp/timelapse/printer
  10. #autorender: False #auto-rendering crashes klipper during gradual bed cooldown macro, but TIMELAPSE_RENDER is performed automatically at times it won't cause a crash at end of cooling or in PRINT_END if not cooling
  11.  
  12. ##if you have a Nebula for a second camera and it stops working:
  13. ##Nebula camera ID in case Qidi overwrites it in "crowsnest.conf" again:
  14. #device:/dev/v4l/by-id/usb-UnionImage_Co._Ltd_CCX2F3298_1234567890-video-index0
  15.  
  16. ##linux commands to disable unused processes during an SSH session:
  17. #default username is mks
  18. #default password is makerbase
  19. ##you could just disable algo_app (the AI spaghetti detection service); it uses the most resources of anything listed here by FAR
  20.  
  21. #sudo systemctl disable --now algo_app.service
  22. #sudo systemctl disable --now QIDILink-client.service
  23. #sudo systemctl disable --now strongswan-starter.service
  24. #sudo systemctl disable --now openvpn.service
  25. #sudo systemctl disable --now triggerhappy.service
  26. #systemctl --user disable --now pulseaudio.service
  27. #systemctl --user disable --now pulseaudio.socket
  28. #sudo systemctl disable --now bluetooth
  29. #sudo systemctl disable --now lightdm
  30. #sudo systemctl disable --now xl2tpd
  31.  
  32. #_________________________________________CONFIGS_____________________________________________________
  33.  
  34. [include ./KAMP/Adaptive_Meshing.cfg] #this should fix the broken stock KAMP implementation Qidi used
  35. [include ./KAMP/Line_Purge.cfg] # Include to enable adaptive line purging configuration.
  36. # [include ./KAMP/Smart_Park.cfg] # Include to enable the Smart Park function, which parks the printhead near the print area for final heating.
  37.  
  38. #fan config for 2-3 wire hotend fan DO NOT USE THIS WITH 4 PIN / STOCK FAN
  39. [heater_fan hotend_fan]
  40. pin:THR:PB10#FAN2 pins
  41. max_power: 1.0
  42. shutdown_speed:0
  43. cycle_time: 0.010
  44. hardware_pwm: False
  45. kick_start_time: 0.100
  46. heater: extruder
  47. heater_temp: 50.0
  48. fan_speed: 1.0
  49. off_below: 0
  50. #comment out tach pins both here AND in printer.cfg if using a 2 wire fan:
  51. tachometer_pin:THR:PA12 #stock hotend fan tach pin
  52. tachometer_ppr: 2
  53. tachometer_poll_interval: 0.00050#0.0015 default
  54.  
  55. #requires Klipper Maintenance addon; delete or comment out if not using that
  56. # [maintain]
  57. # interval: 600 # optional, time (in seconds) between checking if maintenance needs to be done (default is 60)
  58.  
  59. #requires Klipper Maintenance addon; delete or comment out if not using that
  60. # Lubricate XY rods
  61. # [maintain xyrods]
  62. # label: XY smooth rods
  63. # trigger: print_time
  64. # threshold: 100 #this is a conservative time interval
  65. # message: Lubricate XY smooth rods
  66.  
  67. #requires Klipper Maintenance addon; delete or comment out if not using that
  68. # Lubricate Z rods and screws
  69. # [maintain zrodsandscrews]
  70. # label: Z rods and screws
  71. # trigger: print_time
  72. # threshold: 250 #this is a conservative time interval
  73. # message: Lubricate Z smooth rods and lead screws
  74.  
  75.  
  76.  
  77. [verify_heater heater_bed]
  78. max_error: 700 #default 400; hopefully stops crashing when putting a cold plate on bed
  79. check_gain_time:120
  80. hysteresis: 2
  81. heating_gain: 1
  82.  
  83.  
  84. #[resonance_tester] #trying to get sweeping to work with shaketune but it won't
  85. #sweeping_accel: 400
  86. # An acceleration of slow sweeping moves. The default is 400 mm/sec^2.
  87. #sweeping_accel_z: 50
  88. # Same as sweeping_accel above, but for Z axis. The default is 50 mm/sec^2.
  89. #sweeping_period: 1.2
  90. [shaketune]
  91. # result_folder: ~/printer_data/config/ShakeTune_results
  92. # Path where the processed results will be stored. If the folder doesn't exist,
  93. # it will be automatically created. You can change this if you'd like to store
  94. # results in a different location.
  95. # number_of_results_to_keep: 10
  96. # This setting defines how many results you want to keep in the result folder.
  97. # Once the specified number is exceeded, older results will be automatically deleted
  98. # to free up space on the SD card and avoid cluttering the results folder.
  99. # keep_raw_data: False
  100. # If set to True, Shake&Tune will store both the processed graphs and the raw accelerometer
  101. # .stdata files in the results folder. This can be useful for debugging or archiving purposes.
  102. # Please always attach them when reporting any issues on GitHub or Discord.
  103. # show_macros_in_webui: True
  104. # Mainsail and Fluidd doesn't create buttons for system commands (macros that are not part
  105. # of the printer.cfg file). This option allow Shake&Tune to inject them into the webui at runtime.
  106. # If set to False, the macros will be hidden but still accessible from the console by typing
  107. # their names manually, which can be useful if you prefer to encapsulate them into your own macros.
  108. # timeout: 600
  109. # This defines the maximum processing time (in seconds) to allows to Shake&Tune for generating
  110. # graphs from a .stdata file. 10 minutes should be more than enough in most cases, but if you have
  111. # slower hardware (e.g., older SD cards or low-performance devices), increase it to prevent timeouts.
  112. # measurements_chunk_size: 2
  113. # Each Shake&Tune command uses the accelerometer to take multiple measurements. By default,
  114. # Shake&Tune will write a chunk of data to disk every two measurements, and at the end of the
  115. # command will merge these chunks into the final .stdata file for processing. "2" is a very
  116. # conservative setting to avoid Klipper Timer Too Close errors on lower end devices with little
  117. # RAM, and should work for everyone. However, if you are using a powerful computer, you may
  118. # wish to increase this value to keep more measurements in memory (e.g., 15-20) before writing
  119. # the chunk and avoid stressing the filesystem too much.
  120. # max_freq: 200
  121. # This setting defines the maximum frequency at which the calculation of the power spectral density
  122. # is cutoff. The default value should be fine for most machines and accelerometer combinations and
  123. # avoid touching it unless you know what you're doing.
  124. # dpi: 300
  125. # Controls the resolution of the generated graphs. The default value of 300 dpi was optimized
  126. # and strikes a balance between performance and readability, ensuring that graphs are clear
  127. # without using too much RAM to generate them. Usually, you shouldn't need to change this value.
  128.  
  129. #this makes large area bed meshes (automatic bed leveling) more accurate but slower. Reduce 9,9 to something smaller if it's too slow.
  130. [bed_mesh]
  131. speed: 300 #100
  132. horizontal_move_z:2 #stock 5; this should be fine unless I am tramming the bed badly
  133. mesh_min:10,10 #probably can't go lower without removing the filament cutter
  134. mesh_max:270,270#stock260,260 #don't know why they skipped that corner
  135. probe_count:9,9#stock: 6,6
  136. algorithm:bicubic#stock: lagrange#bicubic
  137. bicubic_tension:0.2#stock: commented out
  138. mesh_pps: 2, 2
  139. #fade_target:0
  140.  
  141. [probe_air]
  142. delta_v: 0.08
  143. #z_offset:-0.07
  144. speed: 5
  145. lift_speed:10#5
  146. samples: 2
  147. sample_retract_dist:2#3
  148. samples_result: average
  149. samples_tolerance: 0.02
  150. samples_tolerance_retries: 10
  151.  
  152. [fan_generic cooling_fan]
  153. tachometer_poll_interval: 0.00075#0.001 pre-CFD shroud #poll fan tach more often for accurate RPM of upgraded fan#0.0015 default
  154.  
  155.  
  156. [temperature_sensor Host_CPU]#adds new temp sensor to graph in fluidd
  157. sensor_type: temperature_host
  158. min_temp: 10
  159. max_temp: 100
  160.  
  161. [temperature_sensor toolhead]#adds new temp sensor to graph in fluidd
  162. sensor_type: temperature_mcu
  163. sensor_mcu: THR
  164. min_temp: 0
  165. max_temp: 100
  166.  
  167. [gcode_macro _KAMP_Settings]
  168. description: This macro contains all adjustable settings for KAMP
  169.  
  170. # The following variables are settings for KAMP as a whole.
  171. variable_verbose_enable: True # Set to True to enable KAMP information output when running. This is useful for debugging.
  172.  
  173. # The following variables are for adjusting adaptive mesh settings for KAMP.
  174. variable_mesh_margin: 10 # Expands the mesh size in millimeters if desired. Leave at 0 to disable.
  175. variable_fuzz_amount: 4 #default 0 # Slightly randomizes mesh points to spread out wear from nozzle-based probes. Leave at 0 to disable.
  176.  
  177. # The following variables are for those with a dockable probe like Klicky, Euclid, etc. # ---------------- Attach Macro | Detach Macro
  178. variable_probe_dock_enable: False # Set to True to enable the usage of a dockable probe. # ---------------------------------------------
  179. variable_attach_macro: 'Attach_Probe' # The macro that is used to attach the probe. # Klicky Probe: 'Attach_Probe' | 'Dock_Probe'
  180. variable_detach_macro: 'Dock_Probe' # The macro that is used to store the probe. # Euclid Probe: 'Deploy_Probe' | 'Stow_Probe'
  181. # Legacy Gcode: 'M401' | 'M402'
  182.  
  183. # The following variables are for adjusting adaptive purge settings for KAMP.
  184. variable_purge_height: 0.8 # Z position of nozzle during purge, default is 0.8.
  185. variable_tip_distance: 0 # Distance between tip of filament and nozzle before purge. Should be similar to PRINT_END final retract amount.
  186. variable_purge_margin: 30 #keep purge outside of brims # Distance the purge will be in front of the print area, default is 10.
  187. variable_purge_amount: 2 # Amount of filament to be purged prior to printing.
  188. variable_flow_rate: 7.5 # Flow rate of purge in mm3/s. Default is 12.
  189.  
  190. # The following variables are for adjusting the Smart Park feature for KAMP, which will park the printhead near the print area at a specified height.
  191. variable_smart_park_height: 10 # Z position for Smart Park, default is 10.
  192.  
  193. gcode: # Gcode section left intentionally blank. Do not disturb.
  194.  
  195. {action_respond_info(" Running the KAMP_Settings macro does nothing, it is only used for storing KAMP settings. ")}
  196.  
  197.  
  198. [screws_tilt_adjust]
  199. screw1:30,30
  200. screw1_name: front left screw
  201.  
  202. screw2: 240,30
  203. screw2_name: front right screw
  204.  
  205. screw3: 240,240
  206. screw3_name: rear right screw
  207.  
  208. screw4: 30,240
  209. screw4_name: rear left screw
  210.  
  211. horizontal_move_z: 10
  212. speed: 50
  213. screw_thread: CW-M4
  214.  
  215. [gcode_macro SCREWS_TILT_CALCULATE]
  216. rename_existing: _SCREWS_TILT_CALCULATE_BASE
  217. gcode:
  218. { action_respond_info("starting screw rotation calculation...") }
  219. _SCREWS_TILT_CALCULATE_BASE
  220.  
  221. [tmc2240 stepper_x]
  222. driver_SLOPE_CONTROL:2 #keeps drivers much cooler, commented out by default
  223.  
  224. [tmc2240 stepper_y]
  225. driver_SLOPE_CONTROL:2 #keeps drivers much cooler, commented out by default
  226.  
  227. [controller_fan chamber_fan]
  228. shutdown_speed: 1 #keep fan running to cool chamber heater if klipper crashes
  229.  
  230. #__________________________________________________MACROS___________________________________________________
  231.  
  232. #_____Stock macro overrides; delete these to go back to stock versions or make modifications here:_____
  233.  
  234. # [gcode_macro CANCEL_PRINT]#adds smart plug shut off
  235. # rename_existing: BASE_CANCEL_PRINT
  236. # gcode:
  237. # {% if "xyz" in printer.toolhead.homed_axes %}
  238. # M204 S10000
  239. # G90
  240. # {% if (printer.gcode_move.position.z) < 100 %}
  241. # G1 Z100 F600
  242. # {% endif %}
  243. # {% if (printer.gcode_move.position.y) > printer['gcode_macro PRINTER_PARAM'].max_y_position %}
  244. # G1 Y{printer['gcode_macro PRINTER_PARAM'].max_y_position - 50} F6000
  245. # {% endif %}
  246. # G1 X265 Y5 F7800
  247. # {% endif %}
  248. # {% if printer.save_variables.variables.box_count >= 1 and printer.save_variables.variables.enable_box == 1 and printer["box_extras"]%}
  249. # BUFFER_MONITORING ENABLE=0
  250. # {% endif %}
  251. # M400
  252. # save_zoffset
  253. # SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout}
  254.  
  255. # M106 P2 S0
  256. # M106 P0 S0
  257. # M106 P3 S0
  258. # M106 P4 S0 # 关闭空调
  259.  
  260. # M104 S0
  261. # M140 S0
  262. # M141 S0
  263. # DISABLE_BOX_HEATER
  264.  
  265. # M220 S100
  266. # M221 S100
  267. # M84
  268.  
  269. # DISABLE_ALL_SENSOR
  270. # SET_GCODE_OFFSET Z=0 MOVE=0
  271. # BED_MESH_CLEAR
  272. # G31
  273. # BEEP I=2 DUR=500
  274.  
  275. # BASE_CANCEL_PRINT
  276. # CLEAR_LAST_FILE
  277. # M118 Canceled print!
  278. # M118 Turn off hood in 5 minutes
  279. # UPDATE_DELAYED_GCODE ID=DELAYED_HOOD_OFF DURATION=300
  280.  
  281. [gcode_macro RESUME_PRINT]#fixed a problem that caused layer shifts sometimes
  282. variable_zhop: 0
  283. variable_etemp: 0
  284. variable_efan: 0
  285. variable_echambertemp: 0
  286. gcode:
  287. {% set e = params.E|default(30)|int %}
  288. {% set tool_change = params.TOOL_CHANGE|default(0)|int %}
  289.  
  290.  
  291. {% if printer['pause_resume'].is_paused|int == 1 %}
  292. {% if printer.save_variables.variables.box_count >= 1 and printer.save_variables.variables.enable_box == 1 and printer.save_variables.variables.is_tool_change == 1 and printer["box_extras"]%}
  293. SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout}
  294. MOVE_TO_TRASH
  295. {% if etemp > 0 %}
  296. M109 S{etemp|int}
  297. {% endif %}
  298. M83
  299. G1 Y265 F10000 #move straight out of trash chute without causing layer shift
  300. RESTORE_GCODE_STATE NAME=PAUSEPARK MOVE=1 MOVE_SPEED=200
  301. RESTORE_GCODE_STATE NAME=PAUSE MOVE=1 MOVE_SPEED=15
  302. BASE_RESUME
  303. {% else %}
  304. SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout}
  305. {% if etemp > 0 %}
  306. M109 S{etemp|int}
  307. {% endif %}
  308. {% if printer.save_variables.variables.box_count >= 1 and printer["box_extras"] %}
  309. SAVE_VARIABLE VARIABLE=retry_step VALUE=None
  310. {% endif %}
  311. M83
  312. M106 S{efan}
  313. {% if echambertemp > 0 %}
  314. M141 S{echambertemp|int}
  315. {% endif %}
  316. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position} F9000
  317. G1 Y{printer['gcode_macro PRINTER_PARAM'].clear_y_position} F9000
  318. {% if printer.extruder.can_extrude %}
  319. G91
  320. G1 E{e} F300
  321. G90
  322. {% endif %}
  323. {% if printer.save_variables.variables.box_count >= 1 and printer.save_variables.variables.enable_box == 1 %}
  324. BUFFER_MONITORING ENABLE=1
  325. {% endif %}
  326. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position + 20} F15000
  327. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position} F5000
  328. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position + 20} F15000
  329. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position} F5000
  330. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position + 20} F15000
  331. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position} F5000
  332. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position + 20} F15000
  333. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position} F5000
  334. G1 Y{printer['gcode_macro PRINTER_PARAM'].clear_y_position - 50} F9000
  335. G1 Y265 F10000 #move straight out of trash chute without causing layer shift
  336. RESTORE_GCODE_STATE NAME=PAUSEPARK MOVE=1 MOVE_SPEED=200
  337. RESTORE_GCODE_STATE NAME=PAUSE MOVE=1 MOVE_SPEED=15
  338. BASE_RESUME
  339. {% if tool_change == 0 %}
  340. ENABLE_ALL_SENSOR
  341. {% endif %}
  342. {% endif %}
  343. {% endif %}
  344.  
  345. [gcode_macro M603]#unload filament; made it waste less time, only home XY, and made the heating/cooling minimal
  346. description: filament unlode
  347. gcode:
  348. DISABLE_ALL_SENSOR
  349. {% set hotendtemp = params.S|default(250)|int %}#this seems to always set to 250 no matter what but I'm leaving it
  350. {% if printer.extruder.temperature < 200 %} #heat nozzle to 200 if it's too cold to operate extruder
  351. {% set hotendtemp = 200|int %}
  352. {% endif %}
  353. M104 S{hotendtemp}
  354. {% if "xy" not in printer.toolhead.homed_axes %}#home XY if not homed already
  355. G28 X Y
  356. {% endif %}
  357.  
  358. G92 E0
  359.  
  360. {% if printer.save_variables.variables.box_count > 0 and printer["box_extras"]%}
  361. E_UNLOAD SLOT=16
  362. {% else %}
  363. CUT_FILAMENT_1
  364. M118 Cut filament
  365. MOVE_TO_TRASH
  366. M109 S{hotendtemp}
  367. M118 Heat up complete
  368. M118 Retracting
  369. G1 E-60 F300 #退料60mm
  370. {% endif %}
  371.  
  372. M104 S0
  373.  
  374. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position + 20} F15000
  375. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position} F5000
  376. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position + 20} F15000
  377. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position} F5000
  378. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position + 20} F15000
  379. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position} F5000
  380. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position + 20} F15000
  381. G1 X{printer['gcode_macro PRINTER_PARAM'].clear_x_position} F5000
  382.  
  383. M106 S0
  384. M400
  385. M118 Unload finish
  386.  
  387.  
  388. [gcode_macro PRINT_START]#much faster print start with toggleable waits
  389. gcode:
  390. DISABLE_ALL_SENSOR
  391. CLEAR_PAUSE
  392. {% set vars = printer['gcode_macro END_Vars'] %}
  393. {% set bedtemp = params.get('BED') | int %}
  394. {% set hotendtemp = params.get('HOTEND') | int %}
  395. {% set chambertemp = params.get('CHAMBER', 0) | int %}
  396. {% set extruder = params.EXTRUDER|default(0)|int %}
  397. SET_GCODE_VARIABLE MACRO=END_Vars VARIABLE=printing VALUE=True
  398.  
  399. M118 Heat hotend to 140C
  400. M104 S140
  401.  
  402. M118 Heat bed to {bedtemp}C
  403. M140 S{bedtemp}
  404.  
  405. M118 Heat chamber to {chambertemp}C
  406. M141 S{chambertemp}
  407.  
  408. SET_FAN_SPEED FAN=chamber_circulation_fan SPEED=0
  409. M118 Exhaust fan stopped
  410.  
  411. {% if chambertemp == 0 %}
  412. M106 P3 S255
  413. {% endif %}
  414.  
  415. ;HOOD_ON #power ventilation hood
  416.  
  417. M118 Homing...
  418. G28
  419. SET_GCODE_OFFSET Z=0 MOVE=0
  420. BUFFER_MONITORING ENABLE=0
  421. {% if printer.save_variables.variables.box_count >= 1 and printer["box_extras"] %}
  422. SAVE_VARIABLE VARIABLE=load_retry_num VALUE=0
  423. SAVE_VARIABLE VARIABLE=retry_step VALUE=None
  424. CLEAR_TOOLCHANGE_STATE
  425. {% for i in range(16) %}
  426. SAVE_VARIABLE VARIABLE=runout_{i} VALUE=0
  427. G4 P100
  428. {% endfor %}
  429. {% if printer.save_variables.variables.enable_box == 1 %}
  430. BOX_PRINT_START EXTRUDER={extruder} HOTENDTEMP={hotendtemp}
  431. M400
  432. EXTRUSION_AND_FLUSH HOTEND={hotendtemp}
  433. {% endif %}
  434. {% endif %}
  435.  
  436. M118 Clear nozzle
  437. CLEAR_NOZZLE HOTEND={hotendtemp}
  438. {% if vars.heat_soak_bed == True %}
  439. M118 Wait for bed to heat up for soaking
  440. M190 S{bedtemp}
  441. M118 Wait for chamber to heat up for soaking
  442. M191 S{chambertemp}
  443. M118 Wait 20 minutes to heat soak #10 #30
  444. G4 P1200000 #P600000 #P1800000
  445. {% else %}
  446. M118 Skip heat soaking
  447. {% endif %}
  448. M118 Z tilt
  449. Z_TILT_ADJUST
  450.  
  451. M400
  452. ;SET_GCODE_OFFSET Z=0 MOVE=0
  453.  
  454. M118 Wait for bed to heat up
  455. M190 S{bedtemp}
  456. M118 re-home Z #someone told me it's best practice to re-home Z after adjusting Z tilt
  457. G28 Z #home Z
  458.  
  459.  
  460.  
  461. M118 Mesh probing...
  462. BED_MESH_CALIBRATE
  463.  
  464. G0 Z50 F600
  465. G0 X260 Y5 F6000
  466.  
  467. {% if printer.save_variables.variables.box_count >= 1 and printer["box_extras"] and printer.save_variables.variables.enable_box == 1 %}
  468. BUFFER_MONITORING ENABLE=1
  469. {% endif %}
  470.  
  471. {% if vars.heatup_chamber == True %}
  472. M118 Wait for chamber to heat up
  473. M191 S{chambertemp}
  474. {% else %}
  475. M118 Skip waiting for chamber to heat up
  476. {% endif %}
  477.  
  478. M118 Heat hotend to {hotendtemp}C
  479. M104 S{hotendtemp}
  480.  
  481. M118 Wait for hotend to heat up
  482. M109 S{hotendtemp}
  483.  
  484. M204 S10000
  485. set_zoffset
  486. ENABLE_ALL_SENSOR
  487. save_last_file
  488. M118 SKEW_PROFILE LOAD=calilantern_skew_profile
  489. #center toolhead
  490. G1 Y135 F6000
  491. G1 X135 F6000
  492. SKEW_PROFILE LOAD=calilantern_skew_profile
  493. M118 Start printing
  494.  
  495.  
  496. [homing_override]#randomizes location of Z homing to reduce wear on plate
  497. axes:xyz
  498. gcode:
  499. {% set home_all = 'X' not in params and 'Y' not in params and 'Z' not in params %} #
  500. {% set z_hop_speed = (printer.configfile.settings['stepper_z'].homing_speed * 60) | float %} #
  501. {% set travel_speed = (printer.toolhead.max_velocity * 60 / 2) | float %} #cut travel speed in half
  502. {% set sensorless_variables = printer["gcode_macro _Sensorless_Homing_Variables"] %} #
  503. {% set z_hop_distance = sensorless_variables.z_hop_distance | float %} # Collect all variables needed for sensorless homing
  504. {% set first_homed_axis = sensorless_variables.first_homed_axis | string %} # from machine config file and _Sensorless_Homing_Variables
  505. {% set safe_x = sensorless_variables.safe_x | float %} #
  506. {% set safe_y = sensorless_variables.safe_y | float %} #
  507. {% set safe_z = sensorless_variables.safe_z_enable | abs %} #
  508. {% set chamber = printer["heater_generic chamber"].target|int %}
  509. #
  510.  
  511. {% if safe_x == -128 %} #
  512. {% set safe_x = (printer.configfile.settings.stepper_x.position_max) /2 %} # If safe_x is '-128', set safe_x to the center of the X axis
  513. {% endif %} #
  514.  
  515. #
  516.  
  517. {% if safe_y == -128 %} #
  518. {% set safe_y = (printer.configfile.settings.stepper_y.position_max) /2 %} # If safe_y is '-128', set safe_y to the center of the Y axis
  519. {% endif %} #
  520. #
  521.  
  522. {% if z_hop_distance > 0 %} # Check if z_hop_distance is greater than zero
  523. {% if 'x' not in printer.toolhead.homed_axes and 'y' not in printer.toolhead.homed_axes %} # If X and Y are not homed, move Z to z_hop_distance
  524. SET_KINEMATIC_POSITION Z=0
  525. G0 Z{z_hop_distance} F{z_hop_speed} #
  526. {% endif %} #
  527. {% endif %} #
  528.  
  529. {% if first_homed_axis == 'X' %} # If first_homed_axis is 'X', begin G28 param check
  530. {% if home_all or 'X' in params %} #
  531. _HOME_X # If home_all or 'X' is in params, home X
  532. {% endif %} #
  533. {% if home_all or 'Y' in params %} # If home_all or 'Y' in params, home Y
  534. _HOME_Y #
  535. {% endif %} #
  536. {% endif %} #
  537.  
  538. {% if first_homed_axis == 'Y' %} # If first_homed_axis is 'Y', begin G28 param check
  539. {% if home_all or 'Y' in params %} #
  540. _HOME_Y # if home_all or 'Y' is in params, home Y
  541. {% endif %} #
  542. {% if home_all or 'X' in params %} # If home_all or 'X' in params, home X
  543. _HOME_X #
  544. {% endif %} #
  545. {% endif %} #
  546.  
  547. {% if safe_z == 1 and (('Z' in params) or home_all) and ('Z' not in printer.toolhead.homed_axes) %} # If safe_z is enabled, Z is to be homed, and Z is not homed
  548. {% if (printer.toolhead.position.z|float < 10) %}
  549. SET_KINEMATIC_POSITION Z=0
  550. G1 Z{z_hop_distance} F{z_hop_speed}
  551. {% endif %}
  552. G0 X{safe_x} Y{safe_y} F{travel_speed} # Move to safe XY position at travel speed
  553. {% endif %} #
  554.  
  555. {% if home_all or 'Z' in params %}
  556. G90
  557. {% if printer.extruder.temperature > 145 %} #don't heat nozzle if it's cold
  558. M106 S255 #Turn on part cooling fan to help cooldown nozzle
  559. M109 S140 #cooldown nozzle to 140c, prevents any filament from sticking to bed
  560. {% endif %}
  561. M106 S0 #Turn off part cooling fan, maybe helps remove noise from load cell
  562. SET_HEATER_TEMPERATURE HEATER=chamber TARGET=0 #Turn off chamber heater, maybe helps reduce electrical noise from load cell
  563. SET_GCODE_OFFSET Z=0 MOVE=0
  564. {% set base_x = printer['gcode_macro PRINTER_PARAM'].max_x_position/2 | float %} #Randomize probe point
  565. {% set base_y = printer['gcode_macro PRINTER_PARAM'].max_y_position/2 | float %}
  566. {% set safe_x = range((base_x - 10)|int, (base_x + 10)|int + 1) | random %}
  567. {% set safe_y = range((base_y - 10)|int, (base_y + 10)|int + 1) | random %}
  568. G0 X{safe_x} Y{safe_y} F7800
  569. G28 Z
  570. G1 Z20 F2000
  571. SET_HEATER_TEMPERATURE HEATER=chamber TARGET={chamber} #Restore chamber heater
  572. {% endif %}
  573.  
  574. [gcode_macro PRINT_END]#triggers slow cooldown macros if enabled, clears skew, and renders timelapse
  575. gcode:
  576. {% set vars = printer['gcode_macro END_Vars'] %}
  577. SET_GCODE_VARIABLE MACRO=END_Vars VARIABLE=printing VALUE=False
  578. {% if vars.skip_print_end == False %}
  579. SET_SKEW CLEAR=1 #clear skew
  580. M400
  581. save_zoffset
  582. SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout}
  583. CLEAR_PAUSE
  584. M106 P2 S0
  585. M106 P0 S0
  586. M106 P3 S0
  587. DISABLE_BOX_HEATER
  588.  
  589. M104 S0
  590. M140 S0
  591. M141 S0
  592.  
  593. M220 S100
  594. M221 S100
  595. M84
  596.  
  597. DISABLE_ALL_SENSOR
  598. BED_MESH_CLEAR
  599. G31
  600. CLEAR_LAST_FILE
  601. BEEP I=2 DUR=500
  602. SDCARD_RESET_FILE
  603. {% if vars.cooldown_bed == True %}
  604. Cooldown_Bed
  605. {% else %}
  606. # M118 Turn off hood in 5 minutes
  607. # UPDATE_DELAYED_GCODE ID=DELAYED_HOOD_OFF DURATION=300
  608. M118 Bed cooling disabled
  609. M118 Rendering timelapse...
  610. TIMELAPSE_RENDER
  611. {% endif %}
  612. {% else %}
  613. CLEAR_LAST_FILE
  614. SDCARD_RESET_FILE
  615. {% endif %}
  616.  
  617. [gcode_macro CLEAR_NOZZLE]#extrudes 20mm of filament instead of default 80mm
  618. gcode:
  619. {% set hotendtemp = params.HOTEND|default(250)|int %}
  620. MOVE_TO_TRASH
  621. M400
  622. M109 S{hotendtemp}
  623. G92 E0
  624. G1 E5 F80
  625. G92 E0
  626. G1 E20 F300 #default E80
  627. G92 E0
  628. G1 E-2 F200
  629. M400
  630. M106 S255
  631. G4 P1000
  632. M104 S140
  633. TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={hotendtemp-30}
  634.  
  635. M204 S5000
  636. G1 X103 F5000
  637. G1 X90 F5000
  638. G1 X103 F5000
  639. G1 X90 F5000
  640. G1 X103 F5000
  641. G1 X90 F5000
  642. G1 X103 F5000
  643. G1 X90 F5000
  644. G1 X103 F5000
  645. G1 X90 F5000
  646.  
  647. G1 X114 F5000
  648. G1 X100 F5000
  649. G1 X114 F5000
  650. G1 X100 F5000
  651. G1 X114 F5000
  652. G1 X100 F5000
  653. G1 X114 F5000
  654. G1 X100 F5000
  655. G1 X114 F5000
  656. G1 X100 F5000
  657. G1 X114 F5000
  658. G1 X100 F5000
  659. G1 X114 F5000
  660. G1 X100 F5000
  661.  
  662. G1 X103 F5000
  663. G1 X90 F5000
  664. G1 X103 F5000
  665. G1 X90 F5000
  666. G1 X103 F5000
  667. G1 X90 F5000
  668. G1 X103 F5000
  669. G1 X90 F5000
  670. G1 X103 F5000
  671. G1 X90 F5000
  672.  
  673.  
  674. G1 X125 F15000
  675.  
  676. G1 X130 Y280 F6000
  677. G1 Z-0.2 F600
  678.  
  679. TEMPERATURE_WAIT SENSOR=extruder MAXIMUM=150
  680. M106 S255
  681. G2 I0.5 J0.5 F600
  682. G2 I0.5 J0.5 F600
  683. G2 I0.5 J0.5 F600
  684. G1 X140 F200
  685. G1 Y281 F200
  686. G1 X130 F200
  687. G1 Y283 F200
  688. G1 X140 F200
  689.  
  690. G2 I0.5 J0.5 F600
  691. G2 I0.5 J0.5 F600
  692. G2 I0.5 J0.5 F600
  693.  
  694. G1 Z0.2
  695. G1 X180 F12000
  696. G1 Z-1.5
  697. G1 X164 F12000
  698. G1 X180 F12000
  699. G1 X164 F12000
  700. G1 X180 F12000
  701. G1 X164 F12000
  702. G1 X180 F12000
  703. G1 X164 F12000
  704. M400
  705. M118 Nozzle cleared
  706. G1 Z30 F900
  707. G1 Y10 F18000
  708. G1 X260 F18000
  709. M106 S0
  710.  
  711.  
  712. #_____Custom macros:_____
  713.  
  714. # [gcode_macro TEST_PLUG_OFF]
  715. # gcode:
  716. # RUN_SHELL_COMMAND CMD=shell_test_plug_off
  717. # #{action_call_remote_method(
  718. # # "set_device_power", device="test_plug", state="off"
  719. # #)}
  720.  
  721. # [gcode_macro TEST_PLUG_ON]
  722. # gcode:
  723. # RUN_SHELL_COMMAND CMD=shell_test_plug_on
  724. # #{action_call_remote_method(
  725. # # "set_device_power", device="test_plug", state="on"
  726. # #)}
  727.  
  728. # [gcode_macro HOOD_OFF]
  729. # gcode:
  730. # RUN_SHELL_COMMAND CMD=shell_hood_plug_off
  731. # M118 Hood turned off
  732. # #{action_call_remote_method(
  733. # # "set_device_power", device="hood_plug", state="off"
  734. # #)}
  735.  
  736. # [gcode_macro HOOD_ON]
  737. # gcode:
  738. # RUN_SHELL_COMMAND CMD=shell_hood_plug_on
  739. # M118 Hood turned on
  740. # #{action_call_remote_method(
  741. # # "set_device_power", device="hood_plug", state="on"
  742. # #)}
  743.  
  744. # [delayed_gcode DELAYED_HOOD_OFF]
  745. # gcode:
  746. # {% set vars = printer['gcode_macro END_Vars'] %}
  747. # {% if vars.printing == False %}
  748. # HOOD_OFF
  749. # {% else %}
  750. # M118 Leaving hood on because print in progress
  751. # {% endif %}
  752.  
  753. # [gcode_shell_command shell_test_plug_on]
  754. # command: /home/mks/.local/bin/kasa --type plug --host 192.168.88.44 on
  755. # timeout: 30.
  756. # verbose: True
  757. # [gcode_shell_command shell_test_plug_off]
  758. # command: /home/mks/.local/bin/kasa --type plug --host 192.168.88.44 off
  759. # timeout: 30.
  760. # verbose: True
  761. # [gcode_shell_command shell_hood_plug_on]
  762. # command: /home/mks/.local/bin/kasa --type plug --host 192.168.88.31 on
  763. # timeout: 30.
  764. # verbose: True
  765. # [gcode_shell_command shell_hood_plug_off]
  766. # command: /home/mks/.local/bin/kasa --type plug --host 192.168.88.31 off
  767. # timeout: 30.
  768. # verbose: True
  769.  
  770.  
  771.  
  772. [gcode_macro spread_lube_XY]
  773. gcode:
  774. {% set i = 10 %} #set toolhead movement cycles to 10
  775. G28 X Y #home XY
  776. G90 #absolute coords
  777. M204 S5000 #5k accels
  778. G1 X135 Y135 F10000 #move to center
  779. {% for _ in range(i) %} #sweep X i times
  780. G1 X0 F10000
  781. G1 X270 F10000
  782. {% endfor %}
  783. G1 X165 F10000 #move X to middle of trash chute wall cutout
  784. {% for _ in range(i) %} #sweep Y i times
  785. G1 Y287.5 F10000
  786. G1 Y0 F10000
  787. {% endfor %}
  788. G1 X135 Y135 F10000 #return to center
  789. [gcode_macro _Sensorless_Homing_Variables]#needed for custom homing_override to function
  790. description: Variables for sensorless homing
  791.  
  792. variable_z_hop_distance: 10 # Distance to move Z axis prior to homing, and after homing.
  793. variable_first_homed_axis: 'Y' # First axis to home when 'G28' is called. Some prefer homing Y before X.
  794.  
  795. ## The following variables are used for moving the printhead to a certain part of the bed before homing the Z axis:
  796.  
  797. variable_safe_z_enable: True # Enables/disables moving the printhead before homing the Z axis.
  798. variable_safe_x: -128 # Safe X position to home the Z axis, leave at -128 to home to the center of the X axis.
  799. variable_safe_y: -128 # Safe Y position to home the Z axis, leave at -128 to home to the center of the Y axis.
  800.  
  801. # Do not modify below
  802. gcode:
  803.  
  804.  
  805. [gcode_macro END_Vars] #once upon a time these were all related to print_end
  806. variable_cooldown_chamber: True #this is only ever triggered at the end of cooldown_bed so it's fine to be enabled if cooldown_bed is disabled
  807. variable_cooldown_bed: False
  808. variable_heatup_chamber: False
  809. variable_heat_soak_bed: False
  810. variable_skip_print_end: False
  811. variable_printing: False
  812. gcode:
  813.  
  814.  
  815. #including the next 8 macros as buttons in fluidd's web UI is convenient
  816. [gcode_macro ENABLE_SKIP_PRINT_END]
  817. gcode:
  818. SET_GCODE_VARIABLE MACRO=END_Vars VARIABLE=skip_print_end VALUE=True
  819. M118 will skip PRINT_END
  820.  
  821. [gcode_macro DISABLE_SKIP_PRINT_END]
  822. gcode:
  823. SET_GCODE_VARIABLE MACRO=END_Vars VARIABLE=skip_print_end VALUE=False
  824. M118 will NOT skip PRINT_END
  825.  
  826. [gcode_macro DISABLE_BED_COOLDOWN]
  827. gcode:
  828. SET_GCODE_VARIABLE MACRO=END_Vars VARIABLE=cooldown_bed VALUE=False
  829. M118 bed cooldown disabled
  830. [gcode_macro ENABLE_BED_COOLDOWN]
  831. gcode:
  832. SET_GCODE_VARIABLE MACRO=END_Vars VARIABLE=cooldown_bed VALUE=True
  833. M118 bed cooldown enabled
  834.  
  835. [gcode_macro DISABLE_CHAMBER_COOLDOWN]
  836. gcode:
  837. SET_GCODE_VARIABLE MACRO=END_Vars VARIABLE=cooldown_chamber VALUE=False
  838. M118 chamber cooldown disabled
  839. [gcode_macro ENABLE_CHAMBER_COOLDOWN]
  840. gcode:
  841. SET_GCODE_VARIABLE MACRO=END_Vars VARIABLE=cooldown_chamber VALUE=True
  842. M118 chamber cooldown enabled
  843.  
  844. [gcode_macro DISABLE_WAIT_FOR_CHAMBER_HEAT]
  845. gcode:
  846. SET_GCODE_VARIABLE MACRO=END_Vars VARIABLE=heatup_chamber VALUE=False
  847. M118 chamber heat waiting disabled
  848. [gcode_macro ENABLE_WAIT_FOR_CHAMBER_HEAT]
  849. gcode:
  850. SET_GCODE_VARIABLE MACRO=END_Vars VARIABLE=heatup_chamber VALUE=True
  851. M118 chamber heat waiting enabled
  852. [gcode_macro ENABLE_HEAT_SOAK] #heat soak bed for 10 minutes during print_start
  853. gcode:
  854. SET_GCODE_VARIABLE MACRO=END_Vars VARIABLE=heat_soak_bed VALUE=True
  855. M118 bed heat soaking enabled
  856. [gcode_macro DISABLE_HEAT_SOAK]
  857. gcode:
  858. SET_GCODE_VARIABLE MACRO=END_Vars VARIABLE=heat_soak_bed VALUE=False
  859. M118 bed heat soaking disabled
  860. [gcode_macro Cooldown_Bed]
  861. gcode:
  862. {% set vars = printer['gcode_macro END_Vars'] %}
  863. {% if printer.heater_bed.temperature > 70 and vars.cooldown_bed == True %} #If the bed temp is above this number, do cooldown, if bed temp is less than this don't cooldown.
  864. M118 Maintain chamber temperature at ({printer['heater_generic chamber'].temperature}C�).
  865. M118 Start gradual bed cooling ({printer.heater_bed.temperature}C�).
  866. M118 Reduce bed temp to ({printer.heater_bed.temperature - 2|int }C�).
  867. SET_HEATER_TEMPERATURE HEATER=chamber TARGET={printer['heater_generic chamber'].temperature}
  868. SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={printer.heater_bed.temperature - 2|int}
  869. SET_FAN_SPEED FAN=chamber_circulation_fan SPEED=0.03 #chamber exhaust fan.
  870. UPDATE_DELAYED_GCODE ID=gradual_cooldown_bed DURATION=120 #How long to wait in seconds to run the loop
  871. {% else %}
  872. M118 Gradual bed cooling unnecesary ({printer.heater_bed.temperature}C�).
  873. SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET=0 ; turn off bed
  874. Cooldown_Chamber#necessary in order to trigger timelapse render
  875. {% endif %}
  876.  
  877. [delayed_gcode gradual_cooldown_bed]
  878. gcode:
  879. {% set vars = printer['gcode_macro END_Vars'] %}
  880. {% if printer.heater_bed.temperature > 70 and vars.cooldown_bed == True %} #If bed temp is above this number, run loop and continue cooldown. If it's less than this number cooldown will end.
  881. M118 Reduce bed temp to ({printer.heater_bed.temperature - 2|int }C�).
  882. SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={printer.heater_bed.temperature - 2|int}
  883. UPDATE_DELAYED_GCODE ID=gradual_cooldown_bed DURATION=120
  884. {% else %}
  885. M118 Gradual bed cooling finished or disabled ({printer.heater_bed.temperature}C�).
  886. SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET=0 ; turn off bed
  887. SET_FAN_SPEED FAN=chamber_circulation_fan SPEED=0.0
  888. Cooldown_Chamber#necessary in order to trigger timelapse render
  889. {% endif %}
  890.  
  891.  
  892. [gcode_macro Cooldown_Chamber]
  893. gcode:
  894. {% set vars = printer['gcode_macro END_Vars'] %}
  895. {% if printer['heater_generic chamber'].temperature > 45 and vars.cooldown_chamber == True %}
  896. M118 Start gradual chamber cooling ({printer['heater_generic chamber'].temperature}C�).
  897. M118 Reduce chamber temp to ({printer['heater_generic chamber'].temperature - 1|int }C�).
  898. SET_FAN_SPEED FAN=auxiliary_cooling_fan SPEED=0.08
  899. SET_HEATER_TEMPERATURE HEATER=chamber TARGET={printer['heater_generic chamber'].temperature - 1|int}
  900. SET_FAN_SPEED FAN=chamber_circulation_fan SPEED=0.03
  901. UPDATE_DELAYED_GCODE ID=gradual_cooldown_chamber DURATION=150
  902. {% else %}
  903. M118 No gradual chamber cooling necessary or cooling disabled ({printer['heater_generic chamber'].temperature}C�).
  904. SET_HEATER_TEMPERATURE HEATER=chamber TARGET=0 ; turn off chamber heater
  905. # M118 Turn off hood in 5 minutes
  906. # UPDATE_DELAYED_GCODE ID=DELAYED_HOOD_OFF DURATION=300
  907. M118 Rendering timelapse...
  908. TIMELAPSE_RENDER#render must happen here because auto-render will crash klipper if heaters are on
  909. {% endif %}
  910.  
  911. [delayed_gcode gradual_cooldown_chamber]
  912. gcode:
  913. {% set vars = printer['gcode_macro END_Vars'] %}
  914. {% if printer['heater_generic chamber'].temperature > 45 and vars.cooldown_chamber == True %}
  915. M118 Reduce chamber temp to ({printer['heater_generic chamber'].temperature - 1|int }C�).
  916. SET_HEATER_TEMPERATURE HEATER=chamber TARGET={printer['heater_generic chamber'].temperature - 1|int}
  917. UPDATE_DELAYED_GCODE ID=gradual_cooldown_chamber DURATION=150
  918. {% else %}
  919. M118 Gradual chamber cooling finished or disabled ({printer['heater_generic chamber'].temperature}C�).
  920. SET_HEATER_TEMPERATURE HEATER=chamber TARGET=0 ; turn off chamber heater
  921. SET_FAN_SPEED FAN=auxiliary_cooling_fan SPEED=0
  922. SET_FAN_SPEED FAN=chamber_circulation_fan SPEED=0.0
  923. # M118 Turn off hood in 5 minutes
  924. # UPDATE_DELAYED_GCODE ID=DELAYED_HOOD_OFF DURATION=300
  925. M118 Rendering timelapse...
  926. TIMELAPSE_RENDER#render must happen here because auto-render will crash klipper if heaters are on
  927. {% endif %}
  928.  
  929.  
  930. [gcode_macro BOX_TOGGLE] #weav added box enable/disable toggle
  931. gcode:
  932. {% if printer.save_variables.variables.box_count >= 1 %}
  933. {% if printer.save_variables.variables.enable_box == 0 %}
  934. SAVE_VARIABLE VARIABLE=enable_box VALUE=1
  935. {action_respond_info("Box is Enabled")}
  936. {% else %}
  937. SAVE_VARIABLE VARIABLE=enable_box VALUE=0
  938. {action_respond_info("Box is Disabled")}
  939. {% endif %}
  940. {% endif %}
  941.  
Advertisement
Add Comment
Please, Sign In to add comment