First commit

This commit is contained in:
Cyril 2024-03-10 21:45:05 +01:00
commit 7693c29676
102 changed files with 11831 additions and 0 deletions

View file

@ -0,0 +1,133 @@
########################################
# M600 Support
########################################
[respond]
[idle_timeout]
gcode:
RESPOND TYPE=command MSG="Stopping hotend heating..."
M104 S0
timeout: 99999999
[filament_switch_sensor filament_sensor]
pause_on_runout: true
switch_pin: !PC15
runout_gcode:
M600
[gcode_macro M600]
description: Filament Change
variable_m600_state: 0
gcode:
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
{% set y_park = printer.toolhead.axis_minimum.y|float + 5.0 %}
{% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
{% 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 < 48.0 %}
{% set z_safe = 50.0 - act_z %}
{% elif act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% elif act_z < max_z %}
{% set z_safe = max_z - act_z %}
{% endif %}
{action_respond_info("z_safe = %s"% (z_safe))}
SET_GCODE_VARIABLE MACRO=M600 VARIABLE=m600_state VALUE=1
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE={printer.extruder.target}
RESPOND TYPE=command MSG="Print paused for filament change!"
PAUSE_BASE
G91
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-1.0 F180
G1 E-{E} F4000
{% else %}
RESPOND TYPE=command MSG="Extruder not hot enough!"
{% endif %}
G1 Z{z_safe} F600
M400
G90
G1 X{x_park} Y{y_park} F30000
{% endif %}
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
RESPOND TYPE=command MSG="Extracting filament..."
G1 E20 F180
G1 E-30 F180
G1 E-50 F2000
{% else %}
RESPOND TYPE=command MSG="Extruder not hot enough!"
{% endif %}
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan2_speed VALUE={printer['output_pin fan2'].value}
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=fan0_speed VALUE={printer['output_pin fan0'].value}
M106 P0 S0
M106 P2 S0
SET_IDLE_TIMEOUT TIMEOUT=900
SET_E_MIN_CURRENT
RESPOND TYPE=command MSG="Replace filament at the extruder inlet and click on Resume button!"
[gcode_macro RESUME]
description: Resume the current print
rename_existing: RESUME_BASE
gcode:
RESTORE_E_CURRENT
{% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int != 0 %}
{% if printer['gcode_macro PRINTER_PARAM'].hotend_temp|int > printer.extruder.temperature %}
RESPOND TYPE=command MSG="Starting hotend heating..."
M109 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
{% else %}
RESPOND TYPE=command MSG="Starting hotend heating..."
M104 S{printer['gcode_macro PRINTER_PARAM'].hotend_temp|int}
{% endif %}
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE=0
{% endif %}
{% if printer['gcode_macro PRINTER_PARAM'].fan2_speed > 0 %}
{% 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 %}
{% set z_resume_move = printer['gcode_macro PRINTER_PARAM'].z_safe_pause|int %}
{% if z_resume_move > 2 %}
{% set z_resume_move = z_resume_move - 2 %}
G91
G1 Z-{z_resume_move} F600
M400
{% endif %}
{% set E = printer["gcode_macro PAUSE"].extrude|float + 1.0 %}
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
{% if printer["gcode_macro M600"].m600_state == 1 %}
{% if printer.extruder.can_extrude|lower == 'true' %}
RESPOND TYPE=command MSG="Loading and purging filament..."
G91
G1 E180 F180
G90
M400
{% else %}
RESPOND TYPE=command MSG="Extruder not hot enough!"
{% endif %}
{% if printer['gcode_macro PRINTER_PARAM'].fan0_speed > 0 %}
{% set s_value = (printer['gcode_macro PRINTER_PARAM'].fan0_speed * 255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) * 255 / (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min)|float %}
M106 P0 S{s_value}
{% endif %}
SET_GCODE_VARIABLE MACRO=M600 VARIABLE=m600_state VALUE=0
SET_IDLE_TIMEOUT TIMEOUT=99999999
{% else %}
{% if printer.extruder.can_extrude|lower == 'true' %}
G91
G1 E{E} F2100
G90
M400
{% else %}
RESPOND TYPE=command MSG="Extruder not hot enough!"
{% endif %}
{% endif %}
RESPOND TYPE=command MSG="Restarting print..."
RESUME_BASE {get_params}

View file

@ -0,0 +1,142 @@
########################################
# Fans Control
########################################
[respond]
[duplicate_pin_override]
pins: PC0, PC5, PB2, ADC_TEMPERATURE
[temperature_fan chamber_fan]
pin: PC0
cycle_time: 0.0100
hardware_pwm: false
max_power: 1
shutdown_speed: 0
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC5
min_temp: 0
max_temp: 70
control: watermark
max_delta: 2
target_temp: 35.0
max_speed: 1.0
min_speed: 0.0
[temperature_fan mcu_fan]
pin: PB2
cycle_time: 0.0100
hardware_pwm: false
max_power: 1
shutdown_speed: 0
sensor_type: temperature_mcu
min_temp: 0
max_temp: 100
control: watermark
max_delta: 2
target_temp: 50.0
max_speed: 1.0
min_speed: 0.0
[output_pin mcu_fan]
pin: PB2
pwm: True
cycle_time: 0.0100
hardware_pwm: false
value: 0.00
scale: 255
shutdown_value: 0.0
[gcode_macro M141]
description: Set Chamber Temperature with slicers
gcode:
{% set s = params.S|float %}
SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET={s}
RESPOND TYPE=command MSG="Chamber target temperature: {s}°C"
[gcode_macro M191]
description: Wait for Chamber Temperature to heat up
gcode:
{% set s = params.S|float %}
{% set chamber_temp = printer["temperature_sensor chamber_temp"].temperature|float %}
{% if s > 0 %}
M141 S{s}
{% endif %}
{% if s > chamber_temp and s <= 90 %}
M140 S100
RESPOND TYPE=command MSG="Waiting for the bed to heat up the chamber..."
TEMPERATURE_WAIT SENSOR="temperature_fan chamber_fan" MINIMUM={s-1}
RESPOND TYPE=command MSG="Chamber target temperature reached: {s}°C"
M140 S{s}
{% 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 = (255 - printer["gcode_macro PRINTER_PARAM"].fan0_min) / 255 * tmp %}
{% if printer['gcode_macro Qmode'].flag | int == 1 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan0_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan0_min + value}
{% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) / 2 %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + value %}
{% endif %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan0_min + value %}
{% endif %}
{% endif %}
{% if fan == 1 %}
{% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan1_min) / 255 * tmp %}
{% if printer['gcode_macro Qmode'].flag | int == 1 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan1_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan1_min + value}
{% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan1_min) / 2 %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + value %}
{% endif %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan1_min + value %}
{% endif %}
{% endif %}
{% if fan == 2 %}
{% set value = (255 - printer["gcode_macro PRINTER_PARAM"].fan2_min) / 255 * tmp %}
{% if printer['gcode_macro Qmode'].flag | int == 1 %}
SET_GCODE_VARIABLE MACRO=Qmode VARIABLE=fan2_value VALUE={printer["gcode_macro PRINTER_PARAM"].fan2_min + value}
{% if value > (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) / 2 %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + value %}
{% endif %}
{% else %}
{% set value = printer["gcode_macro PRINTER_PARAM"].fan2_min + value %}
{% endif %}
{% endif %}
{% endif %}
{% if value >= 255 %}
{% set value = 255 %}
{% endif %}
{% if params.P is defined and params.P|int == 3 %}
{% set fan = 1 %}
{% endif %}
SET_PIN PIN=fan{fan} VALUE={value}

View file

@ -0,0 +1,38 @@
########################################
# Save Z-Offset
########################################
[save_variables]
filename: /usr/data/printer_data/config/Helper-Script/variables.cfg
[respond]
[gcode_macro SET_GCODE_OFFSET]
description: Saving Z-Offset
rename_existing: _SET_GCODE_OFFSET
gcode:
{% if printer.save_variables.variables.zoffset %}
{% set zoffset = printer.save_variables.variables.zoffset %}
{% else %}
{% set zoffset = {'z': None} %}
{% endif %}
{% set ns = namespace(zoffset={'z': zoffset.z}) %}
_SET_GCODE_OFFSET {% for p in params %}{'%s=%s '% (p, params[p])}{% endfor %}
{%if 'Z' in params %}{% set null = ns.zoffset.update({'z': params.Z}) %}{% endif %}
{%if 'Z_ADJUST' in params %}
{%if ns.zoffset.z == None %}{% set null = ns.zoffset.update({'z': 0}) %}{% endif %}
{% set null = ns.zoffset.update({'z': (ns.zoffset.z | float) + (params.Z_ADJUST | float)}) %}
{% endif %}
SAVE_VARIABLE VARIABLE=zoffset VALUE="{ns.zoffset}"
[delayed_gcode LOAD_GCODE_OFFSETS]
initial_duration: 2
gcode:
{% if printer.save_variables.variables.zoffset %}
{% set zoffset = printer.save_variables.variables.zoffset %}
_SET_GCODE_OFFSET {% for axis, offset in zoffset.items() if zoffset[axis] %}{ "%s=%s " % (axis, offset) }{% endfor %}
RESPOND TYPE=command MSG="Loaded Z-Offset from variables.cfg: {zoffset.z}mm"
{% endif %}

View file

@ -0,0 +1,205 @@
########################################
# Useful Macros
########################################
[gcode_shell_command Klipper_Backup]
command: sh /usr/data/helper-script/files/scripts/useful_macros.sh -backup_klipper
timeout: 600.0
verbose: true
[gcode_shell_command Klipper_Restore]
command: sh /usr/data/helper-script/files/scripts/useful_macros.sh -restore_klipper
timeout: 600.0
verbose: true
[gcode_shell_command Moonraker_Backup]
command: sh /usr/data/helper-script/files/scripts/useful_macros.sh -backup_moonraker
timeout: 600.0
verbose: true
[gcode_shell_command Moonraker_Restore]
command: sh /usr/data/helper-script/files/scripts/useful_macros.sh -restore_moonraker
timeout: 600.0
verbose: true
[gcode_macro KLIPPER_BACKUP_CONFIG]
gcode:
RUN_SHELL_COMMAND CMD=Klipper_Backup
[gcode_macro KLIPPER_RESTORE_CONFIG]
gcode:
RUN_SHELL_COMMAND CMD=Klipper_Restore
[gcode_macro MOONRAKER_BACKUP_DATABASE]
gcode:
RUN_SHELL_COMMAND CMD=Moonraker_Backup
[gcode_macro MOONRAKER_RESTORE_DATABASE]
gcode:
RUN_SHELL_COMMAND CMD=Moonraker_Restore
[gcode_macro BED_LEVELING]
description: Start Bed Leveling
gcode:
{% if 'PROBE_COUNT' in params|upper %}
{% set get_count = ('PROBE_COUNT=' + params.PROBE_COUNT) %}
{%else %}
{% set get_count = "" %}
{% endif %}
{% set bed_temp = params.BED_TEMP|default(50)|float %}
{% set hotend_temp = params.HOTEND_TEMP|default(140)|float %}
{% set nozzle_clear_temp = params.NOZZLE_CLEAR_TEMP|default(240)|float %}
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
BED_MESH_CLEAR
NOZZLE_CLEAR HOT_MIN_TEMP={hotend_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} F20000
TURN_OFF_HEATERS
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1
[gcode_macro PID_BED]
description: Start Bed PID
gcode:
G90
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
G1 Z10 F600
M106
PID_CALIBRATE HEATER=heater_bed TARGET={params.BED_TEMP|default(70)}
M107
{% 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} F20000
[gcode_macro PID_HOTEND]
description: Start Hotend PID
gcode:
G90
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
G1 Z10 F600
M106
PID_CALIBRATE HEATER=extruder TARGET={params.HOTEND_TEMP|default(250)}
M107
{% 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} F20000
WAIT_TEMP_START
[gcode_macro LUBRICATE_RODS]
description: Distribute lubricant on Rods
gcode:
{% set min_speed = 3000 %} # Minimum speed in mm/min
{% set max_speed = 18000 %} # Maximum speed in mm/min
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
G1 Z50 F300
{% set x_max = printer.toolhead.axis_maximum.x|int %}
{% set y_max = printer.toolhead.axis_maximum.y|int %}
{% set edge_offset_x = x_max * 0.05 %}
{% set edge_offset_y = y_max * 0.05 %}
{% set x_range = x_max - edge_offset_x %}
{% set y_range = y_max - edge_offset_y %}
{% set num_steps_x = (x_range / 10)|int %}
{% set num_steps_y = (y_range / 10)|int %}
{% set speed_increment_x = (max_speed - min_speed) / num_steps_x %}
{% set speed_increment_y = (max_speed - min_speed) / num_steps_y %}
{% set current_speed_x = min_speed %}
{% set current_speed_y = min_speed %}
{% for i in range(num_steps_x) %}
G1 X{edge_offset_x + i * 10} Y{edge_offset_y} F{current_speed_x}
G1 X{edge_offset_x + i * 10} Y{y_range} F{current_speed_x}
{% set current_speed_x = current_speed_x + speed_increment_x %}
{% endfor %}
{% for j in range(num_steps_y) %}
G1 Y{edge_offset_y + j * 10} X{edge_offset_x} F{current_speed_y}
G1 Y{edge_offset_y + j * 10} X{x_range} F{current_speed_y}
{% set current_speed_y = current_speed_y + speed_increment_y %}
{% endfor %}
[gcode_macro WARMUP]
description: Stress Test
variable_maxd: 14142.14 ; = SQRT(2*maxy)
gcode:
{% set min_loops = 2 %}
{% set max_loops = params.LOOPS|default(3)|int %}
{% if 'LOOPS' in params|upper %}
{% if max_loops < min_loops %}
{% set max_loops = min_loops %}
{% endif %}
{% endif %}
{% set loop_cnt = max_loops %}
{% if 'X_ACCEL_MAX' in params|upper %}
{% set maxx = params.X_ACCEL_MAX|default(10000)|int %}
{% endif %}
{% if 'Y_ACCEL_MAX' in params|upper %}
{% set maxy = params.Y_ACCEL_MAX|default(10000)|int %}
{% endif %}
{% set max_x = (printer.toolhead.axis_maximum.x|int-5) %}
{% set max_y = (printer.toolhead.axis_maximum.y|int-5) %}
{% set loop_step_y = max_y//(loop_cnt-1) %}
{% set loop_step_x = max_x//(loop_cnt-1) %}
{% set y_park = printer.toolhead.axis_maximum.y/2 %}
{% set x_park = printer.toolhead.axis_maximum.x|float - 10.0 %}
{% if printer.toolhead.homed_axes != "xyz" %}
G28
{% endif %}
SET_VELOCITY_LIMIT ACCEL={maxx} ACCEL_TO_DECEL={maxx/2}
{% for number in range(10,max_y+11,loop_step_y) %}
{% if number >= max_y %}
{% set number = max_y %}
{% endif %}
G1 F{maxy} X10 Y{number}
G1 F{maxx} X{max_x} Y{number}
{% endfor %}
SET_VELOCITY_LIMIT ACCEL={maxy} ACCEL_TO_DECEL={maxy/2}
{% for number in range(10,max_x+11,loop_step_y) %}
{% if number >= max_x %}
{% set number = max_x %}
{% endif %}
G1 F{maxy} X{number} Y{max_y}
G1 F{maxy} X{number} Y10
{% endfor %}
SET_VELOCITY_LIMIT ACCEL={maxd} ACCEL_TO_DECEL={maxd/2}
{% for times in range(loop_cnt) %}
G1 F{maxx} X10 Y10
G1 F{maxd} X{max_x} Y{max_y}
G1 F{maxx} X10 Y{max_y}
G1 F{maxd} X{max_x} Y10
G1 F{maxy} X{max_x} Y{max_y}
G1 F{maxd} X10 Y10
G1 F{maxy} X10 Y{max_y}
G1 F{maxd} X{max_x} Y10
{% endfor %}
SET_VELOCITY_LIMIT ACCEL={maxx} ACCEL_TO_DECEL={maxx/2}
{% for times in range(loop_cnt) %}
G1 F{maxy} X10 Y10
G1 F{maxy} X10 Y{max_y}
G1 F{maxx} X{max_x} Y{max_y}
G1 F{maxy} X{max_x} Y10
G1 F{maxx} X10 Y10
G1 F{maxx} X{max_x} Y10
G1 F{maxy} X{max_x} Y{max_y}
G1 F{maxx} X10 Y{max_y}
{% endfor %}
G1 X{x_park} Y{y_park} F30000