Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root@creality /usr/share [#] cat klipper/config/K1_MAX_CR4CU220812S11/gcode_macro.cfg
- # K1-MAX
- # CreateDate: 2023/03/15
- # history: 1. date: 2023.03.17
- # modify: [gcode_macro END_PRINT]
- # 2. date: 2023.03.20
- # delete: [gcode_macro Qmode].printer_state
- # 3. date: 2023.03.23
- # modify: [gcode_macro LOAD_MATERIAL]
- # [gcode_macro QUIT_MATERIAL]
- [gcode_macro PRINTER_PARAM]
- variable_z_safe_pause: 0.0
- variable_z_safe_g28: 3.0
- variable_max_x_position: 300.0
- variable_max_y_position: 300.0
- variable_max_z_position: 300.0
- variable_fans: 3
- variable_auto_g29: 0
- variable_fan0_min: 50
- variable_fan1_min: 50
- variable_fan2_min: 180
- variable_fan2_speed: 0
- gcode:
- [gcode_macro AUTOTUNE_SHAPERS]
- variable_autotune_shapers: 'ei'
- gcode:
- [gcode_macro LOAD_MATERIAL_CLOSE_FAN2]
- variable_fan2_value: 0
- gcode:
- SAVE_GCODE_STATE NAME=myMoveState
- {% if printer['output_pin fan2'].value > 0.0 %}
- SET_GCODE_VARIABLE MACRO=LOAD_MATERIAL_CLOSE_FAN2 VARIABLE=fan2_value VALUE={printer['output_pin fan2'].value}
- M107 P2
- {% endif %}
- [gcode_macro LOAD_MATERIAL_RESTORE_FAN2]
- gcode:
- {% set fan2_value = printer['gcode_macro LOAD_MATERIAL_CLOSE_FAN2'].fan2_value|float %}
- RESTORE_GCODE_STATE NAME=myMoveState
- {% if fan2_value > 0.0 %}
- {% set s_value = (fan2_value * 255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) * 255 / (255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) %}
- M106 P2 S{s_value}
- SET_GCODE_VARIABLE MACRO=LOAD_MATERIAL_CLOSE_FAN2 VARIABLE=fan2_value VALUE=0
- {% endif %}
- [gcode_macro LOAD_MATERIAL]
- gcode:
- LOAD_MATERIAL_CLOSE_FAN2
- M109 S{printer.custom_macro.default_extruder_temp}
- G91
- G1 E150 F180
- LOAD_MATERIAL_RESTORE_FAN2
- [gcode_macro QUIT_MATERIAL]
- gcode:
- SAVE_GCODE_STATE NAME=myMoveState
- M109 S{printer.custom_macro.default_extruder_temp}
- G91
- G1 E20 F180
- G1 E-30 F180
- G1 E-50 F2000
- RESTORE_GCODE_STATE NAME=myMoveState
- [gcode_macro Qmode]
- variable_flag: 0
- variable_accel: 0
- variable_accel_to_decel: 0
- variable_velocity: 0
- variable_square_corner_velocity: 0
- variable_pressure_advance:0.0
- variable_fan0_value: 0.00
- variable_fan1_value: 0.00
- variable_fan2_value: 0.00
- variable_speed_factor: 0
- gcode:
- {% set printer_state = printer.print_stats.state %}
- {% if printer['gcode_macro Qmode'].flag|int == 0 %}
- {% if printer_state == "printing" or printer_state == "paused" %}
- SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=accel VALUE={printer.toolhead.max_accel}
- SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=accel_to_decel VALUE={printer.toolhead.max_accel_to_decel}
- SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=velocity VALUE={printer.toolhead.max_velocity}
- SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=square_corner_velocity VALUE={printer.toolhead.square_corner_velocity}
- SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=pressure_advance VALUE={printer.extruder.pressure_advance}
- SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=speed_factor VALUE={printer.gcode_move.speed_factor}
- SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE={printer['output_pin fan0'].value}
- SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE={printer['output_pin fan1'].value}
- SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE={printer['output_pin fan2'].value}
- SET_TMC_FIELD STEPPER=stepper_x FIELD=en_spreadcycle VALUE=0
- SET_TMC_FIELD STEPPER=stepper_y FIELD=en_spreadcycle VALUE=0
- # Set Motion Parameters
- SET_VELOCITY_LIMIT ACCEL=5000
- SET_VELOCITY_LIMIT ACCEL_TO_DECEL=2500
- SET_VELOCITY_LIMIT VELOCITY=200
- SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=5
- SET_PRESSURE_ADVANCE ADVANCE=0.05
- M220 S50
- M106 P0 S80
- M106 P1 S0
- M106 P2 S0
- SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=flag VALUE=1
- {% endif %}
- {% endif %}
- [gcode_macro Qmode_exit]
- gcode:
- {% set printer_state = printer.print_stats.state %}
- {% if printer['gcode_macro Qmode'].flag|int == 1 %}
- {% if printer_state == "printing" or printer_state == "paused" %}
- SET_VELOCITY_LIMIT ACCEL={printer['gcode_macro Qmode'].accel}
- SET_VELOCITY_LIMIT ACCEL_TO_DECEL={printer['gcode_macro Qmode'].accel_to_decel}
- SET_VELOCITY_LIMIT VELOCITY={printer['gcode_macro Qmode'].velocity}
- SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={printer['gcode_macro Qmode'].square_corner_velocity}
- SET_PRESSURE_ADVANCE ADVANCE={printer['gcode_macro Qmode'].pressure_advance}
- M220 S{printer['gcode_macro Qmode'].speed_factor * 100}
- M106 P0 S{(printer['gcode_macro Qmode'].fan0_value * 255 + 0.5)|int}
- M106 P1 S{(printer['gcode_macro Qmode'].fan1_value * 255 + 0.5)|int}
- M106 P2 S{(printer['gcode_macro Qmode'].fan2_value * 255 + 0.5)|int}
- SET_TMC_FIELD STEPPER=stepper_x FIELD=en_spreadcycle VALUE=1
- SET_TMC_FIELD STEPPER=stepper_y FIELD=en_spreadcycle VALUE=1
- SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=flag VALUE=0
- {% endif %}
- {% endif %}
- [gcode_macro M204]
- rename_existing: M204.1
- gcode:
- {% if printer['gcode_macro Qmode'].flag|int == 0 %}
- {% set get_params = "" %}
- {% if 'S' in params|upper %}
- {% set get_params = (get_params + ' ' + 'S' + params.S) %}
- {% endif %}
- {% if 'P' in params|upper %}
- {% set get_params = (get_params + ' ' + 'P' + params.P) %}
- {% endif %}
- {% if 'T' in params|upper %}
- {% set get_params = (get_params + ' ' + 'T' + params.T) %}
- {% endif %}
- M204.1 {get_params}
- {% endif %}
- [gcode_macro M205]
- gcode:
- {% if 'X' in params %}
- SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.X}
- {% elif 'Y' in params %}
- SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.Y}
- {% endif %}
- [gcode_macro M106]
- gcode:
- {% set fans = printer["gcode_macro PRINTER_PARAM"].fans|int %}
- {% set fan = 0 %}
- {% set value = 0 %}
- {% if params.P is defined %}
- {% set tmp = params.P|int %}
- {% if tmp < fans %}
- {% set fan = tmp %}
- {% endif %}
- {% endif %}
- {% if params.S is defined %}
- {% set tmp = params.S|float %}
- {% else %}
- {% set tmp = 255 %}
- {% endif %}
- {% if tmp > 0 %}
- {% if fan == 0 %}
- {% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + (255 - printer["gcode_macro PRINTER_PARAM"].fan0_min) / 255 * tmp %}
- {% endif %}
- {% if fan == 1 %}
- {% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + (255 - printer["gcode_macro PRINTER_PARAM"].fan1_min) / 255 * tmp %}
- {% endif %}
- {% if fan == 2 %}
- {% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + (255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) / 255 * tmp %}
- {% endif %}
- {% endif %}
- {% if value >= 255 %}
- {% set value = 255 %}
- {% endif %}
- SET_PIN PIN=fan{fan} VALUE={value}
- [gcode_macro M107]
- gcode:
- {% if params.P is defined %}
- SET_PIN PIN=fan{params.P|int} VALUE=0
- {% else %}
- SET_PIN PIN=fan0 VALUE=0
- SET_PIN PIN=fan2 VALUE=0
- {% endif %}
- [gcode_macro M900]
- gcode:
- {% if 'K' in params %}
- {% if 'E' in params %}
- SET_PRESSURE_ADVANCE EXTRUDER={params.E} ADVANCE={params.K}
- {% else %}
- SET_PRESSURE_ADVANCE ADVANCE={params.K}
- {% endif %}
- {% endif %}
- [delayed_gcode wait_temp]
- # initial_duration: 2.
- gcode:
- {% set cur_temp = printer.extruder.temperature %}
- {% if cur_temp|int < 40 %}
- {action_respond_info("end_temp!\n")}
- WAIT_TEMP_END
- {% else %}
- {action_respond_info("cur_temp = %s \n" % (cur_temp))}
- UPDATE_DELAYED_GCODE ID=wait_temp DURATION=5
- {% endif %}
- [gcode_macro WAIT_TEMP_START]
- gcode:
- UPDATE_DELAYED_GCODE ID=wait_temp DURATION=1
- M106 P0 S255
- M106 P2 S255
- [gcode_macro WAIT_TEMP_END]
- gcode:
- UPDATE_DELAYED_GCODE ID=wait_temp DURATION=0
- M106 P0 S0
- M106 P2 S0
- [gcode_macro PRINT_CALIBRATION]
- # This part of the command is replaced by the application side without passing parameters
- # The macro of LASER_CALIBRATION is for application use and has not been implemented
- # The macro of FLOW_DETECTION is for application use and has not been implemented
- gcode:
- CX_PRINT_LEVELING_CALIBRATION
- LASER_CALIBRATION
- FLOW_DETECTION
- [gcode_macro FIRST_FLOOR_PAUSE_POSITION]
- gcode:
- {% set extruder_temp = printer.custom_macro.g28_ext_temp %}
- M104 S{extruder_temp}
- {% set y_park = printer.toolhead.axis_maximum.y/2 %}
- {% set x_park = printer['gcode_macro PRINTER_PARAM'].max_x_position|float + 1 %}
- G90
- G1 X{x_park} Y{y_park} Z2.0 F6000
- G1 Z0.2 F600
- [gcode_macro ACCURATE_G28]
- gcode:
- G28 Z
- [gcode_macro START_PRINT]
- gcode:
- WAIT_TEMP_END
- CLEAR_PAUSE
- {% set g28_extruder_temp = printer.custom_macro.g28_ext_temp %}
- {% set bed_temp = printer.custom_macro.default_bed_temp %}
- {% set extruder_temp = printer.custom_macro.default_extruder_temp %}
- {% if 'BED_TEMP' in params|upper and (params.BED_TEMP|float) %}
- {% set bed_temp = params.BED_TEMP %}
- {% endif %}
- {% if 'EXTRUDER_TEMP' in params|upper and (params.EXTRUDER_TEMP|float) %}
- {% set extruder_temp = params.EXTRUDER_TEMP %}
- {% endif %}
- CX_PRINT_DRAW_ONE_LINE
- [gcode_macro END_PRINT_POINT]
- gcode:
- {% if "xyz" in printer.toolhead.homed_axes %}
- {% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
- {% set act_z = printer.toolhead.position.z|float %}
- {% set z_safe = 0.0 %}
- {% if act_z < (max_z / 2) %}
- {% set z_safe = (max_z / 2) - act_z %}
- {% elif act_z < max_z %}
- {% set z_safe = 2.0 %}
- {% endif %}
- G91
- G1 Z{z_safe} F600
- G90
- {% set y_park = printer.toolhead.axis_maximum.y/2 %}
- {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
- G1 X{x_park} Y{y_park} F6000
- {% else %}
- {action_respond_info("end print xyz_axes is NULL\n")}
- {% endif %}
- [gcode_macro END_PRINT]
- gcode:
- # Qmode_exit
- M220 S100
- M204 S500
- TURN_OFF_HEATERS
- M107 P1
- END_PRINT_POINT
- WAIT_TEMP_START
- M84
- [gcode_macro PAUSE]
- description: Pause the actual running print
- rename_existing: PAUSE_BASE
- # change this if you need more or less extrusion
- variable_extrude: 1.0
- gcode:
- ##### read E from pause macro #####
- {% set E = printer["gcode_macro PAUSE"].extrude|float %}
- ##### set park positon for x and y #####
- # default is your max posion from your printer.cfg
- {% set y_park = printer.toolhead.axis_maximum.y/2 %}
- {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
- # save fan2 value and turn off fan2
- SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan2_speed VALUE={printer['output_pin fan2'].value}
- # {% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
- # {action_respond_info("fan2_value1 = %s \n" % (fspeed))}
- # SET_PIN PIN=fan2 VALUE=0
- M106 P2 S0
- ##### calculate save lift position #####
- {% set max_z = printer["gcode_macro PRINTER_PARAM"].max_z_position|float %}
- {% set act_z = printer.toolhead.position.z|float %}
- {% set z_safe = 0.0 %}
- {% if act_z < (max_z - 2.0) %}
- {% set z_safe = 2.0 %}
- {% elif act_z < max_z %}
- {% set z_safe = max_z - act_z %}
- {% endif %}
- ##### end of definitions #####
- SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=z_safe_pause VALUE={z_safe|float}
- PAUSE_BASE
- G91
- {% if printer.extruder.can_extrude|lower == 'true' %}
- G1 E-{E} F2100
- {% else %}
- {action_respond_info("Extruder not hot enough")}
- {% endif %}
- {% if "xyz" in printer.toolhead.homed_axes %}
- G1 Z{z_safe} F600
- G90
- G1 X{x_park} Y{y_park} F6000
- {% else %}
- {action_respond_info("Printer not homed")}
- {% endif %}
- [gcode_macro INPUTSHAPER]
- gcode:
- SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
- G90
- G28
- {% set POSITION_X = printer.configfile.settings['stepper_x'].position_max/2 %}
- {% set POSITION_Y = printer.configfile.settings['stepper_y'].position_max/2 %}
- G1 X{POSITION_X} Y{POSITION_Y} Z5 F6000
- SHAPER_CALIBRATE
- CXSAVE_CONFIG
- SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1
- [gcode_macro BEDPID]
- gcode:
- PID_CALIBRATE HEATER=heater_bed TARGET=100
- SAVE_CONFIG
- [gcode_macro TUNOFFINPUTSHAPER]
- gcode:
- SET_INPUT_SHAPER SHAPER_FREQ_X=0 SHAPER_FREQ_Y=0
- [gcode_macro RESUME]
- description: Resume the actual running print
- rename_existing: RESUME_BASE
- gcode:
- {% if printer['gcode_macro PRINTER_PARAM'].fan2_speed > 0 %}
- # {% set fspeed = printer['gcode_macro PRINTER_PARAM'].fan2_speed %}
- # {action_respond_info("fan2_value2 = %s \n" % (fspeed))}
- # SET_PIN PIN=fan2 VALUE={(printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 + 0.5)|int}
- {% 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 %}
- M106 P2 S{s_value}
- {% endif %}
- ##### read E from pause macro #####
- {% set E = printer["gcode_macro PAUSE"].extrude|float %}
- #### get VELOCITY parameter if specified ####
- {% if 'VELOCITY' in params|upper %}
- {% set get_params = ('VELOCITY=' + params.VELOCITY) %}
- {%else %}
- {% set get_params = "" %}
- {% endif %}
- ##### end of definitions #####
- {% if printer.extruder.can_extrude|lower == 'true' %}
- G91
- G1 E{E} F2100
- {% else %}
- {action_respond_info("Extruder not hot enough")}
- {% endif %}
- RESUME_BASE {get_params}
- [gcode_macro CANCEL_PRINT]
- description: Cancel the actual running print
- rename_existing: CANCEL_PRINT_BASE
- gcode:
- END_PRINT
- CANCEL_PRINT_BASE
- [gcode_macro G29]
- gcode:
- {% if 'PROBE_COUNT' in params|upper %}
- {% set get_count = ('PROBE_COUNT' + params.PROBE_COUNT) %}
- {%else %}
- {% set get_count = "" %}
- {% endif %}
- {% set bed_temp = printer.custom_macro.default_bed_temp %}
- {% set extruder_temp = printer.custom_macro.g28_ext_temp %}
- {% set nozzle_clear_temp = printer.custom_macro.default_extruder_temp %}
- {% if 'BED_TEMP' in params|upper %}
- {% set bed_temp = params.BED_TEMP %}
- {% endif %}
- {% if 'EXTRUDER_TEMP' in params|upper %}
- {% set nozzle_clear_temp = params.EXTRUDER_TEMP %}
- {% endif %}
- G28
- BED_MESH_CLEAR
- NOZZLE_CLEAR HOT_MIN_TEMP={extruder_temp} HOT_MAX_TEMP={nozzle_clear_temp} BED_MAX_TEMP={bed_temp}
- ACCURATE_G28
- M204 S5000
- SET_VELOCITY_LIMIT ACCEL_TO_DECEL=5000
- BED_MESH_CALIBRATE {get_count}
- BED_MESH_OUTPUT
- {% set y_park = printer.toolhead.axis_maximum.y/2 %}
- {% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
- G1 X{x_park} Y{y_park} F2000
- CXSAVE_CONFIG
- TURN_OFF_HEATERS
- # [gcode_macro G299]
- # gcode:
- # BED_MESH_CLEAR
- # G28
- # PRTOUCH_READY
- # BED_MESH_CALIBRATE
- # BED_MESH_OUTPUT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement