Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ################################
- # BED MESH
- ################################
- [gcode_macro BED_MESH_CALIBRATE]
- rename_existing: BED_MESH_CALIBRATE_BASE
- ; gcode parameters
- variable_parameter_AREA_START : 0,0
- variable_parameter_AREA_END : 0,0
- ; the clearance between print area and probe area
- variable_mesh_area_offset : 5.0
- ; number of sample per probe point
- variable_probe_samples : 2
- ; minimum probe count
- variable_min_probe_count : 3
- ; scale up the probe count, should be 1.0 ~ < variable_max_probe_count/variable_min_probe_count
- variable_probe_count_scale_factor : 1.0
- ; enable preference index
- variable_enable_reference_index : False
- gcode:
- {% if params.AREA_START and params.AREA_END %}
- {% set bedMeshConfig = printer["configfile"].config["bed_mesh"] %}
- {% set safe_min_x = bedMeshConfig.mesh_min.split(",")[0]|float %}
- {% set safe_min_y = bedMeshConfig.mesh_min.split(",")[1]|float %}
- {% set safe_max_x = bedMeshConfig.mesh_max.split(",")[0]|float %}
- {% set safe_max_y = bedMeshConfig.mesh_max.split(",")[1]|float %}
- {% set area_min_x = params.AREA_START.split(",")[0]|float %}
- {% set area_min_y = params.AREA_START.split(",")[1]|float %}
- {% set area_max_x = params.AREA_END.split(",")[0]|float %}
- {% set area_max_y = params.AREA_END.split(",")[1]|float %}
- {% if bedMeshConfig.probe_count.split(",")|length == 2 %}
- {% set meshPointX = bedMeshConfig.probe_count.split(",")[0]|int %}
- {% set meshPointY = bedMeshConfig.probe_count.split(",")[1]|int %}
- {% else %}
- {% set meshPointX = bedMeshConfig.probe_count.split(",")[0]|int %}
- {% set meshPointY = bedMeshConfig.probe_count.split(",")[0]|int %}
- {% endif %}
- {% set meshMaxPointX = meshPointX %}
- {% set meshMaxPointY = meshPointY %}
- {% if (area_min_x < area_max_x) and (area_min_y < area_max_y) %}
- {% if area_min_x - mesh_area_offset >= safe_min_x %}
- {% set area_min_x = area_min_x - mesh_area_offset %}
- {% else %}
- {% set area_min_x = safe_min_x %}
- {% endif %}
- {% if area_min_y - mesh_area_offset >= safe_min_y %}
- {% set area_min_y = area_min_y - mesh_area_offset %}
- {% else %}
- {% set area_min_y = safe_min_y %}
- {% endif %}
- {% if area_max_x + mesh_area_offset <= safe_max_x %}
- {% set area_max_x = area_max_x + mesh_area_offset %}
- {% else %}
- {% set area_max_x = safe_max_x %}
- {% endif %}
- {% if area_max_y + mesh_area_offset <= safe_max_y %}
- {% set area_max_y = area_max_y + mesh_area_offset %}
- {% else %}
- {% set area_max_y = safe_max_y %}
- {% endif %}
- {% set meshPointX = (meshPointX * (area_max_x - area_min_x) / (safe_max_x - safe_min_x) * probe_count_scale_factor)|round(0)|int %}
- {% if meshPointX < min_probe_count %}
- {% set meshPointX = min_probe_count %}
- {% endif %}
- {% if meshPointX > meshMaxPointX %}
- {% set meshPointX = meshMaxPointX %}
- {% endif %}
- {% set meshPointY = (meshPointY * (area_max_y -area_min_y ) / (safe_max_y - safe_min_y) * probe_count_scale_factor )|round(0)|int %}
- {% if meshPointY < min_probe_count %}
- {% set meshPointY = min_probe_count %}
- {% endif %}
- {% if meshPointY > meshMaxPointY %}
- {% set meshPointY = meshMaxPointY %}
- {% endif %}
- {% set algorithm = "lagrange" %}
- {% if "algorithm" in bedMeshConfig and meshPointX >=4 and meshPointY >=4 %}
- {% set algorithm = bedMeshConfig.algorithm %}
- {% endif %}
- {% if enable_reference_index %}
- {% set referenceIndex = (meshPointX * meshPointY / 2 - 1 )|round(0)|int %}
- BED_MESH_CALIBRATE_BASE mesh_min={area_min_x},{area_min_y} mesh_max={area_max_x},{area_max_y} probe_count={meshPointX},{meshPointY} samples={probe_samples|int} algorithm={algorithm} relative_reference_index={referenceIndex}
- {% else %}
- BED_MESH_CALIBRATE_BASE mesh_min={area_min_x},{area_min_y} mesh_max={area_max_x},{area_max_y} probe_count={meshPointX},{meshPointY} samples={probe_samples|int} algorithm={algorithm}
- {% endif %}
- {% else %}
- BED_MESH_CALIBRATE_BASE
- {% endif %}
- {% else %}
- BED_MESH_CALIBRATE_BASE
- {% endif %}
- ################################
- # BED MESH
- ################################
- #[gcode_macro BED_MESH_CALIBRATE]
- #description: custom overwrite of the base BED_MESH_CALIBRATE function
- #rename_existing: BED_MESH_CALIBRATE_BASE
- #gcode:
- # BED_MESH_CLEAR
- # G28
- # BED_MESH_CALIBRATE_BASE {rawparams}
- ################################
- # START PRINT
- ################################
- [gcode_macro START_PRINT]
- # Use PRINT_START for the slicer starting script - PLEASE CUSTOMISE THE SCRIPT
- # gcode parameters for area bed mesh
- variable_parameter_AREA_START : 0,0
- variable_parameter_AREA_END : 0,0
- gcode:
- {% set th = printer.toolhead %}
- # Get temps from slicer
- {% set BED_TEMP = params.BED_TEMP|default(51)|float %}
- {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(191)|float %}
- {% set CHAMBER_TEMP = params.CHAMBER|default(45)|float %}
- {% set FILAMENT_TYPE = params.FILAMENT|default(PLA)|string %}
- # Get Boundaries
- {% set max_x = printer.configfile.config["stepper_x"]["position_max"]|float %}
- {% set max_y = printer.configfile.config["stepper_y"]["position_max"]|float %}
- {% set max_z = printer.configfile.config["stepper_z"]["position_max"]|float %}
- # Homing sequence
- G28
- SCREWS_TILT_CALCULATE MAX_DEVIATION=0.06 ; need to enable screw tile in printer.cfg
- M104 S170 ; set nozzle temp without waiting
- M190 S{BED_TEMP} ; wait for bed to reach temp
- # BED_MESH_CALIBRATE ; This is the default bed mesh method
- {% if params.AREA_START and params.AREA_END %} ; source: https://gist.github.com/ChipCE/95fdbd3c2f3a064397f9610f915f7d02
- BED_MESH_CALIBRATE AREA_START={params.AREA_START} AREA_END={params.AREA_END}
- {% else %}
- BED_MESH_CALIBRATE
- {% endif %}
- # BED_MESH_PROFILE LOAD=default
- # M140 S{BED_TEMP} ; heat bed to reach temp without waiting
- PROBE_IN
- G0 X46 Y0 F3000 ; park nozzle at front
- M109 S{EXTRUDER_TEMP} ; wait for nozzle to reach temperature
- # nozzle_clean
- M82 ; set extruder to absolute
- G92 E0 ; zero the extruder
- G90 ; absolute positioning
- G1 E5.0 F3000 ; reset filament in extruder
- G1 X46 Y0 Z1 F4000 ; Go to start pos for purge line
- G1 Z0.4 F600 ; Lower to purge height
- G91 ; relative positioning
- G1 X5 E40 F40 ; Extrude blob of filament on the bed
- M106 P0 ; Enable Cooling Fan
- G1 X20 Z5 F100 ; Slow drag away from the blob with fans helping cool and break strings. Also raise z so the blob clears the fan duct
- G1 X5 Z-5.1 F1000 ; Now that the blob has cleared the duct we go back down for a short 0.3mm height extrusion
- G1 X5 E2 F180 ; Slow 5mm extrude move to help with stringing
- G1 X30 E-1 F5000 ; Fast move and retract to break strings and reduce ooze
- G1 Z2 F100 ; Lift
- M106 P0 S0 ; Disable Cooling Fan
- G92 E0 ; zero the extruder
- G90 ; absolute positioning
- SKEW_PROFILE LOAD=my_skew_profile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement