From 16da67ab05951c39c7944debe7762a22125e9862 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 12 Jun 2023 06:47:42 -0400 Subject: [PATCH] feat(print_macros.cfg): add new gcode macro SET_START_PRINT to set up print start variables and improve print start semantics. feat(print_macros.cfg): add SET_CHAMBER gcode macro to set up enclosure control variables This commit adds a new gcode macro called SET_CHAMBER to the print_macros.cfg file. This macro sets up the enclosure control variables for the printer. It gets the printcfg variables and sets the parameters for the chamber, start temps and times, chamber sensor, and soaking. It also converts the strings to booleans where necessary. Finally, it sets the variables using the SET_GCODE_VARIABLE macro. feat(print_macros.cfg): add gcode macro SET_NOZZLE_CLEANING to set up nozzle cleaning parameters and improve cleaning process. feat(print_macros.cfg): add SET_PARKING gcode macro to set up parking coordinate parameters This commit adds a new gcode macro called SET_PARKING to the print_macros.cfg file. This macro sets up the parking coordinate parameters for the printer. It takes in several parameters, including the X, Y, and Z coordinates for the general parking, preheat parking, and maintenance parking positions. It also sets up the axis limits for the printer and logs any errors that occur if the coordinates are out of range. Finally, it sets the variables for the parking coordinates in the _printcfg macro. feat(print_macros.cfg): add SET_HOMING macro to set up homing parameters and improve homing error reporting in SET_HOME_POSITION macro --- print_macros.cfg | 545 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 529 insertions(+), 16 deletions(-) diff --git a/print_macros.cfg b/print_macros.cfg index 7f5ca51..701aced 100644 --- a/print_macros.cfg +++ b/print_macros.cfg @@ -55,6 +55,115 @@ gcode: FINALIZE_ENVIRO {% endif %} +################################ +####### SET_START_PRINT ######## +################################ +[gcode_macro SET_START_PRINT] +description: Set up print start variables +gcode: + ################## Get PrintCFG ################## + {% set printcfg = printer['gcode_macro _printcfg'] %} ; get printcfg variables + ################## Get Parameters ################## + ## Start Temps + {% set bed_temp = params.BED_TEMP | default(printcfg.bed_temp) | float %} + {% set extruder_temp = params.EXTRUDER_TEMP | default(printcfg.extruder_temp) | float %} + {% set extruder_pre_temp = params.EXTRUDER_PRE_TEMP | default(printcfg.extruder_pre_temp) | float %} + {% set chamber_temp = params.CHAMBER_TEMP | default(printcfg.chamber_temp) | float %} + + ## Start Steps + {% set heat_soak = params.HEAT_SOAK | default(printcfg.heat_soak) | int %} + {% set auto_z = params.AUTO_Z | default(printcfg.auto_z_calibrate) | int %} + {% set z_tilt = params.Z_TILT | default(printcfg.z_tilt) | int %} + {% set qgl = params.QUAD_GANTRY_LEVEL | default(printcfg.qgl) | int %} + ## Bed Meshing + {% set mesh = params.BED_MESH | default(printcfg.bed_mesh) | int %} + {% set adaptive_mesh = params.ADAPTIVE_MESH | default (printcfg.mesh_adaptive) | int %} + {% set load_mesh = params.LOAD_MESH | default(printcfg.load_mesh) | int %} + {% set mesh_profile = params.MESH_PROFILE | default(printcfg.mesh_profile) | string %} + ## Cleaning and Purging + {% set cleaning = params.NOZZLE_BRUSH | default(printcfg.cleaning) | int %} + {% set purging = params.NOZZLE_PURGE | default(printcfg.purging) | int %} + {% set adaptive_purge = params.ADAPTIVE_PURGE | default(printcfg.adaptive_purge) | int %} + {% set nevermore = params.USE_NEVERMORE | default(printcfg.nevermore) | int %} + ############## Make Strings Booleans ##############%} + {% if params.HEAT_SOAK is defined and params.HEAT_SOAK | lower == 'true' %} + {% set heat_soak = 1 %} + {% elif params.HEAT_SOAK is defined and params.HEAT_SOAK | lower == 'false' %} + {% set heat_soak = 0 %} + {% endif %} + {% if params.AUTO_Z is defined and params.AUTO_Z | lower == ' true' %} + {% set auto_z = 1 %} + {% elif params.AUTO_Z is defined params.AUTO_Z | lower == 'false' %} + {% set auto_z = 0 %} + {% endif %} + {% if params.Z_TILT is defined and params.Z_TILT | lower == 'true' %} + {% set auto_z = 1 %} + {% elif params.Z_TILT is defined and params.Z_TILT | lower == 'false' %} + {% set auto_z = 0 %} + {% endif %} + {% if params.QUAD_GANTRY_LEVEL is defined and params.QUAD_GANTRY_LEVEL | lower == 'true' %} + {% set qgl = 1 %} + {% elif params.QUAD_GANTRY_LEVEL is defined and params.QUAD_GANTRY_LEVEL | lower == 'false' %} + {% set qgl = 0 %} + {% endif %} + {% if params.BED_MESH is defined and params.BED_MESH | lower == 'true' %} + {% set mesh = 1 %} + {% elif params.BED_MESH is defined and params.BED_MESH | lower == 'false' %} + {% set mesh = 0 %} + {% endif %} + {% if params.ADAPTIVE_MESH is defined and params.ADAPTIVE_MESH | lower == 'true' %} + {% set adaptive_mesh = 1 %} + {% elif params.ADAPTIVE_MESH is defined and params.ADAPTIVE_MESH | lower == 'false' %} + {% set adaptive_mesh = 0 %} + {% endif %} + {% if params.LOAD_MESH is defined and params.LOAD_MESH | lower == 'true' %} + {% set load_mesh = 1 %} + {% elif params.LOAD_MESH is defined and params.LOAD_MESH | lower == 'false' %} + {% set load_mesh = 0 %} + {% endif %} + {% if params.NOZZLE_BRUSH is defined and params.NOZZLE_BRUSH | lower == 'true' %} + {% set cleaning = 1 %} + {% elif params.NOZZLE_BRUSH is defined and params.NOZZLE_BRUSH | lower == 'false' %} + {% set cleaning = 0 %} + {% endif %} + {% if params.NOZZLE_PURGE is defined and params.NOZZLE_PURGE | lower == 'true' %} + {% set purging = 1 %} + {% elif params.NOZZLE_PURGE is defined and params.NOZZLE_PURGE | lower == 'false' %} + {% set purging = 0 %} + {% endif %} + {% if params.ADAPTIVE_PURGE is defined and params.ADAPTIVE_PURGE | lower == 'true' %} + {% set adaptive_purge = 1 %} + {% elif params.ADAPTIVE_PURGE is defined and params.ADAPTIVE_PURGE | lower == 'false' %} + {% set adaptive_purge = 0 %} + {% endif %} + {% if params.USE_NEVERMORE is defined and params.USE_NEVERMORE | lower == 'true' %} + {% set nevermore = 1 %} + {% elif params.USE_NEVERMORE is defined and params.USE_NEVERMORE | lower == 'false' %} + {% set nevermore = 0 %} + {% endif %} + ################## Set Variables ################## + ## Start Temps + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=bed_temp VALUE={ bed_temp } ; set bed temp + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=extruder_temp VALUE={ extruder_temp } ; set extruder temp + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=extruder_pre_temp VALUE={ extruder_pre_temp } ; set extruder pre-heat temp + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=chamber_temp VALUE={ chamber_temp } ; set chamber temp + ## Start Steps + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=heat_soak VALUE={ heat_soak } ; set heat soak time + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=auto_z_calibrate VALUE={ auto_z } ; set auto z calibrate + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=z_tilt VALUE={ z_tilt } ; set z tilt + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=qgl VALUE={ qgl } ; set qgl + ## Bed Meshing + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=bed_mesh VALUE={ mesh } ; set bed mesh + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=mesh_adaptive VALUE={ adaptive_mesh } ; set adaptive mesh + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=load_mesh VALUE={ load_mesh } ; set load mesh + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=mesh_profile VALUE={ mesh_profile } ; set mesh profile + ## Cleaning and Purging + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=cleaning VALUE={ cleaning } ; set nozzle cleaning + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=purging VALUE={ purging } ; set nozzle purging + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=adaptive_purge VALUE={ adaptive_purge } ; set adaptive purging + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=nevermore VALUE={ nevermore } ; set nevermore + + ################################ ######### HEAT_SURFACE ######### ################################ @@ -214,6 +323,64 @@ gcode: {% endif %} {% endif %} +################################ +######### SET_CHAMBER ########## +################################ +[gcode_macro SET_CHAMBER] +description: Set up enclosure control variables +gcode: + ################## Get PrintCFG ################## + {% set printcfg = printer['gcode_macro _printcfg'] %} ; get printcfg variables + ################## Get Parameters ################## + ## Use Chamber + {% set chamber = params.USE_CHAMBER | default(printcfg.chamber) | int %} + ## Start Temps and Times + {% set chamber_temp = params.CHAMBER_TEMP | default(printcfg.chamber_temp) | float %} + {% set chamber_time = params.CHAMBER_TIME | default(printcfg.chamber_time) | int %} + {% set bed_temp = params.BED_TEMP | default(printcfg.bed_temp) | float %} + ## Chamber Sensor + {% set chamber_type = params.CHAMBER_TYPE | default(printcfg.chamber_type) | string %} + {% set chamber_name = params.CHAMBER_NAME | default(printcfg.chamber_name) | string %} + ## Soaking + {% set heat_soak = params.HEAT_SOAK | default(printcfg.heat_soak) | int %} + {% set time_soak = params.TIME_SOAK | default(printcfg.time_soak) | int %} + {% set temp_soak = params.TEMP_SOAK | default(printcfg.temp_soak) | int %} + ############## Make Strings Booleans ##############%} + {% if params.USE_CHAMBER is defined and params.USE_CHAMBER | lower == 'true' %} + {% set chamber = 1 %} + {% elif params.USE_CHAMBER is defined and params.USE_CHAMBER | lower == 'false' %} + {% set chamber = 0 %} + {% endif %} + {% if params.TIME_SOAK is defined and params.TIME_SOAK | lower == ' true' %} + {% set time_soak = 1 %} + {% elif params.TIME_SOAK is defined params.TIME_SOAK | lower == 'false' %} + {% set time_soak = 0 %} + {% endif %} + {% if params.HEAT_SOAK is defined and params.HEAT_SOAK | lower == 'true' %} + {% set heat_soak = 1 %} + {% elif params.HEAT_SOAK is defined and params.HEAT_SOAK | lower == 'false' %} + {% set heat_soak = 0 %} + {% endif %} + {% if params.TEMP_SOAK is defined and params.TEMP_SOAK | lower == 'true' %} + {% set temp_soak = 1 %} + {% elif params.TEMP_SOAK is defined and params.TEMP_SOAK | lower == 'false' %} + {% set temp_soak = 0 %} + {% endif %} + ################## Set Variables ################## + ## Use Chamber + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=chamber VALUE={ chamber } ; set bed temp + ## Start Temps and Times + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=chamber_temp VALUE={ chamber_temp } ; set chamber temp + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=chamber_time VALUE={ chamber_time } ; set chamber time + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=bed_temp VALUE={ bed_temp } ; set bed temp + ## Chamber Sensor + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=chamber_type VALUE={ chamber_type } ; set chamber type + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=chamber_name VALUE={ chamber_name } ; set chamber name + ## Soaking + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=heat_soak VALUE={ heat_soak } ; set qgl + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=time_soak VALUE={ time_soak } ; set bed mesh + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=temp_soak VALUE={ temp_soak } ; set adaptive mesh + ################################ ########## PREP_FANS ########### ################################ @@ -645,6 +812,126 @@ gcode: G28 Z {% endif %} +################################ +######### SET_CLEANING ######### +################################ +[gcode_macro SET_NOZZLE_CLEANING] +description: Set up nozzle cleaning parameters +gcode: + ################## Get PrintCFG ################## + {% set printcfg = printer['gcode_macro _printcfg'] %} ; get printcfg variables + ################## Get Parameters ################## + ## Cleaning Coordinates + {% set clean_x = params.X | default(printcfg.clean_x) | float %} + {% set clean_y = params.Y | default(printcfg.clean_y) | float %} + {% set clean_z = params.Z | default(printcfg.clean_z) | float %} + {% set cleaning = params.USE_CLEAN | default(printcfg.cleaning) | int %} + ## Cleaning Temperature + {% set clean_temp = params.TEMPERATURE | default(printcfg.clean_temp) | float %} + ## Cleaning Scenarios + {% set clean_probe = params.CLEAN_BEFORE_PROBING | default(printcfg.clean_probe) | int %} + {% set clean_end = params.CLEAN_AFTER_PRINT | default(printcfg.clean_end) | int %} + {% set post_clean_home = params.HOME_AFTER_CLEANING | default(printcfg.post_clean_home) | int %} + {% set clean_m600 = params.CLEAN_AFTER_M600 | default(printcfg.clean_m600) | int %} + ## Cleaning Wipe + {% set clean_wipe_qty = params.WIPE_QUANTITY | default(printcfg.clean_wipe_qty) | int %} + {% set clean_wipe_dist = params.WIPE_DISTANCE | default(printcfg.clean_wipe_dist) | float %} + {% set clean_wipe_spd = params.WIPE_SPEED | default(printcfg.clean_wipe_spd) | float %} + ## Cleaning Raise + {% set clean_raise_dist = params.RAISE_DISTANCE | default(printcfg.clean_raise_dist) | float %} + ################ Get Axis Limits ################ + {% set x_min = printer.toolhead.axis_minimum.x %} + {% set x_max = printer.toolhead.axis_maximum.x %} + {% set y_min = printer.toolhead.axis_minimum.y %} + {% set y_max = printer.toolhead.axis_maximum.y %} + {% set z_min = printer.toolhead.axis_minimum.z %} + {% set z_max = printer.toolhead.axis_maximum.z %} + ############### Check Coordinates ################ + {% set x = clean_x %} + {% set y = clean_y %} + {% set z = clean_z %} + {% set mode = "Cleaning" %} + {% if x < x_min or x > x_max %} ; if x is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "X position is out of range: " + x|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "X position is within range: " + x|string %} ; set message + {% set level = "debug" %} ; set level + {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message + {% if y < y_min or y > y_max %} ; if y is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "Y position is out of range: " + y|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "Y position is within range: " + y|string %} ; set message + {% set level = "debug" %} ; set level + {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message + {% if z < z_min or z > z_max %} ; if z is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "Z position is out of range: " + z|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "Z position is within range: " + z|string %} ; set message + {% set level = "debug" %} ; set level + {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message + ############## Make Strings Booleans ##############%} + {% if params.USE_CLEAN is defined and params.USE_CLEAN | lower == 'true' %} + {% set cleaning = 1 %} + {% elif params.USE_CLEAN is defined and params.USE_CLEAN | lower == 'false' %} + {% set cleaning = 0 %} + {% endif %} + {% if params.CLEAN_BEFORE_PROBING is defined and params.CLEAN_BEFORE_PROBING | lower == 'true' %} + {% set clean_probe = 1 %} + {% elif params.CLEAN_BEFORE_PROBING is defined and params.CLEAN_BEFORE_PROBING | lower == 'false' %} + {% set clean_probe = 0 %} + {% endif %} + {% if params.CLEAN_AFTER_PRINT is defined and params.CLEAN_AFTER_PRINT | lower == 'true' %} + {% set clean_end = 1 %} + {% elif params.CLEAN_AFTER_PRINT is defined and params.CLEAN_AFTER_PRINT | lower == 'false' %} + {% set clean_end = 0 %} + {% endif %} + {% if params.HOME_AFTER_CLEANING is defined and params.HOME_AFTER_CLEANING | lower == 'true' %} + {% set post_clean_home = 1 %} + {% elif params.HOME_AFTER_CLEANING is defined and params.HOME_AFTER_CLEANING | lower == 'false' %} + {% set post_clean_home = 0 %} + {% endif %} + {% if params.CLEAN_AFTER_M600 is defined and params.CLEAN_AFTER_M600 | lower == 'true' %} + {% set clean_m600 = 1 %} + {% elif params.CLEAN_AFTER_M600 is defined and params.CLEAN_AFTER_M600 | lower == 'false' %} + {% set clean_m600 = 0 %} + {% endif %} + + ################## Set Variables ################## + ## Use CLeaning + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=cleaning VALUE={ cleaning } ; set cleaning + ## Cleaning Scenarios + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=clean_probe VALUE={ clean_probe } ; set clean probe + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=clean_end VALUE={ clean_end } ; set clean end + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=post_clean_home VALUE={ post_clean_home } ; set post clean home + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=clean_m600 VALUE={ clean_m600 } ; set clean m600 + ## Cleaning Coordinates + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=clean_x VALUE={ clean_x } ; set clean x + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=clean_y VALUE={ clean_y } ; set clean y + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=clean_z VALUE={ clean_z } ; set clean z + ## Cleaning Wipe + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=clean_wipe_qty VALUE={ clean_wipe_qty } ; set clean wipe qty + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=clean_wipe_dist VALUE={ clean_wipe_dist } ; set clean wipe dist + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=clean_wipe_spd VALUE={ clean_wipe_spd } ; set clean wipe speed + ## Cleaning Raise + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=clean_raise_dist VALUE={ clean_raise_dist } ; set clean raise dist + ## Cleaning Temperture + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=clean_temp VALUE={ clean_temp } ; set clean temp + ################################ ######## SET_DEFAULTS ########## ################################ @@ -1167,6 +1454,169 @@ gcode: G90 ; Absolute positioning G0 X{printcfg.park_x|int} Y{printcfg.park_y|int} F{printcfg.park_speed|int} ; Move to park position +################################ +######### SET_PARKING ########## +################################ +[gcode_macro SET_PARKING] +description: Set up parking coordinate parameters +gcode: + ################## Get PrintCFG ################## + {% set printcfg = printer['gcode_macro _printcfg'] %} ; get printcfg variables + {% set SUCCESS = 0 %} + ################## Get Parameters ################## + ## General Parking + {% set park_x = params.X | default(printcfg.park_x) | float %} + {% set park_y = params.Y | default(printcfg.park_y) | float %} + {% set park_z = params.Z | default(printcfg.park_z) | float %} + {% set park_zmin = params.Z_MIN | default(printcfg.park_zmin) | float %} + {% set park_zrel = params.Z_RELATIVE | default(printcfg.park_zrel) | float %} + {% set park_speed = params.SPEED | default(printcfg.park_speed) | float %} + ## Preheat Parking + {% set preheat_x = params.PREHEAT_X | default(printcfg.preheat_x) | float %} + {% set preheat_y = params.PREHEAT_Y | default(printcfg.preheat_y) | float %} + {% set preheat_z = params.PREHEAT_Z | default(printcfg.preheat_z) | float %} + ## Maintenance Parking + {% set maint_x = params.MAINT_X | default(printcfg.maint_x) | float %} + {% set maint_y = params.MAINT_Y | default(printcfg.maint_y) | float %} + {% set maint_z = params.MAINT_Z | default(printcfg.maint_z) | float %} + ################ Get Axis Limits ################ + {% set x_min = printer.toolhead.axis_minimum.x %} + {% set x_max = printer.toolhead.axis_maximum.x %} + {% set y_min = printer.toolhead.axis_minimum.y %} + {% set y_max = printer.toolhead.axis_maximum.y %} + {% set z_min = printer.toolhead.axis_minimum.z %} + {% set z_max = printer.toolhead.axis_maximum.z %} + ################## Set Parking ################### + {% set x = park_x %} + {% set y = park_y %} + {% set z = park_z %} + {% set mode = "Parking" %} + {% if x < x_min or x > x_max %} ; if x is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "X position is out of range: " + x|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "X position is within range: " + x|string %} ; set message + {% set level = "debug" %} ; set level + {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message + {% if y < y_min or y > y_max %} ; if y is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "Y position is out of range: " + y|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "Y position is within range: " + y|string %} ; set message + {% set level = "debug" %} ; set level + {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message + {% if z < z_min or z > z_max %} ; if z is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "Z position is out of range: " + z|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "Z position is within range: " + z|string %} ; set message + {% set level = "debug" %} ; set level + {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message + {% set x = preheat_x %} + {% set y = preheat_y %} + {% set z = preheat_z %} + {% set mode = "Preheat" %} + {% if x < x_min or x > x_max %} ; if x is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "X position is out of range: " + x|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "X position is within range: " + x|string %} ; set message + {% set level = "debug" %} ; set level + {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message + {% if y < y_min or y > y_max %} ; if y is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "Y position is out of range: " + y|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "Y position is within range: " + y|string %} ; set message + {% set level = "debug" %} ; set level + {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message + {% if z < z_min or z > z_max %} ; if z is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "Z position is out of range: " + z|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "Z position is within range: " + z|string %} ; set message + {% set level = "debug" %} ; set level + {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message + {% if maint_x != -1 and maint_y != -1 and maint_z != -1 %} + {% set x = maint_x %} + {% set y = maint_y %} + {% set z = maint_z %} + {% set mode = "Maintenance" %} + {% if x < x_min or x > x_max %} ; if x is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "X position is out of range: " + x|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "X position is within range: " + x|string %} ; set message + {% set level = "debug" %} ; set level + {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message + {% if y < y_min or y > y_max %} ; if y is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "Y position is out of range: " + y|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "Y position is within range: " + y|string %} ; set message + {% set level = "debug" %} ; set level + {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message + {% if z < z_min or z > z_max %} ; if z is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "Z position is out of range: " + z|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "Z position is within range: " + z|string %} ; set message + {% set level = "debug" %} ; set level + {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message + {% endif %} + ################## Set Variables ################## + ## General Parking + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=park_x VALUE={ park_x } ; set park x + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=park_y VALUE={ park_y } ; set park y + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=park_z VALUE={ park_z } ; set park z + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=park_zmin VALUE={ park_zmin } ; set park zmin + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=park_zrel VALUE={ park_zrel } ; set park zrel + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=park_speed VALUE={ park_speed } ; set park speed + ## Preheat Parking + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=preheat_x VALUE={ preheat_x } ; set preheat x + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=preheat_y VALUE={ preheat_y } ; set preheat y + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=preheat_z VALUE={ preheat_z } ; set preheat z + ## Maintenance Parking + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=maint_x VALUE={ maint_x } ; set maint x + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=maint_y VALUE={ maint_y } ; set maint y + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=maint_z VALUE={ maint_z } ; set maint z + ## MAINTENANCE [gcode_macro MAINTENANCE] description: move the toolhead to a convenient position for working on it @@ -1323,17 +1773,42 @@ gcode: [gcode_macro SET_HOME_POSITION] description: Set a new temporary Z-homing position gcode: + ################ Get Axis Limits ################ + {% set x_min = printer.toolhead.axis_minimum.x %} + {% set x_max = printer.toolhead.axis_maximum.x %} + {% set y_min = printer.toolhead.axis_minimum.y %} + {% set y_max = printer.toolhead.axis_maximum.y %} + {% set z_min = printer.toolhead.axis_minimum.z %} + {% set z_max = printer.toolhead.axis_maximum.z %} {% if params.X is defined and params.Y is defined %} ; if x and y are defined {% set homex = params.X|float %} ; get x position {% set homey = params.Y|float %} ; get y position - {% if homex < printer.toolhead.axis_minimum.x or homex > printer.toolhead.axis_maximum.x %} ; if x is out of range - { action_respond_info("X position is out of range: " + homex|string) } ; report error - {% set bad_values = True %} ; set bad values flag - {% endif %} - {% if homey < printer.toolhead.axis_minimum.y or homey > printer.toolhead.axis_maximum.y %} ; if y is out of range - { action_respond_info("Y position is out of range: " + homey|string) } ; report error - {% set bad_values = True %} ; set bad values flag + {% set x = homex %} + {% set y = homey %} + {% set mode = "Homing" %} + {% if x < x_min or x > x_max %} ; if x is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "X position is out of range: " + x|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "X position is within range: " + x|string %} ; set message + {% set level = "debug" %} ; set level + {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message + {% if y < y_min or y > y_max %} ; if y is out of range + {% set title = mode + " Coordinates" %} + {% set msg = "Y position is out of range: " + y|string %} ; set message + {% set level = "error" %} ; set level + { action_respond_info( "{}: {}".format( title, msg ) ) } ; report error + {% else %} + {% set title = mode + " Coordinates" %} + {% set msg = "Y position is within range: " + y|string %} ; set message + {% set level = "debug" %} ; set level {% endif %} + logger title="{title}" msg="{msg}" level={level} ; log message {% if bad_values is not defined %} ; if no bad values SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=home_x VALUE={homex} ; set x home position SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=home_y VALUE={homey} ; set y home position @@ -1343,6 +1818,53 @@ gcode: { action_respond_info("X and Y parameters must be provided.") } ; report error {% endif %} +################################ +########## SET_HOMING ########## +################################ +[gcode_macro SET_HOMING] +description: Set up homing parameters +gcode: + ################## Get PrintCFG ################## + {% set printcfg = printer['gcode_macro _printcfg'] %} ; get printcfg variables + ################## Get Parameters ################## + ## Homing Position + {% set homex = params.X | default(printcfg.home_x) | float %} ; get x position + {% set homey = params.Y | default(printcfg.home_y) | float %} ; get y position + SET_HOME_POSITION X={homex} Y={homey} ; set home position + ## Homing Speed + {% set travel_speed = params.TRAVEL_SPEED | default(printcfg.home_travel_speed) | float %} ; get travel speed + {% set z_speed = params.Z_SPEED | default(printcfg.home_z_speed) | float %} ; get z speed + ## Homing Current + {% set home_current = params.HOME_CURRENT | default(printcfg.home_current) | float %} ; get home current + ## Retraction + {% set home_retract = params.HOME_RETRACT | default(printcfg.home_retract) | float %} ; get home retract + {% set home_retract_speed = params.HOME_RETRACT_SPEED | default(printcfg.home_retract_speed) | float %} ; get home retract speed + ## Z Lift + {% set pre_home_z = params.PRE_HOME_Z | default(printcfg.pre_home_z) | float %} ; get pre home z + {% set post_home_z = params.POST_HOME_Z | default(printcfg.post_home_z) | float %} ; get post home z + ## Sensorless Homing + {% set sensorless_homing = params.SENSORLESS_HOMING | default(printcfg.sensorless_home) | int %} ; get sensorless homing + ############## Make Strings Booleans ##############%} + {% if params.SENSORLESS_HOMING is defined and params.SENSORLESS_HOMING | lower == 'true' %} ; if sensorless homing is true + {% set sensorless_homing = 1 %} ; set sensorless homing + {% elif params.SENSORLESS_HOMING is defined and params.SENSORLESS_HOMING | lower == 'false' %} ; if sensorless homing is false + {% set sensorless_homing = 0 %} ; set sensorless homing + {% endif %} + ################## Set Variables ################## + ## Homing Speed + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=home_travel_speed VALUE={travel_speed} ; set travel speed + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=home_z_speed VALUE={z_speed} ; set z speed + ## Homing Current + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=home_current VALUE={home_current} ; set home current + ## Retraction + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=home_retract VALUE={home_retract} ; set home retract + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=home_retract_speed VALUE={home_retract_speed} ; set home retract speed + ## Z Lift + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=pre_home_z VALUE={pre_home_z} ; set pre home z + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=post_home_z VALUE={post_home_z} ; set post home z + ## Sensorless Homing + SET_GCODE_VARIABLE MACRO=_printcfg VARIABLE=sensorless_home VALUE={sensorless_homing} ; set sensorless homing + ## Only home if not homed [gcode_macro CG28] variable_output: 116 ; Output method for status feedback @@ -1416,15 +1938,6 @@ gcode: M{output} All axes are homed {% endif %} -## Simpler version without per-axis homing -#[gcode_macro CG28] -#gcode: -# {% set printcfg = printer['gcode_macro _printcfg'] %} ; get printcfg variables -# {% if printer.toolhead.homed_axes != "xyz" %} -# M{printcfg.output|int} Homing axis -# G28 -# {% endif %} - ## Only QGL if not QGL'd [gcode_macro CQGL] gcode: