===== Config file =====
[mcu rpi]
serial = /tmp/klipper_host_mcu
[board_pins btt-skrat-10]
aliases =
x_step_pin=PF9,
x_dir_pin=PD7,
x_enable_pin=PD6,
x_uart_pin=PF10,
x_diag_pin=PB5,
x_endstop_pin=PB5,
y_step_pin=PD3,
y_dir_pin=PD2,
y_enable_pin=PD5,
y_uart_pin=PD4,
y_diag_pin=PC1,
y_endstop_pin=PC1,
z0_step_pin=PA15,
z0_dir_pin=PF8,
z0_enable_pin=PC9,
z0_uart_pin=PC8,
z0_diag_pin=PC0,
e_step_pin=PB10,
e_dir_pin=PE15,
e_enable_pin=PA8,
e_uart_pin=PB11,
e_diag_pin=PF5,
e_heater_pin=PE11,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PE5,
bltouch_control_pin=PE6,
probe_pin=PE5,
fan_part_cooling_pin=PD15,
fan_toolhead_cooling_pin=PD14,
fan_controller_board_pin=PD13,
heater_bed_heating_pin=PB3,
heater_bed_sensor_pin=PB2,
4p_fan_part_cooling_pin=PE9,
4p_fan_part_cooling_tach_pin=PD11,
4p_toolhead_cooling_pin=PE14,
4p_toolhead_cooling_tach_pin=PD10,
4p_controller_board_pin=PE14,
4p_controller_board_tach_pin=PD10
[mcu]
serial = /dev/RatOS/btt-skrat-10
[temperature_sensor SKRat_v1.0]
sensor_type = temperature_mcu
[adxl345 controlboard]
cs_pin = PB12
spi_bus = spi2
[board_pins toolboard_t0]
mcu = toolboard_t0
aliases =
e_step_pin=PD0,
e_dir_pin=PD1,
e_enable_pin=PD2,
e_uart_pin=PA15,
e_heater_pin=PB13,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PB8,
bltouch_control_pin=PB9,
probe_pin=PB9,
fan_part_cooling_pin=PA0,
fan_toolhead_cooling_pin=PA1,
fan_controller_board_pin=null,
heater_bed_heating_pin=null,
heater_bed_sensor_pin=null,
4p_fan_part_cooling_pin=null,
4p_fan_part_cooling_tach_pin=null,
4p_toolhead_cooling_pin=null,
4p_toolhead_cooling_tach_pin=null,
4p_controller_board_pin=null,
4p_controller_board_tach_pin=null
[mcu toolboard_t0]
serial = /dev/RatOS/btt-ebb42-12-t0
[temperature_sensor EBB42_v1.2_T0]
sensor_type = temperature_mcu
sensor_mcu = toolboard_t0
[adxl345 toolboard_t0]
axes_map = x, z, y
cs_pin = toolboard_t0:PB12
spi_software_mosi_pin = toolboard_t0:PB11
spi_software_miso_pin = toolboard_t0:PB2
spi_software_sclk_pin = toolboard_t0:PB10
[gcode_macro RatOS]
variable_homing = "endstops"
variable_z_probe = "static"
variable_sensorless_x_current = 0.6
variable_sensorless_y_current = 0.9
variable_safe_home_x = "middle"
variable_safe_home_y = "middle"
variable_driver_type_x = "tmc2209"
variable_driver_type_y = "tmc2209"
variable_stowable_probe_stop_on_error = False
variable_chamber_filter_enable = True
variable_chamber_filter_speed = 0.5
variable_chamber_filter_disable_speed = 1.0
variable_chamber_filter_enable_at = "after_print_start"
variable_chamber_filter_disable_period = 300
variable_chamber_filter_disable_bed_temp = 0
variable_chamber_heater_enable = True
variable_chamber_heater_bed_temp = 115
variable_chamber_heater_preheating_temp = 150
variable_chamber_heater_heating_temp_offset = 25
variable_chamber_heater_control_external_heater = False
variable_chamber_heater_air_circulation_enable = True
variable_chamber_heater_air_circulation_fan_speed = 0.35
variable_chamber_heater_air_circulation_y_pos = 0
variable_chamber_heater_air_circulation_z_pos = 100
variable_chamber_heater_extra_fan_speed = 1.0
variable_chamber_heater_filter_fan_speed = 1.0
variable_led_status_action = 0.0,1.0,1.0
variable_led_status_success = 0.0,1.0,0.0
variable_led_status_error = 1.0,0.0,1.0
variable_led_status_on = 1.0,1.0,1.0
variable_led_status_off = 0.0,0.0,1.0
variable_led_status_standby = 0.1,0.1,0.1
variable_led_status_heating = 1.0,0.0,0.0
variable_led_status_cooling = 0.0,0.0,1.0
variable_calibrate_bed_mesh = True
variable_adaptive_mesh = True
variable_start_print_park_in = "front"
variable_start_print_park_z_height = 50
variable_end_print_park_in = "back"
variable_pause_print_park_in = "front"
variable_end_print_park_z_hop = 20
variable_nozzle_priming = "primeblob"
variable_nozzle_prime_start_x = "max"
variable_nozzle_prime_start_y = "min"
variable_nozzle_prime_direction = "auto"
variable_nozzle_prime_bridge_fan = 102
variable_probe_for_priming_result = None
variable_probe_for_priming_end_result = None
variable_probe_for_priming_result_t1 = None
variable_probe_for_priming_end_result_t1 = None
variable_probe_for_priming_disable_mesh_constraints = False
variable_adaptive_prime_offset_threshold = -1.0
variable_last_z_offset = None
variable_runout_park_in = "front"
variable_enable_unload_tip_forming = False
variable_filament_unload_length = 150
description = RatOS variable storage macro, will echo variables to the console when run.
variable_relative_extrusion = False
variable_force_absolute_position = False
variable_preheat_extruder = True
variable_preheat_extruder_temp = 150
variable_macro_travel_speed = 200
variable_macro_travel_accel = 3000
variable_macro_z_speed = 15
variable_bed_margin_x = [0, 0]
variable_bed_margin_y = [0, 0]
variable_printable_x_min = 0
variable_printable_x_max = 0
variable_printable_y_min = 0
variable_printable_y_max = 0
variable_end_print_motors_off = True
variable_status_color_ok = "00FF00"
variable_status_color_error = "FF0000"
variable_status_color_unknown = "FFFF00"
variable_end_print_retract_filament = 10
gcode =
ECHO_RATOS_VARS
variable_homing_x = "endstop"
variable_homing_y = "endstop"
variable_x_driver_types = ["tmc2209"]
variable_x_axes = ["x"]
variable_y_driver_types = ["tmc2209"]
variable_y_axes = ["y"]
variable_z_driver_types = ["tmc2209"]
variable_z_axes = ["z"]
[ratos_homing]
axes = xyz
z_hop = 15
z_hop_speed = 15
gcode =
_LED_ON
{% set prev_stop_on_error = printer["gcode_macro RatOS"].stowable_probe_stop_on_error %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set target_idex_mode = printer["dual_carriage"].carriage_1|lower %}
_IDEX_SINGLE
_SELECT_TOOL T={default_toolhead} TOOLSHIFT=false
{% endif %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE=True
M400
G90
{% set X = true if params.X is defined else false %}
{% set Y = true if params.Y is defined else false %}
{% set Z = true if params.Z is defined else false %}
{% if printer["gcode_macro RatOS"].home_y_first|default(false)|lower == 'true' %}
HOME_Y X={X} Y={Y} Z={Z}
HOME_X X={X} Y={Y} Z={Z}
{% else %}
HOME_X X={X} Y={Y} Z={Z}
HOME_Y X={X} Y={Y} Z={Z}
{% endif %}
HOME_Z X={X} Y={Y} Z={Z}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE={prev_stop_on_error}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR
{% endif %}
{% endif %}
[gcode_macro HOME_X]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_x = printer["gcode_macro RatOS"].homing_x|lower %}
{% set homing_x = homing_x if homing_x else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_X" MSG="printable_x_max: {printable_x_max}, safe_home_x: {safe_home_x}, axis_maximum.x: {printer.toolhead.axis_maximum.x}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}"
{% if X or not Y and not Z %}
{% if homing_x == 'endstop' %}
G28 X
{% elif homing_x == 'sensorless' %}
{% if printer["dual_carriage"] is defined %}
{ action_emergency_stop("sensorless homing not supported on IDEX!") }
{% endif %}
HOME_X_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_x to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_x, homing)) }
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % (0 if default_toolhead==1 else 1)].parking_position|float %}
SET_DUAL_CARRIAGE CARRIAGE={0 if default_toolhead==1 else 1} MODE=PRIMARY
G1 X{parking_position} F{speed}
SET_DUAL_CARRIAGE CARRIAGE={default_toolhead} MODE=PRIMARY
{% endif %}
{% set x_homed = True %}
G0 X{safe_home_x} F{speed}
M400
{% endif %}
[gcode_macro HOME_Y]
gcode =
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_y = printer["gcode_macro RatOS"].homing_y|lower %}
{% set homing_y = homing_y if homing_y else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Y" MSG="printable_y_max: {printable_y_max}, safe_home_y: {safe_home_y}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}"
{% if Y or not X and not Z %}
{% if homing_y == 'endstop' %}
G28 Y
{% elif homing_y == 'sensorless' %}
HOME_Y_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_y to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_y, homing)) }
{% endif %}
{% set y_homed = True %}
G0 Y{safe_home_y} F{speed}
{% endif %}
[gcode_macro HOME_Z]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set z_probe = printer["gcode_macro RatOS"].z_probe %}
{% set beacon_contact_z_homing = true if printer["gcode_macro RatOS"].beacon_contact_z_homing|default(false)|lower == 'true' else false %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Z" MSG="x_homed: {x_homed}, y_homed: {y_homed}, z_probe: {z_probe}, beacon_contact_z_homing: {beacon_contact_z_homing}"
{% if Z or not Y and not X %}
RATOS_ECHO MSG="Homing Z"
{% if x_homed == False or y_homed == False %}
{ action_emergency_stop("X and Y must be homed before homing Z") }
{% else %}
{% if z_probe == "stowable" %}
DEPLOY_PROBE
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
STOW_PROBE
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
{% endif %}
{% endif %}
{% endif %}
[gcode_macro HOME_X_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
G4 P300
G28 X
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
[gcode_macro HOME_Y_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
G4 P300
G28 Y
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
[gcode_macro _Z_HOP]
description = Move Z axis up by Z_HOP distance at Z_HOP_SPEED. In relative mode it will move Z axis up by Z_HOP distance. In absolute mode it will move Z axis to Z_HOP distance.
gcode =
{% set z_hop = printer.configfile.config.ratos_homing.z_hop|float %}
{% set z_hop_speed = printer.configfile.config.ratos_homing.z_hop_speed|float * 60 %}
G0 Z{z_hop} F{z_hop_speed}
[gcode_macro _MOVE_TO_SAFE_Z_HOME]
description = Move to safe home position with optional Z_HOP (pass Z_HOP=True as parameter)
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% if params.Z_HOP is defined %}
_Z_HOP
{% endif %}
DEBUG_ECHO PREFIX="_MOVE_TO_SAFE_Z_HOME" MSG="axis_maximum.x: {printer.toolhead.axis_maximum.x}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}, safe_home_x: {safe_home_x}, safe_home_y: {safe_home_y}, printable_x_max: {printable_x_max}, printable_y_max: {printable_y_max}"
G0 X{safe_home_x} Y{safe_home_y} F{speed}
[gcode_macro MAYBE_HOME]
description = Only home unhomed axis
variable_is_kinematic_position_overriden = False
gcode =
{% if printer["gcode_macro MAYBE_HOME"].is_kinematic_position_overriden|lower == 'true' %}
RATOS_ECHO MSG="SET_CENTER_KINEMATIC_POSITION has been abused. Homing all axes. Please refrain from using SET_CENTER_KINEMATIC_POSITION outside of debugging purposes."
G28
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=False
{% else %}
{% set axes = '' %}
{% set isHomed = true %}
{% set axesToHome = '' %}
{% if params.X is defined %}
{% set axes = axes ~ 'X ' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% endif %}
{% if params.Y is defined %}
{% set axes = axes ~ 'Y ' %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% endif %}
{% if params.Z is defined %}
{% set axes = axes ~ 'Z ' %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if params.X is not defined and params.Y is not defined and params.Z is not defined %}
{% set axes = '' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if isHomed is false %}
RATOS_ECHO MSG="Homing {axesToHome}"
G28 {axesToHome}
{% else %}
RATOS_ECHO MSG="All requested axes already homed, skipping.."
{% endif %}
{% endif %}
[gcode_macro PID_CALIBRATE_HOTEND]
description = Perform a PID calibration test for a given extruder heater.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set temp = params.TEMP|default(220)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_HOTEND" MSG="TEMP={temp}"
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO MSG="PID calibration hotend heater T0 at {temp}°C..."
PID_CALIBRATE HEATER=extruder TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
{% if toolhead==0 or toolhead==1 %}
RATOS_ECHO MSG="PID calibration hotend heater T{toolhead} at {temp}°C..."
PID_CALIBRATE HEATER=extruder{'' if toolhead==0 else toolhead} TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_BED]
description = Perform a PID calibration test for the bed heater.
gcode =
{% set temp = params.TEMP|default(80)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_BED" MSG="TEMP={temp}"
RATOS_ECHO MSG="PID calibration bed heater at {temp}°C..."
PID_CALIBRATE HEATER=heater_bed TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_CHAMBER_HEATER]
description = Perform a PID calibration test for the chamber heater.
gcode =
{% set temp = params.TEMP|default(150)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_CHAMBER_HEATER" MSG="TEMP={temp}"
{% if printer["heater_generic chamber_heater"] is defined %}
RATOS_ECHO MSG="PID calibration chamber heater at {temp}°C..."
PID_CALIBRATE HEATER=chamber_heater TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_heater" %}
{% set link_text = "RatOS Chamber Heater" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber heater found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro INITIALIZE_PA_TUNING]
description = Start a pressure advance tuning tower.
gcode =
{% set start = params.START|default(0.0)|float %}
{% set factor = params.FACTOR|default(0.001)|float %}
{% set layer_number = printer["gcode_macro _ON_LAYER_CHANGE"].layer_number|default(0)|int %}
{% set is_printing_gcode = true if printer["gcode_macro START_PRINT"].is_printing_gcode|default(true)|lower == 'true' else false %}
{% if is_printing_gcode and layer_number < 2 %}
DEBUG_ECHO PREFIX="START_PA_TOWER" MSG="START: {start}, FACTOR: {factor}"
RATOS_ECHO MSG="Starting presssure advance tuning tower..."
TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START={start} FACTOR={factor}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro CHAMBER_FILTER_ON]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro CHAMBER_FILTER_OFF]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Deactivating chamber filter..."
_CHAMBER_FILTER_TURN_OFF
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro _CHAMBER_FILTER_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set chamber_filter_enable_at = printer["gcode_macro RatOS"].chamber_filter_enable_at|default('after_print_start')|lower %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_ON" MSG="at: {at}, chamber_filter_enable: {chamber_filter_enable}, chamber_filter_enable_at: {chamber_filter_enable_at}, chamber_filter_speed: {chamber_filter_speed}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if chamber_filter_enable_at == at %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON AT={at}
{% if chamber_filter_enable_at == "print_end" %}
_LED_CHAMBER_FILTER_ON
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_FILTER_OFF]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF" MSG="chamber_filter_enable: {chamber_filter_enable}, filter_disable_period: {filter_disable_period}, filter_disable_bed_temp: {filter_disable_bed_temp}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_period > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting {filter_disable_period} seconds before turning chamber filter off..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION={filter_disable_period}
{% endif %}
{% if filter_disable_bed_temp > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting for bed temp to cool down to {filter_disable_bed_temp}°C to turn filter off..."
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM=0 MAXIMUM={filter_disable_bed_temp}
_CHAMBER_FILTER_TURN_OFF
_LED_CHAMBER_FILTER_OFF
{% endif %}
{% endif %}
[delayed_gcode _CHAMBER_FILTER_OFF_TIMER]
gcode =
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF_TIMER" MSG="executed"
_CHAMBER_FILTER_TURN_OFF
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Chamber filter turned off!"
_LED_CHAMBER_FILTER_OFF
[gcode_macro _CHAMBER_FILTER_TURN_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_speed|default(0)|float %}
{% if at == "print_end" %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_disable_speed|default(0)|float %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION=0
SET_FAN_SPEED FAN=filter SPEED={chamber_filter_speed}
[gcode_macro _CHAMBER_FILTER_TURN_OFF]
gcode =
SET_FAN_SPEED FAN=filter SPEED=0
[gcode_macro _CHAMBER_FILTER_SANITY_CHECK]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_bed_temp > 0 and filter_disable_period > 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable, not both.")}
{% endif %}
{% if filter_disable_bed_temp == 0 and filter_disable_period == 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable.")}
{% endif %}
{% endif %}
[gcode_macro CHAMBER_HEATER_ON]
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(45)|int %}
_CHAMBER_HEATER_ON CHAMBER_TEMP={chamber_temp} IS_FROM_START_PRINT=False
[gcode_macro CHAMBER_HEATER_OFF]
gcode =
_CHAMBER_HEATER_OFF
[gcode_macro _CHAMBER_HEATER_ON]
variable_chamber_temp = 0
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set is_from_start_print = true if params.IS_FROM_START_PRINT|default(True)|lower == 'true' else false %}
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set chamber_heater_enable = true if printer["gcode_macro RatOS"].chamber_heater_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
{% set chamber_heater_preheating_temp = printer["gcode_macro RatOS"].chamber_heater_preheating_temp|default(150)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set chamber_heater_control_external_heater = true if printer["gcode_macro RatOS"].chamber_heater_control_external_heater|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_enable = true if printer["gcode_macro RatOS"].chamber_heater_air_circulation_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_fan_speed = printer["gcode_macro RatOS"].chamber_heater_air_circulation_fan_speed|default(0.35)|float %}
{% set chamber_heater_air_circulation_y_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_y_pos|default(0)|float %}
{% set chamber_heater_air_circulation_z_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_z_pos|default(100)|float %}
DEBUG_ECHO PREFIX="_CHAMBER_HEATER_ON" MSG="chamber_heater_enable: {chamber_heater_enable}, chamber_heater_preheating_temp: {chamber_heater_preheating_temp}, chamber_heater_heating_temp_offset: {chamber_heater_heating_temp_offset}, bed_temp: {bed_temp}, chamber_temp: {chamber_temp}, start_chamber_temp: {start_chamber_temp}"
{% if chamber_heater_enable and chamber_temp > 0 and chamber_heater_bed_temp > 0 %}
_LED_HEATING
RATOS_ECHO MSG="Preheating chamber to {(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}°C..."
{% set chamber_temp_sensor = "extruder" %}
{% if printer["dual_carriage"] is defined and default_toolhead == 1 %}
{% set chamber_temp_sensor = "extruder1" %}
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% set chamber_temp_sensor = "temperature_sensor chamber" %}
{% endif %}
{% set current_chamber_temp = printer['%s' % chamber_temp_sensor].temperature|int %}
{% set needs_heating = current_chamber_temp < (start_chamber_temp if start_chamber_temp > 0 else chamber_temp) %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_BEFORE_PREHEATING
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
{% if not is_from_start_print %}
MAYBE_HOME
{% endif %}
G0 Z{chamber_heater_air_circulation_z_pos} F{z_speed}
G0 Y{chamber_heater_air_circulation_y_pos} F{speed}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 1 else 0}
{% else %}
M106 S{(255 * chamber_heater_air_circulation_fan_speed)}
{% endif %}
{% else %}
{% if is_from_start_print %}
G0 Z{z} F{z_speed}
{% endif %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE={chamber_temp}
{% if needs_heating %}
M140 S{chamber_heater_bed_temp}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={chamber_heater_preheating_temp}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if needs_heating %}
_CHAMBER_HEATER_EXTRA_FAN_ON
{% endif %}
{% if needs_heating %}
TEMPERATURE_WAIT SENSOR="{chamber_temp_sensor}" MINIMUM={(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% endif %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED=0
_CHAMBER_FILTER_ON AT="before_print_start"
{% endif %}
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
G28 Z
{% endif %}
{% endif %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_AFTER_PREHEATING
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% if printer["heater_generic chamber_heater"] is defined %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined and chamber_heater_control_external_heater %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
_LED_SUCCESS
{% endif %}
[gcode_macro _CHAMBER_HEATER_OFF]
gcode =
RATOS_ECHO MSG="Deactivating chamber heater..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=0
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE=0
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
_CHAMBER_HEATER_EXTRA_FAN_OFF
[delayed_gcode _CHAMBER_HEATER_CONTROL]
initial_duration = 0.
gcode =
{% set chamber_temp = printer["gcode_macro _CHAMBER_HEATER_ON"].chamber_temp|default(0)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set current_chamber_temp = printer['temperature_sensor chamber'].temperature|int %}
{% if current_chamber_temp < chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if current_chamber_temp >= chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_ON]
gcode =
{% set chamber_heater_extra_fan_speed = printer["gcode_macro RatOS"].chamber_heater_extra_fan_speed|default(0.0)|float %}
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
{% if chamber_heater_extra_fan_speed > 0 %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED={chamber_heater_extra_fan_speed}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_OFF]
gcode =
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED=0
{% endif %}
[gcode_macro _USER_CHAMBER_HEATER_BEFORE_PREHEATING]
description = Will be executed before chamber preheating, only if heating is needed.
gcode =
[gcode_macro _USER_CHAMBER_HEATER_AFTER_PREHEATING]
description = Will be executed after chamber preheating, only if heating was needed.
gcode =
[gcode_macro _LED_START_PRINTING]
gcode =
_LED_ACTION
[gcode_macro _LED_START_PRINTING_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_PRINTING]
gcode =
_LED_ON TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_PAUSE]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_ON]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_OFF]
gcode =
_LED_STANDBY
[gcode_macro _LED_LOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_LOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_RUNOUT]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_CLOG]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_UNLOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_UNLOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_DEACTIVATE_TOOLHEAD]
gcode =
_LED_OFF TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_STANDBY]
gcode =
_LED_STANDBY TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_WAKEUP]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_MOTORS_OFF]
gcode =
_LED_STANDBY
_LED_VAOC_OFF
[gcode_macro _LED_INPUT_SHAPER_START]
gcode =
_LED_ACTION
[gcode_macro _LED_INPUT_SHAPER_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_START]
gcode =
_LED_ACTION
[gcode_macro _LED_BEACON_CALIBRATION_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_VAOC_ON]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=1.0 GREEN=1.0 BLUE=1.0
{% endif %}
[gcode_macro _LED_VAOC_OFF]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=0.0 GREEN=0.0 BLUE=0.0
{% endif %}
[gcode_macro _LED_ACTION]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_action %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SUCCESS]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_success %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_HEATING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_heating %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_COOLING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_cooling %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ERROR]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_error %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ON]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_on %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_OFF]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_off %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_STANDBY]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_standby %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
{% if toolhead >= 0 %}
{% if printer['neopixel nozzle_led_t%s' % toolhead] is defined %}
SET_LED LED={'nozzle_led_t%s' % toolhead} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% else %}
{% if printer['neopixel nozzle_led_t0'] is defined %}
SET_LED LED={'nozzle_led_t0'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% if printer['neopixel nozzle_led_t1'] is defined %}
SET_LED LED={'nozzle_led_t1'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% endif %}
_USER_LED_SET { rawparams }
[gcode_macro _USER_LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
[gcode_macro LOAD_FILAMENT]
description = Loads new filament. Note: be careful with PETG, make sure you inspect the tip of your filament before loading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% if filament_name == '' or filament_type == '' %}
{% set filament_name = 'unknown' %}
{% set filament_type = 'unknown' %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_LOAD_FILAMENT TEMP={temp} NAME={filament_name} TYPE={filament_type}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_LOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME={filament_name} TYPE={filament_type}
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _DEFAULT_LOAD_FILAMENT]
description = Load filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_LOAD_FILAMENT" MSG="TEMP={temp}"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=load_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
_LOAD_FILAMENT TOOLHEAD=0
RESTORE_GCODE_STATE NAME=load_state
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD=0
[gcode_macro _IDEX_LOAD_FILAMENT]
description = Load filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_LOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
_LOAD_FILAMENT TOOLHEAD={toolhead} TEMP={temp}
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into hotend.."
G92 E0
G0 E{extruder_gear_to_cooling_position_distance} F{extruder_load_speed}
G92 E0
M400
RATOS_ECHO MSG="Filament loaded into hotend."
[gcode_macro _LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set load_speed = printer["gcode_macro T%s" % toolhead].filament_load_speed|float * 60 %}
{% set filament_loading_nozzle_offset = printer["gcode_macro T%s" % toolhead].filament_loading_nozzle_offset|float %}
{% set cooling_position_to_nozzle_distance = printer["gcode_macro T%s" % toolhead].cooling_position_to_nozzle_distance|float %}
{% set purge_after_load = printer["gcode_macro T%s" % toolhead].purge_after_load|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into nozzle... Please wait!"
G92 E0
G0 E{cooling_position_to_nozzle_distance + filament_loading_nozzle_offset} F{load_speed}
G92 E0
G4 P1000
_PURGE_FILAMENT TOOLHEAD={toolhead} E={purge_after_load}
RATOS_ECHO MSG="Filament loaded into nozzle!"
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
{% set filament_grabbing_length = printer["gcode_macro T%s" % toolhead].filament_grabbing_length|float %}
{% set filament_grabbing_speed = printer["gcode_macro T%s" % toolhead].filament_grabbing_speed|float %}
{% set resume_after_insert = true if printer["gcode_macro T%s" % toolhead].resume_after_insert|default(true)|lower == 'true' else false %}
{% set enable_insert_detection = true if printer["gcode_macro T%s" % toolhead].enable_insert_detection|default(true)|lower == 'true' else false %}
{% set current_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% if enable_insert_detection %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="toolhead: {toolhead}, filament_grabbing_length: {filament_grabbing_length}, filament_grabbing_speed: {filament_grabbing_speed}, current_idex_mode: {current_idex_mode}"
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
FORCE_MOVE STEPPER={'extruder%s' % ('' if toolhead == 0 else toolhead)} DISTANCE={filament_grabbing_length} VELOCITY={filament_grabbing_speed}
M400
{% if printer.pause_resume.is_paused %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% if resume_after_insert %}
RESUME
{% endif %}
{% else %}
{% if not printer.virtual_sdcard.is_active %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
[gcode_macro _PURGE_BEFORE_UNLOAD]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set purge_before_unload = printer["gcode_macro T%s" % toolhead].purge_before_unload|float %}
DEBUG_ECHO PREFIX="_PURGE_BEFORE_UNLOAD" MSG="TOOLHEAD: {toolhead}"
{% if purge_before_unload > 0 %}
G92 E0
G0 E{purge_before_unload} F300
G92 E0
M400
{% endif %}
[gcode_macro _PURGE_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set e = params.E|int %}
{% set r = params.R|default(0)|int %}
DEBUG_ECHO PREFIX="_PURGE_FILAMENT" MSG="TOOLHEAD: {toolhead}, E: {e}"
{% if e > 0 %}
G92 E0
G0 E{e} F300
G92 E0
M400
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={0.4 if toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={0.4 if toolhead == 1 else 0}
{% else %}
M106 S{(255 * 0.4)}
{% endif %}
{% endif %}
G4 P3000
{% if r > 0 %}
G92 E0
G0 E-{r} F300
G92 E0
M400
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_PARKING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_PARKING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_LOADING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_LOADING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% if act_t == toolhead %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{loading_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CLEANING_MOVE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined and printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% set cleaning_position = loading_position %}
{% if loading_position == parking_position %}
{% if loading_position > 0 %}
{% set cleaning_position = loading_position - 30 %}
{% else %}
{% set cleaning_position = loading_position + 30 %}
{% endif %}
{% endif %}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _START_PRINT_BED_MESH]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
SET_MACRO_TRAVEL_SETTINGS
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set X=[params.X0|default(-1)|float, params.X1|default(-1)|float] %}
{% set Y=[params.Y0|default(-1)|float, params.Y1|default(-1)|float] %}
DEBUG_ECHO PREFIX="_START_PRINT_BED_MESH" MSG="idex_mode: {idex_mode}, X: {X}, Y: {Y}"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set X=[0, printable_x_max] %}
{% endif %}
{% set beacon_bed_mesh_scv = printer["gcode_macro RatOS"].beacon_bed_mesh_scv|default(25)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% if printer.configfile.settings.beacon is defined and not beacon_contact_bed_mesh %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={beacon_bed_mesh_scv}
{% endif %}
{% set default_profile = printer["gcode_macro RatOS"].bed_mesh_profile|default('ratos') %}
{% if printer["gcode_macro RatOS"].calibrate_bed_mesh|lower == 'true' %}
BED_MESH_CLEAR
{% if printer["gcode_macro RatOS"].adaptive_mesh|lower == 'true' %}
CALIBRATE_ADAPTIVE_MESH PROFILE={default_profile} X0={X[0]} X1={X[1]} Y0={Y[0]} Y1={Y[1]} T={params.T|int} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={idex_mode}
{% else %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% endif %}
BED_MESH_PROFILE LOAD={default_profile}
{% elif printer["gcode_macro RatOS"].bed_mesh_profile is defined %}
BED_MESH_CLEAR
BED_MESH_PROFILE LOAD={printer["gcode_macro RatOS"].bed_mesh_profile}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
[gcode_macro CALIBRATE_ADAPTIVE_MESH]
gcode =
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set default_profile = params.PROFILE %}
{% set x0 = params.X0|default(-1)|float %}
{% set y0 = params.Y0|default(-1)|float %}
{% set x1 = params.X1|default(-1)|float %}
{% set y1 = params.Y1|default(-1)|float %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Recieved coordinates X0={x0} Y0={y0} X1={x1} Y1={y1}"
{% if x0 >= x1 or y0 >= y1 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Invalid coordinates received. Please check your slicer settings. Falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float %}
{% set mesh_x0 = [[x0, max_x]|min, min_x]|max %}
{% set mesh_y0 = [[y0, max_y]|min, min_y]|max %}
{% set mesh_x1 = [[x1, max_x]|min, min_x]|max %}
{% set mesh_y1 = [[y1, max_y]|min, min_y]|max %}
{% if mesh_x0 == min_x and mesh_y0 == min_y and mesh_x1 == max_x and mesh_y1 == max_y %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Print is using the full bed, falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
DEPLOY_PROBE
{% endif %}
{% set probe_count_x = mesh_config.probe_count.split(",")[0]|int %}
{% if mesh_config.probe_count.split(",")|length == 2 %}
{% set probe_count_y = mesh_config.probe_count.split(",")[1]|int %}
{% else %}
{% set probe_count_y = mesh_config.probe_count.split(",")[0]|int %}
{% endif %}
{% set probe_x_step = (max_x - min_x) / probe_count_x %}
{% set probe_y_step = (max_y - min_y) / probe_count_y %}
{% set mesh_count_x = ([(mesh_x1 - mesh_x0) / probe_x_step, 3]|max)|int %}
{% set mesh_count_y = ([(mesh_y1 - mesh_y0) / probe_y_step, 3]|max)|int %}
{% set min_mesh_count = [mesh_count_x, mesh_count_y]|min %}
{% set max_mesh_count = [mesh_count_x, mesh_count_y]|max %}
{% set algorithm = mesh_config.algorithm %}
{% if algorithm|lower == 'lagrange' and max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="cannot exceed a probe_count of 6 when using lagrange interpolation. Falling back to bicubic interpolation."
{% set algorithm = 'bicubic' %}
{% endif %}
{% if algorithm|lower == 'bicubic' and min_mesh_count < 4 %}
{% if max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="invalid probe_count option when using bicubic interpolation. Combination of 3 points on one axis with more than 6 on another is not permitted. Forcing minimum mesh count to be 4."
{% set min_mesh_count = 4 %}
{% else %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="bicubic interpolation with a probe_count of less than 4 points detected. Forcing lagrange interpolation."
{% set algorithm = 'lagrange' %}
{% endif %}
{% endif %}
{% set mesh_count_x = ([min_mesh_count, mesh_count_x]|max)|int %}
{% set mesh_count_x = ([max_mesh_count, mesh_count_x]|min)|int %}
{% set mesh_count_y = ([min_mesh_count, mesh_count_y]|max)|int %}
{% set mesh_count_y = ([max_mesh_count, mesh_count_y]|min)|int %}
{% set should_prime = printer["gcode_macro RatOS"].nozzle_priming == 'primeblob' %}
{% if printer["dual_carriage"] is not defined %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% else %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% endif %}
{% if printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 != 0 and probe_first %}
{% set probe_first = false %}
{% elif printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 == 0 and not probe_first %}
{% set probe_first = true %}
{% endif %}
{% if should_prime and probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="mesh coordinates X0={mesh_x0} Y0={mesh_y0} X1={mesh_x1} Y1={mesh_y1}"
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% if should_prime and not probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
STOW_PROBE
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M84]
rename_existing = M84.1
gcode =
M84.1
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
{% if printer["dual_carriage"] is defined %}
_SET_TOOLHEAD_OFFSET T={printer["gcode_macro RatOS"].default_toolhead|int} MOVE=0
SET_GCODE_VARIABLE MACRO=SET_PRESSURE_ADVANCE VARIABLE=snyc_toolheads VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro _VAOC"] is defined %}
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started VALUE=False
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started_at_temp VALUE=False
{% endif %}
SET_GCODE_OFFSET X=0 Y=0 Z=0 MOVE=0
_IDEX_SINGLE INIT=1
{% endif %}
SET_SKEW CLEAR=1
_LED_MOTORS_OFF
[gcode_macro M104]
rename_existing = M104.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
DEBUG_ECHO PREFIX="M104" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set temperature_offset_t0 = printer["gcode_macro T0"].temperature_offset|default(0)|int %}
{% set temperature_offset_t1 = printer["gcode_macro T1"].temperature_offset|default(0)|int %}
{% set s0 = [s + temperature_offset_t0, 0]|max %}
{% set s1 = [s + temperature_offset_t1, 0]|max %}
{% if temperature_offset_t0 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t0}°C added to toolhead T0."
{% endif %}
{% if temperature_offset_t1 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t1}°C added to toolhead T1."
{% endif %}
{% else %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
M104.1 S{s0} T0
M104.1 S{s1} T1
{% else %}
M104.1 S{s} T{t}
{% endif %}
{% endif %}
[gcode_macro M109]
rename_existing = M109.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
DEBUG_ECHO PREFIX="M109" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M109" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
M109.1 S{s} T{t}
{% endif %}
[gcode_macro SET_HEATER_TEMPERATURE]
rename_existing = SET_HEATER_TEMPERATURE_BASE
gcode =
{% set heater = params.HEATER|default("") %}
{% set target = params.TARGET|default(0)|int %}
DEBUG_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="heater: {heater}, target: {target}"
{% if heater|lower == "extruder" or heater|lower == "extruder1" %}
{% set t = 0 if heater|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and target > 0 %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set target = [target + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
SET_HEATER_TEMPERATURE_BASE HEATER="{heater}" TARGET={target}
[gcode_macro TEMPERATURE_WAIT]
rename_existing = TEMPERATURE_WAIT_BASE
gcode =
{% set sensor = params.SENSOR|default("") %}
{% set minimum = params.MINIMUM|default(-1)|int %}
{% set maximum = params.MAXIMUM|default(-1)|int %}
DEBUG_ECHO PREFIX="TEMPERATURE_WAIT" MSG="sensor: {sensor}, minimum: {minimum}, maximum: {maximum}"
{% if sensor|lower == "extruder" or sensor|lower == "extruder1" %}
{% set t = 0 if sensor|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and (minimum > 0 or maximum > 0) %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% if minimum > -1 %}
{% set minimum = [minimum + temperature_offset, 0]|max %}
{% endif %}
{% if maximum > -1 %}
{% set maximum = [maximum + temperature_offset, 0]|max %}
{% endif %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% if minimum > -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum} MAXIMUM={maximum}
{% elif minimum > -1 and maximum == -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum}
{% elif minimum == -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MAXIMUM={maximum}
{% endif %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature for toolhead T{t} reached."
[gcode_macro SET_GCODE_OFFSET]
rename_existing = SET_GCODE_OFFSET_ORG
gcode =
SET_GCODE_OFFSET_ORG { rawparams }
{% if printer.configfile.settings.beacon is defined and (params.Z_ADJUST is defined or params.Z is defined) %}
_BEACON_APPLY_RUNTIME_MULTIPLIER
{% endif %}
[gcode_macro SDCARD_PRINT_FILE]
rename_existing = SDCARD_PRINT_FILE_BASE
gcode =
{% if printer["ratos"] is defined %}
PROCESS_GCODE_FILE { rawparams }
{% else %}
SDCARD_PRINT_FILE_BASE { rawparams }
{% endif %}
[gcode_macro SKEW_PROFILE]
rename_existing = SKEW_PROFILE_BASE
variable_loaded_profile = ""
gcode =
{% if params.LOAD is defined %}
{% if printer.configfile.settings["skew_correction %s" % params.LOAD] is defined %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='"{params.LOAD}"'
{% endif %}
{% endif %}
SKEW_PROFILE_BASE { rawparams }
[gcode_macro SET_SKEW]
rename_existing = SET_SKEW_BASE
gcode =
{% if params.CLEAR is defined %}
{% if params.CLEAR|default(0)|int == 1 %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='""'
{% endif %}
{% endif %}
SET_SKEW_BASE { rawparams }
[gcode_macro SET_VELOCITY_LIMIT]
rename_existing = SET_VELOCITY_LIMIT_BASE
gcode =
{% if params.ACCEL_TO_DECEL is defined %}
{% if params.ACCEL is defined %}
{% set accel = params.ACCEL|float %}
{% else %}
{% set accel = printer.toolhead.max_accel|float %}
{% endif %}
{% if params.VELOCITY is defined %}
{% set velocity = params.VELOCITY|float %}
{% else %}
{% set velocity = printer.toolhead.max_velocity|float %}
{% endif %}
{% if params.SQUARE_CORNER_VELOCITY is defined %}
{% set scv = params.SQUARE_CORNER_VELOCITY|float %}
{% else %}
{% set scv = printer.toolhead.square_corner_velocity|float %}
{% endif %}
{% set mcr = params.ACCEL_TO_DECEL|float / accel %}
DEBUG_ECHO PREFIX="SET_VELOCITY_LIMIT" MSG="ACCEL={accel}, VELOCITY={velocity}, SQUARE_CORNER_VELOCITY={scv}, MINIMUM_CRUISE_RATIO={mcr}"
SET_VELOCITY_LIMIT_BASE ACCEL={accel} VELOCITY={velocity} SQUARE_CORNER_VELOCITY={scv} MINIMUM_CRUISE_RATIO={1-mcr}
{% else %}
SET_VELOCITY_LIMIT_BASE { rawparams }
{% endif %}
[gcode_macro _START_PRINT_PARK]
gcode =
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_x = printer["gcode_macro RatOS"].start_print_park_x %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% endif %}
{% if printer["dual_carriage"] is defined and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
{% if printer["gcode_macro RatOS"].start_print_park_x is defined and printer["gcode_macro RatOS"].start_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="start_print_park_x is ignored for IDEX printers"
{% endif %}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={start_print_park_in} X={start_print_park_x}
G0 Z{z} F{z_speed}
[gcode_macro _END_PRINT_PARK]
gcode =
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro RatOS"].end_print_park_x is defined and printer["gcode_macro RatOS"].end_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="end_print_park_x is ignored for IDEX printers"
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={printer["gcode_macro RatOS"].end_print_park_in} X={printer["gcode_macro RatOS"].end_print_park_x}
[gcode_macro _PARK]
gcode =
{% set x = params.X %}
{% set location = params.LOCATION|default('back')|lower %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set nozzle_priming = printer["gcode_macro RatOS"].nozzle_priming|lower %}
CACHE_TOOLHEAD_SETTINGS KEY="park"
SET_MACRO_TRAVEL_SETTINGS
{% if x != '' %}
{% if x|float >= printer.toolhead.axis_minimum.x + 5 and x|float <= printable_x_max - 5 %}
{% set park_x = x|float %}
{% else %}
{action_respond_info('The requested X co-ordinate is outside the defined axis bounds - using defaults')}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% else %}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% set park_y = printable_y_max - 15 %}
{% if location == 'front' %}
{% set park_y = printer.toolhead.axis_minimum.y + 5 %}
{% elif location == 'center' %}
{% set park_y = printable_y_max / 2 %}
{% elif location == 'primeblob' and printer["dual_carriage"] is defined %}
{% set park_y = printable_y_max - 15 %}
{% endif %}
{% if location == 'primeblob' and printer["dual_carriage"] is not defined %}
{% if (nozzle_priming == 'primeblob' or nozzle_priming == 'primeline') %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set park_x = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set park_x = printable_x_max - 5 %}
{% else %}
{% set park_x = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set park_y = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set park_y = printable_y_max - 5 %}
{% else %}
{% set park_y = nozzle_prime_start_y|float %}
{% endif %}
{% endif %}
{% endif %}
G90
{% if printer["dual_carriage"] is not defined %}
G0 X{park_x} Y{park_y} F{speed}
{% else %}
G0 Y{park_y} F{speed}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="park"
[gcode_macro SAVE_PROBE_RESULT]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
{% set last_z_offset = 9999.9 %}
{% if printer.configfile.settings.beacon is defined %}
{% set current_z = printer.toolhead.position.z|float %}
{% if beacon_contact_prime_probing %}
{% set last_z_offset = printer.beacon.last_z_result %}
{% else %}
{% set last_z_offset = printer.beacon.last_sample.dist - current_z %}
{% endif %}
{% elif printer.configfile.settings.bltouch is defined %}
{% set config_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% elif printer.configfile.settings.probe is defined %}
{% set config_offset = printer.configfile.settings.probe.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Saving offset adjustment of {last_z_offset} in {params.VARIABLE|default('last_z_offset')}"
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE={params.VARIABLE|default('last_z_offset')} VALUE={last_z_offset}
[gcode_macro PROBE_FOR_PRIMING]
gcode =
{% set probe_for_priming_disable_mesh_constraints = true if printer["gcode_macro RatOS"].probe_for_priming_disable_mesh_constraints|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower != 'false' %}
SAVE_GCODE_STATE NAME=probe_for_priming_state
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the prime location.."
CACHE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
SET_MACRO_TRAVEL_SETTINGS
{% set t = params.TOOLHEAD|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% if idex_mode == '' %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% if t == 0 %}
{% set x_start = 5 %}
{% else %}
{% set x_start = printable_x_max - 5 %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% endif %}
{% endif %}
{% set z = printer.configfile.settings.bed_mesh.horizontal_move_z|float %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% if printer.configfile.settings.bltouch is defined %}
{% set x_offset = printer.configfile.settings.bltouch.x_offset|float %}
{% set y_offset = printer.configfile.settings.bltouch.y_offset|float %}
{% set z_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% elif printer.configfile.settings.probe is defined %}
{% set x_offset = printer.configfile.settings.probe.x_offset|float %}
{% set y_offset = printer.configfile.settings.probe.y_offset|float %}
{% set z_offset = printer.configfile.settings.probe.z_offset|float %}
{% elif printer.configfile.settings.beacon is defined %}
{% set x_offset = printer.configfile.settings.beacon.x_offset|float %}
{% set y_offset = printer.configfile.settings.beacon.y_offset|float %}
{% set z_offset = printer.configfile.settings.beacon.trigger_distance|float %}
{% else %}
{ action_raise_error("No probe, beacon or bltouch section found. Adaptive priming only works with a [probe], [beacon] or [bltouch] section defined.") }
{% endif %}
{% if z < z_offset %}
{ action_raise_error("Horizontal move Z ({z}) is below your probe's Z offset ({z_offset}). Please adjust your horizontal_move_z setting in [bed_mesh] to be above {z}.") }
{% endif %}
{% if not probe_for_priming_disable_mesh_constraints %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float - x_offset %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float - y_offset %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float - x_offset %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float - y_offset %}
{% set x_start = [[x_start, max_x]|min, min_x]|max %}
{% set y_start = [[y_start, max_y]|min, min_y]|max %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the start of the prime location at {x_start}, {y_start}"
G90
M83
G0 Z{z} F{z_speed}
G1 X{x_start} Y{y_start} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result
{% endif %}
{% if idex_mode == '' %}
{% set x_end = x_start %}
{% set y_end = y_start + 45 %}
{% else %}
{% if t==1 %}
{% set x_end = x_start - 45 %}
{% else %}
{% set x_end = x_start + 45 %}
{% endif %}
{% set y_end = y_start %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the end of the prime location at {x_end}, {y_end}"
G1 X{x_end} Y{y_end} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result
{% endif %}
RESTORE_GCODE_STATE NAME=probe_for_priming_state
RESTORE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
{% endif %}
[gcode_macro RESET_PRIME_PROBE_STATE]
gcode =
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result VALUE=None
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result_t1 VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result_t1 VALUE=None
{% endif %}
[gcode_macro PROBE_CURRENT_POSITION]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
SAVE_GCODE_STATE NAME=probe_current_position_state
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
ASSERT_PROBE_DEPLOYED
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_prime_probing %}
PROBE PROBE_METHOD=contact SAMPLES=1
{% else %}
PROBE
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
BEACON_QUERY
{% else %}
RESTORE_GCODE_STATE NAME=probe_current_position_state MOVE=1 MOVE_SPEED={printer["gcode_macro RatOS"].macro_z_speed|float}
{% endif %}
[gcode_macro PRIME_BLOB]
description = Prints a primeblob, used internally, if configured, as part of the START_PRINT macro.
variable_x_offset = 5
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="prime_blob"
SET_MACRO_TRAVEL_SETTINGS
RATOS_ECHO PREFIX="Priming" MSG="Priming nozzle with prime blob.."
{% set current_toolhead = 0 %}
{% set target_idex_mode = '' %}
{% set extruder = 'extruder' %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE is defined %}
{% set target_idex_mode = params.IDEX_MODE|default('')|lower %}
{% else %}
{ action_raise_error("IDEX_MODE parameter not found for PRIME_BLOB macro. This is likely a bug.") }
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Priming in IDEX {target_idex_mode} mode.."
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set current_toolhead = 1 if current_idex_mode=='primary' else 0 %}
{% set extruder = 'extruder1' if current_toolhead == 1 else 'extruder' %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
SAVE_GCODE_STATE NAME=prime_blob_state
{% endif %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set fan_speed = printer["gcode_macro RatOS"].nozzle_prime_bridge_fan|float %}
{% set nozzle_diameter = printer.configfile.settings[extruder].nozzle_diameter|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set has_start_offset_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) != 9999.9 %}
{% if printer["dual_carriage"] is defined %}
{% set has_start_offset_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) != 9999.9 %}
{% endif %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_z_height = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set nozzle_prime_direction = printer["gcode_macro RatOS"].nozzle_prime_direction|lower %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% if target_idex_mode == '' %}
{% set x_factor = 0 %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% set y_factor = 1 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% set y_factor = -1 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% if nozzle_prime_start_y|float < printable_y_max / 2 %}
{% set y_factor = 1 %}
{% else %}
{% set y_factor = -1 %}
{% endif %}
{% endif %}
{% if nozzle_prime_direction == 'forwards' %}
{% set y_factor = 1 %}
{% elif nozzle_prime_direction == 'backwards' %}
{% set y_factor = -1 %}
{% endif %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% else %}
{% set z = start_print_park_z_height %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% set y_factor = 0 %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set x_start = center_x / 2 + 5 %}
{% set x_factor = 1 %}
{% else %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% if current_toolhead == 0 %}
{% set x_start = 55 %}
{% set x_factor = -1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 55 %}
{% set x_factor = 1 %}
{% endif %}
{% else %}
{% if current_toolhead == 0 %}
{% set x_start = 5 %}
{% set x_factor = 1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 5 %}
{% set x_factor = -1 %}
{% endif %}
{% endif %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_x_max - 5 %}
{% endif %}
{% set z = 10 %}
{% endif %}
{% set start_z_offset = 0 %}
{% set end_z_offset = 0 %}
{% if has_start_offset_t0 %}
{% set start_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) %}
{% set end_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_end_result|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t0) ) }
{% endif %}
{% if end_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t0) ) }
{% endif %}
{% set start_z_offset = start_z_probe_result_t0 %}
{% set end_z_offset = end_z_probe_result_t0 %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if current_toolhead == 1 or both_toolheads or target_idex_mode == "copy" or target_idex_mode == "mirror" %}
{% if has_start_offset_t1 %}
{% set start_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) %}
{% set end_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_end_result_t1|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t1) ) }
{% endif %}
{% if end_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t1) ) }
{% endif %}
{% set start_z_offset = [start_z_offset, start_z_probe_result_t1]|max %}
{% set end_z_offset = [end_z_offset, start_z_probe_result_t1]|max %}
{% endif %}
{% endif %}
{% if target_idex_mode != 'copy' and target_idex_mode != 'mirror' %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% set original_start_z_offset = start_z_offset %}
{% set original_end_z_offset = end_z_offset %}
{% set start_z_offset = original_end_z_offset %}
{% set end_z_offset = original_start_z_offset %}
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={current_toolhead}
{% endif %}
DEBUG_ECHO PREFIX="PRIME_BLOB" MSG="x_start: {x_start}, y_start: {y_start}, x_factor: {x_factor}, y_factor: {y_factor}, z: {z}, start_z_offset: {start_z_offset}, end_z_offset: {end_z_offset}"
G90
M83
RATOS_ECHO PREFIX="Priming" MSG="Lifting Z to {z}.."
G0 Z{z} F{z_speed}
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% if start_print_park_in != 'primeblob' %}
G1 X{x_start} F{speed}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% endif %}
{% else %}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% if target_idex_mode=="copy" or target_idex_mode=="mirror" %}
RATOS_ECHO PREFIX="Priming" MSG="Mirroring move to {x_start}, {y_start} along the edge of the print area.."
_IDEX_MIRROR PRIMING=1
{% else %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% endif %}
G1 X{x_start} F{speed}
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Starting prime blob.."
G1 Z{0.5 + start_z_offset} F{z_speed}
G1 Y{y_start} F{speed}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
M106 S{fan_speed}
G1 Z5 F100 E5
G92 E0
RATOS_ECHO PREFIX="Priming" MSG="Bridging with {((fan_speed/255) * 100)|int}% fan speed.."
G1 F3000 X{x_start + (15 * x_factor)} Y{y_start + (15 * y_factor)} E{1 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (20 * x_factor)} Y{y_start + (20 * y_factor)} Z{3.8 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (34 * x_factor)} Y{y_start + (34 * y_factor)} Z{2.6 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (38 * x_factor)} Y{y_start + (38 * y_factor)} Z{1.4 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (42 * x_factor)} Y{y_start + (42 * y_factor)} Z{0.2 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
M106 S0
G1 F3000 X{x_start + (46 * x_factor)} Y{y_start + (46 * y_factor)} Z{0.2 + end_z_offset} E0.6
G1 F{speed} X{x_start + (50 * x_factor)} Y{y_start + (50 * y_factor)}
{% if target_idex_mode == "copy" or target_idex_mode == "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if target_idex_mode == "copy" %}
{% if first_y >= 0 %}
_IDEX_COPY DANCE=0 Y={first_y}
{% else %}
_IDEX_COPY DANCE=0 Y={params.Y1}
{% endif %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
RESTORE_GCODE_STATE NAME=prime_blob_state
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="prime_blob"
G92 E0
[gcode_macro UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% set temp = params.TEMP|default(220)|int %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_UNLOAD_FILAMENT TEMP={temp} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _LEGACY_UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set unload_speed = 5 * 60 %}
{% set unload_length = printer["gcode_macro RatOS"].filament_unload_length|float %}
M117 Unloading filament...
G0 E10 F300
G0 E-5 F3600
G4 P3000
G0 E5 F6000
G0 E-15 F6000
G0 E-{unload_length} F{unload_speed}
_CLEANING_MOVE TOOLHEAD={toolhead}
M117 Filament unloaded!
RESPOND MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _DEFAULT_UNLOAD_FILAMENT]
description = Unload filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_UNLOAD_FILAMENT" MSG="TEMP: {temp}"
_LED_UNLOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=unload_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD=0 NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TOOLHEAD=0
{% endif %}
RESTORE_GCODE_STATE NAME=unload_state
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD=0
[gcode_macro _IDEX_UNLOAD_FILAMENT]
description = Unload filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_UNLOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead}
{% endif %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Unloading filament from nozzle to cooling zone... Please wait!"
_PURGE_BEFORE_UNLOAD TOOLHEAD={toolhead}
{% if printer["gcode_macro _UNLOAD_WITHOUT_TIP_FORMING"] is defined %}
_UNLOAD_WITHOUT_TIP_FORMING TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_UNLOAD_WITH_TIP_FORMING NAME='{filament_name}' TYPE='{filament_type}'
{% endif %}
G4 P3000
[gcode_macro _UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
{% set tooolhead_sensor_to_extruder_gear_distance = printer["gcode_macro T%s" % toolhead].tooolhead_sensor_to_extruder_gear_distance|float %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER" MSG="TOOLHEAD: {toolhead}"
G0 E-{extruder_gear_to_cooling_position_distance + tooolhead_sensor_to_extruder_gear_distance + 50} F{extruder_load_speed}
RATOS_ECHO MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _UNLOAD_WITH_TIP_FORMING]
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% if filament_name != '' and filament_type != '' %}
_UNLOAD_KNOWN_FILAMENT NAME={filament_name} TYPE={filament_type}
{% else %}
_UNLOAD_UNKNOWN_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _UNLOAD_KNOWN_FILAMENT]
description = User overrideable tip forming macro if slicer filament profiles are known
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
RATOS_ECHO PREFIX="FILAMENT TYPE" MSG='{filament_type}'
RATOS_ECHO PREFIX="FILAMENT PROFILE" MSG='{filament_name}'
{% if filament_name == "Prusament PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% elif filament_name == "Nobufil PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% else %}
RATOS_ECHO PREFIX="_UNLOAD_KNOWN_FILAMENT" MSG="Filament profile not found!"
_UNLOAD_UNKNOWN_FILAMENT
{% endif %}
[gcode_macro _UNLOAD_UNKNOWN_FILAMENT]
description = User overrideable standard tip forming macro
gcode =
DEBUG_ECHO PREFIX="_UNLOAD_UNKNOWN_FILAMENT" MSG="Using standard tip forming macro!"
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
[gcode_macro _TIP_FORMING]
gcode =
{% set cooling_moves = params.COOLING_MOVES|default(4)|int %}
{% set cooling_move_length = params.COOLING_MOVE_LENGTH|default(10)|float %}
{% set start_cooling_speed = params.START_COOLING_SPEED|default(10)|float * 60 %}
{% set end_cooling_speed = params.END_COOLING_SPEED|default(50)|float * 60 %}
{% if cooling_moves == 0 %}
{% set cooling_move_length = 0 %}
{% endif %}
{% set dip = true if params.DIP|default(false)|lower == "true" else false %}
{% set dip_length = params.DIP_LENGTH|default(22)|float %}
{% set dip_speed = params.DIP_SPEED|default(30)|float * 60 %}
{% set dip_retract_speed = params.DIP_RETRACT_SPEED|default(70)|float * 60 %}
{% set retract_length = params.RETRACT_LENGTH|default(18)|float %}
{% set start_retract_speed = params.START_RETRACT_SPEED|default(120)|float * 60 %}
{% set end_retract_speed = params.END_RETRACT_SPEED|default(20)|float * 60 %}
DEBUG_ECHO PREFIX="_TIP_FORMING" MSG="cooling_moves: {cooling_moves}, cooling_move_length: {cooling_move_length}, start_cooling_speed: {start_cooling_speed}, end_cooling_speed: {end_cooling_speed}, dip: {dip}, dip_length: {dip_length}, dip_speed: {dip_speed}, dip_retract_speed: {dip_retract_speed}, retract_length: {retract_length}, start_retract_speed: {start_retract_speed}, end_retract_speed: {end_retract_speed}"
M220 S100
G92 E0
{% set retract = retract_length + cooling_move_length / 2 - 15 %}
G1 E-15 F{start_retract_speed}
G1 E-{0.7 * retract} F{1.0 * end_retract_speed}
G1 E-{0.2 * retract} F{0.5 * end_retract_speed}
G1 E-{0.1 * retract} F{0.3 * end_retract_speed}
G92 E0
{% if cooling_moves > 0 %}
{% set i = (end_cooling_speed - start_cooling_speed) / (2 * cooling_moves - 1) %}
{% for m in range(cooling_moves) %}
G1 E{cooling_move_length} F{(start_cooling_speed + i * m * 2)}
G1 E-{cooling_move_length} F{(start_cooling_speed + i * (m * 2 + 1))}
{% endfor %}
{% endif %}
G92 E0
{% if dip %}
G1 E{dip_length} F{dip_speed}
G4 P100
G1 E-{dip_length} F{dip_retract_speed}
{% endif %}
G92 E0
M400
[gcode_macro _ON_FILAMENT_SENSOR_BUTTON_PRESSED]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_SENSOR_BUTTON_PRESSED" MSG="TOOLHEAD: {toolhead}"
{% if not printer.virtual_sdcard.is_active %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_FILAMENT_END]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set clogged = true if params.CLOGGED|default(false)|lower == 'true' else false %}
{% set unload_after_runout = printer["gcode_macro T%s" % toolhead].unload_after_runout|float %}
{% if clogged %}
_LED_FILAMENT_CLOG TOOLHEAD={toolhead}
{% else %}
_LED_FILAMENT_RUNOUT TOOLHEAD={toolhead}
{% endif %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_END" MSG="TOOLHEAD: {toolhead}"
{% if printer.virtual_sdcard.is_active %}
{% if not printer.pause_resume.is_paused %}
PAUSE RUNOUT=True
{% endif %}
{% if not clogged and unload_after_runout %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% if not clogged and printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true'%}
_JOIN_SPOOL TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M600]
description = Executes a color change by pausing the printer an unloading the filament.
gcode =
PAUSE
UNLOAD_FILAMENT
RATOS_ECHO MSG="Please load new filament and resume"
[gcode_macro COLD_PULL]
description = Automated hotend cold pull.
gcode =
{% set extrusion_temp = params.EXTRUSION_TEMP|default(220)|int %}
{% set cold_pull_temp = params.COLD_PULL_TEMP|default(80)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% if printer["dual_carriage"] is not defined %}
{% set toolhead = 0 %}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead != 0 and toolhead != 1 %}
{action_raise_error("Please select toolhead! 0 = left, 1 = right toolhead")}
{% endif %}
{% endif %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
SAVE_GCODE_STATE NAME=cold_pull_state
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
RATOS_ECHO MSG="Heating T{toolhead} to {extrusion_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={extrusion_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={extrusion_temp} MAXIMUM={extrusion_temp + 2}
G4 P3000
RATOS_ECHO MSG="extruding..."
G92 E0
G1 E30 F300
G92 E0
RATOS_ECHO MSG="Heating T{toolhead} to {cold_pull_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={cold_pull_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={cold_pull_temp} MAXIMUM={cold_pull_temp + 2}
G4 P10000
RATOS_ECHO MSG="cold pull..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-40 VELOCITY=5 ACCEL=100
RATOS_ECHO MSG="eject filament..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-200 VELOCITY=20 ACCEL=500
RATOS_ECHO MSG="cooling down extruder..."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET=0
RESTORE_GCODE_STATE NAME=cold_pull_state
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
CONSOLE_ECHO TITLE="Cold pull finished!" MSG="Please remove the filament from the PTFE tube and cut the end off. Do NOT try to load it again." TYPE="warning"
[gcode_macro _USER_START_PRINT_BEFORE_HOMING]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_BED]
gcode =
[gcode_macro _USER_START_PRINT_BED_MESH]
gcode =
[gcode_macro _USER_START_PRINT_PARK]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
[gcode_macro _USER_START_PRINT_HEAT_CHAMBER]
description = Uses the extruder sensor to wait for chamber temp. Override the _START_PRINT_HEAT_CHAMBER macro to implement heated chamber handling.
gcode =
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
[gcode_macro _USER_END_PRINT_BEFORE_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_AFTER_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_PARK]
gcode =
[gcode_macro _USER_END_PRINT_FINISHED]
description = User hook for when the print is finished after gcode state has been restored.
gcode =
[gcode_macro _USER_START_PRINT]
gcode =
[gcode_macro _USER_END_START_PRINT]
gcode =
[gcode_macro _USER_START_FEATURE]
gcode =
[gcode_macro _USER_END_FEATURE]
gcode =
[gcode_macro ECHO_T_VARS]
description = Echo Toolhead variables to the console.
gcode =
{% set t = params.T|default(0) %}
RATOS_ECHO MSG="T{t} Variables"
{% for var, value in printer["gcode_macro T%s" % t].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[gcode_macro ECHO_RATOS_VARS]
description = Echo RatOS variables to the console.
gcode =
{% for var, value in printer["gcode_macro RatOS"].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[delayed_gcode RATOS_INIT]
initial_duration = 0.1
gcode =
_LED_STANDBY
CALCULATE_PRINTABLE_AREA
INITIAL_FRONTEND_UPDATE
_CHAMBER_FILTER_SANITY_CHECK
[delayed_gcode RATOS_LOGO]
initial_duration = 2
gcode =
HELLO_RATOS
[gcode_macro INITIAL_FRONTEND_UPDATE]
gcode =
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_error = printer["gcode_macro RatOS"].status_color_error|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_unknown}"'
{% endif %}
{% set t0_sensor = "undefined" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].filament_detected|lower == "true" %}
{% set t0_sensor = "detected" %}
{% else %}
{% set t0_sensor = "empty" %}
{% endif %}
{% else %}
{% set t0_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set t1_sensor = "undefined" %}
{% if printer["dual_carriage"] is defined and printer["filament_switch_sensor toolhead_filament_sensor_t1"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].filament_detected|lower == "true" %}
{% set t1_sensor = "detected" %}
{% else %}
{% set t1_sensor = "empty" %}
{% endif %}
{% else %}
{% set t1_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set svv = printer.save_variables.variables %}
{% if svv.t0_filament is defined and printer["gcode_macro T0"] is defined %}
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
{% if t0_sensor != "empty" %}
{% set t0_filament_type = svv.t0_filament[0]|default('')|string %}
{% set t0_filament_name = svv.t0_filament[1]|default('')|string %}
{% set t0_filament_temp = svv.t0_filament[2]|default(0)|float %}
{% if t0_filament_name != '' and t0_filament_type != '' and t0_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{t0_filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{t0_filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={t0_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
{% if svv.t1_filament is defined and printer["gcode_macro T1"] is defined %}
{% if printer["gcode_macro T1"].filament_name is defined and printer["gcode_macro T1"].filament_type is defined and printer["gcode_macro T1"].filament_temp is defined %}
{% if t1_sensor != "empty" %}
{% set t1_filament_type = svv.t1_filament[0]|default('')|string %}
{% set t1_filament_name = svv.t1_filament[1]|default('')|string %}
{% set t1_filament_temp = svv.t1_filament[2]|default(0)|float %}
{% if t1_filament_name != '' and t1_filament_type != '' and t1_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='"{t1_filament_name}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='"{t1_filament_type}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE={t1_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t1_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro CALCULATE_PRINTABLE_AREA]
gcode =
{% set bed_margin_x = printer["gcode_macro RatOS"].bed_margin_x %}
{% set bed_margin_y = printer["gcode_macro RatOS"].bed_margin_y %}
{% set tool = 0 if printer["gcode_macro T0"] is not defined or printer["gcode_macro T0"].active else 1 %}
{% set max_x = printer.toolhead.axis_maximum.x if printer["dual_carriage"] is defined and tool == 0 else printer.toolhead.axis_maximum.x - bed_margin_x[1] %}
{% if printer["dual_carriage"] is defined %}
{% set max_x = printer.toolhead.axis_maximum.x %}
{% endif %}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="printer.toolhead.axis_maximum.x {printer.toolhead.axis_maximum.x}"
{% set max_y = printer.toolhead.axis_maximum.y - bed_margin_y[1]%}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_x_max VALUE={max_x}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_y_max VALUE={max_y}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="Printable area calculated: X: 0,{max_x} Y: 0,{max_y}"
[gcode_macro CACHE_TOOLHEAD_SETTINGS]
variable_cache = {"global": {"accel": 1000, "ratio": 0.5, "speed": 50, "scv": 5}}
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set dummy = cache.__setitem__(key, {"accel": printer.toolhead.max_accel, "ratio": printer.toolhead.minimum_cruise_ratio, "speed": printer.toolhead.max_velocity, "scv": printer.toolhead.square_corner_velocity}) %}
SET_GCODE_VARIABLE MACRO=CACHE_TOOLHEAD_SETTINGS VARIABLE=cache VALUE="{cache | pprint | replace("\n", "") | replace("\"", "\\\"")}"
DEBUG_ECHO PREFIX="CACHE_TOOLHEAD_SETTINGS" MSG="Toolhead settings cached for {key}. {printer.toolhead.max_accel} accel, {printer.toolhead.minimum_cruise_ratio} ratio, {printer.toolhead.max_velocity} velocity, {printer.toolhead.square_corner_velocity} scv."
[gcode_macro RESTORE_TOOLHEAD_SETTINGS]
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set values = printer["gcode_macro CACHE_TOOLHEAD_SETTINGS"].cache.__getitem__(key) %}
{% if values is not defined or values == 'None' %}
{ action_raise_error("RESTORE_TOOLHEAD_SETTINGS: Toolhead settings not cached for key '" ~ key ~ "'.") }
{% endif %}
SET_VELOCITY_LIMIT ACCEL={values.accel} MINIMUM_CRUISE_RATIO={values.ratio} VELOCITY={values.speed} SQUARE_CORNER_VELOCITY={values.scv}
DEBUG_ECHO PREFIX="RESTORE_TOOLHEAD_SETTINGS" MSG="Toolhead settings restored. {values.accel} accel, {values.ratio} ratio, {values.speed} velocity, {values.scv} scv."
[gcode_macro SET_MACRO_TRAVEL_SETTINGS]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set accel = printer["gcode_macro RatOS"].macro_travel_accel %}
SET_VELOCITY_LIMIT ACCEL={accel} MINIMUM_CRUISE_RATIO=0.5 VELOCITY={speed} SQUARE_CORNER_VELOCITY={5}
DEBUG_ECHO PREFIX="SET_MACRO_TRAVEL_SETTINGS" MSG="Macro travel settings set. {accel} accel, {speed} velocity"
[gcode_macro SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% if printer["dual_carriage"] is not defined %}
SET_KINEMATIC_POSITION X={printable_x_max / 2} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
{% else %}
IDEX_SET_CENTER_KINEMATIC_POSITION
{% endif %}
[gcode_macro IDEX_SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set center_x = printable_x_max / 2 %}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x - (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x + (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
[gcode_macro VERIFY_HYBRID_INVERTED]
gcode =
{% set inverted = False %}
{% if printer.configfile.settings.ratos_hybrid_corexy is defined and printer.configfile.settings.ratos_hybrid_corexy.inverted is defined %}
{% if printer.configfile.settings.ratos_hybrid_corexy.inverted|lower == 'true' %}
{% set inverted = True %}
{% endif %}
{% endif %}
{% if inverted == False %}
{ action_emergency_stop("ratos_hybrid_corexy NOT INVERTED! Inverted hybrid core-xy bugfix not detected.") }
{% endif %}
[gcode_macro RATOS_ECHO]
gcode =
{% set prefix = "RatOS" %}
{% set debug = params.DEBUG|default(0)|int %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " | " ~ params.PREFIX %}
{% endif %}
{% set prefix = prefix ~ ":" %}
{% set msg = "" %}
{% if params.MSG is defined %}
{% set msg = params.MSG %}
{% else %}
{% set msg = "No msg parameter provided (this is a bug or unintended use)." %}
{% endif %}
{% if not debug %}
M117 {prefix} {msg}
{% endif %}
RATOS_LOG PREFIX="{prefix}" MSG="{msg}"
{% if not debug %}
RESPOND PREFIX="{prefix}" MSG="{msg}"
{% else %}
CONSOLE_ECHO TITLE="{prefix}" TYPE="debug" MSG="{msg}"
{% endif %}
[gcode_macro ENABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=True
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=prefix_filter VALUE="'{params.FILTER|default('')|lower}'"
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging enabled."
[gcode_macro DISABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=False
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging disabled."
[gcode_macro DEBUG_ECHO]
variable_enabled = False
variable_prefix_filter = ''
gcode =
{% set prefix = "DEBUG" %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " - " ~ params.PREFIX %}
{% endif %}
{% if enabled and (prefix_filter|lower == '' or prefix_filter|lower in params.PREFIX|lower) %}
RATOS_ECHO PREFIX="{prefix}" MSG="{params.MSG}" DEBUG=1
{% endif %}
[gcode_macro START_FEATURE]
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="Start {params.FEATURE} feature gcode"
{% set scv = printer.toolhead.square_corner_velocity|int|default(5) %}
{% set accel = printer.toolhead.max_accel|int|default(10000) %}
{% set ratio = printer.toolhead.minimum_cruise_ratio|float|default(0.5) %}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="scv" VALUE={scv}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="accel" VALUE={accel}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="ratio" VALUE={ratio}
_USER_START_FEATURE FEATURE="{params.FEATURE}"
[gcode_macro END_FEATURE]
variable_scv = 5
variable_accel = 10000
variable_ratio = 0.5
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="End {params.FEATURE} feature gcode"
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={scv} ACCEL={accel} MINIMUM_CRUISE_RATIO={ratio}
_USER_END_FEATURE FEATURE="{params.FEATURE}" SCV={scv} ACCEL={accel} RATIO={ratio}
[gcode_macro _ON_LAYER_CHANGE]
variable_layer_number = 0
description = INTERNAL USE ONLY. Call it from the slicers after layer change custom gcode
gcode =
{% set layer = params.LAYER|int %}
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE={layer}
SET_PRINT_STATS_INFO CURRENT_LAYER={layer}
[gcode_macro _LEARN_MORE_CALIBRATION]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/calibration" %}
{% set link_text = "RatOS Calibration Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_CHAMBER_FILTER]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter Control" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_FILAMENT]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/filaments" %}
{% set link_text = "RatOS Filament Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _CONSOLE_SAVE_CONFIG]
gcode =
M118 Click SAVE_CONFIG to save the settings to your printer.cfg.
[gcode_macro SAVE_Z_OFFSET]
gcode =
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SAVE_MULTIPLIER
{% else %}
Z_OFFSET_APPLY_PROBE
{% endif %}
[gcode_macro _LOAD_RATOS_SKEW_PROFILE]
gcode =
{% set ratos_skew_profile = printer["gcode_macro RatOS"].skew_profile|default("") %}
{% if ratos_skew_profile != "" %}
{% if printer.configfile.config["skew_correction %s" % ratos_skew_profile] is defined %}
SKEW_PROFILE LOAD={ratos_skew_profile}
GET_CURRENT_SKEW
{% else %}
{% set line_1 = '"Could not find skew profile %s!_N_Clearing skew correction."' % ratos_skew_profile %}
CONSOLE_ECHO TITLE="Missing skew profile!" TYPE="warning" MSG={line_1}
SET_SKEW CLEAR=1
{% endif %}
{% endif %}
[gcode_macro M601]
gcode =
PAUSE
[gcode_macro PAUSE]
description = Pauses the print
rename_existing = PAUSE_BASE
variable_extrude = 1.5
variable_retract = 1.5
variable_fan_speed = 0
variable_idex_mode = ""
variable_idex_toolhead = 0
variable_idex_toolhead_x = 0.0
variable_idex_toolhead_y = 0.0
variable_idex_toolhead_z = 0.0
gcode =
{% set runout_detected = true if params.RUNOUT|default(false)|lower == 'true' else false %}
_LED_PAUSE
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set idex_toolhead = 1 if idex_mode == 'primary' else 0 %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
SAVE_GCODE_STATE NAME=PAUSE_state
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_mode VALUE='"{idex_mode}"'
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead VALUE={idex_toolhead}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_x VALUE={printer.gcode_move.gcode_position.x|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_y VALUE={printer.gcode_move.gcode_position.y|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_z VALUE={printer.gcode_move.gcode_position.z|float}
DEBUG_ECHO PREFIX="PAUSE" MSG="idex_mode: {idex_mode}, idex_toolhead: {idex_toolhead}, idex_toolhead_x: {idex_toolhead_x}, idex_toolhead_y: {idex_toolhead_y}, idex_toolhead_z: {idex_toolhead_z}"
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
CACHE_TOOLHEAD_SETTINGS KEY="pause"
SET_MACRO_TRAVEL_SETTINGS
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% if current_z < (max_z - 20.0) %}
{% set z_safe = 20.0 %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
PAUSE_BASE
{% if printer["dual_carriage"] is not defined %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan"].speed|float}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
{% if idex_toolhead == 0 %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t1"].speed|float}
{% endif %}
{% endif %}
{% endif %}
M106 S0
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if idex_mode != '' %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set R = printer["gcode_macro PAUSE"].retract|float %}
{% if can_extrude %}
G91
G1 E-{R} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].pause_print_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].pause_print_park_in %}
{% if runout_detected %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].runout_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].runout_park_in %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
DEBUG_ECHO PREFIX="PAUSE" MSG="z_speed: {z_speed}, pause_print_park_x: {pause_print_park_x}, pause_print_park_in: {pause_print_park_in}, default_toolhead: {default_toolhead}"
{% if "xyz" in printer.toolhead.homed_axes %}
G91
G1 Z{z_safe} F{z_speed}
G90
{% if printer["dual_carriage"] is not defined %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% else %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
_IDEX_SINGLE X={parking_position}
{% else %}
PARK_TOOLHEAD
{% endif %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% endif %}
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="pause"
[gcode_macro RESUME]
description = Resumes the print if the printer is paused.
rename_existing = RESUME_BASE
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set target_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set target_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% endif %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if target_idex_mode != '' %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set fan_speed = printer["gcode_macro PAUSE"].fan_speed|float %}
{% if printer["dual_carriage"] is not defined %}
M106 S{(fan_speed * 255)}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% else %}
{% if params.TOOLHEAD is defined %}
{% if params.TOOLHEAD == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% else %}
{% if printer["gcode_macro PAUSE"].idex_toolhead == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% endif %}
{% endif %}
M106.1 S{fan_speed}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY DANCE=0
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR DANCE=0
{% else %}
{% if params.TOOLHEAD is defined %}
_SELECT_TOOL T={params.TOOLHEAD} X=-1 Y=-1 TOOLSHIFT=false
{% else %}
_SELECT_TOOL T={printer["gcode_macro PAUSE"].idex_toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% endif %}
{% set x = printer["gcode_macro PAUSE"].idex_toolhead_x|float %}
{% set y = printer["gcode_macro PAUSE"].idex_toolhead_y|float %}
{% set z = printer["gcode_macro PAUSE"].idex_toolhead_z|float %}
G1 X{x} Y{y} Z{z} F{speed}
{% if params.TOOLHEAD is defined %}
SAVE_GCODE_STATE NAME=PAUSE_STATE
{% endif %}
{% endif %}
{% if params.TOOLHEAD is not defined %}
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
{% if can_extrude %}
G91
G1 E{E} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1 MOVE_SPEED={speed}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
RESUME_BASE
_LED_PRINTING
[gcode_macro CANCEL_PRINT]
description = Cancels the printer
rename_existing = CANCEL_PRINT_BASE
gcode =
END_PRINT
TURN_OFF_HEATERS
CLEAR_PAUSE
CANCEL_PRINT_BASE
[gcode_macro START_PRINT]
description = Start print procedure, use this in your Slicer.
variable_post_processor_version = 2
variable_is_printing_gcode = False
variable_both_toolheads = True
variable_object_xoffset = 0
variable_first_x = -1
variable_first_y = -1
variable_total_toolshifts = 0
variable_initial_tool = 0
variable_extruder_first_layer_temp = ""
variable_extruder_other_layer_temp = ""
gcode =
{% if "xyz" in printer.toolhead.homed_axes and printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% if printer["gcode_macro _VAOC"].is_started|default(true)|lower == 'true' %}
_VAOC_END
{% endif %}
{% endif %}
_LED_START_PRINTING
CACHE_TOOLHEAD_SETTINGS KEY="start_print"
_USER_START_PRINT { rawparams }
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set bed_heat_soak_time = printer["gcode_macro RatOS"].bed_heat_soak_time|default(0)|int %}
{% set hotend_heat_soak_time = printer["gcode_macro RatOS"].hotend_heat_soak_time|default(0)|int %}
{% set z_probe_stowable = printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set X0 = params.X0|default(-1)|float %}
{% set X1 = params.X1|default(-1)|float %}
{% set Y0 = params.Y0|default(-1)|float %}
{% set Y1 = params.Y1|default(-1)|float %}
{% if first_x == -1 or first_y == -1 %}
{% set first_x = params.FIRST_X|default(-1)|float %}
{% set first_y = params.FIRST_Y|default(-1)|float %}
{% endif %}
{% set total_toolshifts = params.TOTAL_TOOLSHIFTS|default(0)|int %}
{% set initial_tool = params.INITIAL_TOOL|default(default_toolhead)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set bed_temp = params.BED_TEMP|default(printer.heater_bed.target, true)|float %}
{% set total_layer_count = params.TOTAL_LAYER_COUNT|default(0)|int %}
{% set extruder_first_layer_temp = (params.EXTRUDER_TEMP|default("")).split(",") %}
RATOS_ECHO MSG="First print coordinates X:{first_x} Y:{first_y}"
{% if params.TOTAL_LAYER_COUNT is not defined %}
{% set link_url = "https://os.ratrig.com/docs/slicers" %}
{% set link_text = "RatOS Slicer Configuration" %}
{% set line_1 = '"Your slicer gcode settings are not up to date._N_Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="Incomplete Slicer Configuration detected" TYPE="warning" MSG={line_1}
{% endif %}
SET_PRINT_STATS_INFO CURRENT_LAYER=1
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE=1
{% if total_layer_count > 0 %}
SET_PRINT_STATS_INFO TOTAL_LAYER={total_layer_count}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set swap_toolheads = true if printer["gcode_macro _IDEX_REMAP_TOOLHEADS"].enabled|default(false)|lower == 'true' else false %}
{% if swap_toolheads %}
{% set initial_tool = 0 if initial_tool == 1 else 1 %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=active VALUE=True
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=active VALUE=True
{% endif %}
{% set both_toolheads = true %}
{% if total_toolshifts == 0 %}
{% set both_toolheads = false %}
{% endif %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
{% endif %}
{% if both_toolheads and (idex_mode == "copy" or idex_mode == "mirror") %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Gcode tool changes found. Copy and mirror mode do not support toolchanges.")}
{% endif %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set both_toolheads = true %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=initial_tool VALUE={initial_tool}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_x VALUE={first_x}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_y VALUE={first_y}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=total_toolshifts VALUE={total_toolshifts}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=both_toolheads VALUE={both_toolheads}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_first_layer_temp VALUE="'{params.EXTRUDER_TEMP}'"
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_other_layer_temp VALUE="'{params.EXTRUDER_OTHER_LAYER_TEMP}'"
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE VARIABLE=toolshift_count VALUE=0
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set svv = printer.save_variables.variables %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
{% set stepper_x_position_min = printer.configfile.settings.stepper_x.position_min|float %}
{% set stepper_x_position_endstop = printer.configfile.settings.stepper_x.position_endstop|float %}
{% set dual_carriage_position_max = printer.configfile.settings.dual_carriage.position_max|float %}
{% set dual_carriage_position_endstop = printer.configfile.settings.dual_carriage.position_endstop|float %}
{% set x_parking_space = parking_position_t0 - (stepper_x_position_endstop , stepper_x_position_min)|max %}
{% set dc_parking_space = (dual_carriage_position_endstop , dual_carriage_position_max)|min - parking_position_t1 %}
{% if svv.idex_xoffset|abs >= (x_parking_space - 0.5) or svv.idex_xoffset|abs >= (dc_parking_space - 0.5) %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Toolhead x-offset is too high for the available parking space. Calibrate your X and DC endstop positions and make sure you stay below 1mm." % (copy_mode_max_width)) }
{% endif %}
{% endif %}
{% if (idex_mode == "copy" or idex_mode == "mirror") and printer.configfile.settings.ratos.enable_gcode_transform %}
{% if params.MIN_X is not defined or params.MAX_X is not defined %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Something went wrong! Missing important post processor start print parameter!") }
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE=0
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set boundary_box_min_x = params.MIN_X|default(0)|float %}
{% set boundary_box_max_x = params.MAX_X|default(printable_x_max)|float %}
{% set svv = printer.save_variables.variables %}
{% if default_toolhead == 0 %}
{% set boundary_box_max_x = boundary_box_max_x + svv.idex_xoffset %}
{% else %}
{% set boundary_box_min_x = boundary_box_min_x - svv.idex_xoffset %}
{% endif %}
{% set center_x = printable_x_max / 2.0 %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% set object_width = boundary_box_max_x - boundary_box_min_x %}
{% set copy_mode_max_width = center_x %}
{% set mirror_mode_max_width = center_x - safe_distance / 2.0 %}
DEBUG_ECHO PREFIX="START_PRINT" MSG="OBJECT_WIDTH: {object_width} BOUNDARY_BOX_MIN_X: {boundary_box_min_x} BOUNDARY_BOX_MAX_X: {boundary_box_max_x} CENTER_X: {center_x} SAFE_DISTANCE: {safe_distance}"
{% if idex_mode == "copy" and object_width > copy_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for copy mode! Max supported width is %s mm" % (copy_mode_max_width)) }
{% endif %}
{% if idex_mode == "mirror" and object_width > mirror_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for mirror mode! Max supported width is %s mm" % (mirror_mode_max_width)) }
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = (printable_x_max - boundary_box_max_x - boundary_box_min_x) / 2 %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE={object_xoffset}
{% endif %}
{% endif %}
{% set has_initial_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_initial_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined and both_toolheads %}
{% set has_secondary_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_secondary_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% endif %}
_CHAMBER_FILTER_ON AT="before_print_start"
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true' %}
{% if both_toolheads %}
RATOS_ECHO MSG="Spool join is not possible if both toolheads are in use!"
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if idex_mode == '' %}
_SET_TOOLHEAD_OFFSET T={default_toolhead} MOVE={1 if "xyz" in printer.toolhead.homed_axes else 0}
{% endif %}
{% endif %}
CLEAR_PAUSE
{% if printer["gcode_macro RatOS"].force_absolute_position|lower == 'true' %}
G90
{% endif %}
SAVE_GCODE_STATE NAME=start_print_state
G21
G90
M82
_USER_START_PRINT_BEFORE_HOMING { rawparams }
{% if z_probe_stowable == true %}
STOWABLE_PROBE_BEGIN_BATCH
{% endif %}
MAYBE_HOME
_Z_HOP
{% if idex_mode != '' and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
PARK_TOOLHEAD
{% endif %}
{% if chamber_temp > 0 %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED={printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float}
{% endif %}
{% endif %}
_CHAMBER_HEATER_ON START_CHAMBER_TEMP={start_chamber_temp} CHAMBER_TEMP={chamber_temp}
_USER_START_PRINT_HEAT_CHAMBER { rawparams } CHAMBER_TEMP={chamber_temp}
{% endif %}
_START_PRINT_BEFORE_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
RATOS_ECHO MSG="Heating bed..."
M190 S{bed_temp}
{% if bed_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking bed for {bed_heat_soak_time} seconds..."
G4 P{(bed_heat_soak_time * 1000)}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_BED { rawparams }
_START_PRINT_AFTER_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
_USER_START_PRINT_BED_MESH { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_BED_MESH X0={X0} X1={X1} Y0={Y0} Y1={Y1} T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if z_probe_stowable == true %}
STOWABLE_PROBE_END_BATCH
{% endif %}
{% if idex_mode == '' %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={extruder_first_layer_temp[1]|float}
{% endif %}
{% endif %}
_USER_START_PRINT_PARK { rawparams }
_START_PRINT_PARK
RATOS_ECHO MSG="Heating Extruder..."
{% if idex_mode == '' %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder1" MINIMUM={extruder_first_layer_temp[1]|float} MAXIMUM={extruder_first_layer_temp[1]|float + 5}
{% endif %}
{% endif %}
{% if hotend_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking hotend for {hotend_heat_soak_time} seconds..."
G4 P{(hotend_heat_soak_time * 1000)}
{% endif %}
{% if idex_mode == '' %}
_LED_PRINTING
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
_LED_PRINTING
{% else %}
{% if both_toolheads %}
_LED_PRINTING TOOLHEAD={initial_tool}
{% if toolchange_standby_temp > -1 %}
_LED_TOOLHEAD_STANDBY TOOLHEAD={0 if initial_tool == 1 else 1}
{% else %}
_LED_PRINTING TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% else %}
_LED_PRINTING TOOLHEAD={initial_tool}
_LED_DEACTIVATE_TOOLHEAD TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% endif %}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_EXTRUDER { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_AFTER_HEATING_EXTRUDER X0={X0} X1={X1} Y0={Y0} Y1={Y1} INITIAL_TOOLHEAD={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if idex_mode != '' %}
{% if not both_toolheads %}
{% if initial_tool != default_toolhead %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET=0
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if toolchange_standby_temp > -1 %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if initial_tool == 1 else 'extruder1'} TARGET={toolchange_standby_temp}
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% set x_offset = printer.toolhead.position.x|float - printer.gcode_move.gcode_position.x|float %}
{% endif %}
RESTORE_GCODE_STATE NAME=start_print_state
{% if idex_mode != '' %}
{% set act_idex_mode = printer["dual_carriage"].carriage_1|default('')|lower %}
{% if act_idex_mode == "copy" or act_idex_mode == "mirror" %}
SET_GCODE_OFFSET X={x_offset} MOVE=0
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% if idex_mode == "copy" and idex_mode != act_idex_mode %}
_IDEX_COPY DANCE=0
{% elif idex_mode == "mirror" and idex_mode != act_idex_mode %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
RATOS_ECHO MSG="Adjusting object x-offset by {(object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={object_xoffset} MOVE=0
{% endif %}
{% else %}
_SELECT_TOOL T={initial_tool} TOOLSHIFT=false
{% if initial_tool != default_toolhead %}
{% set svv = printer.save_variables.variables %}
SAVE_VARIABLE VARIABLE=idex_applied_offset VALUE={default_toolhead}
_SET_TOOLHEAD_OFFSET T={initial_tool} MOVE=0
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={initial_tool}
{% endif %}
_SET_EXTRUSION_MODE
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
SET_GCODE_VARIABLE MACRO=_SELECT_TOOL VARIABLE=last_timestamp VALUE={printer["print_stats"].print_duration}
{% endif %}
_USER_END_START_PRINT { rawparams }
G92 E0
_CHAMBER_FILTER_ON AT="after_print_start"
RATOS_ECHO MSG="Printing..."
[gcode_macro _START_PRINT_BEFORE_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set is_stowable_probe = true if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Pre-heating extruder..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={min_temp}
{% else %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET={min_temp}
{% endif %}
{% else %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
{% endif %}
{% endif %}
{% if not is_stowable_probe %}
{% if printer["dual_carriage"] is defined and act_t != default_toolhead %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
{% endif %}
RATOS_ECHO MSG="Heat soaking z probe..."
{% if auto_z_offset_calibration %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% if default_toolhead == 0 %}
_SELECT_TOOL T=0 TOOLSHIFT=false
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
{% elif default_toolhead == 1 %}
_SELECT_TOOL T=1 TOOLSHIFT=false
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
{% endif %}
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% endif %}
G0 Z2 F{z_speed}
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Waiting for extruder to be preheated..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
{% if default_toolhead == 0 %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_Z_HOP
{% endif %}
{% if auto_z_offset_calibration %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
PARK_TOOLHEAD
_CLEANING_MOVE TOOLHEAD={default_toolhead}
_SELECT_TOOL T={0 if default_toolhead == 1 else 1} X={parking_position_t0 if default_toolhead == 1 else parking_position_t1} Y=0 TOOLSHIFT=false
_CLEANING_MOVE TOOLHEAD={0 if default_toolhead == 1 else 1}
_VAOC_CALIBRATE_Z_OFFSET AUTO_Z_OFFSET=True
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=false
{% endif %}
{% set needs_rehoming = False %}
{% if printer.z_tilt is defined and not printer.z_tilt.applied %}
RATOS_ECHO MSG="Adjusting Z tilt..."
Z_TILT_ADJUST
RATOS_ECHO MSG="Rehoming Z after Z tilt adjustment..."
{% set needs_rehoming = True %}
{% endif %}
{% if printer.quad_gantry_level is defined and not printer.quad_gantry_level.applied %}
RATOS_ECHO MSG="Running quad gantry leveling..."
QUAD_GANTRY_LEVEL
RATOS_ECHO MSG="Rehoming Z after quad gantry leveling..."
{% set needs_rehoming = True %}
{% endif %}
{% if needs_rehoming %}
G28 Z
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %}
{% if beacon_contact_wipe_before_true_zero %}
_START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE
{% endif %}
_START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
G0 Z5 F{z_speed}
G0 X50 Y10 F{speed}
PROBE PROBE_METHOD=contact SAMPLES=1
BEACON_QUERY
[gcode_macro _START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_true_zero_temp = printer["gcode_macro RatOS"].beacon_contact_true_zero_temp|default(150)|int %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_true_zero_location = printer["gcode_macro RatOS"].beacon_contact_true_zero_location|default("front")|lower %}
{% set beacon_contact_true_zero_margin_x = printer["gcode_macro RatOS"].beacon_contact_true_zero_margin_x|default(30)|int %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if beacon_contact_wipe_before_true_zero %}
{% if printer.beacon.last_probe_result|lower == "ok" %}
{% set last_z_offset = printer.beacon.last_z_result %}
RATOS_ECHO MSG="Auto calibration nozzle wipe with probe result {last_z_offset}..."
G0 Z{(0.2 + last_z_offset)} F{z_speed}
G0 X70 F300
{% else %}
RATOS_ECHO MSG="Skipping auto calibration nozzle wipe because probing failed!"
{% endif %}
{% endif %}
G0 Z5 F{z_speed}
_MOVE_TO_SAFE_Z_HOME
RATOS_ECHO MSG="Heating extruder to probing temperature..."
SET_HEATER_TEMPERATURE HEATER={"extruder" if default_toolhead == 0 else "extruder1"} TARGET={beacon_contact_true_zero_temp}
TEMPERATURE_WAIT SENSOR={"extruder" if default_toolhead == 0 else "extruder1"} MINIMUM={beacon_contact_true_zero_temp} MAXIMUM={beacon_contact_true_zero_temp + 5}
RATOS_ECHO MSG="Beacon contact auto calibration..."
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
G0 Z5 F{z_speed}
[gcode_macro _START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set first_x = printer["gcode_macro START_PRINT"].first_x|default(-1)|float %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set center_x = printable_x_max / 2.0 %}
{% set center_y = printable_y_max / 2.0 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% if printer["dual_carriage"] is defined %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% endif %}
{% set X0 = params.X0|default(-1)|int %}
{% set X1 = params.X1|default(-1)|int %}
{% set Y0 = params.Y0|default(-1)|int %}
{% set Y1 = params.Y1|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% if idex_mode == '' %}
_PRIME
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
RATOS_ECHO PREFIX="IDEX" MSG="using combined prime offset for IDEX {idex_mode} mode"
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
{% if both_toolheads %}
{% if initial_toolhead == 0 %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T{initial_toolhead}"
_SELECT_TOOL T={initial_toolhead} TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% endif %}
{% endif %}
CACHE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
SET_MACRO_TRAVEL_SETTINGS
{% if (X0 > -1 and Y1 > -1) or (first_x > 0 and first_y > 0) %}
{% if printer["dual_carriage"] is defined %}
{% set acceleration = printer["gcode_macro RatOS"].toolchange_travel_accel %}
{% set max_accel = printer.toolhead.max_accel|float %}
{% set square_corner_velocity = printer.toolhead.square_corner_velocity|float %}
SET_VELOCITY_LIMIT ACCEL={acceleration} MINIMUM_CRUISE_RATIO=0 SQUARE_CORNER_VELOCITY=20
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
{% set first_z = 1 %}
{% else %}
{% set first_z = 3 %}
{% endif %}
{% if idex_mode == "mirror" %}
{% if first_y >= 0 %}
G0 Y{first_y} F{speed}
{% else %}
G0 Y{Y1} F{speed}
{% endif %}
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
_MOVE_TO_LOADING_POSITION TOOLHEAD={initial_toolhead}
_PURGE_FILAMENT TOOLHEAD={initial_toolhead} E={printer["gcode_macro RatOS"].toolchange_first_purge|default(50)|float}
_CLEANING_MOVE TOOLHEAD={initial_toolhead}
{% endif %}
{% if first_x >= 0 and first_y >= 0 %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% else %}
{% set first_x = X0 %}
{% set first_y = Y0 %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'min' %}
{% set first_x = X0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'max' %}
{% set first_x = X1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|float <= center_x %}
{% set first_x = X0 %}
{% else %}
{% set first_x = X1 %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'min' %}
{% set first_y = Y0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'max' %}
{% set first_y = Y1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|float <= center_y %}
{% set first_y = Y0 %}
{% else %}
{% set first_y = Y1 %}
{% endif %}
{% endif %}
{% endif %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% endif %}
{% endif %}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
_LOAD_RATOS_SKEW_PROFILE
[gcode_macro _PRIME]
gcode =
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
PRIME_BLOB INITIAL_TOOLHEAD={params.INITIAL_TOOLHEAD} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={params.IDEX_MODE} Y1={params.Y1}
{% else %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE == "copy" %}
_IDEX_COPY DANCE=0
{% elif params.IDEX_MODE == "mirror" %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro END_PRINT]
description = End print procedure, use this in your Slicer.
gcode =
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SAVE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = printer["gcode_macro START_PRINT"].object_xoffset|default(0)|float %}
RATOS_ECHO MSG="Adjusting object x-offset by {(0-object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={(0-object_xoffset)}
{% endif %}
{% endif %}
_USER_END_PRINT_BEFORE_HEATERS_OFF { rawparams }
_END_PRINT_BEFORE_HEATERS_OFF
TURN_OFF_HEATERS
_USER_END_PRINT_AFTER_HEATERS_OFF { rawparams }
_END_PRINT_AFTER_HEATERS_OFF
_USER_END_PRINT_PARK { rawparams }
_END_PRINT_PARK
{% if printer["gcode_macro RatOS"].skew_profile is defined %}
SET_SKEW CLEAR=1
{% endif %}
{% if printer["dual_carriage"] is not defined and printer["gcode_macro RatOS"].end_print_motors_off|lower != 'false' %}
M84
{% endif %}
M107
BED_MESH_CLEAR
RATOS_ECHO MSG="Done :)"
RESTORE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
M84
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
{% if printer["dual_carriage"] is not defined %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_expansion_compensation = true if printer["gcode_macro RatOS"].beacon_contact_expansion_compensation|default(false)|lower == 'true' else false %}
{% if beacon_contact_start_print_true_zero and beacon_contact_expansion_compensation %}
SET_GCODE_OFFSET Z=0 MOVE=0
{% endif %}
{% endif %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print"
_CHAMBER_FILTER_ON AT="print_end"
_CHAMBER_FILTER_OFF
_CHAMBER_HEATER_OFF
_USER_END_PRINT_FINISHED { rawparams }
[gcode_macro _END_PRINT_BEFORE_HEATERS_OFF]
gcode =
RATOS_ECHO MSG="Cleaning up..."
[gcode_macro _END_PRINT_AFTER_HEATERS_OFF]
gcode =
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% set z_hop = printer["gcode_macro RatOS"].end_print_park_z_hop|float %}
{% set r = printer["gcode_macro RatOS"].end_print_retract_filament|default(4)|float %}
{% if current_z < (max_z - z_hop) %}
{% set z_safe = z_hop %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
G91
G1 E-2 F3600
G0 Z{z_safe} F3600
G1 E-{(r-2)} F3600
G90
[gcode_macro _SET_EXTRUSION_MODE]
gcode =
{% if printer["gcode_macro RatOS"].relative_extrusion|lower == 'true' %}
M83
{% else %}
M82
{% endif %}
[gcode_macro GENERATE_SHAPER_GRAPHS]
description = Genarates input shaper resonances graphs for analysis. Uses the AXIS parameter for if you only want to do one axis at a time, (eg. GENERATE_SHAPER_GRAPHS AXIS=X)
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set axis = params.AXIS|default('')|lower %}
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
{% if axis != '' %}
{% if axis == 'x' %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
{% elif axis == 'y' %}
MAYBE_HOME
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% else %}
{action_raise_error("Unknown axis specified. Expected X or Y.")}
{% endif %}
{% else %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% endif %}
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Shaper graph"
[gcode_shell_command generate_shaper_graph_x]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-x.sh
timeout = 60.
verbose = True
[gcode_shell_command generate_shaper_graph_y]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-y.sh
timeout = 60.
verbose = True
[gcode_macro MEASURE_COREXY_BELT_TENSION]
description = Generates resonance graph used to ensure belts are equally tensioned.
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
MAYBE_HOME
TEST_RESONANCES AXIS=1,1 OUTPUT=raw_data NAME=belt-tension-upper FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=belt-tension-lower FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_belt_tension_graph
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Belt Tension Graph"
[gcode_shell_command generate_belt_tension_graph]
command = /home/pi/printer_data/config/RatOS/scripts/generate-belt-tension-graph.sh
timeout = 90.
verbose = True
[idle_timeout]
gcode =
{% if printer.webhooks.state|lower == 'ready' %}
{% if printer.pause_resume.is_paused|lower == 'false' %}
RATOS_ECHO PREFIX="IDLE" MSG="2 hours since last activity. Powering off heaters and motors.."
TURN_OFF_HEATERS
M84
{% endif %}
{% endif %}
timeout = 7200
[temperature_sensor raspberry_pi]
sensor_type = temperature_host
[skew_correction]
[input_shaper]
[virtual_sdcard]
path = ~/printer_data/gcodes
[display_status]
[pause_resume]
[force_move]
enable_force_move = True
[respond]
[resonance_generator]
[ratos]
allow_unknown_gcode_generator = True
[exclude_object]
[heater_bed]
heater_pin = heater_bed_heating_pin
sensor_pin = heater_bed_sensor_pin
sensor_type = EPCOS 100K B57560G104F
min_temp = 0
max_temp = 130
control = pid
pid_kp = 68.203
pid_ki = 2.842
pid_kd = 409.216
[fan]
pin = toolboard_t0:PA0
shutdown_speed = 1.0
kick_start_time = 0.5
cycle_time = 0.00004
[heater_fan toolhead_cooling_fan]
pin = PD14
fan_speed = 1
heater = extruder
heater_temp = 50.0
[controller_fan controller_fan]
pin = PD13
idle_speed = 0.7
[printer]
kinematics = cartesian
max_velocity = 200
max_accel = 3000
minimum_cruise_ratio = 0.5
max_z_velocity = 15
max_z_accel = 200
square_corner_velocity = 5
[bed_mesh]
speed = 200
horizontal_move_z = 5
mesh_min = 15,15
mesh_max = 150,160
probe_count = 5,5
fade_start = 1.0
fade_end = 10.0
mesh_pps = 2,2
algorithm = bicubic
bicubic_tension = .2
[screws_tilt_adjust]
screw1 = 80, 108
screw1_name = Left Screw
screw2 = 155, 72
screw2_name = Front Right Screw
screw3 = 155, 147
screw3_name = Rear Right Screw
horizontal_move_z = 10
speed = 200
screw_thread = CCW-M4
[stepper_x]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PF9
dir_pin = !x_dir_pin
enable_pin = !PD6
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = toolboard_t0:PB6
[stepper_y]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PD3
dir_pin = y_dir_pin
enable_pin = !PD5
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = PC1
[stepper_z]
position_min = -5
position_max = 180
step_pin = PA15
dir_pin = !z0_dir_pin
enable_pin = !PC9
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 4
homing_speed = 15
endstop_pin = probe:z_virtual_endstop
[gcode_macro SCREWS_TILT_CALCULATE]
rename_existing = SCREWS_TILT_CALCULATE_ORIG
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
MAYBE_HOME
SAVE_GCODE_STATE NAME=screws_tilt_state
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
DEPLOY_PROBE
{% endif %}
SCREWS_TILT_CALCULATE_ORIG
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
STOW_PROBE
{% endif %}
G90
G0 Z120 F{printer["gcode_macro RatOS"].macro_z_speed|float * 60}
G0 Y{printable_y_max} X{printable_x_max / 2} F{printer["gcode_macro RatOS"].macro_travel_speed|float * 60}
RESTORE_GCODE_STATE NAME=screws_tilt_state
M84
[extruder]
rotation_distance = 5.57
full_steps_per_rotation = 200
filament_diameter = 1.750
max_extrude_only_velocity = 120
max_extrude_only_accel = 800
pressure_advance_smooth_time = 0.02
max_extrude_only_distance = 200
nozzle_diameter = 0.4
heater_pin = toolboard_t0:PB13
sensor_type = MAX31865
sensor_pin = toolboard_t0:PA4
min_extrude_temp = 170
min_temp = 0
max_temp = 350
pressure_advance = 0.03
step_pin = toolboard_t0:PD0
dir_pin = !toolboard_t0:e_dir_pin
enable_pin = !toolboard_t0:PD2
microsteps = 64
control = pid
pid_kp = 21.673
pid_ki = 1.338
pid_kd = 87.776
spi_software_sclk_pin = toolboard_t0:PA5
spi_software_miso_pin = toolboard_t0:PA6
spi_software_mosi_pin = toolboard_t0:PA7
[firmware_retraction]
retract_speed = 120
unretract_extra_length = 0
unretract_speed = 120
retract_length = 0.5
[adxl345 rpi]
cs_pin = rpi:None
[resonance_tester]
accel_chip_x = adxl345 toolboard_t0
accel_chip_y = adxl345 rpi
probe_points =
90,90,20
[tmc2209 stepper_x]
stealthchop_threshold = 0
interpolate = False
uart_pin = PF10
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_y]
stealthchop_threshold = 0
interpolate = False
uart_pin = PD4
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_z]
stealthchop_threshold = 0
interpolate = False
uart_pin = PC8
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 extruder]
stealthchop_threshold = 0
interpolate = False
uart_pin = toolboard_t0:PA15
run_current = 0.707
driver_tbl = 0
driver_toff = 4
driver_hend = 6
driver_hstrt = 7
sense_resistor = 0.11
[bltouch]
sensor_pin = ^toolboard_t0:bltouch_sensor_pin
control_pin = toolboard_t0:bltouch_control_pin
speed = 7
pin_move_time = 0.675
sample_retract_dist = 10
pin_up_reports_not_triggered = True
pin_up_touch_mode_reports_triggered = True
x_offset = -28
y_offset = -13
z_offset = 2.375
[gcode_macro T0]
variable_join = 0
variable_remap = 0
variable_alert = ""
variable_filament_name = ""
variable_filament_type = ""
variable_filament_temp = 0
variable_runout_sensor = ""
variable_active = True
variable_color = "7bff33"
variable_hotend_type = "HF"
variable_has_cht_nozzle = False
variable_cooling_position_to_nozzle_distance = 40
variable_tooolhead_sensor_to_extruder_gear_distance = 15
variable_extruder_gear_to_cooling_position_distance = 30
variable_filament_loading_nozzle_offset = -5
variable_filament_grabbing_length = 5
variable_filament_grabbing_speed = 1
variable_enable_insert_detection = True
variable_enable_runout_detection = True
variable_enable_clog_detection = True
variable_unload_after_runout = True
variable_purge_after_load = 0
variable_purge_before_unload = 0
variable_extruder_load_speed = 60
variable_filament_load_speed = 10
variable_standby = False
variable_temperature_offset = 0
variable_has_oozeguard = False
variable_has_front_arm_nozzle_wiper = False
variable_resume_after_insert = False
gcode =
{% set x = params.X|default(-1.0)|float %}
{% set y = params.Y|default(-1.0)|float %}
{% set z = params.Z|default(0.0)|float %}
{% set s = params.S|default(1)|int %}
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
_SELECT_TOOL T=0 X={x} Y={y} Z={z} TOOLSHIFT={s}
{% endif %}
[save_variables]
filename = /home/pi/printer_data/config/ratos-variables.cfg
[fan_generic right_blower]
pin = toolboard_t0:PA1
kick_start_time = 0.5
cycle_time = 0.00004
[gcode_macro SYNC_FANS]
gcode =
{% set speed = printer.fan.speed %}
SET_FAN_SPEED FAN=right_blower SPEED={speed}
=======================
Loaded MCU 'mcu' 118 commands (v0.12.0-396-gb7233d119 / gcc: (15:8-2019-q3-1+b1) 8.3.1 20190703 (release) [gcc-8-branch revision 273027] binutils: (2.34-4+rpi1+14) 2.34)
MCU 'mcu' config: ADC_MAX=4095 BUS_PINS_i2c1_PA9_PA10=PA9,PA10 BUS_PINS_i2c1_PB6_PB7=PB6,PB7 BUS_PINS_i2c1_PB8_PB9=PB8,PB9 BUS_PINS_i2c2_PB10_PB11=PB10,PB11 BUS_PINS_i2c2_PB13_PB14=PB13,PB14 BUS_PINS_i2c3_PB3_PB4=PB3,PB4 BUS_PINS_i2c3_PC0_PC1=PC0,PC1 BUS_PINS_spi1=PA6,PA7,PA5 BUS_PINS_spi1a=PB4,PB5,PB3 BUS_PINS_spi2=PB14,PB15,PB13 BUS_PINS_spi2_PB2_PB11_PB10=PB2,PB11,PB10 BUS_PINS_spi2a=PC2,PC3,PB10 BUS_PINS_spi3=PB4,PB5,PB3 CLOCK_FREQ=64000000 INITIAL_PINS=PA4 MCU=stm32g0b1xx PWM_MAX=255 RESERVE_PINS_USB=PA11,PA12 RESERVE_PINS_crystal=PF0,PF1 STATS_SUMSQ_BASE=256 STEPPER_BOTH_EDGE=1
Configured MCU 'mcu' (1024 moves)
Loaded MCU 'rpi' 119 commands (?-20240727_132503-fv-az659-741 / gcc: (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110 binutils: (GNU Binutils for Raspbian) 2.35.2)
MCU 'rpi' config: ADC_MAX=4095 CLOCK_FREQ=50000000 MCU=linux PCA9685_MAX=4096 PWM_MAX=32768 STATS_SUMSQ_BASE=256
Configured MCU 'rpi' (1024 moves)
Loaded MCU 'toolboard_t0' 118 commands (v0.12.0-396-gb7233d119 / gcc: (15:8-2019-q3-1+b1) 8.3.1 20190703 (release) [gcc-8-branch revision 273027] binutils: (2.34-4+rpi1+14) 2.34)
MCU 'toolboard_t0' config: ADC_MAX=4095 BUS_PINS_i2c1_PA9_PA10=PA9,PA10 BUS_PINS_i2c1_PB6_PB7=PB6,PB7 BUS_PINS_i2c1_PB8_PB9=PB8,PB9 BUS_PINS_i2c2_PB10_PB11=PB10,PB11 BUS_PINS_i2c2_PB13_PB14=PB13,PB14 BUS_PINS_i2c3_PB3_PB4=PB3,PB4 BUS_PINS_i2c3_PC0_PC1=PC0,PC1 BUS_PINS_spi1=PA6,PA7,PA5 BUS_PINS_spi1a=PB4,PB5,PB3 BUS_PINS_spi2=PB14,PB15,PB13 BUS_PINS_spi2_PB2_PB11_PB10=PB2,PB11,PB10 BUS_PINS_spi2a=PC2,PC3,PB10 BUS_PINS_spi3=PB4,PB5,PB3 CLOCK_FREQ=64000000 MCU=stm32g0b1xx PWM_MAX=255 RESERVE_PINS_USB=PA11,PA12 RESERVE_PINS_crystal=PF0,PF1 STATS_SUMSQ_BASE=256 STEPPER_BOTH_EDGE=1
Configured MCU 'toolboard_t0' (1024 moves)
Args: ['/home/pi/klipper/klippy/klippy.py', '/home/pi/printer_data/config/printer.cfg', '-l', '/home/pi/printer_data/logs/klippy.log', '-I', '/home/pi/printer_data/comms/klippy.serial', '-a', '/home/pi/printer_data/comms/klippy.sock']
Git version: 'v0.12.0-396-gb7233d119-dirty'
Untracked files: klippy/extras/beacon.py, klippy/extras/gcode_shell_command.py, klippy/extras/linear_movement_vibrations.py, klippy/extras/ratos.py, klippy/extras/ratos_homing.py, klippy/extras/resonance_generator.py, klippy/extras/z_offset_probe.py, klippy/kinematics/ratos_hybrid_corexy.py
Branch: master
Remote: origin
Tracked URL: https://github.com/Klipper3d/klipper.git
CPU: 4 core ARMv7 Processor rev 4 (v7l)
Python: '3.9.2 (default, Mar 20 2025, 22:21:41) \n[GCC 10.2.1 20210110]'
webhooks client 1963496016: {'program': 'Moonraker', 'version': 'v0.9.3-0-g71f9e67'}
=============== Log rollover at Wed Nov 12 16:43:03 2025 ===============
Starting heater checks for extruder
Stats 42.0: gcodein=0 mcu: mcu_awake=0.018 mcu_task_avg=0.000021 mcu_task_stddev=0.000023 bytes_write=2367 bytes_read=6115 bytes_retransmit=9 bytes_invalid=0 send_seq=219 receive_seq=219 retransmit_seq=2 srtt=0.002 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999632 rpi: mcu_awake=0.000 mcu_task_avg=0.000000 mcu_task_stddev=0.000000 bytes_write=874 bytes_read=4747 bytes_retransmit=0 bytes_invalid=0 send_seq=118 receive_seq=118 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999081 adj=50006284 toolboard_t0: mcu_awake=0.013 mcu_task_avg=0.000021 mcu_task_stddev=0.000026 bytes_write=1632 bytes_read=5262 bytes_retransmit=9 bytes_invalid=0 send_seq=169 receive_seq=169 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999955 adj=63997734 SKRat_v1.0: temp=40.9 EBB42_v1.2_T0: temp=33.6 raspberry_pi: temp=50.5 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=2.30 cputime=10.054 memavail=160628 print_time=46.271 buffer_time=0.247 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
webhooks: registering remote method 'shutdown_machine' for connection id: 1963496016
webhooks: registering remote method 'reboot_machine' for connection id: 1963496016
webhooks: registering remote method 'pause_job_queue' for connection id: 1963496016
webhooks: registering remote method 'start_job_queue' for connection id: 1963496016
Stats 43.0: gcodein=0 mcu: mcu_awake=0.018 mcu_task_avg=0.000021 mcu_task_stddev=0.000023 bytes_write=2373 bytes_read=6247 bytes_retransmit=9 bytes_invalid=0 send_seq=220 receive_seq=220 retransmit_seq=2 srtt=0.002 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999372 rpi: mcu_awake=0.003 mcu_task_avg=0.000019 mcu_task_stddev=0.000013 bytes_write=880 bytes_read=4777 bytes_retransmit=0 bytes_invalid=0 send_seq=119 receive_seq=119 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999019 adj=49994458 toolboard_t0: mcu_awake=0.013 mcu_task_avg=0.000021 mcu_task_stddev=0.000026 bytes_write=1638 bytes_read=5368 bytes_retransmit=9 bytes_invalid=0 send_seq=170 receive_seq=170 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999813 adj=64002038 SKRat_v1.0: temp=41.2 EBB42_v1.2_T0: temp=33.5 raspberry_pi: temp=50.5 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=2.30 cputime=10.123 memavail=164132 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 61.5: gcodein=0 mcu: mcu_awake=0.002 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2385 bytes_read=8104 bytes_retransmit=9 bytes_invalid=0 send_seq=222 receive_seq=222 retransmit_seq=2 srtt=0.002 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999250 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000003 bytes_write=892 bytes_read=4848 bytes_retransmit=0 bytes_invalid=0 send_seq=121 receive_seq=121 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999858 adj=49995588 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000032 bytes_write=1650 bytes_read=7320 bytes_retransmit=9 bytes_invalid=0 send_seq=172 receive_seq=172 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000113 adj=64001857 SKRat_v1.0: temp=41.1 EBB42_v1.2_T0: temp=33.9 raspberry_pi: temp=52.1 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.71 cputime=10.260 memavail=180512 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 62.5: gcodein=0 mcu: mcu_awake=0.002 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2391 bytes_read=8229 bytes_retransmit=9 bytes_invalid=0 send_seq=223 receive_seq=223 retransmit_seq=2 srtt=0.002 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999249 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000004 bytes_write=898 bytes_read=4877 bytes_retransmit=0 bytes_invalid=0 send_seq=122 receive_seq=122 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999868 adj=50019782 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000032 bytes_write=1656 bytes_read=7419 bytes_retransmit=9 bytes_invalid=0 send_seq=173 receive_seq=173 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000114 adj=63998027 SKRat_v1.0: temp=41.1 EBB42_v1.2_T0: temp=33.7 raspberry_pi: temp=52.1 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.71 cputime=10.273 memavail=181148 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 63.5: gcodein=0 mcu: mcu_awake=0.002 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2397 bytes_read=8325 bytes_retransmit=9 bytes_invalid=0 send_seq=224 receive_seq=224 retransmit_seq=2 srtt=0.001 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999256 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000004 bytes_write=904 bytes_read=4893 bytes_retransmit=0 bytes_invalid=0 send_seq=123 receive_seq=123 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999867 adj=50015019 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000032 bytes_write=1662 bytes_read=7518 bytes_retransmit=9 bytes_invalid=0 send_seq=174 receive_seq=174 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000116 adj=63999306 SKRat_v1.0: temp=41.2 EBB42_v1.2_T0: temp=33.9 raspberry_pi: temp=52.1 heater_bed: target=0 temp=26.4 pwm=0.000 sysload=3.71 cputime=10.286 memavail=179048 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 64.5: gcodein=0 mcu: mcu_awake=0.002 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2403 bytes_read=8421 bytes_retransmit=9 bytes_invalid=0 send_seq=225 receive_seq=225 retransmit_seq=2 srtt=0.001 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999256 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000004 bytes_write=910 bytes_read=4909 bytes_retransmit=0 bytes_invalid=0 send_seq=124 receive_seq=124 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999868 adj=50011333 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000032 bytes_write=1668 bytes_read=7632 bytes_retransmit=9 bytes_invalid=0 send_seq=175 receive_seq=175 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000126 adj=63999665 SKRat_v1.0: temp=41.1 EBB42_v1.2_T0: temp=33.9 raspberry_pi: temp=52.6 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.71 cputime=10.299 memavail=176256 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 65.5: gcodein=0 mcu: mcu_awake=0.002 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2409 bytes_read=8544 bytes_retransmit=9 bytes_invalid=0 send_seq=226 receive_seq=226 retransmit_seq=2 srtt=0.001 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999253 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000004 bytes_write=916 bytes_read=4925 bytes_retransmit=0 bytes_invalid=0 send_seq=125 receive_seq=125 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999888 adj=50008616 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000032 bytes_write=1674 bytes_read=7744 bytes_retransmit=9 bytes_invalid=0 send_seq=176 receive_seq=176 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000121 adj=64000027 SKRat_v1.0: temp=41.2 EBB42_v1.2_T0: temp=33.5 raspberry_pi: temp=52.1 heater_bed: target=0 temp=26.1 pwm=0.000 sysload=3.74 cputime=10.312 memavail=178616 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 66.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2415 bytes_read=8659 bytes_retransmit=9 bytes_invalid=0 send_seq=227 receive_seq=227 retransmit_seq=2 srtt=0.001 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999256 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000004 bytes_write=922 bytes_read=4941 bytes_retransmit=0 bytes_invalid=0 send_seq=126 receive_seq=126 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999913 adj=50006740 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1680 bytes_read=7863 bytes_retransmit=9 bytes_invalid=0 send_seq=177 receive_seq=177 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000122 adj=64000229 SKRat_v1.0: temp=41.2 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=52.1 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.74 cputime=10.323 memavail=176980 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 67.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2421 bytes_read=8762 bytes_retransmit=9 bytes_invalid=0 send_seq=228 receive_seq=228 retransmit_seq=2 srtt=0.001 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999259 rpi: mcu_awake=0.000 mcu_task_avg=0.000008 mcu_task_stddev=0.000007 bytes_write=928 bytes_read=4970 bytes_retransmit=0 bytes_invalid=0 send_seq=127 receive_seq=127 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999909 adj=50005338 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1686 bytes_read=7985 bytes_retransmit=9 bytes_invalid=0 send_seq=178 receive_seq=178 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000145 adj=64000367 SKRat_v1.0: temp=41.2 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=52.1 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.74 cputime=10.337 memavail=183032 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 68.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2427 bytes_read=8894 bytes_retransmit=9 bytes_invalid=0 send_seq=229 receive_seq=229 retransmit_seq=2 srtt=0.001 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999265 rpi: mcu_awake=0.000 mcu_task_avg=0.000008 mcu_task_stddev=0.000007 bytes_write=934 bytes_read=4986 bytes_retransmit=0 bytes_invalid=0 send_seq=128 receive_seq=128 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999925 adj=50004080 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1692 bytes_read=8105 bytes_retransmit=9 bytes_invalid=0 send_seq=179 receive_seq=179 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000145 adj=64000644 SKRat_v1.0: temp=41.0 EBB42_v1.2_T0: temp=33.7 raspberry_pi: temp=52.6 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.74 cputime=10.352 memavail=179160 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 69.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2433 bytes_read=8997 bytes_retransmit=9 bytes_invalid=0 send_seq=230 receive_seq=230 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999265 rpi: mcu_awake=0.000 mcu_task_avg=0.000008 mcu_task_stddev=0.000007 bytes_write=940 bytes_read=5002 bytes_retransmit=0 bytes_invalid=0 send_seq=129 receive_seq=129 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999916 adj=50003270 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1698 bytes_read=8211 bytes_retransmit=9 bytes_invalid=0 send_seq=180 receive_seq=180 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000143 adj=64000664 SKRat_v1.0: temp=41.3 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=52.6 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.74 cputime=10.365 memavail=182508 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 70.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2439 bytes_read=9100 bytes_retransmit=9 bytes_invalid=0 send_seq=231 receive_seq=231 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999273 rpi: mcu_awake=0.000 mcu_task_avg=0.000008 mcu_task_stddev=0.000007 bytes_write=946 bytes_read=5018 bytes_retransmit=0 bytes_invalid=0 send_seq=130 receive_seq=130 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999938 adj=50002502 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1704 bytes_read=8333 bytes_retransmit=9 bytes_invalid=0 send_seq=181 receive_seq=181 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000145 adj=64000690 SKRat_v1.0: temp=41.1 EBB42_v1.2_T0: temp=33.9 raspberry_pi: temp=53.2 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.52 cputime=10.377 memavail=192252 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 71.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2445 bytes_read=9246 bytes_retransmit=9 bytes_invalid=0 send_seq=232 receive_seq=232 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999271 rpi: mcu_awake=0.000 mcu_task_avg=0.000008 mcu_task_stddev=0.000007 bytes_write=952 bytes_read=5034 bytes_retransmit=0 bytes_invalid=0 send_seq=131 receive_seq=131 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999929 adj=50002131 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1710 bytes_read=8468 bytes_retransmit=9 bytes_invalid=0 send_seq=182 receive_seq=182 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000144 adj=64000687 SKRat_v1.0: temp=41.1 EBB42_v1.2_T0: temp=33.9 raspberry_pi: temp=52.6 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.52 cputime=10.389 memavail=183360 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 72.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2451 bytes_read=9349 bytes_retransmit=9 bytes_invalid=0 send_seq=233 receive_seq=233 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999273 rpi: mcu_awake=0.000 mcu_task_avg=0.000008 mcu_task_stddev=0.000007 bytes_write=958 bytes_read=5050 bytes_retransmit=0 bytes_invalid=0 send_seq=132 receive_seq=132 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999930 adj=50001665 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1716 bytes_read=8574 bytes_retransmit=9 bytes_invalid=0 send_seq=183 receive_seq=183 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000149 adj=64000740 SKRat_v1.0: temp=41.1 EBB42_v1.2_T0: temp=33.9 raspberry_pi: temp=52.6 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.52 cputime=10.400 memavail=181324 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 73.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2457 bytes_read=9452 bytes_retransmit=9 bytes_invalid=0 send_seq=234 receive_seq=234 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999272 rpi: mcu_awake=0.000 mcu_task_avg=0.000008 mcu_task_stddev=0.000009 bytes_write=964 bytes_read=5079 bytes_retransmit=0 bytes_invalid=0 send_seq=133 receive_seq=133 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999954 adj=50001370 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1722 bytes_read=8696 bytes_retransmit=9 bytes_invalid=0 send_seq=184 receive_seq=184 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000148 adj=64000805 SKRat_v1.0: temp=41.3 EBB42_v1.2_T0: temp=33.5 raspberry_pi: temp=53.7 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.52 cputime=10.410 memavail=185976 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 74.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2463 bytes_read=9584 bytes_retransmit=9 bytes_invalid=0 send_seq=235 receive_seq=235 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999273 rpi: mcu_awake=0.000 mcu_task_avg=0.000008 mcu_task_stddev=0.000009 bytes_write=970 bytes_read=5095 bytes_retransmit=0 bytes_invalid=0 send_seq=134 receive_seq=134 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999977 adj=50001370 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1728 bytes_read=8816 bytes_retransmit=9 bytes_invalid=0 send_seq=185 receive_seq=185 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000148 adj=64000828 SKRat_v1.0: temp=41.4 EBB42_v1.2_T0: temp=33.7 raspberry_pi: temp=52.6 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.52 cputime=10.422 memavail=181620 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 75.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2469 bytes_read=9687 bytes_retransmit=9 bytes_invalid=0 send_seq=236 receive_seq=236 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999272 rpi: mcu_awake=0.000 mcu_task_avg=0.000008 mcu_task_stddev=0.000009 bytes_write=976 bytes_read=5111 bytes_retransmit=0 bytes_invalid=0 send_seq=135 receive_seq=135 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999996 adj=50001357 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1734 bytes_read=8922 bytes_retransmit=9 bytes_invalid=0 send_seq=186 receive_seq=186 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000156 adj=64000820 SKRat_v1.0: temp=41.2 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=52.6 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.56 cputime=10.434 memavail=181748 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 76.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2475 bytes_read=9804 bytes_retransmit=9 bytes_invalid=0 send_seq=237 receive_seq=237 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999270 rpi: mcu_awake=0.000 mcu_task_avg=0.000008 mcu_task_stddev=0.000009 bytes_write=982 bytes_read=5127 bytes_retransmit=0 bytes_invalid=0 send_seq=136 receive_seq=136 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000007 adj=50001344 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1740 bytes_read=9059 bytes_retransmit=9 bytes_invalid=0 send_seq=187 receive_seq=187 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000155 adj=64000919 SKRat_v1.0: temp=41.3 EBB42_v1.2_T0: temp=33.7 raspberry_pi: temp=53.2 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.56 cputime=10.446 memavail=181576 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 77.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2481 bytes_read=9936 bytes_retransmit=9 bytes_invalid=0 send_seq=238 receive_seq=238 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999268 rpi: mcu_awake=0.000 mcu_task_avg=0.000008 mcu_task_stddev=0.000009 bytes_write=988 bytes_read=5143 bytes_retransmit=0 bytes_invalid=0 send_seq=137 receive_seq=137 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999991 adj=50001273 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1746 bytes_read=9179 bytes_retransmit=9 bytes_invalid=0 send_seq=188 receive_seq=188 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000154 adj=64000923 SKRat_v1.0: temp=41.4 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=52.6 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.56 cputime=10.455 memavail=181576 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.3 pwm=0.000
Stats 78.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2487 bytes_read=10039 bytes_retransmit=9 bytes_invalid=0 send_seq=239 receive_seq=239 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999269 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000006 bytes_write=994 bytes_read=5172 bytes_retransmit=0 bytes_invalid=0 send_seq=138 receive_seq=138 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999982 adj=50001247 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1752 bytes_read=9285 bytes_retransmit=9 bytes_invalid=0 send_seq=189 receive_seq=189 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000154 adj=64000923 SKRat_v1.0: temp=41.4 EBB42_v1.2_T0: temp=33.7 raspberry_pi: temp=53.2 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.56 cputime=10.463 memavail=181576 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 79.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2493 bytes_read=10142 bytes_retransmit=9 bytes_invalid=0 send_seq=240 receive_seq=240 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999267 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000006 bytes_write=1000 bytes_read=5188 bytes_retransmit=0 bytes_invalid=0 send_seq=139 receive_seq=139 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999973 adj=50000978 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1758 bytes_read=9421 bytes_retransmit=9 bytes_invalid=0 send_seq=190 receive_seq=190 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000154 adj=64000905 SKRat_v1.0: temp=41.3 EBB42_v1.2_T0: temp=33.9 raspberry_pi: temp=52.6 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.56 cputime=10.473 memavail=181460 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 80.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2499 bytes_read=10274 bytes_retransmit=9 bytes_invalid=0 send_seq=241 receive_seq=241 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999266 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000006 bytes_write=1006 bytes_read=5204 bytes_retransmit=0 bytes_invalid=0 send_seq=140 receive_seq=140 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999965 adj=50000795 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1764 bytes_read=9527 bytes_retransmit=9 bytes_invalid=0 send_seq=191 receive_seq=191 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000155 adj=64000922 SKRat_v1.0: temp=41.3 EBB42_v1.2_T0: temp=33.7 raspberry_pi: temp=52.6 heater_bed: target=0 temp=26.4 pwm=0.000 sysload=3.35 cputime=10.482 memavail=181460 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.3 pwm=0.000
Stats 81.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2505 bytes_read=10391 bytes_retransmit=9 bytes_invalid=0 send_seq=242 receive_seq=242 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999267 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000006 bytes_write=1012 bytes_read=5220 bytes_retransmit=0 bytes_invalid=0 send_seq=141 receive_seq=141 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999986 adj=50000569 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000022 mcu_task_stddev=0.000030 bytes_write=1770 bytes_read=9648 bytes_retransmit=9 bytes_invalid=0 send_seq=192 receive_seq=192 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000156 adj=64000803 SKRat_v1.0: temp=41.2 EBB42_v1.2_T0: temp=33.9 raspberry_pi: temp=52.1 heater_bed: target=0 temp=26.4 pwm=0.000 sysload=3.35 cputime=10.494 memavail=180760 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 82.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2511 bytes_read=10494 bytes_retransmit=9 bytes_invalid=0 send_seq=243 receive_seq=243 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999268 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000006 bytes_write=1018 bytes_read=5236 bytes_retransmit=0 bytes_invalid=0 send_seq=142 receive_seq=142 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000003 adj=50000766 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000022 mcu_task_stddev=0.000030 bytes_write=1776 bytes_read=9784 bytes_retransmit=9 bytes_invalid=0 send_seq=193 receive_seq=193 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000156 adj=64000824 SKRat_v1.0: temp=41.2 EBB42_v1.2_T0: temp=33.7 raspberry_pi: temp=52.6 heater_bed: target=0 temp=26.4 pwm=0.000 sysload=3.35 cputime=10.507 memavail=181168 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 83.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2517 bytes_read=10626 bytes_retransmit=9 bytes_invalid=0 send_seq=244 receive_seq=244 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999267 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000006 bytes_write=1024 bytes_read=5265 bytes_retransmit=0 bytes_invalid=0 send_seq=143 receive_seq=143 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999994 adj=50000874 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000022 mcu_task_stddev=0.000030 bytes_write=1782 bytes_read=9890 bytes_retransmit=9 bytes_invalid=0 send_seq=194 receive_seq=194 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000156 adj=64000829 SKRat_v1.0: temp=41.4 EBB42_v1.2_T0: temp=33.9 raspberry_pi: temp=52.6 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.35 cputime=10.517 memavail=181120 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.3 pwm=0.000
Stats 84.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2523 bytes_read=10729 bytes_retransmit=9 bytes_invalid=0 send_seq=245 receive_seq=245 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999268 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000006 bytes_write=1030 bytes_read=5281 bytes_retransmit=0 bytes_invalid=0 send_seq=144 receive_seq=144 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999988 adj=50000714 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000022 mcu_task_stddev=0.000030 bytes_write=1788 bytes_read=9996 bytes_retransmit=9 bytes_invalid=0 send_seq=195 receive_seq=195 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000157 adj=64000853 SKRat_v1.0: temp=41.5 EBB42_v1.2_T0: temp=33.7 raspberry_pi: temp=53.7 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.35 cputime=10.526 memavail=181172 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 85.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2529 bytes_read=10832 bytes_retransmit=9 bytes_invalid=0 send_seq=246 receive_seq=246 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999276 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000006 bytes_write=1036 bytes_read=5297 bytes_retransmit=0 bytes_invalid=0 send_seq=145 receive_seq=145 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999986 adj=50000609 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000022 mcu_task_stddev=0.000030 bytes_write=1794 bytes_read=10132 bytes_retransmit=9 bytes_invalid=0 send_seq=196 receive_seq=196 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000162 adj=64000862 SKRat_v1.0: temp=41.3 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=53.2 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.16 cputime=10.535 memavail=181220 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 86.5: gcodein=0 mcu: mcu_awake=0.002 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2535 bytes_read=10978 bytes_retransmit=9 bytes_invalid=0 send_seq=247 receive_seq=247 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999275 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000006 bytes_write=1042 bytes_read=5313 bytes_retransmit=0 bytes_invalid=0 send_seq=146 receive_seq=146 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999983 adj=50000512 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000022 mcu_task_stddev=0.000030 bytes_write=1800 bytes_read=10238 bytes_retransmit=9 bytes_invalid=0 send_seq=197 receive_seq=197 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000161 adj=64000836 SKRat_v1.0: temp=41.2 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=52.1 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.16 cputime=10.544 memavail=181220 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 87.5: gcodein=0 mcu: mcu_awake=0.002 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2541 bytes_read=11081 bytes_retransmit=9 bytes_invalid=0 send_seq=248 receive_seq=248 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999276 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000006 bytes_write=1048 bytes_read=5329 bytes_retransmit=0 bytes_invalid=0 send_seq=147 receive_seq=147 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999984 adj=50000492 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1806 bytes_read=10359 bytes_retransmit=9 bytes_invalid=0 send_seq=198 receive_seq=198 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000163 adj=64000855 SKRat_v1.0: temp=41.4 EBB42_v1.2_T0: temp=33.9 raspberry_pi: temp=52.6 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.16 cputime=10.553 memavail=184620 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 88.5: gcodein=0 mcu: mcu_awake=0.002 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2547 bytes_read=11184 bytes_retransmit=9 bytes_invalid=0 send_seq=249 receive_seq=249 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999278 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000007 bytes_write=1054 bytes_read=5358 bytes_retransmit=0 bytes_invalid=0 send_seq=148 receive_seq=148 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000004 adj=50000504 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1812 bytes_read=10495 bytes_retransmit=9 bytes_invalid=0 send_seq=199 receive_seq=199 retransmit_seq=2 srtt=0.002 rttvar=0.002 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000164 adj=64000862 SKRat_v1.0: temp=41.3 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=52.1 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=3.16 cputime=10.566 memavail=185324 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 89.5: gcodein=0 mcu: mcu_awake=0.002 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2553 bytes_read=11316 bytes_retransmit=9 bytes_invalid=0 send_seq=250 receive_seq=250 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999281 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000007 bytes_write=1060 bytes_read=5374 bytes_retransmit=0 bytes_invalid=0 send_seq=149 receive_seq=149 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000025 adj=50000717 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1818 bytes_read=10601 bytes_retransmit=9 bytes_invalid=0 send_seq=200 receive_seq=200 retransmit_seq=2 srtt=0.002 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000170 adj=64000863 SKRat_v1.0: temp=41.2 EBB42_v1.2_T0: temp=33.9 raspberry_pi: temp=53.2 heater_bed: target=0 temp=26.4 pwm=0.000 sysload=3.16 cputime=10.578 memavail=182092 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 90.5: gcodein=0 mcu: mcu_awake=0.002 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2559 bytes_read=11419 bytes_retransmit=9 bytes_invalid=0 send_seq=251 receive_seq=251 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999281 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000007 bytes_write=1066 bytes_read=5390 bytes_retransmit=0 bytes_invalid=0 send_seq=150 receive_seq=150 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000020 adj=50000896 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1824 bytes_read=10707 bytes_retransmit=9 bytes_invalid=0 send_seq=201 receive_seq=201 retransmit_seq=2 srtt=0.002 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000170 adj=64000900 SKRat_v1.0: temp=41.3 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=53.7 heater_bed: target=0 temp=26.4 pwm=0.000 sysload=2.99 cputime=10.587 memavail=182120 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 91.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2565 bytes_read=11536 bytes_retransmit=9 bytes_invalid=0 send_seq=252 receive_seq=252 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999280 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000007 bytes_write=1072 bytes_read=5406 bytes_retransmit=0 bytes_invalid=0 send_seq=151 receive_seq=151 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000016 adj=50000758 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1830 bytes_read=10843 bytes_retransmit=9 bytes_invalid=0 send_seq=202 receive_seq=202 retransmit_seq=2 srtt=0.002 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000174 adj=64000898 SKRat_v1.0: temp=41.4 EBB42_v1.2_T0: temp=33.7 raspberry_pi: temp=53.2 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=2.99 cputime=10.597 memavail=181760 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 92.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2571 bytes_read=11668 bytes_retransmit=9 bytes_invalid=0 send_seq=253 receive_seq=253 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999281 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000007 bytes_write=1078 bytes_read=5422 bytes_retransmit=0 bytes_invalid=0 send_seq=152 receive_seq=152 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000011 adj=50000672 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1836 bytes_read=10964 bytes_retransmit=9 bytes_invalid=0 send_seq=203 receive_seq=203 retransmit_seq=2 srtt=0.001 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000174 adj=64000947 SKRat_v1.0: temp=41.4 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=53.2 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=2.99 cputime=10.607 memavail=181200 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 93.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2577 bytes_read=11771 bytes_retransmit=9 bytes_invalid=0 send_seq=254 receive_seq=254 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999282 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000007 bytes_write=1084 bytes_read=5451 bytes_retransmit=0 bytes_invalid=0 send_seq=153 receive_seq=153 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000009 adj=50000599 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1842 bytes_read=11070 bytes_retransmit=9 bytes_invalid=0 send_seq=204 receive_seq=204 retransmit_seq=2 srtt=0.001 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000175 adj=64000935 SKRat_v1.0: temp=41.4 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=53.2 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=2.99 cputime=10.624 memavail=181364 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 94.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2583 bytes_read=11874 bytes_retransmit=9 bytes_invalid=0 send_seq=255 receive_seq=255 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999282 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000007 bytes_write=1090 bytes_read=5467 bytes_retransmit=0 bytes_invalid=0 send_seq=154 receive_seq=154 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000009 adj=50000561 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1848 bytes_read=11206 bytes_retransmit=9 bytes_invalid=0 send_seq=205 receive_seq=205 retransmit_seq=2 srtt=0.001 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000176 adj=64000926 SKRat_v1.0: temp=41.4 EBB42_v1.2_T0: temp=33.7 raspberry_pi: temp=53.7 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=2.99 cputime=10.641 memavail=175428 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 95.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2589 bytes_read=12006 bytes_retransmit=9 bytes_invalid=0 send_seq=256 receive_seq=256 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999283 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000007 bytes_write=1096 bytes_read=5483 bytes_retransmit=0 bytes_invalid=0 send_seq=155 receive_seq=155 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000021 adj=50000549 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1854 bytes_read=11312 bytes_retransmit=9 bytes_invalid=0 send_seq=206 receive_seq=206 retransmit_seq=2 srtt=0.001 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000177 adj=64000914 SKRat_v1.0: temp=41.4 EBB42_v1.2_T0: temp=33.9 raspberry_pi: temp=53.7 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=2.99 cputime=10.654 memavail=181288 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 96.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2595 bytes_read=12109 bytes_retransmit=9 bytes_invalid=0 send_seq=257 receive_seq=257 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999286 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000007 bytes_write=1102 bytes_read=5499 bytes_retransmit=0 bytes_invalid=0 send_seq=156 receive_seq=156 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000036 adj=50000689 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1860 bytes_read=11418 bytes_retransmit=9 bytes_invalid=0 send_seq=207 receive_seq=207 retransmit_seq=2 srtt=0.001 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000177 adj=64000910 SKRat_v1.0: temp=41.3 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=54.2 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=2.99 cputime=10.702 memavail=177136 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 97.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2601 bytes_read=12226 bytes_retransmit=9 bytes_invalid=0 send_seq=258 receive_seq=258 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999285 rpi: mcu_awake=0.000 mcu_task_avg=0.000006 mcu_task_stddev=0.000007 bytes_write=1108 bytes_read=5514 bytes_retransmit=0 bytes_invalid=0 send_seq=157 receive_seq=157 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000030 adj=50000825 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1866 bytes_read=11569 bytes_retransmit=9 bytes_invalid=0 send_seq=208 receive_seq=208 retransmit_seq=2 srtt=0.001 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000177 adj=64000874 SKRat_v1.0: temp=41.5 EBB42_v1.2_T0: temp=33.7 raspberry_pi: temp=54.2 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=2.99 cputime=10.726 memavail=176632 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 98.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2607 bytes_read=12358 bytes_retransmit=9 bytes_invalid=0 send_seq=259 receive_seq=259 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999286 rpi: mcu_awake=0.000 mcu_task_avg=0.000007 mcu_task_stddev=0.000007 bytes_write=1114 bytes_read=5542 bytes_retransmit=0 bytes_invalid=0 send_seq=158 receive_seq=158 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000027 adj=50000695 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1872 bytes_read=11675 bytes_retransmit=9 bytes_invalid=0 send_seq=209 receive_seq=209 retransmit_seq=2 srtt=0.001 rttvar=0.001 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000177 adj=64000888 SKRat_v1.0: temp=41.3 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=54.2 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=2.99 cputime=10.749 memavail=176632 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 99.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2613 bytes_read=12461 bytes_retransmit=9 bytes_invalid=0 send_seq=260 receive_seq=260 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999291 rpi: mcu_awake=0.000 mcu_task_avg=0.000007 mcu_task_stddev=0.000007 bytes_write=1120 bytes_read=5557 bytes_retransmit=0 bytes_invalid=0 send_seq=159 receive_seq=159 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000024 adj=50000619 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1878 bytes_read=11781 bytes_retransmit=9 bytes_invalid=0 send_seq=210 receive_seq=210 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000178 adj=64000879 SKRat_v1.0: temp=41.3 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=54.2 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=2.99 cputime=10.773 memavail=177860 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 100.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2619 bytes_read=12564 bytes_retransmit=9 bytes_invalid=0 send_seq=261 receive_seq=261 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999293 rpi: mcu_awake=0.000 mcu_task_avg=0.000007 mcu_task_stddev=0.000007 bytes_write=1126 bytes_read=5572 bytes_retransmit=0 bytes_invalid=0 send_seq=160 receive_seq=160 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000024 adj=50000537 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1884 bytes_read=11917 bytes_retransmit=9 bytes_invalid=0 send_seq=211 receive_seq=211 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000178 adj=64000833 SKRat_v1.0: temp=41.5 EBB42_v1.2_T0: temp=33.7 raspberry_pi: temp=53.7 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=2.83 cputime=10.798 memavail=180884 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 101.5: gcodein=0 mcu: mcu_awake=0.003 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=2625 bytes_read=12696 bytes_retransmit=9 bytes_invalid=0 send_seq=262 receive_seq=262 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999294 rpi: mcu_awake=0.000 mcu_task_avg=0.000007 mcu_task_stddev=0.000007 bytes_write=1132 bytes_read=5587 bytes_retransmit=0 bytes_invalid=0 send_seq=161 receive_seq=161 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=50000022 adj=50000517 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=1890 bytes_read=12023 bytes_retransmit=9 bytes_invalid=0 send_seq=212 receive_seq=212 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000179 adj=64000826 SKRat_v1.0: temp=41.4 EBB42_v1.2_T0: temp=33.8 raspberry_pi: temp=53.7 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=2.83 cputime=10.821 memavail=175640 print_time=46.271 buffer_time=0.000 print_stall=0 extruder: target=0 temp=27.2 pwm=0.000
Stats 1029.8: gcodein=0 mcu: mcu_awake=0.002 mcu_task_avg=0.000015 mcu_task_stddev=0.000010 bytes_write=8283 bytes_read=119616 bytes_retransmit=9 bytes_invalid=0 send_seq=1205 receive_seq=1205 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=63999322 rpi: mcu_awake=0.001 mcu_task_avg=0.000010 mcu_task_stddev=0.000012 bytes_write=6790 bytes_read=23010 bytes_retransmit=0 bytes_invalid=0 send_seq=1104 receive_seq=1104 retransmit_seq=0 srtt=0.000 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=49999986 adj=50000475 toolboard_t0: mcu_awake=0.004 mcu_task_avg=0.000023 mcu_task_stddev=0.000031 bytes_write=7548 bytes_read=122224 bytes_retransmit=9 bytes_invalid=0 send_seq=1155 receive_seq=1155 retransmit_seq=2 srtt=0.001 rttvar=0.000 rto=0.025 ready_bytes=0 upcoming_bytes=0 freq=64000238 adj=64000792 SKRat_v1.0: temp=41.4 EBB42_v1.2_T0: temp=33.9 raspberry_pi: temp=48.9 heater_bed: target=0 temp=26.3 pwm=0.000 sysload=0.14 cputime=47.162 memavail=176376 print_time=1034.536 buffer_time=0.749 print_stall=0 extruder: target=0 temp=27.1 pwm=0.000
Attempting MCU 'mcu' reset command
Attempting MCU 'rpi' config_reset command
b'Got EOF when reading from device'
Attempting MCU 'toolboard_t0' reset command
webhooks client 1963496016: Disconnected
Restarting printer
Start printer at Wed Nov 12 16:59:33 2025 (1762966773.3 1032.3)
===== Config file =====
[mcu rpi]
serial = /tmp/klipper_host_mcu
[board_pins btt-skrat-10]
aliases =
x_step_pin=PF9,
x_dir_pin=PD7,
x_enable_pin=PD6,
x_uart_pin=PF10,
x_diag_pin=PB5,
x_endstop_pin=PB5,
y_step_pin=PD3,
y_dir_pin=PD2,
y_enable_pin=PD5,
y_uart_pin=PD4,
y_diag_pin=PC1,
y_endstop_pin=PC1,
z0_step_pin=PA15,
z0_dir_pin=PF8,
z0_enable_pin=PC9,
z0_uart_pin=PC8,
z0_diag_pin=PC0,
e_step_pin=PB10,
e_dir_pin=PE15,
e_enable_pin=PA8,
e_uart_pin=PB11,
e_diag_pin=PF5,
e_heater_pin=PE11,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PE5,
bltouch_control_pin=PE6,
probe_pin=PE5,
fan_part_cooling_pin=PD15,
fan_toolhead_cooling_pin=PD14,
fan_controller_board_pin=PD13,
heater_bed_heating_pin=PB3,
heater_bed_sensor_pin=PB2,
4p_fan_part_cooling_pin=PE9,
4p_fan_part_cooling_tach_pin=PD11,
4p_toolhead_cooling_pin=PE14,
4p_toolhead_cooling_tach_pin=PD10,
4p_controller_board_pin=PE14,
4p_controller_board_tach_pin=PD10
[mcu]
serial = /dev/RatOS/btt-skrat-10
[temperature_sensor SKRat_v1.0]
sensor_type = temperature_mcu
[adxl345 controlboard]
cs_pin = PB12
spi_bus = spi2
[board_pins toolboard_t0]
mcu = toolboard_t0
aliases =
e_step_pin=PD0,
e_dir_pin=PD1,
e_enable_pin=PD2,
e_uart_pin=PA15,
e_heater_pin=PB13,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PB8,
bltouch_control_pin=PB9,
probe_pin=PB9,
fan_part_cooling_pin=PA0,
fan_toolhead_cooling_pin=PA1,
fan_controller_board_pin=null,
heater_bed_heating_pin=null,
heater_bed_sensor_pin=null,
4p_fan_part_cooling_pin=null,
4p_fan_part_cooling_tach_pin=null,
4p_toolhead_cooling_pin=null,
4p_toolhead_cooling_tach_pin=null,
4p_controller_board_pin=null,
4p_controller_board_tach_pin=null
[mcu toolboard_t0]
serial = /dev/RatOS/btt-ebb42-12-t0
[temperature_sensor EBB42_v1.2_T0]
sensor_type = temperature_mcu
sensor_mcu = toolboard_t0
[adxl345 toolboard_t0]
axes_map = x, z, y
cs_pin = toolboard_t0:PB12
spi_software_mosi_pin = toolboard_t0:PB11
spi_software_miso_pin = toolboard_t0:PB2
spi_software_sclk_pin = toolboard_t0:PB10
[gcode_macro RatOS]
variable_homing = "endstops"
variable_z_probe = "static"
variable_sensorless_x_current = 0.6
variable_sensorless_y_current = 0.9
variable_safe_home_x = "middle"
variable_safe_home_y = "middle"
variable_driver_type_x = "tmc2209"
variable_driver_type_y = "tmc2209"
variable_stowable_probe_stop_on_error = False
variable_chamber_filter_enable = True
variable_chamber_filter_speed = 0.5
variable_chamber_filter_disable_speed = 1.0
variable_chamber_filter_enable_at = "after_print_start"
variable_chamber_filter_disable_period = 300
variable_chamber_filter_disable_bed_temp = 0
variable_chamber_heater_enable = True
variable_chamber_heater_bed_temp = 115
variable_chamber_heater_preheating_temp = 150
variable_chamber_heater_heating_temp_offset = 25
variable_chamber_heater_control_external_heater = False
variable_chamber_heater_air_circulation_enable = True
variable_chamber_heater_air_circulation_fan_speed = 0.35
variable_chamber_heater_air_circulation_y_pos = 0
variable_chamber_heater_air_circulation_z_pos = 100
variable_chamber_heater_extra_fan_speed = 1.0
variable_chamber_heater_filter_fan_speed = 1.0
variable_led_status_action = 0.0,1.0,1.0
variable_led_status_success = 0.0,1.0,0.0
variable_led_status_error = 1.0,0.0,1.0
variable_led_status_on = 1.0,1.0,1.0
variable_led_status_off = 0.0,0.0,1.0
variable_led_status_standby = 0.1,0.1,0.1
variable_led_status_heating = 1.0,0.0,0.0
variable_led_status_cooling = 0.0,0.0,1.0
variable_calibrate_bed_mesh = True
variable_adaptive_mesh = True
variable_start_print_park_in = "front"
variable_start_print_park_z_height = 50
variable_end_print_park_in = "back"
variable_pause_print_park_in = "front"
variable_end_print_park_z_hop = 20
variable_nozzle_priming = "primeblob"
variable_nozzle_prime_start_x = "max"
variable_nozzle_prime_start_y = "min"
variable_nozzle_prime_direction = "auto"
variable_nozzle_prime_bridge_fan = 102
variable_probe_for_priming_result = None
variable_probe_for_priming_end_result = None
variable_probe_for_priming_result_t1 = None
variable_probe_for_priming_end_result_t1 = None
variable_probe_for_priming_disable_mesh_constraints = False
variable_adaptive_prime_offset_threshold = -1.0
variable_last_z_offset = None
variable_runout_park_in = "front"
variable_enable_unload_tip_forming = False
variable_filament_unload_length = 150
description = RatOS variable storage macro, will echo variables to the console when run.
variable_relative_extrusion = False
variable_force_absolute_position = False
variable_preheat_extruder = True
variable_preheat_extruder_temp = 150
variable_macro_travel_speed = 200
variable_macro_travel_accel = 3000
variable_macro_z_speed = 15
variable_bed_margin_x = [0, 0]
variable_bed_margin_y = [0, 0]
variable_printable_x_min = 0
variable_printable_x_max = 0
variable_printable_y_min = 0
variable_printable_y_max = 0
variable_end_print_motors_off = True
variable_status_color_ok = "00FF00"
variable_status_color_error = "FF0000"
variable_status_color_unknown = "FFFF00"
variable_end_print_retract_filament = 10
gcode =
ECHO_RATOS_VARS
variable_homing_x = "endstop"
variable_homing_y = "endstop"
variable_x_driver_types = ["tmc2209"]
variable_x_axes = ["x"]
variable_y_driver_types = ["tmc2209"]
variable_y_axes = ["y"]
variable_z_driver_types = ["tmc2209"]
variable_z_axes = ["z"]
[ratos_homing]
axes = xyz
z_hop = 15
z_hop_speed = 15
gcode =
_LED_ON
{% set prev_stop_on_error = printer["gcode_macro RatOS"].stowable_probe_stop_on_error %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set target_idex_mode = printer["dual_carriage"].carriage_1|lower %}
_IDEX_SINGLE
_SELECT_TOOL T={default_toolhead} TOOLSHIFT=false
{% endif %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE=True
M400
G90
{% set X = true if params.X is defined else false %}
{% set Y = true if params.Y is defined else false %}
{% set Z = true if params.Z is defined else false %}
{% if printer["gcode_macro RatOS"].home_y_first|default(false)|lower == 'true' %}
HOME_Y X={X} Y={Y} Z={Z}
HOME_X X={X} Y={Y} Z={Z}
{% else %}
HOME_X X={X} Y={Y} Z={Z}
HOME_Y X={X} Y={Y} Z={Z}
{% endif %}
HOME_Z X={X} Y={Y} Z={Z}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE={prev_stop_on_error}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR
{% endif %}
{% endif %}
[gcode_macro HOME_X]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_x = printer["gcode_macro RatOS"].homing_x|lower %}
{% set homing_x = homing_x if homing_x else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_X" MSG="printable_x_max: {printable_x_max}, safe_home_x: {safe_home_x}, axis_maximum.x: {printer.toolhead.axis_maximum.x}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}"
{% if X or not Y and not Z %}
{% if homing_x == 'endstop' %}
G28 X
{% elif homing_x == 'sensorless' %}
{% if printer["dual_carriage"] is defined %}
{ action_emergency_stop("sensorless homing not supported on IDEX!") }
{% endif %}
HOME_X_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_x to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_x, homing)) }
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % (0 if default_toolhead==1 else 1)].parking_position|float %}
SET_DUAL_CARRIAGE CARRIAGE={0 if default_toolhead==1 else 1} MODE=PRIMARY
G1 X{parking_position} F{speed}
SET_DUAL_CARRIAGE CARRIAGE={default_toolhead} MODE=PRIMARY
{% endif %}
{% set x_homed = True %}
G0 X{safe_home_x} F{speed}
M400
{% endif %}
[gcode_macro HOME_Y]
gcode =
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_y = printer["gcode_macro RatOS"].homing_y|lower %}
{% set homing_y = homing_y if homing_y else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Y" MSG="printable_y_max: {printable_y_max}, safe_home_y: {safe_home_y}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}"
{% if Y or not X and not Z %}
{% if homing_y == 'endstop' %}
G28 Y
{% elif homing_y == 'sensorless' %}
HOME_Y_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_y to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_y, homing)) }
{% endif %}
{% set y_homed = True %}
G0 Y{safe_home_y} F{speed}
{% endif %}
[gcode_macro HOME_Z]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set z_probe = printer["gcode_macro RatOS"].z_probe %}
{% set beacon_contact_z_homing = true if printer["gcode_macro RatOS"].beacon_contact_z_homing|default(false)|lower == 'true' else false %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Z" MSG="x_homed: {x_homed}, y_homed: {y_homed}, z_probe: {z_probe}, beacon_contact_z_homing: {beacon_contact_z_homing}"
{% if Z or not Y and not X %}
RATOS_ECHO MSG="Homing Z"
{% if x_homed == False or y_homed == False %}
{ action_emergency_stop("X and Y must be homed before homing Z") }
{% else %}
{% if z_probe == "stowable" %}
DEPLOY_PROBE
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
STOW_PROBE
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
{% endif %}
{% endif %}
{% endif %}
[gcode_macro HOME_X_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
G4 P300
G28 X
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
[gcode_macro HOME_Y_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
G4 P300
G28 Y
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
[gcode_macro _Z_HOP]
description = Move Z axis up by Z_HOP distance at Z_HOP_SPEED. In relative mode it will move Z axis up by Z_HOP distance. In absolute mode it will move Z axis to Z_HOP distance.
gcode =
{% set z_hop = printer.configfile.config.ratos_homing.z_hop|float %}
{% set z_hop_speed = printer.configfile.config.ratos_homing.z_hop_speed|float * 60 %}
G0 Z{z_hop} F{z_hop_speed}
[gcode_macro _MOVE_TO_SAFE_Z_HOME]
description = Move to safe home position with optional Z_HOP (pass Z_HOP=True as parameter)
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% if params.Z_HOP is defined %}
_Z_HOP
{% endif %}
DEBUG_ECHO PREFIX="_MOVE_TO_SAFE_Z_HOME" MSG="axis_maximum.x: {printer.toolhead.axis_maximum.x}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}, safe_home_x: {safe_home_x}, safe_home_y: {safe_home_y}, printable_x_max: {printable_x_max}, printable_y_max: {printable_y_max}"
G0 X{safe_home_x} Y{safe_home_y} F{speed}
[gcode_macro MAYBE_HOME]
description = Only home unhomed axis
variable_is_kinematic_position_overriden = False
gcode =
{% if printer["gcode_macro MAYBE_HOME"].is_kinematic_position_overriden|lower == 'true' %}
RATOS_ECHO MSG="SET_CENTER_KINEMATIC_POSITION has been abused. Homing all axes. Please refrain from using SET_CENTER_KINEMATIC_POSITION outside of debugging purposes."
G28
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=False
{% else %}
{% set axes = '' %}
{% set isHomed = true %}
{% set axesToHome = '' %}
{% if params.X is defined %}
{% set axes = axes ~ 'X ' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% endif %}
{% if params.Y is defined %}
{% set axes = axes ~ 'Y ' %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% endif %}
{% if params.Z is defined %}
{% set axes = axes ~ 'Z ' %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if params.X is not defined and params.Y is not defined and params.Z is not defined %}
{% set axes = '' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if isHomed is false %}
RATOS_ECHO MSG="Homing {axesToHome}"
G28 {axesToHome}
{% else %}
RATOS_ECHO MSG="All requested axes already homed, skipping.."
{% endif %}
{% endif %}
[gcode_macro PID_CALIBRATE_HOTEND]
description = Perform a PID calibration test for a given extruder heater.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set temp = params.TEMP|default(220)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_HOTEND" MSG="TEMP={temp}"
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO MSG="PID calibration hotend heater T0 at {temp}°C..."
PID_CALIBRATE HEATER=extruder TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
{% if toolhead==0 or toolhead==1 %}
RATOS_ECHO MSG="PID calibration hotend heater T{toolhead} at {temp}°C..."
PID_CALIBRATE HEATER=extruder{'' if toolhead==0 else toolhead} TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_BED]
description = Perform a PID calibration test for the bed heater.
gcode =
{% set temp = params.TEMP|default(80)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_BED" MSG="TEMP={temp}"
RATOS_ECHO MSG="PID calibration bed heater at {temp}°C..."
PID_CALIBRATE HEATER=heater_bed TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_CHAMBER_HEATER]
description = Perform a PID calibration test for the chamber heater.
gcode =
{% set temp = params.TEMP|default(150)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_CHAMBER_HEATER" MSG="TEMP={temp}"
{% if printer["heater_generic chamber_heater"] is defined %}
RATOS_ECHO MSG="PID calibration chamber heater at {temp}°C..."
PID_CALIBRATE HEATER=chamber_heater TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_heater" %}
{% set link_text = "RatOS Chamber Heater" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber heater found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro INITIALIZE_PA_TUNING]
description = Start a pressure advance tuning tower.
gcode =
{% set start = params.START|default(0.0)|float %}
{% set factor = params.FACTOR|default(0.001)|float %}
{% set layer_number = printer["gcode_macro _ON_LAYER_CHANGE"].layer_number|default(0)|int %}
{% set is_printing_gcode = true if printer["gcode_macro START_PRINT"].is_printing_gcode|default(true)|lower == 'true' else false %}
{% if is_printing_gcode and layer_number < 2 %}
DEBUG_ECHO PREFIX="START_PA_TOWER" MSG="START: {start}, FACTOR: {factor}"
RATOS_ECHO MSG="Starting presssure advance tuning tower..."
TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START={start} FACTOR={factor}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro CHAMBER_FILTER_ON]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro CHAMBER_FILTER_OFF]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Deactivating chamber filter..."
_CHAMBER_FILTER_TURN_OFF
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro _CHAMBER_FILTER_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set chamber_filter_enable_at = printer["gcode_macro RatOS"].chamber_filter_enable_at|default('after_print_start')|lower %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_ON" MSG="at: {at}, chamber_filter_enable: {chamber_filter_enable}, chamber_filter_enable_at: {chamber_filter_enable_at}, chamber_filter_speed: {chamber_filter_speed}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if chamber_filter_enable_at == at %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON AT={at}
{% if chamber_filter_enable_at == "print_end" %}
_LED_CHAMBER_FILTER_ON
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_FILTER_OFF]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF" MSG="chamber_filter_enable: {chamber_filter_enable}, filter_disable_period: {filter_disable_period}, filter_disable_bed_temp: {filter_disable_bed_temp}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_period > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting {filter_disable_period} seconds before turning chamber filter off..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION={filter_disable_period}
{% endif %}
{% if filter_disable_bed_temp > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting for bed temp to cool down to {filter_disable_bed_temp}°C to turn filter off..."
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM=0 MAXIMUM={filter_disable_bed_temp}
_CHAMBER_FILTER_TURN_OFF
_LED_CHAMBER_FILTER_OFF
{% endif %}
{% endif %}
[delayed_gcode _CHAMBER_FILTER_OFF_TIMER]
gcode =
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF_TIMER" MSG="executed"
_CHAMBER_FILTER_TURN_OFF
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Chamber filter turned off!"
_LED_CHAMBER_FILTER_OFF
[gcode_macro _CHAMBER_FILTER_TURN_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_speed|default(0)|float %}
{% if at == "print_end" %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_disable_speed|default(0)|float %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION=0
SET_FAN_SPEED FAN=filter SPEED={chamber_filter_speed}
[gcode_macro _CHAMBER_FILTER_TURN_OFF]
gcode =
SET_FAN_SPEED FAN=filter SPEED=0
[gcode_macro _CHAMBER_FILTER_SANITY_CHECK]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_bed_temp > 0 and filter_disable_period > 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable, not both.")}
{% endif %}
{% if filter_disable_bed_temp == 0 and filter_disable_period == 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable.")}
{% endif %}
{% endif %}
[gcode_macro CHAMBER_HEATER_ON]
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(45)|int %}
_CHAMBER_HEATER_ON CHAMBER_TEMP={chamber_temp} IS_FROM_START_PRINT=False
[gcode_macro CHAMBER_HEATER_OFF]
gcode =
_CHAMBER_HEATER_OFF
[gcode_macro _CHAMBER_HEATER_ON]
variable_chamber_temp = 0
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set is_from_start_print = true if params.IS_FROM_START_PRINT|default(True)|lower == 'true' else false %}
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set chamber_heater_enable = true if printer["gcode_macro RatOS"].chamber_heater_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
{% set chamber_heater_preheating_temp = printer["gcode_macro RatOS"].chamber_heater_preheating_temp|default(150)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set chamber_heater_control_external_heater = true if printer["gcode_macro RatOS"].chamber_heater_control_external_heater|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_enable = true if printer["gcode_macro RatOS"].chamber_heater_air_circulation_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_fan_speed = printer["gcode_macro RatOS"].chamber_heater_air_circulation_fan_speed|default(0.35)|float %}
{% set chamber_heater_air_circulation_y_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_y_pos|default(0)|float %}
{% set chamber_heater_air_circulation_z_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_z_pos|default(100)|float %}
DEBUG_ECHO PREFIX="_CHAMBER_HEATER_ON" MSG="chamber_heater_enable: {chamber_heater_enable}, chamber_heater_preheating_temp: {chamber_heater_preheating_temp}, chamber_heater_heating_temp_offset: {chamber_heater_heating_temp_offset}, bed_temp: {bed_temp}, chamber_temp: {chamber_temp}, start_chamber_temp: {start_chamber_temp}"
{% if chamber_heater_enable and chamber_temp > 0 and chamber_heater_bed_temp > 0 %}
_LED_HEATING
RATOS_ECHO MSG="Preheating chamber to {(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}°C..."
{% set chamber_temp_sensor = "extruder" %}
{% if printer["dual_carriage"] is defined and default_toolhead == 1 %}
{% set chamber_temp_sensor = "extruder1" %}
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% set chamber_temp_sensor = "temperature_sensor chamber" %}
{% endif %}
{% set current_chamber_temp = printer['%s' % chamber_temp_sensor].temperature|int %}
{% set needs_heating = current_chamber_temp < (start_chamber_temp if start_chamber_temp > 0 else chamber_temp) %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_BEFORE_PREHEATING
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
{% if not is_from_start_print %}
MAYBE_HOME
{% endif %}
G0 Z{chamber_heater_air_circulation_z_pos} F{z_speed}
G0 Y{chamber_heater_air_circulation_y_pos} F{speed}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 1 else 0}
{% else %}
M106 S{(255 * chamber_heater_air_circulation_fan_speed)}
{% endif %}
{% else %}
{% if is_from_start_print %}
G0 Z{z} F{z_speed}
{% endif %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE={chamber_temp}
{% if needs_heating %}
M140 S{chamber_heater_bed_temp}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={chamber_heater_preheating_temp}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if needs_heating %}
_CHAMBER_HEATER_EXTRA_FAN_ON
{% endif %}
{% if needs_heating %}
TEMPERATURE_WAIT SENSOR="{chamber_temp_sensor}" MINIMUM={(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% endif %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED=0
_CHAMBER_FILTER_ON AT="before_print_start"
{% endif %}
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
G28 Z
{% endif %}
{% endif %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_AFTER_PREHEATING
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% if printer["heater_generic chamber_heater"] is defined %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined and chamber_heater_control_external_heater %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
_LED_SUCCESS
{% endif %}
[gcode_macro _CHAMBER_HEATER_OFF]
gcode =
RATOS_ECHO MSG="Deactivating chamber heater..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=0
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE=0
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
_CHAMBER_HEATER_EXTRA_FAN_OFF
[delayed_gcode _CHAMBER_HEATER_CONTROL]
initial_duration = 0.
gcode =
{% set chamber_temp = printer["gcode_macro _CHAMBER_HEATER_ON"].chamber_temp|default(0)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set current_chamber_temp = printer['temperature_sensor chamber'].temperature|int %}
{% if current_chamber_temp < chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if current_chamber_temp >= chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_ON]
gcode =
{% set chamber_heater_extra_fan_speed = printer["gcode_macro RatOS"].chamber_heater_extra_fan_speed|default(0.0)|float %}
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
{% if chamber_heater_extra_fan_speed > 0 %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED={chamber_heater_extra_fan_speed}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_OFF]
gcode =
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED=0
{% endif %}
[gcode_macro _USER_CHAMBER_HEATER_BEFORE_PREHEATING]
description = Will be executed before chamber preheating, only if heating is needed.
gcode =
[gcode_macro _USER_CHAMBER_HEATER_AFTER_PREHEATING]
description = Will be executed after chamber preheating, only if heating was needed.
gcode =
[gcode_macro _LED_START_PRINTING]
gcode =
_LED_ACTION
[gcode_macro _LED_START_PRINTING_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_PRINTING]
gcode =
_LED_ON TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_PAUSE]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_ON]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_OFF]
gcode =
_LED_STANDBY
[gcode_macro _LED_LOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_LOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_RUNOUT]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_CLOG]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_UNLOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_UNLOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_DEACTIVATE_TOOLHEAD]
gcode =
_LED_OFF TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_STANDBY]
gcode =
_LED_STANDBY TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_WAKEUP]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_MOTORS_OFF]
gcode =
_LED_STANDBY
_LED_VAOC_OFF
[gcode_macro _LED_INPUT_SHAPER_START]
gcode =
_LED_ACTION
[gcode_macro _LED_INPUT_SHAPER_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_START]
gcode =
_LED_ACTION
[gcode_macro _LED_BEACON_CALIBRATION_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_VAOC_ON]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=1.0 GREEN=1.0 BLUE=1.0
{% endif %}
[gcode_macro _LED_VAOC_OFF]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=0.0 GREEN=0.0 BLUE=0.0
{% endif %}
[gcode_macro _LED_ACTION]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_action %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SUCCESS]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_success %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_HEATING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_heating %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_COOLING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_cooling %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ERROR]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_error %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ON]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_on %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_OFF]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_off %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_STANDBY]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_standby %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
{% if toolhead >= 0 %}
{% if printer['neopixel nozzle_led_t%s' % toolhead] is defined %}
SET_LED LED={'nozzle_led_t%s' % toolhead} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% else %}
{% if printer['neopixel nozzle_led_t0'] is defined %}
SET_LED LED={'nozzle_led_t0'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% if printer['neopixel nozzle_led_t1'] is defined %}
SET_LED LED={'nozzle_led_t1'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% endif %}
_USER_LED_SET { rawparams }
[gcode_macro _USER_LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
[gcode_macro LOAD_FILAMENT]
description = Loads new filament. Note: be careful with PETG, make sure you inspect the tip of your filament before loading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% if filament_name == '' or filament_type == '' %}
{% set filament_name = 'unknown' %}
{% set filament_type = 'unknown' %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_LOAD_FILAMENT TEMP={temp} NAME={filament_name} TYPE={filament_type}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_LOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME={filament_name} TYPE={filament_type}
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _DEFAULT_LOAD_FILAMENT]
description = Load filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_LOAD_FILAMENT" MSG="TEMP={temp}"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=load_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
_LOAD_FILAMENT TOOLHEAD=0
RESTORE_GCODE_STATE NAME=load_state
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD=0
[gcode_macro _IDEX_LOAD_FILAMENT]
description = Load filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_LOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
_LOAD_FILAMENT TOOLHEAD={toolhead} TEMP={temp}
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into hotend.."
G92 E0
G0 E{extruder_gear_to_cooling_position_distance} F{extruder_load_speed}
G92 E0
M400
RATOS_ECHO MSG="Filament loaded into hotend."
[gcode_macro _LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set load_speed = printer["gcode_macro T%s" % toolhead].filament_load_speed|float * 60 %}
{% set filament_loading_nozzle_offset = printer["gcode_macro T%s" % toolhead].filament_loading_nozzle_offset|float %}
{% set cooling_position_to_nozzle_distance = printer["gcode_macro T%s" % toolhead].cooling_position_to_nozzle_distance|float %}
{% set purge_after_load = printer["gcode_macro T%s" % toolhead].purge_after_load|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into nozzle... Please wait!"
G92 E0
G0 E{cooling_position_to_nozzle_distance + filament_loading_nozzle_offset} F{load_speed}
G92 E0
G4 P1000
_PURGE_FILAMENT TOOLHEAD={toolhead} E={purge_after_load}
RATOS_ECHO MSG="Filament loaded into nozzle!"
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
{% set filament_grabbing_length = printer["gcode_macro T%s" % toolhead].filament_grabbing_length|float %}
{% set filament_grabbing_speed = printer["gcode_macro T%s" % toolhead].filament_grabbing_speed|float %}
{% set resume_after_insert = true if printer["gcode_macro T%s" % toolhead].resume_after_insert|default(true)|lower == 'true' else false %}
{% set enable_insert_detection = true if printer["gcode_macro T%s" % toolhead].enable_insert_detection|default(true)|lower == 'true' else false %}
{% set current_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% if enable_insert_detection %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="toolhead: {toolhead}, filament_grabbing_length: {filament_grabbing_length}, filament_grabbing_speed: {filament_grabbing_speed}, current_idex_mode: {current_idex_mode}"
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
FORCE_MOVE STEPPER={'extruder%s' % ('' if toolhead == 0 else toolhead)} DISTANCE={filament_grabbing_length} VELOCITY={filament_grabbing_speed}
M400
{% if printer.pause_resume.is_paused %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% if resume_after_insert %}
RESUME
{% endif %}
{% else %}
{% if not printer.virtual_sdcard.is_active %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
[gcode_macro _PURGE_BEFORE_UNLOAD]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set purge_before_unload = printer["gcode_macro T%s" % toolhead].purge_before_unload|float %}
DEBUG_ECHO PREFIX="_PURGE_BEFORE_UNLOAD" MSG="TOOLHEAD: {toolhead}"
{% if purge_before_unload > 0 %}
G92 E0
G0 E{purge_before_unload} F300
G92 E0
M400
{% endif %}
[gcode_macro _PURGE_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set e = params.E|int %}
{% set r = params.R|default(0)|int %}
DEBUG_ECHO PREFIX="_PURGE_FILAMENT" MSG="TOOLHEAD: {toolhead}, E: {e}"
{% if e > 0 %}
G92 E0
G0 E{e} F300
G92 E0
M400
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={0.4 if toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={0.4 if toolhead == 1 else 0}
{% else %}
M106 S{(255 * 0.4)}
{% endif %}
{% endif %}
G4 P3000
{% if r > 0 %}
G92 E0
G0 E-{r} F300
G92 E0
M400
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_PARKING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_PARKING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_LOADING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_LOADING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% if act_t == toolhead %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{loading_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CLEANING_MOVE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined and printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% set cleaning_position = loading_position %}
{% if loading_position == parking_position %}
{% if loading_position > 0 %}
{% set cleaning_position = loading_position - 30 %}
{% else %}
{% set cleaning_position = loading_position + 30 %}
{% endif %}
{% endif %}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _START_PRINT_BED_MESH]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
SET_MACRO_TRAVEL_SETTINGS
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set X=[params.X0|default(-1)|float, params.X1|default(-1)|float] %}
{% set Y=[params.Y0|default(-1)|float, params.Y1|default(-1)|float] %}
DEBUG_ECHO PREFIX="_START_PRINT_BED_MESH" MSG="idex_mode: {idex_mode}, X: {X}, Y: {Y}"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set X=[0, printable_x_max] %}
{% endif %}
{% set beacon_bed_mesh_scv = printer["gcode_macro RatOS"].beacon_bed_mesh_scv|default(25)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% if printer.configfile.settings.beacon is defined and not beacon_contact_bed_mesh %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={beacon_bed_mesh_scv}
{% endif %}
{% set default_profile = printer["gcode_macro RatOS"].bed_mesh_profile|default('ratos') %}
{% if printer["gcode_macro RatOS"].calibrate_bed_mesh|lower == 'true' %}
BED_MESH_CLEAR
{% if printer["gcode_macro RatOS"].adaptive_mesh|lower == 'true' %}
CALIBRATE_ADAPTIVE_MESH PROFILE={default_profile} X0={X[0]} X1={X[1]} Y0={Y[0]} Y1={Y[1]} T={params.T|int} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={idex_mode}
{% else %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% endif %}
BED_MESH_PROFILE LOAD={default_profile}
{% elif printer["gcode_macro RatOS"].bed_mesh_profile is defined %}
BED_MESH_CLEAR
BED_MESH_PROFILE LOAD={printer["gcode_macro RatOS"].bed_mesh_profile}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
[gcode_macro CALIBRATE_ADAPTIVE_MESH]
gcode =
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set default_profile = params.PROFILE %}
{% set x0 = params.X0|default(-1)|float %}
{% set y0 = params.Y0|default(-1)|float %}
{% set x1 = params.X1|default(-1)|float %}
{% set y1 = params.Y1|default(-1)|float %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Recieved coordinates X0={x0} Y0={y0} X1={x1} Y1={y1}"
{% if x0 >= x1 or y0 >= y1 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Invalid coordinates received. Please check your slicer settings. Falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float %}
{% set mesh_x0 = [[x0, max_x]|min, min_x]|max %}
{% set mesh_y0 = [[y0, max_y]|min, min_y]|max %}
{% set mesh_x1 = [[x1, max_x]|min, min_x]|max %}
{% set mesh_y1 = [[y1, max_y]|min, min_y]|max %}
{% if mesh_x0 == min_x and mesh_y0 == min_y and mesh_x1 == max_x and mesh_y1 == max_y %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Print is using the full bed, falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
DEPLOY_PROBE
{% endif %}
{% set probe_count_x = mesh_config.probe_count.split(",")[0]|int %}
{% if mesh_config.probe_count.split(",")|length == 2 %}
{% set probe_count_y = mesh_config.probe_count.split(",")[1]|int %}
{% else %}
{% set probe_count_y = mesh_config.probe_count.split(",")[0]|int %}
{% endif %}
{% set probe_x_step = (max_x - min_x) / probe_count_x %}
{% set probe_y_step = (max_y - min_y) / probe_count_y %}
{% set mesh_count_x = ([(mesh_x1 - mesh_x0) / probe_x_step, 3]|max)|int %}
{% set mesh_count_y = ([(mesh_y1 - mesh_y0) / probe_y_step, 3]|max)|int %}
{% set min_mesh_count = [mesh_count_x, mesh_count_y]|min %}
{% set max_mesh_count = [mesh_count_x, mesh_count_y]|max %}
{% set algorithm = mesh_config.algorithm %}
{% if algorithm|lower == 'lagrange' and max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="cannot exceed a probe_count of 6 when using lagrange interpolation. Falling back to bicubic interpolation."
{% set algorithm = 'bicubic' %}
{% endif %}
{% if algorithm|lower == 'bicubic' and min_mesh_count < 4 %}
{% if max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="invalid probe_count option when using bicubic interpolation. Combination of 3 points on one axis with more than 6 on another is not permitted. Forcing minimum mesh count to be 4."
{% set min_mesh_count = 4 %}
{% else %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="bicubic interpolation with a probe_count of less than 4 points detected. Forcing lagrange interpolation."
{% set algorithm = 'lagrange' %}
{% endif %}
{% endif %}
{% set mesh_count_x = ([min_mesh_count, mesh_count_x]|max)|int %}
{% set mesh_count_x = ([max_mesh_count, mesh_count_x]|min)|int %}
{% set mesh_count_y = ([min_mesh_count, mesh_count_y]|max)|int %}
{% set mesh_count_y = ([max_mesh_count, mesh_count_y]|min)|int %}
{% set should_prime = printer["gcode_macro RatOS"].nozzle_priming == 'primeblob' %}
{% if printer["dual_carriage"] is not defined %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% else %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% endif %}
{% if printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 != 0 and probe_first %}
{% set probe_first = false %}
{% elif printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 == 0 and not probe_first %}
{% set probe_first = true %}
{% endif %}
{% if should_prime and probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="mesh coordinates X0={mesh_x0} Y0={mesh_y0} X1={mesh_x1} Y1={mesh_y1}"
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% if should_prime and not probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
STOW_PROBE
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M84]
rename_existing = M84.1
gcode =
M84.1
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
{% if printer["dual_carriage"] is defined %}
_SET_TOOLHEAD_OFFSET T={printer["gcode_macro RatOS"].default_toolhead|int} MOVE=0
SET_GCODE_VARIABLE MACRO=SET_PRESSURE_ADVANCE VARIABLE=snyc_toolheads VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro _VAOC"] is defined %}
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started VALUE=False
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started_at_temp VALUE=False
{% endif %}
SET_GCODE_OFFSET X=0 Y=0 Z=0 MOVE=0
_IDEX_SINGLE INIT=1
{% endif %}
SET_SKEW CLEAR=1
_LED_MOTORS_OFF
[gcode_macro M104]
rename_existing = M104.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
DEBUG_ECHO PREFIX="M104" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set temperature_offset_t0 = printer["gcode_macro T0"].temperature_offset|default(0)|int %}
{% set temperature_offset_t1 = printer["gcode_macro T1"].temperature_offset|default(0)|int %}
{% set s0 = [s + temperature_offset_t0, 0]|max %}
{% set s1 = [s + temperature_offset_t1, 0]|max %}
{% if temperature_offset_t0 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t0}°C added to toolhead T0."
{% endif %}
{% if temperature_offset_t1 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t1}°C added to toolhead T1."
{% endif %}
{% else %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
M104.1 S{s0} T0
M104.1 S{s1} T1
{% else %}
M104.1 S{s} T{t}
{% endif %}
{% endif %}
[gcode_macro M109]
rename_existing = M109.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
DEBUG_ECHO PREFIX="M109" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M109" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
M109.1 S{s} T{t}
{% endif %}
[gcode_macro SET_HEATER_TEMPERATURE]
rename_existing = SET_HEATER_TEMPERATURE_BASE
gcode =
{% set heater = params.HEATER|default("") %}
{% set target = params.TARGET|default(0)|int %}
DEBUG_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="heater: {heater}, target: {target}"
{% if heater|lower == "extruder" or heater|lower == "extruder1" %}
{% set t = 0 if heater|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and target > 0 %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set target = [target + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
SET_HEATER_TEMPERATURE_BASE HEATER="{heater}" TARGET={target}
[gcode_macro TEMPERATURE_WAIT]
rename_existing = TEMPERATURE_WAIT_BASE
gcode =
{% set sensor = params.SENSOR|default("") %}
{% set minimum = params.MINIMUM|default(-1)|int %}
{% set maximum = params.MAXIMUM|default(-1)|int %}
DEBUG_ECHO PREFIX="TEMPERATURE_WAIT" MSG="sensor: {sensor}, minimum: {minimum}, maximum: {maximum}"
{% if sensor|lower == "extruder" or sensor|lower == "extruder1" %}
{% set t = 0 if sensor|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and (minimum > 0 or maximum > 0) %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% if minimum > -1 %}
{% set minimum = [minimum + temperature_offset, 0]|max %}
{% endif %}
{% if maximum > -1 %}
{% set maximum = [maximum + temperature_offset, 0]|max %}
{% endif %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% if minimum > -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum} MAXIMUM={maximum}
{% elif minimum > -1 and maximum == -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum}
{% elif minimum == -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MAXIMUM={maximum}
{% endif %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature for toolhead T{t} reached."
[gcode_macro SET_GCODE_OFFSET]
rename_existing = SET_GCODE_OFFSET_ORG
gcode =
SET_GCODE_OFFSET_ORG { rawparams }
{% if printer.configfile.settings.beacon is defined and (params.Z_ADJUST is defined or params.Z is defined) %}
_BEACON_APPLY_RUNTIME_MULTIPLIER
{% endif %}
[gcode_macro SDCARD_PRINT_FILE]
rename_existing = SDCARD_PRINT_FILE_BASE
gcode =
{% if printer["ratos"] is defined %}
PROCESS_GCODE_FILE { rawparams }
{% else %}
SDCARD_PRINT_FILE_BASE { rawparams }
{% endif %}
[gcode_macro SKEW_PROFILE]
rename_existing = SKEW_PROFILE_BASE
variable_loaded_profile = ""
gcode =
{% if params.LOAD is defined %}
{% if printer.configfile.settings["skew_correction %s" % params.LOAD] is defined %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='"{params.LOAD}"'
{% endif %}
{% endif %}
SKEW_PROFILE_BASE { rawparams }
[gcode_macro SET_SKEW]
rename_existing = SET_SKEW_BASE
gcode =
{% if params.CLEAR is defined %}
{% if params.CLEAR|default(0)|int == 1 %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='""'
{% endif %}
{% endif %}
SET_SKEW_BASE { rawparams }
[gcode_macro SET_VELOCITY_LIMIT]
rename_existing = SET_VELOCITY_LIMIT_BASE
gcode =
{% if params.ACCEL_TO_DECEL is defined %}
{% if params.ACCEL is defined %}
{% set accel = params.ACCEL|float %}
{% else %}
{% set accel = printer.toolhead.max_accel|float %}
{% endif %}
{% if params.VELOCITY is defined %}
{% set velocity = params.VELOCITY|float %}
{% else %}
{% set velocity = printer.toolhead.max_velocity|float %}
{% endif %}
{% if params.SQUARE_CORNER_VELOCITY is defined %}
{% set scv = params.SQUARE_CORNER_VELOCITY|float %}
{% else %}
{% set scv = printer.toolhead.square_corner_velocity|float %}
{% endif %}
{% set mcr = params.ACCEL_TO_DECEL|float / accel %}
DEBUG_ECHO PREFIX="SET_VELOCITY_LIMIT" MSG="ACCEL={accel}, VELOCITY={velocity}, SQUARE_CORNER_VELOCITY={scv}, MINIMUM_CRUISE_RATIO={mcr}"
SET_VELOCITY_LIMIT_BASE ACCEL={accel} VELOCITY={velocity} SQUARE_CORNER_VELOCITY={scv} MINIMUM_CRUISE_RATIO={1-mcr}
{% else %}
SET_VELOCITY_LIMIT_BASE { rawparams }
{% endif %}
[gcode_macro _START_PRINT_PARK]
gcode =
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_x = printer["gcode_macro RatOS"].start_print_park_x %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% endif %}
{% if printer["dual_carriage"] is defined and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
{% if printer["gcode_macro RatOS"].start_print_park_x is defined and printer["gcode_macro RatOS"].start_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="start_print_park_x is ignored for IDEX printers"
{% endif %}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={start_print_park_in} X={start_print_park_x}
G0 Z{z} F{z_speed}
[gcode_macro _END_PRINT_PARK]
gcode =
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro RatOS"].end_print_park_x is defined and printer["gcode_macro RatOS"].end_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="end_print_park_x is ignored for IDEX printers"
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={printer["gcode_macro RatOS"].end_print_park_in} X={printer["gcode_macro RatOS"].end_print_park_x}
[gcode_macro _PARK]
gcode =
{% set x = params.X %}
{% set location = params.LOCATION|default('back')|lower %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set nozzle_priming = printer["gcode_macro RatOS"].nozzle_priming|lower %}
CACHE_TOOLHEAD_SETTINGS KEY="park"
SET_MACRO_TRAVEL_SETTINGS
{% if x != '' %}
{% if x|float >= printer.toolhead.axis_minimum.x + 5 and x|float <= printable_x_max - 5 %}
{% set park_x = x|float %}
{% else %}
{action_respond_info('The requested X co-ordinate is outside the defined axis bounds - using defaults')}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% else %}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% set park_y = printable_y_max - 15 %}
{% if location == 'front' %}
{% set park_y = printer.toolhead.axis_minimum.y + 5 %}
{% elif location == 'center' %}
{% set park_y = printable_y_max / 2 %}
{% elif location == 'primeblob' and printer["dual_carriage"] is defined %}
{% set park_y = printable_y_max - 15 %}
{% endif %}
{% if location == 'primeblob' and printer["dual_carriage"] is not defined %}
{% if (nozzle_priming == 'primeblob' or nozzle_priming == 'primeline') %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set park_x = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set park_x = printable_x_max - 5 %}
{% else %}
{% set park_x = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set park_y = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set park_y = printable_y_max - 5 %}
{% else %}
{% set park_y = nozzle_prime_start_y|float %}
{% endif %}
{% endif %}
{% endif %}
G90
{% if printer["dual_carriage"] is not defined %}
G0 X{park_x} Y{park_y} F{speed}
{% else %}
G0 Y{park_y} F{speed}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="park"
[gcode_macro SAVE_PROBE_RESULT]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
{% set last_z_offset = 9999.9 %}
{% if printer.configfile.settings.beacon is defined %}
{% set current_z = printer.toolhead.position.z|float %}
{% if beacon_contact_prime_probing %}
{% set last_z_offset = printer.beacon.last_z_result %}
{% else %}
{% set last_z_offset = printer.beacon.last_sample.dist - current_z %}
{% endif %}
{% elif printer.configfile.settings.bltouch is defined %}
{% set config_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% elif printer.configfile.settings.probe is defined %}
{% set config_offset = printer.configfile.settings.probe.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Saving offset adjustment of {last_z_offset} in {params.VARIABLE|default('last_z_offset')}"
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE={params.VARIABLE|default('last_z_offset')} VALUE={last_z_offset}
[gcode_macro PROBE_FOR_PRIMING]
gcode =
{% set probe_for_priming_disable_mesh_constraints = true if printer["gcode_macro RatOS"].probe_for_priming_disable_mesh_constraints|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower != 'false' %}
SAVE_GCODE_STATE NAME=probe_for_priming_state
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the prime location.."
CACHE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
SET_MACRO_TRAVEL_SETTINGS
{% set t = params.TOOLHEAD|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% if idex_mode == '' %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% if t == 0 %}
{% set x_start = 5 %}
{% else %}
{% set x_start = printable_x_max - 5 %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% endif %}
{% endif %}
{% set z = printer.configfile.settings.bed_mesh.horizontal_move_z|float %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% if printer.configfile.settings.bltouch is defined %}
{% set x_offset = printer.configfile.settings.bltouch.x_offset|float %}
{% set y_offset = printer.configfile.settings.bltouch.y_offset|float %}
{% set z_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% elif printer.configfile.settings.probe is defined %}
{% set x_offset = printer.configfile.settings.probe.x_offset|float %}
{% set y_offset = printer.configfile.settings.probe.y_offset|float %}
{% set z_offset = printer.configfile.settings.probe.z_offset|float %}
{% elif printer.configfile.settings.beacon is defined %}
{% set x_offset = printer.configfile.settings.beacon.x_offset|float %}
{% set y_offset = printer.configfile.settings.beacon.y_offset|float %}
{% set z_offset = printer.configfile.settings.beacon.trigger_distance|float %}
{% else %}
{ action_raise_error("No probe, beacon or bltouch section found. Adaptive priming only works with a [probe], [beacon] or [bltouch] section defined.") }
{% endif %}
{% if z < z_offset %}
{ action_raise_error("Horizontal move Z ({z}) is below your probe's Z offset ({z_offset}). Please adjust your horizontal_move_z setting in [bed_mesh] to be above {z}.") }
{% endif %}
{% if not probe_for_priming_disable_mesh_constraints %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float - x_offset %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float - y_offset %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float - x_offset %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float - y_offset %}
{% set x_start = [[x_start, max_x]|min, min_x]|max %}
{% set y_start = [[y_start, max_y]|min, min_y]|max %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the start of the prime location at {x_start}, {y_start}"
G90
M83
G0 Z{z} F{z_speed}
G1 X{x_start} Y{y_start} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result
{% endif %}
{% if idex_mode == '' %}
{% set x_end = x_start %}
{% set y_end = y_start + 45 %}
{% else %}
{% if t==1 %}
{% set x_end = x_start - 45 %}
{% else %}
{% set x_end = x_start + 45 %}
{% endif %}
{% set y_end = y_start %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the end of the prime location at {x_end}, {y_end}"
G1 X{x_end} Y{y_end} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result
{% endif %}
RESTORE_GCODE_STATE NAME=probe_for_priming_state
RESTORE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
{% endif %}
[gcode_macro RESET_PRIME_PROBE_STATE]
gcode =
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result VALUE=None
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result_t1 VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result_t1 VALUE=None
{% endif %}
[gcode_macro PROBE_CURRENT_POSITION]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
SAVE_GCODE_STATE NAME=probe_current_position_state
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
ASSERT_PROBE_DEPLOYED
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_prime_probing %}
PROBE PROBE_METHOD=contact SAMPLES=1
{% else %}
PROBE
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
BEACON_QUERY
{% else %}
RESTORE_GCODE_STATE NAME=probe_current_position_state MOVE=1 MOVE_SPEED={printer["gcode_macro RatOS"].macro_z_speed|float}
{% endif %}
[gcode_macro PRIME_BLOB]
description = Prints a primeblob, used internally, if configured, as part of the START_PRINT macro.
variable_x_offset = 5
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="prime_blob"
SET_MACRO_TRAVEL_SETTINGS
RATOS_ECHO PREFIX="Priming" MSG="Priming nozzle with prime blob.."
{% set current_toolhead = 0 %}
{% set target_idex_mode = '' %}
{% set extruder = 'extruder' %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE is defined %}
{% set target_idex_mode = params.IDEX_MODE|default('')|lower %}
{% else %}
{ action_raise_error("IDEX_MODE parameter not found for PRIME_BLOB macro. This is likely a bug.") }
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Priming in IDEX {target_idex_mode} mode.."
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set current_toolhead = 1 if current_idex_mode=='primary' else 0 %}
{% set extruder = 'extruder1' if current_toolhead == 1 else 'extruder' %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
SAVE_GCODE_STATE NAME=prime_blob_state
{% endif %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set fan_speed = printer["gcode_macro RatOS"].nozzle_prime_bridge_fan|float %}
{% set nozzle_diameter = printer.configfile.settings[extruder].nozzle_diameter|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set has_start_offset_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) != 9999.9 %}
{% if printer["dual_carriage"] is defined %}
{% set has_start_offset_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) != 9999.9 %}
{% endif %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_z_height = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set nozzle_prime_direction = printer["gcode_macro RatOS"].nozzle_prime_direction|lower %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% if target_idex_mode == '' %}
{% set x_factor = 0 %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% set y_factor = 1 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% set y_factor = -1 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% if nozzle_prime_start_y|float < printable_y_max / 2 %}
{% set y_factor = 1 %}
{% else %}
{% set y_factor = -1 %}
{% endif %}
{% endif %}
{% if nozzle_prime_direction == 'forwards' %}
{% set y_factor = 1 %}
{% elif nozzle_prime_direction == 'backwards' %}
{% set y_factor = -1 %}
{% endif %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% else %}
{% set z = start_print_park_z_height %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% set y_factor = 0 %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set x_start = center_x / 2 + 5 %}
{% set x_factor = 1 %}
{% else %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% if current_toolhead == 0 %}
{% set x_start = 55 %}
{% set x_factor = -1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 55 %}
{% set x_factor = 1 %}
{% endif %}
{% else %}
{% if current_toolhead == 0 %}
{% set x_start = 5 %}
{% set x_factor = 1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 5 %}
{% set x_factor = -1 %}
{% endif %}
{% endif %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_x_max - 5 %}
{% endif %}
{% set z = 10 %}
{% endif %}
{% set start_z_offset = 0 %}
{% set end_z_offset = 0 %}
{% if has_start_offset_t0 %}
{% set start_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) %}
{% set end_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_end_result|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t0) ) }
{% endif %}
{% if end_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t0) ) }
{% endif %}
{% set start_z_offset = start_z_probe_result_t0 %}
{% set end_z_offset = end_z_probe_result_t0 %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if current_toolhead == 1 or both_toolheads or target_idex_mode == "copy" or target_idex_mode == "mirror" %}
{% if has_start_offset_t1 %}
{% set start_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) %}
{% set end_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_end_result_t1|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t1) ) }
{% endif %}
{% if end_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t1) ) }
{% endif %}
{% set start_z_offset = [start_z_offset, start_z_probe_result_t1]|max %}
{% set end_z_offset = [end_z_offset, start_z_probe_result_t1]|max %}
{% endif %}
{% endif %}
{% if target_idex_mode != 'copy' and target_idex_mode != 'mirror' %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% set original_start_z_offset = start_z_offset %}
{% set original_end_z_offset = end_z_offset %}
{% set start_z_offset = original_end_z_offset %}
{% set end_z_offset = original_start_z_offset %}
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={current_toolhead}
{% endif %}
DEBUG_ECHO PREFIX="PRIME_BLOB" MSG="x_start: {x_start}, y_start: {y_start}, x_factor: {x_factor}, y_factor: {y_factor}, z: {z}, start_z_offset: {start_z_offset}, end_z_offset: {end_z_offset}"
G90
M83
RATOS_ECHO PREFIX="Priming" MSG="Lifting Z to {z}.."
G0 Z{z} F{z_speed}
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% if start_print_park_in != 'primeblob' %}
G1 X{x_start} F{speed}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% endif %}
{% else %}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% if target_idex_mode=="copy" or target_idex_mode=="mirror" %}
RATOS_ECHO PREFIX="Priming" MSG="Mirroring move to {x_start}, {y_start} along the edge of the print area.."
_IDEX_MIRROR PRIMING=1
{% else %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% endif %}
G1 X{x_start} F{speed}
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Starting prime blob.."
G1 Z{0.5 + start_z_offset} F{z_speed}
G1 Y{y_start} F{speed}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
M106 S{fan_speed}
G1 Z5 F100 E5
G92 E0
RATOS_ECHO PREFIX="Priming" MSG="Bridging with {((fan_speed/255) * 100)|int}% fan speed.."
G1 F3000 X{x_start + (15 * x_factor)} Y{y_start + (15 * y_factor)} E{1 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (20 * x_factor)} Y{y_start + (20 * y_factor)} Z{3.8 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (34 * x_factor)} Y{y_start + (34 * y_factor)} Z{2.6 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (38 * x_factor)} Y{y_start + (38 * y_factor)} Z{1.4 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (42 * x_factor)} Y{y_start + (42 * y_factor)} Z{0.2 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
M106 S0
G1 F3000 X{x_start + (46 * x_factor)} Y{y_start + (46 * y_factor)} Z{0.2 + end_z_offset} E0.6
G1 F{speed} X{x_start + (50 * x_factor)} Y{y_start + (50 * y_factor)}
{% if target_idex_mode == "copy" or target_idex_mode == "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if target_idex_mode == "copy" %}
{% if first_y >= 0 %}
_IDEX_COPY DANCE=0 Y={first_y}
{% else %}
_IDEX_COPY DANCE=0 Y={params.Y1}
{% endif %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
RESTORE_GCODE_STATE NAME=prime_blob_state
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="prime_blob"
G92 E0
[gcode_macro UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% set temp = params.TEMP|default(220)|int %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_UNLOAD_FILAMENT TEMP={temp} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _LEGACY_UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set unload_speed = 5 * 60 %}
{% set unload_length = printer["gcode_macro RatOS"].filament_unload_length|float %}
M117 Unloading filament...
G0 E10 F300
G0 E-5 F3600
G4 P3000
G0 E5 F6000
G0 E-15 F6000
G0 E-{unload_length} F{unload_speed}
_CLEANING_MOVE TOOLHEAD={toolhead}
M117 Filament unloaded!
RESPOND MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _DEFAULT_UNLOAD_FILAMENT]
description = Unload filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_UNLOAD_FILAMENT" MSG="TEMP: {temp}"
_LED_UNLOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=unload_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD=0 NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TOOLHEAD=0
{% endif %}
RESTORE_GCODE_STATE NAME=unload_state
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD=0
[gcode_macro _IDEX_UNLOAD_FILAMENT]
description = Unload filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_UNLOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead}
{% endif %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Unloading filament from nozzle to cooling zone... Please wait!"
_PURGE_BEFORE_UNLOAD TOOLHEAD={toolhead}
{% if printer["gcode_macro _UNLOAD_WITHOUT_TIP_FORMING"] is defined %}
_UNLOAD_WITHOUT_TIP_FORMING TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_UNLOAD_WITH_TIP_FORMING NAME='{filament_name}' TYPE='{filament_type}'
{% endif %}
G4 P3000
[gcode_macro _UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
{% set tooolhead_sensor_to_extruder_gear_distance = printer["gcode_macro T%s" % toolhead].tooolhead_sensor_to_extruder_gear_distance|float %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER" MSG="TOOLHEAD: {toolhead}"
G0 E-{extruder_gear_to_cooling_position_distance + tooolhead_sensor_to_extruder_gear_distance + 50} F{extruder_load_speed}
RATOS_ECHO MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _UNLOAD_WITH_TIP_FORMING]
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% if filament_name != '' and filament_type != '' %}
_UNLOAD_KNOWN_FILAMENT NAME={filament_name} TYPE={filament_type}
{% else %}
_UNLOAD_UNKNOWN_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _UNLOAD_KNOWN_FILAMENT]
description = User overrideable tip forming macro if slicer filament profiles are known
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
RATOS_ECHO PREFIX="FILAMENT TYPE" MSG='{filament_type}'
RATOS_ECHO PREFIX="FILAMENT PROFILE" MSG='{filament_name}'
{% if filament_name == "Prusament PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% elif filament_name == "Nobufil PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% else %}
RATOS_ECHO PREFIX="_UNLOAD_KNOWN_FILAMENT" MSG="Filament profile not found!"
_UNLOAD_UNKNOWN_FILAMENT
{% endif %}
[gcode_macro _UNLOAD_UNKNOWN_FILAMENT]
description = User overrideable standard tip forming macro
gcode =
DEBUG_ECHO PREFIX="_UNLOAD_UNKNOWN_FILAMENT" MSG="Using standard tip forming macro!"
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
[gcode_macro _TIP_FORMING]
gcode =
{% set cooling_moves = params.COOLING_MOVES|default(4)|int %}
{% set cooling_move_length = params.COOLING_MOVE_LENGTH|default(10)|float %}
{% set start_cooling_speed = params.START_COOLING_SPEED|default(10)|float * 60 %}
{% set end_cooling_speed = params.END_COOLING_SPEED|default(50)|float * 60 %}
{% if cooling_moves == 0 %}
{% set cooling_move_length = 0 %}
{% endif %}
{% set dip = true if params.DIP|default(false)|lower == "true" else false %}
{% set dip_length = params.DIP_LENGTH|default(22)|float %}
{% set dip_speed = params.DIP_SPEED|default(30)|float * 60 %}
{% set dip_retract_speed = params.DIP_RETRACT_SPEED|default(70)|float * 60 %}
{% set retract_length = params.RETRACT_LENGTH|default(18)|float %}
{% set start_retract_speed = params.START_RETRACT_SPEED|default(120)|float * 60 %}
{% set end_retract_speed = params.END_RETRACT_SPEED|default(20)|float * 60 %}
DEBUG_ECHO PREFIX="_TIP_FORMING" MSG="cooling_moves: {cooling_moves}, cooling_move_length: {cooling_move_length}, start_cooling_speed: {start_cooling_speed}, end_cooling_speed: {end_cooling_speed}, dip: {dip}, dip_length: {dip_length}, dip_speed: {dip_speed}, dip_retract_speed: {dip_retract_speed}, retract_length: {retract_length}, start_retract_speed: {start_retract_speed}, end_retract_speed: {end_retract_speed}"
M220 S100
G92 E0
{% set retract = retract_length + cooling_move_length / 2 - 15 %}
G1 E-15 F{start_retract_speed}
G1 E-{0.7 * retract} F{1.0 * end_retract_speed}
G1 E-{0.2 * retract} F{0.5 * end_retract_speed}
G1 E-{0.1 * retract} F{0.3 * end_retract_speed}
G92 E0
{% if cooling_moves > 0 %}
{% set i = (end_cooling_speed - start_cooling_speed) / (2 * cooling_moves - 1) %}
{% for m in range(cooling_moves) %}
G1 E{cooling_move_length} F{(start_cooling_speed + i * m * 2)}
G1 E-{cooling_move_length} F{(start_cooling_speed + i * (m * 2 + 1))}
{% endfor %}
{% endif %}
G92 E0
{% if dip %}
G1 E{dip_length} F{dip_speed}
G4 P100
G1 E-{dip_length} F{dip_retract_speed}
{% endif %}
G92 E0
M400
[gcode_macro _ON_FILAMENT_SENSOR_BUTTON_PRESSED]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_SENSOR_BUTTON_PRESSED" MSG="TOOLHEAD: {toolhead}"
{% if not printer.virtual_sdcard.is_active %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_FILAMENT_END]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set clogged = true if params.CLOGGED|default(false)|lower == 'true' else false %}
{% set unload_after_runout = printer["gcode_macro T%s" % toolhead].unload_after_runout|float %}
{% if clogged %}
_LED_FILAMENT_CLOG TOOLHEAD={toolhead}
{% else %}
_LED_FILAMENT_RUNOUT TOOLHEAD={toolhead}
{% endif %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_END" MSG="TOOLHEAD: {toolhead}"
{% if printer.virtual_sdcard.is_active %}
{% if not printer.pause_resume.is_paused %}
PAUSE RUNOUT=True
{% endif %}
{% if not clogged and unload_after_runout %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% if not clogged and printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true'%}
_JOIN_SPOOL TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M600]
description = Executes a color change by pausing the printer an unloading the filament.
gcode =
PAUSE
UNLOAD_FILAMENT
RATOS_ECHO MSG="Please load new filament and resume"
[gcode_macro COLD_PULL]
description = Automated hotend cold pull.
gcode =
{% set extrusion_temp = params.EXTRUSION_TEMP|default(220)|int %}
{% set cold_pull_temp = params.COLD_PULL_TEMP|default(80)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% if printer["dual_carriage"] is not defined %}
{% set toolhead = 0 %}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead != 0 and toolhead != 1 %}
{action_raise_error("Please select toolhead! 0 = left, 1 = right toolhead")}
{% endif %}
{% endif %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
SAVE_GCODE_STATE NAME=cold_pull_state
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
RATOS_ECHO MSG="Heating T{toolhead} to {extrusion_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={extrusion_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={extrusion_temp} MAXIMUM={extrusion_temp + 2}
G4 P3000
RATOS_ECHO MSG="extruding..."
G92 E0
G1 E30 F300
G92 E0
RATOS_ECHO MSG="Heating T{toolhead} to {cold_pull_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={cold_pull_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={cold_pull_temp} MAXIMUM={cold_pull_temp + 2}
G4 P10000
RATOS_ECHO MSG="cold pull..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-40 VELOCITY=5 ACCEL=100
RATOS_ECHO MSG="eject filament..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-200 VELOCITY=20 ACCEL=500
RATOS_ECHO MSG="cooling down extruder..."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET=0
RESTORE_GCODE_STATE NAME=cold_pull_state
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
CONSOLE_ECHO TITLE="Cold pull finished!" MSG="Please remove the filament from the PTFE tube and cut the end off. Do NOT try to load it again." TYPE="warning"
[gcode_macro _USER_START_PRINT_BEFORE_HOMING]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_BED]
gcode =
[gcode_macro _USER_START_PRINT_BED_MESH]
gcode =
[gcode_macro _USER_START_PRINT_PARK]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
[gcode_macro _USER_START_PRINT_HEAT_CHAMBER]
description = Uses the extruder sensor to wait for chamber temp. Override the _START_PRINT_HEAT_CHAMBER macro to implement heated chamber handling.
gcode =
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
[gcode_macro _USER_END_PRINT_BEFORE_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_AFTER_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_PARK]
gcode =
[gcode_macro _USER_END_PRINT_FINISHED]
description = User hook for when the print is finished after gcode state has been restored.
gcode =
[gcode_macro _USER_START_PRINT]
gcode =
[gcode_macro _USER_END_START_PRINT]
gcode =
[gcode_macro _USER_START_FEATURE]
gcode =
[gcode_macro _USER_END_FEATURE]
gcode =
[gcode_macro ECHO_T_VARS]
description = Echo Toolhead variables to the console.
gcode =
{% set t = params.T|default(0) %}
RATOS_ECHO MSG="T{t} Variables"
{% for var, value in printer["gcode_macro T%s" % t].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[gcode_macro ECHO_RATOS_VARS]
description = Echo RatOS variables to the console.
gcode =
{% for var, value in printer["gcode_macro RatOS"].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[delayed_gcode RATOS_INIT]
initial_duration = 0.1
gcode =
_LED_STANDBY
CALCULATE_PRINTABLE_AREA
INITIAL_FRONTEND_UPDATE
_CHAMBER_FILTER_SANITY_CHECK
[delayed_gcode RATOS_LOGO]
initial_duration = 2
gcode =
HELLO_RATOS
[gcode_macro INITIAL_FRONTEND_UPDATE]
gcode =
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_error = printer["gcode_macro RatOS"].status_color_error|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_unknown}"'
{% endif %}
{% set t0_sensor = "undefined" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].filament_detected|lower == "true" %}
{% set t0_sensor = "detected" %}
{% else %}
{% set t0_sensor = "empty" %}
{% endif %}
{% else %}
{% set t0_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set t1_sensor = "undefined" %}
{% if printer["dual_carriage"] is defined and printer["filament_switch_sensor toolhead_filament_sensor_t1"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].filament_detected|lower == "true" %}
{% set t1_sensor = "detected" %}
{% else %}
{% set t1_sensor = "empty" %}
{% endif %}
{% else %}
{% set t1_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set svv = printer.save_variables.variables %}
{% if svv.t0_filament is defined and printer["gcode_macro T0"] is defined %}
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
{% if t0_sensor != "empty" %}
{% set t0_filament_type = svv.t0_filament[0]|default('')|string %}
{% set t0_filament_name = svv.t0_filament[1]|default('')|string %}
{% set t0_filament_temp = svv.t0_filament[2]|default(0)|float %}
{% if t0_filament_name != '' and t0_filament_type != '' and t0_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{t0_filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{t0_filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={t0_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
{% if svv.t1_filament is defined and printer["gcode_macro T1"] is defined %}
{% if printer["gcode_macro T1"].filament_name is defined and printer["gcode_macro T1"].filament_type is defined and printer["gcode_macro T1"].filament_temp is defined %}
{% if t1_sensor != "empty" %}
{% set t1_filament_type = svv.t1_filament[0]|default('')|string %}
{% set t1_filament_name = svv.t1_filament[1]|default('')|string %}
{% set t1_filament_temp = svv.t1_filament[2]|default(0)|float %}
{% if t1_filament_name != '' and t1_filament_type != '' and t1_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='"{t1_filament_name}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='"{t1_filament_type}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE={t1_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t1_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro CALCULATE_PRINTABLE_AREA]
gcode =
{% set bed_margin_x = printer["gcode_macro RatOS"].bed_margin_x %}
{% set bed_margin_y = printer["gcode_macro RatOS"].bed_margin_y %}
{% set tool = 0 if printer["gcode_macro T0"] is not defined or printer["gcode_macro T0"].active else 1 %}
{% set max_x = printer.toolhead.axis_maximum.x if printer["dual_carriage"] is defined and tool == 0 else printer.toolhead.axis_maximum.x - bed_margin_x[1] %}
{% if printer["dual_carriage"] is defined %}
{% set max_x = printer.toolhead.axis_maximum.x %}
{% endif %}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="printer.toolhead.axis_maximum.x {printer.toolhead.axis_maximum.x}"
{% set max_y = printer.toolhead.axis_maximum.y - bed_margin_y[1]%}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_x_max VALUE={max_x}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_y_max VALUE={max_y}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="Printable area calculated: X: 0,{max_x} Y: 0,{max_y}"
[gcode_macro CACHE_TOOLHEAD_SETTINGS]
variable_cache = {"global": {"accel": 1000, "ratio": 0.5, "speed": 50, "scv": 5}}
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set dummy = cache.__setitem__(key, {"accel": printer.toolhead.max_accel, "ratio": printer.toolhead.minimum_cruise_ratio, "speed": printer.toolhead.max_velocity, "scv": printer.toolhead.square_corner_velocity}) %}
SET_GCODE_VARIABLE MACRO=CACHE_TOOLHEAD_SETTINGS VARIABLE=cache VALUE="{cache | pprint | replace("\n", "") | replace("\"", "\\\"")}"
DEBUG_ECHO PREFIX="CACHE_TOOLHEAD_SETTINGS" MSG="Toolhead settings cached for {key}. {printer.toolhead.max_accel} accel, {printer.toolhead.minimum_cruise_ratio} ratio, {printer.toolhead.max_velocity} velocity, {printer.toolhead.square_corner_velocity} scv."
[gcode_macro RESTORE_TOOLHEAD_SETTINGS]
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set values = printer["gcode_macro CACHE_TOOLHEAD_SETTINGS"].cache.__getitem__(key) %}
{% if values is not defined or values == 'None' %}
{ action_raise_error("RESTORE_TOOLHEAD_SETTINGS: Toolhead settings not cached for key '" ~ key ~ "'.") }
{% endif %}
SET_VELOCITY_LIMIT ACCEL={values.accel} MINIMUM_CRUISE_RATIO={values.ratio} VELOCITY={values.speed} SQUARE_CORNER_VELOCITY={values.scv}
DEBUG_ECHO PREFIX="RESTORE_TOOLHEAD_SETTINGS" MSG="Toolhead settings restored. {values.accel} accel, {values.ratio} ratio, {values.speed} velocity, {values.scv} scv."
[gcode_macro SET_MACRO_TRAVEL_SETTINGS]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set accel = printer["gcode_macro RatOS"].macro_travel_accel %}
SET_VELOCITY_LIMIT ACCEL={accel} MINIMUM_CRUISE_RATIO=0.5 VELOCITY={speed} SQUARE_CORNER_VELOCITY={5}
DEBUG_ECHO PREFIX="SET_MACRO_TRAVEL_SETTINGS" MSG="Macro travel settings set. {accel} accel, {speed} velocity"
[gcode_macro SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% if printer["dual_carriage"] is not defined %}
SET_KINEMATIC_POSITION X={printable_x_max / 2} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
{% else %}
IDEX_SET_CENTER_KINEMATIC_POSITION
{% endif %}
[gcode_macro IDEX_SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set center_x = printable_x_max / 2 %}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x - (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x + (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
[gcode_macro VERIFY_HYBRID_INVERTED]
gcode =
{% set inverted = False %}
{% if printer.configfile.settings.ratos_hybrid_corexy is defined and printer.configfile.settings.ratos_hybrid_corexy.inverted is defined %}
{% if printer.configfile.settings.ratos_hybrid_corexy.inverted|lower == 'true' %}
{% set inverted = True %}
{% endif %}
{% endif %}
{% if inverted == False %}
{ action_emergency_stop("ratos_hybrid_corexy NOT INVERTED! Inverted hybrid core-xy bugfix not detected.") }
{% endif %}
[gcode_macro RATOS_ECHO]
gcode =
{% set prefix = "RatOS" %}
{% set debug = params.DEBUG|default(0)|int %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " | " ~ params.PREFIX %}
{% endif %}
{% set prefix = prefix ~ ":" %}
{% set msg = "" %}
{% if params.MSG is defined %}
{% set msg = params.MSG %}
{% else %}
{% set msg = "No msg parameter provided (this is a bug or unintended use)." %}
{% endif %}
{% if not debug %}
M117 {prefix} {msg}
{% endif %}
RATOS_LOG PREFIX="{prefix}" MSG="{msg}"
{% if not debug %}
RESPOND PREFIX="{prefix}" MSG="{msg}"
{% else %}
CONSOLE_ECHO TITLE="{prefix}" TYPE="debug" MSG="{msg}"
{% endif %}
[gcode_macro ENABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=True
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=prefix_filter VALUE="'{params.FILTER|default('')|lower}'"
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging enabled."
[gcode_macro DISABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=False
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging disabled."
[gcode_macro DEBUG_ECHO]
variable_enabled = False
variable_prefix_filter = ''
gcode =
{% set prefix = "DEBUG" %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " - " ~ params.PREFIX %}
{% endif %}
{% if enabled and (prefix_filter|lower == '' or prefix_filter|lower in params.PREFIX|lower) %}
RATOS_ECHO PREFIX="{prefix}" MSG="{params.MSG}" DEBUG=1
{% endif %}
[gcode_macro START_FEATURE]
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="Start {params.FEATURE} feature gcode"
{% set scv = printer.toolhead.square_corner_velocity|int|default(5) %}
{% set accel = printer.toolhead.max_accel|int|default(10000) %}
{% set ratio = printer.toolhead.minimum_cruise_ratio|float|default(0.5) %}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="scv" VALUE={scv}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="accel" VALUE={accel}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="ratio" VALUE={ratio}
_USER_START_FEATURE FEATURE="{params.FEATURE}"
[gcode_macro END_FEATURE]
variable_scv = 5
variable_accel = 10000
variable_ratio = 0.5
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="End {params.FEATURE} feature gcode"
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={scv} ACCEL={accel} MINIMUM_CRUISE_RATIO={ratio}
_USER_END_FEATURE FEATURE="{params.FEATURE}" SCV={scv} ACCEL={accel} RATIO={ratio}
[gcode_macro _ON_LAYER_CHANGE]
variable_layer_number = 0
description = INTERNAL USE ONLY. Call it from the slicers after layer change custom gcode
gcode =
{% set layer = params.LAYER|int %}
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE={layer}
SET_PRINT_STATS_INFO CURRENT_LAYER={layer}
[gcode_macro _LEARN_MORE_CALIBRATION]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/calibration" %}
{% set link_text = "RatOS Calibration Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_CHAMBER_FILTER]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter Control" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_FILAMENT]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/filaments" %}
{% set link_text = "RatOS Filament Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _CONSOLE_SAVE_CONFIG]
gcode =
M118 Click SAVE_CONFIG to save the settings to your printer.cfg.
[gcode_macro SAVE_Z_OFFSET]
gcode =
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SAVE_MULTIPLIER
{% else %}
Z_OFFSET_APPLY_PROBE
{% endif %}
[gcode_macro _LOAD_RATOS_SKEW_PROFILE]
gcode =
{% set ratos_skew_profile = printer["gcode_macro RatOS"].skew_profile|default("") %}
{% if ratos_skew_profile != "" %}
{% if printer.configfile.config["skew_correction %s" % ratos_skew_profile] is defined %}
SKEW_PROFILE LOAD={ratos_skew_profile}
GET_CURRENT_SKEW
{% else %}
{% set line_1 = '"Could not find skew profile %s!_N_Clearing skew correction."' % ratos_skew_profile %}
CONSOLE_ECHO TITLE="Missing skew profile!" TYPE="warning" MSG={line_1}
SET_SKEW CLEAR=1
{% endif %}
{% endif %}
[gcode_macro M601]
gcode =
PAUSE
[gcode_macro PAUSE]
description = Pauses the print
rename_existing = PAUSE_BASE
variable_extrude = 1.5
variable_retract = 1.5
variable_fan_speed = 0
variable_idex_mode = ""
variable_idex_toolhead = 0
variable_idex_toolhead_x = 0.0
variable_idex_toolhead_y = 0.0
variable_idex_toolhead_z = 0.0
gcode =
{% set runout_detected = true if params.RUNOUT|default(false)|lower == 'true' else false %}
_LED_PAUSE
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set idex_toolhead = 1 if idex_mode == 'primary' else 0 %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
SAVE_GCODE_STATE NAME=PAUSE_state
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_mode VALUE='"{idex_mode}"'
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead VALUE={idex_toolhead}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_x VALUE={printer.gcode_move.gcode_position.x|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_y VALUE={printer.gcode_move.gcode_position.y|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_z VALUE={printer.gcode_move.gcode_position.z|float}
DEBUG_ECHO PREFIX="PAUSE" MSG="idex_mode: {idex_mode}, idex_toolhead: {idex_toolhead}, idex_toolhead_x: {idex_toolhead_x}, idex_toolhead_y: {idex_toolhead_y}, idex_toolhead_z: {idex_toolhead_z}"
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
CACHE_TOOLHEAD_SETTINGS KEY="pause"
SET_MACRO_TRAVEL_SETTINGS
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% if current_z < (max_z - 20.0) %}
{% set z_safe = 20.0 %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
PAUSE_BASE
{% if printer["dual_carriage"] is not defined %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan"].speed|float}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
{% if idex_toolhead == 0 %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t1"].speed|float}
{% endif %}
{% endif %}
{% endif %}
M106 S0
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if idex_mode != '' %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set R = printer["gcode_macro PAUSE"].retract|float %}
{% if can_extrude %}
G91
G1 E-{R} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].pause_print_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].pause_print_park_in %}
{% if runout_detected %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].runout_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].runout_park_in %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
DEBUG_ECHO PREFIX="PAUSE" MSG="z_speed: {z_speed}, pause_print_park_x: {pause_print_park_x}, pause_print_park_in: {pause_print_park_in}, default_toolhead: {default_toolhead}"
{% if "xyz" in printer.toolhead.homed_axes %}
G91
G1 Z{z_safe} F{z_speed}
G90
{% if printer["dual_carriage"] is not defined %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% else %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
_IDEX_SINGLE X={parking_position}
{% else %}
PARK_TOOLHEAD
{% endif %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% endif %}
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="pause"
[gcode_macro RESUME]
description = Resumes the print if the printer is paused.
rename_existing = RESUME_BASE
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set target_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set target_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% endif %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if target_idex_mode != '' %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set fan_speed = printer["gcode_macro PAUSE"].fan_speed|float %}
{% if printer["dual_carriage"] is not defined %}
M106 S{(fan_speed * 255)}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% else %}
{% if params.TOOLHEAD is defined %}
{% if params.TOOLHEAD == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% else %}
{% if printer["gcode_macro PAUSE"].idex_toolhead == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% endif %}
{% endif %}
M106.1 S{fan_speed}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY DANCE=0
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR DANCE=0
{% else %}
{% if params.TOOLHEAD is defined %}
_SELECT_TOOL T={params.TOOLHEAD} X=-1 Y=-1 TOOLSHIFT=false
{% else %}
_SELECT_TOOL T={printer["gcode_macro PAUSE"].idex_toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% endif %}
{% set x = printer["gcode_macro PAUSE"].idex_toolhead_x|float %}
{% set y = printer["gcode_macro PAUSE"].idex_toolhead_y|float %}
{% set z = printer["gcode_macro PAUSE"].idex_toolhead_z|float %}
G1 X{x} Y{y} Z{z} F{speed}
{% if params.TOOLHEAD is defined %}
SAVE_GCODE_STATE NAME=PAUSE_STATE
{% endif %}
{% endif %}
{% if params.TOOLHEAD is not defined %}
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
{% if can_extrude %}
G91
G1 E{E} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1 MOVE_SPEED={speed}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
RESUME_BASE
_LED_PRINTING
[gcode_macro CANCEL_PRINT]
description = Cancels the printer
rename_existing = CANCEL_PRINT_BASE
gcode =
END_PRINT
TURN_OFF_HEATERS
CLEAR_PAUSE
CANCEL_PRINT_BASE
[gcode_macro START_PRINT]
description = Start print procedure, use this in your Slicer.
variable_post_processor_version = 2
variable_is_printing_gcode = False
variable_both_toolheads = True
variable_object_xoffset = 0
variable_first_x = -1
variable_first_y = -1
variable_total_toolshifts = 0
variable_initial_tool = 0
variable_extruder_first_layer_temp = ""
variable_extruder_other_layer_temp = ""
gcode =
{% if "xyz" in printer.toolhead.homed_axes and printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% if printer["gcode_macro _VAOC"].is_started|default(true)|lower == 'true' %}
_VAOC_END
{% endif %}
{% endif %}
_LED_START_PRINTING
CACHE_TOOLHEAD_SETTINGS KEY="start_print"
_USER_START_PRINT { rawparams }
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set bed_heat_soak_time = printer["gcode_macro RatOS"].bed_heat_soak_time|default(0)|int %}
{% set hotend_heat_soak_time = printer["gcode_macro RatOS"].hotend_heat_soak_time|default(0)|int %}
{% set z_probe_stowable = printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set X0 = params.X0|default(-1)|float %}
{% set X1 = params.X1|default(-1)|float %}
{% set Y0 = params.Y0|default(-1)|float %}
{% set Y1 = params.Y1|default(-1)|float %}
{% if first_x == -1 or first_y == -1 %}
{% set first_x = params.FIRST_X|default(-1)|float %}
{% set first_y = params.FIRST_Y|default(-1)|float %}
{% endif %}
{% set total_toolshifts = params.TOTAL_TOOLSHIFTS|default(0)|int %}
{% set initial_tool = params.INITIAL_TOOL|default(default_toolhead)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set bed_temp = params.BED_TEMP|default(printer.heater_bed.target, true)|float %}
{% set total_layer_count = params.TOTAL_LAYER_COUNT|default(0)|int %}
{% set extruder_first_layer_temp = (params.EXTRUDER_TEMP|default("")).split(",") %}
RATOS_ECHO MSG="First print coordinates X:{first_x} Y:{first_y}"
{% if params.TOTAL_LAYER_COUNT is not defined %}
{% set link_url = "https://os.ratrig.com/docs/slicers" %}
{% set link_text = "RatOS Slicer Configuration" %}
{% set line_1 = '"Your slicer gcode settings are not up to date._N_Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="Incomplete Slicer Configuration detected" TYPE="warning" MSG={line_1}
{% endif %}
SET_PRINT_STATS_INFO CURRENT_LAYER=1
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE=1
{% if total_layer_count > 0 %}
SET_PRINT_STATS_INFO TOTAL_LAYER={total_layer_count}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set swap_toolheads = true if printer["gcode_macro _IDEX_REMAP_TOOLHEADS"].enabled|default(false)|lower == 'true' else false %}
{% if swap_toolheads %}
{% set initial_tool = 0 if initial_tool == 1 else 1 %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=active VALUE=True
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=active VALUE=True
{% endif %}
{% set both_toolheads = true %}
{% if total_toolshifts == 0 %}
{% set both_toolheads = false %}
{% endif %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
{% endif %}
{% if both_toolheads and (idex_mode == "copy" or idex_mode == "mirror") %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Gcode tool changes found. Copy and mirror mode do not support toolchanges.")}
{% endif %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set both_toolheads = true %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=initial_tool VALUE={initial_tool}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_x VALUE={first_x}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_y VALUE={first_y}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=total_toolshifts VALUE={total_toolshifts}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=both_toolheads VALUE={both_toolheads}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_first_layer_temp VALUE="'{params.EXTRUDER_TEMP}'"
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_other_layer_temp VALUE="'{params.EXTRUDER_OTHER_LAYER_TEMP}'"
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE VARIABLE=toolshift_count VALUE=0
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set svv = printer.save_variables.variables %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
{% set stepper_x_position_min = printer.configfile.settings.stepper_x.position_min|float %}
{% set stepper_x_position_endstop = printer.configfile.settings.stepper_x.position_endstop|float %}
{% set dual_carriage_position_max = printer.configfile.settings.dual_carriage.position_max|float %}
{% set dual_carriage_position_endstop = printer.configfile.settings.dual_carriage.position_endstop|float %}
{% set x_parking_space = parking_position_t0 - (stepper_x_position_endstop , stepper_x_position_min)|max %}
{% set dc_parking_space = (dual_carriage_position_endstop , dual_carriage_position_max)|min - parking_position_t1 %}
{% if svv.idex_xoffset|abs >= (x_parking_space - 0.5) or svv.idex_xoffset|abs >= (dc_parking_space - 0.5) %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Toolhead x-offset is too high for the available parking space. Calibrate your X and DC endstop positions and make sure you stay below 1mm." % (copy_mode_max_width)) }
{% endif %}
{% endif %}
{% if (idex_mode == "copy" or idex_mode == "mirror") and printer.configfile.settings.ratos.enable_gcode_transform %}
{% if params.MIN_X is not defined or params.MAX_X is not defined %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Something went wrong! Missing important post processor start print parameter!") }
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE=0
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set boundary_box_min_x = params.MIN_X|default(0)|float %}
{% set boundary_box_max_x = params.MAX_X|default(printable_x_max)|float %}
{% set svv = printer.save_variables.variables %}
{% if default_toolhead == 0 %}
{% set boundary_box_max_x = boundary_box_max_x + svv.idex_xoffset %}
{% else %}
{% set boundary_box_min_x = boundary_box_min_x - svv.idex_xoffset %}
{% endif %}
{% set center_x = printable_x_max / 2.0 %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% set object_width = boundary_box_max_x - boundary_box_min_x %}
{% set copy_mode_max_width = center_x %}
{% set mirror_mode_max_width = center_x - safe_distance / 2.0 %}
DEBUG_ECHO PREFIX="START_PRINT" MSG="OBJECT_WIDTH: {object_width} BOUNDARY_BOX_MIN_X: {boundary_box_min_x} BOUNDARY_BOX_MAX_X: {boundary_box_max_x} CENTER_X: {center_x} SAFE_DISTANCE: {safe_distance}"
{% if idex_mode == "copy" and object_width > copy_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for copy mode! Max supported width is %s mm" % (copy_mode_max_width)) }
{% endif %}
{% if idex_mode == "mirror" and object_width > mirror_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for mirror mode! Max supported width is %s mm" % (mirror_mode_max_width)) }
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = (printable_x_max - boundary_box_max_x - boundary_box_min_x) / 2 %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE={object_xoffset}
{% endif %}
{% endif %}
{% set has_initial_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_initial_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined and both_toolheads %}
{% set has_secondary_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_secondary_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% endif %}
_CHAMBER_FILTER_ON AT="before_print_start"
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true' %}
{% if both_toolheads %}
RATOS_ECHO MSG="Spool join is not possible if both toolheads are in use!"
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if idex_mode == '' %}
_SET_TOOLHEAD_OFFSET T={default_toolhead} MOVE={1 if "xyz" in printer.toolhead.homed_axes else 0}
{% endif %}
{% endif %}
CLEAR_PAUSE
{% if printer["gcode_macro RatOS"].force_absolute_position|lower == 'true' %}
G90
{% endif %}
SAVE_GCODE_STATE NAME=start_print_state
G21
G90
M82
_USER_START_PRINT_BEFORE_HOMING { rawparams }
{% if z_probe_stowable == true %}
STOWABLE_PROBE_BEGIN_BATCH
{% endif %}
MAYBE_HOME
_Z_HOP
{% if idex_mode != '' and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
PARK_TOOLHEAD
{% endif %}
{% if chamber_temp > 0 %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED={printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float}
{% endif %}
{% endif %}
_CHAMBER_HEATER_ON START_CHAMBER_TEMP={start_chamber_temp} CHAMBER_TEMP={chamber_temp}
_USER_START_PRINT_HEAT_CHAMBER { rawparams } CHAMBER_TEMP={chamber_temp}
{% endif %}
_START_PRINT_BEFORE_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
RATOS_ECHO MSG="Heating bed..."
M190 S{bed_temp}
{% if bed_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking bed for {bed_heat_soak_time} seconds..."
G4 P{(bed_heat_soak_time * 1000)}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_BED { rawparams }
_START_PRINT_AFTER_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
_USER_START_PRINT_BED_MESH { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_BED_MESH X0={X0} X1={X1} Y0={Y0} Y1={Y1} T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if z_probe_stowable == true %}
STOWABLE_PROBE_END_BATCH
{% endif %}
{% if idex_mode == '' %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={extruder_first_layer_temp[1]|float}
{% endif %}
{% endif %}
_USER_START_PRINT_PARK { rawparams }
_START_PRINT_PARK
RATOS_ECHO MSG="Heating Extruder..."
{% if idex_mode == '' %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder1" MINIMUM={extruder_first_layer_temp[1]|float} MAXIMUM={extruder_first_layer_temp[1]|float + 5}
{% endif %}
{% endif %}
{% if hotend_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking hotend for {hotend_heat_soak_time} seconds..."
G4 P{(hotend_heat_soak_time * 1000)}
{% endif %}
{% if idex_mode == '' %}
_LED_PRINTING
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
_LED_PRINTING
{% else %}
{% if both_toolheads %}
_LED_PRINTING TOOLHEAD={initial_tool}
{% if toolchange_standby_temp > -1 %}
_LED_TOOLHEAD_STANDBY TOOLHEAD={0 if initial_tool == 1 else 1}
{% else %}
_LED_PRINTING TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% else %}
_LED_PRINTING TOOLHEAD={initial_tool}
_LED_DEACTIVATE_TOOLHEAD TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% endif %}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_EXTRUDER { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_AFTER_HEATING_EXTRUDER X0={X0} X1={X1} Y0={Y0} Y1={Y1} INITIAL_TOOLHEAD={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if idex_mode != '' %}
{% if not both_toolheads %}
{% if initial_tool != default_toolhead %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET=0
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if toolchange_standby_temp > -1 %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if initial_tool == 1 else 'extruder1'} TARGET={toolchange_standby_temp}
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% set x_offset = printer.toolhead.position.x|float - printer.gcode_move.gcode_position.x|float %}
{% endif %}
RESTORE_GCODE_STATE NAME=start_print_state
{% if idex_mode != '' %}
{% set act_idex_mode = printer["dual_carriage"].carriage_1|default('')|lower %}
{% if act_idex_mode == "copy" or act_idex_mode == "mirror" %}
SET_GCODE_OFFSET X={x_offset} MOVE=0
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% if idex_mode == "copy" and idex_mode != act_idex_mode %}
_IDEX_COPY DANCE=0
{% elif idex_mode == "mirror" and idex_mode != act_idex_mode %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
RATOS_ECHO MSG="Adjusting object x-offset by {(object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={object_xoffset} MOVE=0
{% endif %}
{% else %}
_SELECT_TOOL T={initial_tool} TOOLSHIFT=false
{% if initial_tool != default_toolhead %}
{% set svv = printer.save_variables.variables %}
SAVE_VARIABLE VARIABLE=idex_applied_offset VALUE={default_toolhead}
_SET_TOOLHEAD_OFFSET T={initial_tool} MOVE=0
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={initial_tool}
{% endif %}
_SET_EXTRUSION_MODE
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
SET_GCODE_VARIABLE MACRO=_SELECT_TOOL VARIABLE=last_timestamp VALUE={printer["print_stats"].print_duration}
{% endif %}
_USER_END_START_PRINT { rawparams }
G92 E0
_CHAMBER_FILTER_ON AT="after_print_start"
RATOS_ECHO MSG="Printing..."
[gcode_macro _START_PRINT_BEFORE_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set is_stowable_probe = true if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Pre-heating extruder..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={min_temp}
{% else %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET={min_temp}
{% endif %}
{% else %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
{% endif %}
{% endif %}
{% if not is_stowable_probe %}
{% if printer["dual_carriage"] is defined and act_t != default_toolhead %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
{% endif %}
RATOS_ECHO MSG="Heat soaking z probe..."
{% if auto_z_offset_calibration %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% if default_toolhead == 0 %}
_SELECT_TOOL T=0 TOOLSHIFT=false
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
{% elif default_toolhead == 1 %}
_SELECT_TOOL T=1 TOOLSHIFT=false
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
{% endif %}
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% endif %}
G0 Z2 F{z_speed}
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Waiting for extruder to be preheated..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
{% if default_toolhead == 0 %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_Z_HOP
{% endif %}
{% if auto_z_offset_calibration %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
PARK_TOOLHEAD
_CLEANING_MOVE TOOLHEAD={default_toolhead}
_SELECT_TOOL T={0 if default_toolhead == 1 else 1} X={parking_position_t0 if default_toolhead == 1 else parking_position_t1} Y=0 TOOLSHIFT=false
_CLEANING_MOVE TOOLHEAD={0 if default_toolhead == 1 else 1}
_VAOC_CALIBRATE_Z_OFFSET AUTO_Z_OFFSET=True
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=false
{% endif %}
{% set needs_rehoming = False %}
{% if printer.z_tilt is defined and not printer.z_tilt.applied %}
RATOS_ECHO MSG="Adjusting Z tilt..."
Z_TILT_ADJUST
RATOS_ECHO MSG="Rehoming Z after Z tilt adjustment..."
{% set needs_rehoming = True %}
{% endif %}
{% if printer.quad_gantry_level is defined and not printer.quad_gantry_level.applied %}
RATOS_ECHO MSG="Running quad gantry leveling..."
QUAD_GANTRY_LEVEL
RATOS_ECHO MSG="Rehoming Z after quad gantry leveling..."
{% set needs_rehoming = True %}
{% endif %}
{% if needs_rehoming %}
G28 Z
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %}
{% if beacon_contact_wipe_before_true_zero %}
_START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE
{% endif %}
_START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
G0 Z5 F{z_speed}
G0 X50 Y10 F{speed}
PROBE PROBE_METHOD=contact SAMPLES=1
BEACON_QUERY
[gcode_macro _START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_true_zero_temp = printer["gcode_macro RatOS"].beacon_contact_true_zero_temp|default(150)|int %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_true_zero_location = printer["gcode_macro RatOS"].beacon_contact_true_zero_location|default("front")|lower %}
{% set beacon_contact_true_zero_margin_x = printer["gcode_macro RatOS"].beacon_contact_true_zero_margin_x|default(30)|int %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if beacon_contact_wipe_before_true_zero %}
{% if printer.beacon.last_probe_result|lower == "ok" %}
{% set last_z_offset = printer.beacon.last_z_result %}
RATOS_ECHO MSG="Auto calibration nozzle wipe with probe result {last_z_offset}..."
G0 Z{(0.2 + last_z_offset)} F{z_speed}
G0 X70 F300
{% else %}
RATOS_ECHO MSG="Skipping auto calibration nozzle wipe because probing failed!"
{% endif %}
{% endif %}
G0 Z5 F{z_speed}
_MOVE_TO_SAFE_Z_HOME
RATOS_ECHO MSG="Heating extruder to probing temperature..."
SET_HEATER_TEMPERATURE HEATER={"extruder" if default_toolhead == 0 else "extruder1"} TARGET={beacon_contact_true_zero_temp}
TEMPERATURE_WAIT SENSOR={"extruder" if default_toolhead == 0 else "extruder1"} MINIMUM={beacon_contact_true_zero_temp} MAXIMUM={beacon_contact_true_zero_temp + 5}
RATOS_ECHO MSG="Beacon contact auto calibration..."
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
G0 Z5 F{z_speed}
[gcode_macro _START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set first_x = printer["gcode_macro START_PRINT"].first_x|default(-1)|float %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set center_x = printable_x_max / 2.0 %}
{% set center_y = printable_y_max / 2.0 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% if printer["dual_carriage"] is defined %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% endif %}
{% set X0 = params.X0|default(-1)|int %}
{% set X1 = params.X1|default(-1)|int %}
{% set Y0 = params.Y0|default(-1)|int %}
{% set Y1 = params.Y1|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% if idex_mode == '' %}
_PRIME
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
RATOS_ECHO PREFIX="IDEX" MSG="using combined prime offset for IDEX {idex_mode} mode"
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
{% if both_toolheads %}
{% if initial_toolhead == 0 %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T{initial_toolhead}"
_SELECT_TOOL T={initial_toolhead} TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% endif %}
{% endif %}
CACHE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
SET_MACRO_TRAVEL_SETTINGS
{% if (X0 > -1 and Y1 > -1) or (first_x > 0 and first_y > 0) %}
{% if printer["dual_carriage"] is defined %}
{% set acceleration = printer["gcode_macro RatOS"].toolchange_travel_accel %}
{% set max_accel = printer.toolhead.max_accel|float %}
{% set square_corner_velocity = printer.toolhead.square_corner_velocity|float %}
SET_VELOCITY_LIMIT ACCEL={acceleration} MINIMUM_CRUISE_RATIO=0 SQUARE_CORNER_VELOCITY=20
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
{% set first_z = 1 %}
{% else %}
{% set first_z = 3 %}
{% endif %}
{% if idex_mode == "mirror" %}
{% if first_y >= 0 %}
G0 Y{first_y} F{speed}
{% else %}
G0 Y{Y1} F{speed}
{% endif %}
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
_MOVE_TO_LOADING_POSITION TOOLHEAD={initial_toolhead}
_PURGE_FILAMENT TOOLHEAD={initial_toolhead} E={printer["gcode_macro RatOS"].toolchange_first_purge|default(50)|float}
_CLEANING_MOVE TOOLHEAD={initial_toolhead}
{% endif %}
{% if first_x >= 0 and first_y >= 0 %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% else %}
{% set first_x = X0 %}
{% set first_y = Y0 %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'min' %}
{% set first_x = X0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'max' %}
{% set first_x = X1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|float <= center_x %}
{% set first_x = X0 %}
{% else %}
{% set first_x = X1 %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'min' %}
{% set first_y = Y0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'max' %}
{% set first_y = Y1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|float <= center_y %}
{% set first_y = Y0 %}
{% else %}
{% set first_y = Y1 %}
{% endif %}
{% endif %}
{% endif %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% endif %}
{% endif %}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
_LOAD_RATOS_SKEW_PROFILE
[gcode_macro _PRIME]
gcode =
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
PRIME_BLOB INITIAL_TOOLHEAD={params.INITIAL_TOOLHEAD} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={params.IDEX_MODE} Y1={params.Y1}
{% else %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE == "copy" %}
_IDEX_COPY DANCE=0
{% elif params.IDEX_MODE == "mirror" %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro END_PRINT]
description = End print procedure, use this in your Slicer.
gcode =
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SAVE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = printer["gcode_macro START_PRINT"].object_xoffset|default(0)|float %}
RATOS_ECHO MSG="Adjusting object x-offset by {(0-object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={(0-object_xoffset)}
{% endif %}
{% endif %}
_USER_END_PRINT_BEFORE_HEATERS_OFF { rawparams }
_END_PRINT_BEFORE_HEATERS_OFF
TURN_OFF_HEATERS
_USER_END_PRINT_AFTER_HEATERS_OFF { rawparams }
_END_PRINT_AFTER_HEATERS_OFF
_USER_END_PRINT_PARK { rawparams }
_END_PRINT_PARK
{% if printer["gcode_macro RatOS"].skew_profile is defined %}
SET_SKEW CLEAR=1
{% endif %}
{% if printer["dual_carriage"] is not defined and printer["gcode_macro RatOS"].end_print_motors_off|lower != 'false' %}
M84
{% endif %}
M107
BED_MESH_CLEAR
RATOS_ECHO MSG="Done :)"
RESTORE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
M84
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
{% if printer["dual_carriage"] is not defined %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_expansion_compensation = true if printer["gcode_macro RatOS"].beacon_contact_expansion_compensation|default(false)|lower == 'true' else false %}
{% if beacon_contact_start_print_true_zero and beacon_contact_expansion_compensation %}
SET_GCODE_OFFSET Z=0 MOVE=0
{% endif %}
{% endif %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print"
_CHAMBER_FILTER_ON AT="print_end"
_CHAMBER_FILTER_OFF
_CHAMBER_HEATER_OFF
_USER_END_PRINT_FINISHED { rawparams }
[gcode_macro _END_PRINT_BEFORE_HEATERS_OFF]
gcode =
RATOS_ECHO MSG="Cleaning up..."
[gcode_macro _END_PRINT_AFTER_HEATERS_OFF]
gcode =
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% set z_hop = printer["gcode_macro RatOS"].end_print_park_z_hop|float %}
{% set r = printer["gcode_macro RatOS"].end_print_retract_filament|default(4)|float %}
{% if current_z < (max_z - z_hop) %}
{% set z_safe = z_hop %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
G91
G1 E-2 F3600
G0 Z{z_safe} F3600
G1 E-{(r-2)} F3600
G90
[gcode_macro _SET_EXTRUSION_MODE]
gcode =
{% if printer["gcode_macro RatOS"].relative_extrusion|lower == 'true' %}
M83
{% else %}
M82
{% endif %}
[gcode_macro GENERATE_SHAPER_GRAPHS]
description = Genarates input shaper resonances graphs for analysis. Uses the AXIS parameter for if you only want to do one axis at a time, (eg. GENERATE_SHAPER_GRAPHS AXIS=X)
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set axis = params.AXIS|default('')|lower %}
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
{% if axis != '' %}
{% if axis == 'x' %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
{% elif axis == 'y' %}
MAYBE_HOME
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% else %}
{action_raise_error("Unknown axis specified. Expected X or Y.")}
{% endif %}
{% else %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% endif %}
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Shaper graph"
[gcode_shell_command generate_shaper_graph_x]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-x.sh
timeout = 60.
verbose = True
[gcode_shell_command generate_shaper_graph_y]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-y.sh
timeout = 60.
verbose = True
[gcode_macro MEASURE_COREXY_BELT_TENSION]
description = Generates resonance graph used to ensure belts are equally tensioned.
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
MAYBE_HOME
TEST_RESONANCES AXIS=1,1 OUTPUT=raw_data NAME=belt-tension-upper FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=belt-tension-lower FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_belt_tension_graph
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Belt Tension Graph"
[gcode_shell_command generate_belt_tension_graph]
command = /home/pi/printer_data/config/RatOS/scripts/generate-belt-tension-graph.sh
timeout = 90.
verbose = True
[idle_timeout]
gcode =
{% if printer.webhooks.state|lower == 'ready' %}
{% if printer.pause_resume.is_paused|lower == 'false' %}
RATOS_ECHO PREFIX="IDLE" MSG="2 hours since last activity. Powering off heaters and motors.."
TURN_OFF_HEATERS
M84
{% endif %}
{% endif %}
timeout = 7200
[temperature_sensor raspberry_pi]
sensor_type = temperature_host
[skew_correction]
[input_shaper]
[virtual_sdcard]
path = ~/printer_data/gcodes
[display_status]
[pause_resume]
[force_move]
enable_force_move = True
[respond]
[resonance_generator]
[ratos]
allow_unknown_gcode_generator = True
[exclude_object]
[heater_bed]
heater_pin = heater_bed_heating_pin
sensor_pin = heater_bed_sensor_pin
sensor_type = EPCOS 100K B57560G104F
min_temp = 0
max_temp = 130
control = pid
pid_kp = 68.203
pid_ki = 2.842
pid_kd = 409.216
[fan]
pin = dual_blower_fan
shutdown_speed = 1.0
kick_start_time = 0.5
cycle_time = 0.00004
[heater_fan toolhead_cooling_fan]
pin = PD14
fan_speed = 1
heater = extruder
heater_temp = 50.0
[controller_fan controller_fan]
pin = PD13
idle_speed = 0.7
[printer]
kinematics = cartesian
max_velocity = 200
max_accel = 3000
minimum_cruise_ratio = 0.5
max_z_velocity = 15
max_z_accel = 200
square_corner_velocity = 5
[bed_mesh]
speed = 200
horizontal_move_z = 5
mesh_min = 15,15
mesh_max = 150,160
probe_count = 5,5
fade_start = 1.0
fade_end = 10.0
mesh_pps = 2,2
algorithm = bicubic
bicubic_tension = .2
[screws_tilt_adjust]
screw1 = 80, 108
screw1_name = Left Screw
screw2 = 155, 72
screw2_name = Front Right Screw
screw3 = 155, 147
screw3_name = Rear Right Screw
horizontal_move_z = 10
speed = 200
screw_thread = CCW-M4
[stepper_x]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PF9
dir_pin = !x_dir_pin
enable_pin = !PD6
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = toolboard_t0:PB6
[stepper_y]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PD3
dir_pin = y_dir_pin
enable_pin = !PD5
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = PC1
[stepper_z]
position_min = -5
position_max = 180
step_pin = PA15
dir_pin = !z0_dir_pin
enable_pin = !PC9
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 4
homing_speed = 15
endstop_pin = probe:z_virtual_endstop
[gcode_macro SCREWS_TILT_CALCULATE]
rename_existing = SCREWS_TILT_CALCULATE_ORIG
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
MAYBE_HOME
SAVE_GCODE_STATE NAME=screws_tilt_state
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
DEPLOY_PROBE
{% endif %}
SCREWS_TILT_CALCULATE_ORIG
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
STOW_PROBE
{% endif %}
G90
G0 Z120 F{printer["gcode_macro RatOS"].macro_z_speed|float * 60}
G0 Y{printable_y_max} X{printable_x_max / 2} F{printer["gcode_macro RatOS"].macro_travel_speed|float * 60}
RESTORE_GCODE_STATE NAME=screws_tilt_state
M84
[extruder]
rotation_distance = 5.57
full_steps_per_rotation = 200
filament_diameter = 1.750
max_extrude_only_velocity = 120
max_extrude_only_accel = 800
pressure_advance_smooth_time = 0.02
max_extrude_only_distance = 200
nozzle_diameter = 0.4
heater_pin = toolboard_t0:PB13
sensor_type = MAX31865
sensor_pin = toolboard_t0:PA4
min_extrude_temp = 170
min_temp = 0
max_temp = 350
pressure_advance = 0.03
step_pin = toolboard_t0:PD0
dir_pin = !toolboard_t0:e_dir_pin
enable_pin = !toolboard_t0:PD2
microsteps = 64
control = pid
pid_kp = 21.673
pid_ki = 1.338
pid_kd = 87.776
spi_software_sclk_pin = toolboard_t0:PA5
spi_software_miso_pin = toolboard_t0:PA6
spi_software_mosi_pin = toolboard_t0:PA7
[firmware_retraction]
retract_speed = 120
unretract_extra_length = 0
unretract_speed = 120
retract_length = 0.5
[adxl345 rpi]
cs_pin = rpi:None
[resonance_tester]
accel_chip_x = adxl345 toolboard_t0
accel_chip_y = adxl345 rpi
probe_points =
90,90,20
[tmc2209 stepper_x]
stealthchop_threshold = 0
interpolate = False
uart_pin = PF10
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_y]
stealthchop_threshold = 0
interpolate = False
uart_pin = PD4
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_z]
stealthchop_threshold = 0
interpolate = False
uart_pin = PC8
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 extruder]
stealthchop_threshold = 0
interpolate = False
uart_pin = toolboard_t0:PA15
run_current = 0.707
driver_tbl = 0
driver_toff = 4
driver_hend = 6
driver_hstrt = 7
sense_resistor = 0.11
[bltouch]
sensor_pin = ^toolboard_t0:bltouch_sensor_pin
control_pin = toolboard_t0:bltouch_control_pin
speed = 7
pin_move_time = 0.675
sample_retract_dist = 10
pin_up_reports_not_triggered = True
pin_up_touch_mode_reports_triggered = True
x_offset = -28
y_offset = -13
z_offset = 2.375
[gcode_macro T0]
variable_join = 0
variable_remap = 0
variable_alert = ""
variable_filament_name = ""
variable_filament_type = ""
variable_filament_temp = 0
variable_runout_sensor = ""
variable_active = True
variable_color = "7bff33"
variable_hotend_type = "HF"
variable_has_cht_nozzle = False
variable_cooling_position_to_nozzle_distance = 40
variable_tooolhead_sensor_to_extruder_gear_distance = 15
variable_extruder_gear_to_cooling_position_distance = 30
variable_filament_loading_nozzle_offset = -5
variable_filament_grabbing_length = 5
variable_filament_grabbing_speed = 1
variable_enable_insert_detection = True
variable_enable_runout_detection = True
variable_enable_clog_detection = True
variable_unload_after_runout = True
variable_purge_after_load = 0
variable_purge_before_unload = 0
variable_extruder_load_speed = 60
variable_filament_load_speed = 10
variable_standby = False
variable_temperature_offset = 0
variable_has_oozeguard = False
variable_has_front_arm_nozzle_wiper = False
variable_resume_after_insert = False
gcode =
{% set x = params.X|default(-1.0)|float %}
{% set y = params.Y|default(-1.0)|float %}
{% set z = params.Z|default(0.0)|float %}
{% set s = params.S|default(1)|int %}
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
_SELECT_TOOL T=0 X={x} Y={y} Z={z} TOOLSHIFT={s}
{% endif %}
[save_variables]
filename = /home/pi/printer_data/config/ratos-variables.cfg
[multi_pin dual_blower_fan]
pins = toolboard_t0:PA0, toolboard_t0:PA1
=======================
Extruder max_extrude_ratio=0.266081
mcu 'mcu': Starting serial connect
webhooks client 1965028808: New connection
webhooks client 1965028808: Client info {'program': 'Moonraker', 'version': 'v0.9.3-0-g71f9e67'}
Loaded MCU 'mcu' 118 commands (v0.12.0-396-gb7233d119 / gcc: (15:8-2019-q3-1+b1) 8.3.1 20190703 (release) [gcc-8-branch revision 273027] binutils: (2.34-4+rpi1+14) 2.34)
MCU 'mcu' config: ADC_MAX=4095 BUS_PINS_i2c1_PA9_PA10=PA9,PA10 BUS_PINS_i2c1_PB6_PB7=PB6,PB7 BUS_PINS_i2c1_PB8_PB9=PB8,PB9 BUS_PINS_i2c2_PB10_PB11=PB10,PB11 BUS_PINS_i2c2_PB13_PB14=PB13,PB14 BUS_PINS_i2c3_PB3_PB4=PB3,PB4 BUS_PINS_i2c3_PC0_PC1=PC0,PC1 BUS_PINS_spi1=PA6,PA7,PA5 BUS_PINS_spi1a=PB4,PB5,PB3 BUS_PINS_spi2=PB14,PB15,PB13 BUS_PINS_spi2_PB2_PB11_PB10=PB2,PB11,PB10 BUS_PINS_spi2a=PC2,PC3,PB10 BUS_PINS_spi3=PB4,PB5,PB3 CLOCK_FREQ=64000000 INITIAL_PINS=PA4 MCU=stm32g0b1xx PWM_MAX=255 RESERVE_PINS_USB=PA11,PA12 RESERVE_PINS_crystal=PF0,PF1 STATS_SUMSQ_BASE=256 STEPPER_BOTH_EDGE=1
mcu 'rpi': Starting connect
Loaded MCU 'rpi' 119 commands (?-20240727_132503-fv-az659-741 / gcc: (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110 binutils: (GNU Binutils for Raspbian) 2.35.2)
MCU 'rpi' config: ADC_MAX=4095 CLOCK_FREQ=50000000 MCU=linux PCA9685_MAX=4096 PWM_MAX=32768 STATS_SUMSQ_BASE=256
mcu 'toolboard_t0': Starting serial connect
Loaded MCU 'toolboard_t0' 118 commands (v0.12.0-396-gb7233d119 / gcc: (15:8-2019-q3-1+b1) 8.3.1 20190703 (release) [gcc-8-branch revision 273027] binutils: (2.34-4+rpi1+14) 2.34)
MCU 'toolboard_t0' config: ADC_MAX=4095 BUS_PINS_i2c1_PA9_PA10=PA9,PA10 BUS_PINS_i2c1_PB6_PB7=PB6,PB7 BUS_PINS_i2c1_PB8_PB9=PB8,PB9 BUS_PINS_i2c2_PB10_PB11=PB10,PB11 BUS_PINS_i2c2_PB13_PB14=PB13,PB14 BUS_PINS_i2c3_PB3_PB4=PB3,PB4 BUS_PINS_i2c3_PC0_PC1=PC0,PC1 BUS_PINS_spi1=PA6,PA7,PA5 BUS_PINS_spi1a=PB4,PB5,PB3 BUS_PINS_spi2=PB14,PB15,PB13 BUS_PINS_spi2_PB2_PB11_PB10=PB2,PB11,PB10 BUS_PINS_spi2a=PC2,PC3,PB10 BUS_PINS_spi3=PB4,PB5,PB3 CLOCK_FREQ=64000000 MCU=stm32g0b1xx PWM_MAX=255 RESERVE_PINS_USB=PA11,PA12 RESERVE_PINS_crystal=PF0,PF1 STATS_SUMSQ_BASE=256 STEPPER_BOTH_EDGE=1
mcu_temperature 'mcu' nominal base=-272.325581 slope=1309.447674
mcu_temperature 'toolboard_t0' nominal base=-265.428571 slope=1287.000000
Sending MCU 'mcu' printer configuration...
Config error
Traceback (most recent call last):
File "/home/pi/klipper/klippy/mcu.py", line 702, in _send_config
self._serial.send(c)
File "/home/pi/klipper/klippy/serialhdl.py", line 257, in send
cmd = self.msgparser.create_command(msg)
File "/home/pi/klipper/klippy/msgproto.py", line 349, in create_command
cmd = mp.encode_by_name(**argparts)
File "/home/pi/klipper/klippy/msgproto.py", line 179, in encode_by_name
t.encode(out, params[name])
File "/home/pi/klipper/klippy/msgproto.py", line 108, in encode
raise enumeration_error(self.enum_name, v)
msgproto.enumeration_error: Unknown value 'dual_blower_fan' in enumeration 'pin'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/klipper/klippy/klippy.py", line 135, in _connect
cb()
File "/home/pi/klipper/klippy/mcu.py", line 748, in _connect
self._send_config(None)
File "/home/pi/klipper/klippy/mcu.py", line 713, in _send_config
raise self._printer.config_error(
configparser.Error: Pin 'dual_blower_fan' is not a valid pin name on mcu 'mcu'
Attempting MCU 'mcu' reset command
Attempting MCU 'rpi' config_reset command
b'Got EOF when reading from device'
Attempting MCU 'toolboard_t0' reset command
webhooks client 1965028808: Disconnected
Restarting printer
Start printer at Wed Nov 12 17:00:31 2025 (1762966831.5 1090.5)
===== Config file =====
[mcu rpi]
serial = /tmp/klipper_host_mcu
[board_pins btt-skrat-10]
aliases =
x_step_pin=PF9,
x_dir_pin=PD7,
x_enable_pin=PD6,
x_uart_pin=PF10,
x_diag_pin=PB5,
x_endstop_pin=PB5,
y_step_pin=PD3,
y_dir_pin=PD2,
y_enable_pin=PD5,
y_uart_pin=PD4,
y_diag_pin=PC1,
y_endstop_pin=PC1,
z0_step_pin=PA15,
z0_dir_pin=PF8,
z0_enable_pin=PC9,
z0_uart_pin=PC8,
z0_diag_pin=PC0,
e_step_pin=PB10,
e_dir_pin=PE15,
e_enable_pin=PA8,
e_uart_pin=PB11,
e_diag_pin=PF5,
e_heater_pin=PE11,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PE5,
bltouch_control_pin=PE6,
probe_pin=PE5,
fan_part_cooling_pin=PD15,
fan_toolhead_cooling_pin=PD14,
fan_controller_board_pin=PD13,
heater_bed_heating_pin=PB3,
heater_bed_sensor_pin=PB2,
4p_fan_part_cooling_pin=PE9,
4p_fan_part_cooling_tach_pin=PD11,
4p_toolhead_cooling_pin=PE14,
4p_toolhead_cooling_tach_pin=PD10,
4p_controller_board_pin=PE14,
4p_controller_board_tach_pin=PD10
[mcu]
serial = /dev/RatOS/btt-skrat-10
[temperature_sensor SKRat_v1.0]
sensor_type = temperature_mcu
[adxl345 controlboard]
cs_pin = PB12
spi_bus = spi2
[board_pins toolboard_t0]
mcu = toolboard_t0
aliases =
e_step_pin=PD0,
e_dir_pin=PD1,
e_enable_pin=PD2,
e_uart_pin=PA15,
e_heater_pin=PB13,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PB8,
bltouch_control_pin=PB9,
probe_pin=PB9,
fan_part_cooling_pin=PA0,
fan_toolhead_cooling_pin=PA1,
fan_controller_board_pin=null,
heater_bed_heating_pin=null,
heater_bed_sensor_pin=null,
4p_fan_part_cooling_pin=null,
4p_fan_part_cooling_tach_pin=null,
4p_toolhead_cooling_pin=null,
4p_toolhead_cooling_tach_pin=null,
4p_controller_board_pin=null,
4p_controller_board_tach_pin=null
[mcu toolboard_t0]
serial = /dev/RatOS/btt-ebb42-12-t0
[temperature_sensor EBB42_v1.2_T0]
sensor_type = temperature_mcu
sensor_mcu = toolboard_t0
[adxl345 toolboard_t0]
axes_map = x, z, y
cs_pin = toolboard_t0:PB12
spi_software_mosi_pin = toolboard_t0:PB11
spi_software_miso_pin = toolboard_t0:PB2
spi_software_sclk_pin = toolboard_t0:PB10
[gcode_macro RatOS]
variable_homing = "endstops"
variable_z_probe = "static"
variable_sensorless_x_current = 0.6
variable_sensorless_y_current = 0.9
variable_safe_home_x = "middle"
variable_safe_home_y = "middle"
variable_driver_type_x = "tmc2209"
variable_driver_type_y = "tmc2209"
variable_stowable_probe_stop_on_error = False
variable_chamber_filter_enable = True
variable_chamber_filter_speed = 0.5
variable_chamber_filter_disable_speed = 1.0
variable_chamber_filter_enable_at = "after_print_start"
variable_chamber_filter_disable_period = 300
variable_chamber_filter_disable_bed_temp = 0
variable_chamber_heater_enable = True
variable_chamber_heater_bed_temp = 115
variable_chamber_heater_preheating_temp = 150
variable_chamber_heater_heating_temp_offset = 25
variable_chamber_heater_control_external_heater = False
variable_chamber_heater_air_circulation_enable = True
variable_chamber_heater_air_circulation_fan_speed = 0.35
variable_chamber_heater_air_circulation_y_pos = 0
variable_chamber_heater_air_circulation_z_pos = 100
variable_chamber_heater_extra_fan_speed = 1.0
variable_chamber_heater_filter_fan_speed = 1.0
variable_led_status_action = 0.0,1.0,1.0
variable_led_status_success = 0.0,1.0,0.0
variable_led_status_error = 1.0,0.0,1.0
variable_led_status_on = 1.0,1.0,1.0
variable_led_status_off = 0.0,0.0,1.0
variable_led_status_standby = 0.1,0.1,0.1
variable_led_status_heating = 1.0,0.0,0.0
variable_led_status_cooling = 0.0,0.0,1.0
variable_calibrate_bed_mesh = True
variable_adaptive_mesh = True
variable_start_print_park_in = "front"
variable_start_print_park_z_height = 50
variable_end_print_park_in = "back"
variable_pause_print_park_in = "front"
variable_end_print_park_z_hop = 20
variable_nozzle_priming = "primeblob"
variable_nozzle_prime_start_x = "max"
variable_nozzle_prime_start_y = "min"
variable_nozzle_prime_direction = "auto"
variable_nozzle_prime_bridge_fan = 102
variable_probe_for_priming_result = None
variable_probe_for_priming_end_result = None
variable_probe_for_priming_result_t1 = None
variable_probe_for_priming_end_result_t1 = None
variable_probe_for_priming_disable_mesh_constraints = False
variable_adaptive_prime_offset_threshold = -1.0
variable_last_z_offset = None
variable_runout_park_in = "front"
variable_enable_unload_tip_forming = False
variable_filament_unload_length = 150
description = RatOS variable storage macro, will echo variables to the console when run.
variable_relative_extrusion = False
variable_force_absolute_position = False
variable_preheat_extruder = True
variable_preheat_extruder_temp = 150
variable_macro_travel_speed = 200
variable_macro_travel_accel = 3000
variable_macro_z_speed = 15
variable_bed_margin_x = [0, 0]
variable_bed_margin_y = [0, 0]
variable_printable_x_min = 0
variable_printable_x_max = 0
variable_printable_y_min = 0
variable_printable_y_max = 0
variable_end_print_motors_off = True
variable_status_color_ok = "00FF00"
variable_status_color_error = "FF0000"
variable_status_color_unknown = "FFFF00"
variable_end_print_retract_filament = 10
gcode =
ECHO_RATOS_VARS
variable_homing_x = "endstop"
variable_homing_y = "endstop"
variable_x_driver_types = ["tmc2209"]
variable_x_axes = ["x"]
variable_y_driver_types = ["tmc2209"]
variable_y_axes = ["y"]
variable_z_driver_types = ["tmc2209"]
variable_z_axes = ["z"]
[ratos_homing]
axes = xyz
z_hop = 15
z_hop_speed = 15
gcode =
_LED_ON
{% set prev_stop_on_error = printer["gcode_macro RatOS"].stowable_probe_stop_on_error %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set target_idex_mode = printer["dual_carriage"].carriage_1|lower %}
_IDEX_SINGLE
_SELECT_TOOL T={default_toolhead} TOOLSHIFT=false
{% endif %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE=True
M400
G90
{% set X = true if params.X is defined else false %}
{% set Y = true if params.Y is defined else false %}
{% set Z = true if params.Z is defined else false %}
{% if printer["gcode_macro RatOS"].home_y_first|default(false)|lower == 'true' %}
HOME_Y X={X} Y={Y} Z={Z}
HOME_X X={X} Y={Y} Z={Z}
{% else %}
HOME_X X={X} Y={Y} Z={Z}
HOME_Y X={X} Y={Y} Z={Z}
{% endif %}
HOME_Z X={X} Y={Y} Z={Z}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE={prev_stop_on_error}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR
{% endif %}
{% endif %}
[gcode_macro HOME_X]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_x = printer["gcode_macro RatOS"].homing_x|lower %}
{% set homing_x = homing_x if homing_x else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_X" MSG="printable_x_max: {printable_x_max}, safe_home_x: {safe_home_x}, axis_maximum.x: {printer.toolhead.axis_maximum.x}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}"
{% if X or not Y and not Z %}
{% if homing_x == 'endstop' %}
G28 X
{% elif homing_x == 'sensorless' %}
{% if printer["dual_carriage"] is defined %}
{ action_emergency_stop("sensorless homing not supported on IDEX!") }
{% endif %}
HOME_X_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_x to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_x, homing)) }
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % (0 if default_toolhead==1 else 1)].parking_position|float %}
SET_DUAL_CARRIAGE CARRIAGE={0 if default_toolhead==1 else 1} MODE=PRIMARY
G1 X{parking_position} F{speed}
SET_DUAL_CARRIAGE CARRIAGE={default_toolhead} MODE=PRIMARY
{% endif %}
{% set x_homed = True %}
G0 X{safe_home_x} F{speed}
M400
{% endif %}
[gcode_macro HOME_Y]
gcode =
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_y = printer["gcode_macro RatOS"].homing_y|lower %}
{% set homing_y = homing_y if homing_y else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Y" MSG="printable_y_max: {printable_y_max}, safe_home_y: {safe_home_y}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}"
{% if Y or not X and not Z %}
{% if homing_y == 'endstop' %}
G28 Y
{% elif homing_y == 'sensorless' %}
HOME_Y_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_y to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_y, homing)) }
{% endif %}
{% set y_homed = True %}
G0 Y{safe_home_y} F{speed}
{% endif %}
[gcode_macro HOME_Z]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set z_probe = printer["gcode_macro RatOS"].z_probe %}
{% set beacon_contact_z_homing = true if printer["gcode_macro RatOS"].beacon_contact_z_homing|default(false)|lower == 'true' else false %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Z" MSG="x_homed: {x_homed}, y_homed: {y_homed}, z_probe: {z_probe}, beacon_contact_z_homing: {beacon_contact_z_homing}"
{% if Z or not Y and not X %}
RATOS_ECHO MSG="Homing Z"
{% if x_homed == False or y_homed == False %}
{ action_emergency_stop("X and Y must be homed before homing Z") }
{% else %}
{% if z_probe == "stowable" %}
DEPLOY_PROBE
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
STOW_PROBE
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
{% endif %}
{% endif %}
{% endif %}
[gcode_macro HOME_X_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
G4 P300
G28 X
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
[gcode_macro HOME_Y_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
G4 P300
G28 Y
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
[gcode_macro _Z_HOP]
description = Move Z axis up by Z_HOP distance at Z_HOP_SPEED. In relative mode it will move Z axis up by Z_HOP distance. In absolute mode it will move Z axis to Z_HOP distance.
gcode =
{% set z_hop = printer.configfile.config.ratos_homing.z_hop|float %}
{% set z_hop_speed = printer.configfile.config.ratos_homing.z_hop_speed|float * 60 %}
G0 Z{z_hop} F{z_hop_speed}
[gcode_macro _MOVE_TO_SAFE_Z_HOME]
description = Move to safe home position with optional Z_HOP (pass Z_HOP=True as parameter)
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% if params.Z_HOP is defined %}
_Z_HOP
{% endif %}
DEBUG_ECHO PREFIX="_MOVE_TO_SAFE_Z_HOME" MSG="axis_maximum.x: {printer.toolhead.axis_maximum.x}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}, safe_home_x: {safe_home_x}, safe_home_y: {safe_home_y}, printable_x_max: {printable_x_max}, printable_y_max: {printable_y_max}"
G0 X{safe_home_x} Y{safe_home_y} F{speed}
[gcode_macro MAYBE_HOME]
description = Only home unhomed axis
variable_is_kinematic_position_overriden = False
gcode =
{% if printer["gcode_macro MAYBE_HOME"].is_kinematic_position_overriden|lower == 'true' %}
RATOS_ECHO MSG="SET_CENTER_KINEMATIC_POSITION has been abused. Homing all axes. Please refrain from using SET_CENTER_KINEMATIC_POSITION outside of debugging purposes."
G28
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=False
{% else %}
{% set axes = '' %}
{% set isHomed = true %}
{% set axesToHome = '' %}
{% if params.X is defined %}
{% set axes = axes ~ 'X ' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% endif %}
{% if params.Y is defined %}
{% set axes = axes ~ 'Y ' %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% endif %}
{% if params.Z is defined %}
{% set axes = axes ~ 'Z ' %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if params.X is not defined and params.Y is not defined and params.Z is not defined %}
{% set axes = '' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if isHomed is false %}
RATOS_ECHO MSG="Homing {axesToHome}"
G28 {axesToHome}
{% else %}
RATOS_ECHO MSG="All requested axes already homed, skipping.."
{% endif %}
{% endif %}
[gcode_macro PID_CALIBRATE_HOTEND]
description = Perform a PID calibration test for a given extruder heater.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set temp = params.TEMP|default(220)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_HOTEND" MSG="TEMP={temp}"
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO MSG="PID calibration hotend heater T0 at {temp}°C..."
PID_CALIBRATE HEATER=extruder TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
{% if toolhead==0 or toolhead==1 %}
RATOS_ECHO MSG="PID calibration hotend heater T{toolhead} at {temp}°C..."
PID_CALIBRATE HEATER=extruder{'' if toolhead==0 else toolhead} TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_BED]
description = Perform a PID calibration test for the bed heater.
gcode =
{% set temp = params.TEMP|default(80)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_BED" MSG="TEMP={temp}"
RATOS_ECHO MSG="PID calibration bed heater at {temp}°C..."
PID_CALIBRATE HEATER=heater_bed TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_CHAMBER_HEATER]
description = Perform a PID calibration test for the chamber heater.
gcode =
{% set temp = params.TEMP|default(150)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_CHAMBER_HEATER" MSG="TEMP={temp}"
{% if printer["heater_generic chamber_heater"] is defined %}
RATOS_ECHO MSG="PID calibration chamber heater at {temp}°C..."
PID_CALIBRATE HEATER=chamber_heater TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_heater" %}
{% set link_text = "RatOS Chamber Heater" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber heater found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro INITIALIZE_PA_TUNING]
description = Start a pressure advance tuning tower.
gcode =
{% set start = params.START|default(0.0)|float %}
{% set factor = params.FACTOR|default(0.001)|float %}
{% set layer_number = printer["gcode_macro _ON_LAYER_CHANGE"].layer_number|default(0)|int %}
{% set is_printing_gcode = true if printer["gcode_macro START_PRINT"].is_printing_gcode|default(true)|lower == 'true' else false %}
{% if is_printing_gcode and layer_number < 2 %}
DEBUG_ECHO PREFIX="START_PA_TOWER" MSG="START: {start}, FACTOR: {factor}"
RATOS_ECHO MSG="Starting presssure advance tuning tower..."
TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START={start} FACTOR={factor}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro CHAMBER_FILTER_ON]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro CHAMBER_FILTER_OFF]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Deactivating chamber filter..."
_CHAMBER_FILTER_TURN_OFF
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro _CHAMBER_FILTER_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set chamber_filter_enable_at = printer["gcode_macro RatOS"].chamber_filter_enable_at|default('after_print_start')|lower %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_ON" MSG="at: {at}, chamber_filter_enable: {chamber_filter_enable}, chamber_filter_enable_at: {chamber_filter_enable_at}, chamber_filter_speed: {chamber_filter_speed}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if chamber_filter_enable_at == at %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON AT={at}
{% if chamber_filter_enable_at == "print_end" %}
_LED_CHAMBER_FILTER_ON
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_FILTER_OFF]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF" MSG="chamber_filter_enable: {chamber_filter_enable}, filter_disable_period: {filter_disable_period}, filter_disable_bed_temp: {filter_disable_bed_temp}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_period > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting {filter_disable_period} seconds before turning chamber filter off..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION={filter_disable_period}
{% endif %}
{% if filter_disable_bed_temp > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting for bed temp to cool down to {filter_disable_bed_temp}°C to turn filter off..."
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM=0 MAXIMUM={filter_disable_bed_temp}
_CHAMBER_FILTER_TURN_OFF
_LED_CHAMBER_FILTER_OFF
{% endif %}
{% endif %}
[delayed_gcode _CHAMBER_FILTER_OFF_TIMER]
gcode =
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF_TIMER" MSG="executed"
_CHAMBER_FILTER_TURN_OFF
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Chamber filter turned off!"
_LED_CHAMBER_FILTER_OFF
[gcode_macro _CHAMBER_FILTER_TURN_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_speed|default(0)|float %}
{% if at == "print_end" %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_disable_speed|default(0)|float %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION=0
SET_FAN_SPEED FAN=filter SPEED={chamber_filter_speed}
[gcode_macro _CHAMBER_FILTER_TURN_OFF]
gcode =
SET_FAN_SPEED FAN=filter SPEED=0
[gcode_macro _CHAMBER_FILTER_SANITY_CHECK]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_bed_temp > 0 and filter_disable_period > 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable, not both.")}
{% endif %}
{% if filter_disable_bed_temp == 0 and filter_disable_period == 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable.")}
{% endif %}
{% endif %}
[gcode_macro CHAMBER_HEATER_ON]
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(45)|int %}
_CHAMBER_HEATER_ON CHAMBER_TEMP={chamber_temp} IS_FROM_START_PRINT=False
[gcode_macro CHAMBER_HEATER_OFF]
gcode =
_CHAMBER_HEATER_OFF
[gcode_macro _CHAMBER_HEATER_ON]
variable_chamber_temp = 0
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set is_from_start_print = true if params.IS_FROM_START_PRINT|default(True)|lower == 'true' else false %}
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set chamber_heater_enable = true if printer["gcode_macro RatOS"].chamber_heater_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
{% set chamber_heater_preheating_temp = printer["gcode_macro RatOS"].chamber_heater_preheating_temp|default(150)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set chamber_heater_control_external_heater = true if printer["gcode_macro RatOS"].chamber_heater_control_external_heater|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_enable = true if printer["gcode_macro RatOS"].chamber_heater_air_circulation_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_fan_speed = printer["gcode_macro RatOS"].chamber_heater_air_circulation_fan_speed|default(0.35)|float %}
{% set chamber_heater_air_circulation_y_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_y_pos|default(0)|float %}
{% set chamber_heater_air_circulation_z_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_z_pos|default(100)|float %}
DEBUG_ECHO PREFIX="_CHAMBER_HEATER_ON" MSG="chamber_heater_enable: {chamber_heater_enable}, chamber_heater_preheating_temp: {chamber_heater_preheating_temp}, chamber_heater_heating_temp_offset: {chamber_heater_heating_temp_offset}, bed_temp: {bed_temp}, chamber_temp: {chamber_temp}, start_chamber_temp: {start_chamber_temp}"
{% if chamber_heater_enable and chamber_temp > 0 and chamber_heater_bed_temp > 0 %}
_LED_HEATING
RATOS_ECHO MSG="Preheating chamber to {(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}°C..."
{% set chamber_temp_sensor = "extruder" %}
{% if printer["dual_carriage"] is defined and default_toolhead == 1 %}
{% set chamber_temp_sensor = "extruder1" %}
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% set chamber_temp_sensor = "temperature_sensor chamber" %}
{% endif %}
{% set current_chamber_temp = printer['%s' % chamber_temp_sensor].temperature|int %}
{% set needs_heating = current_chamber_temp < (start_chamber_temp if start_chamber_temp > 0 else chamber_temp) %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_BEFORE_PREHEATING
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
{% if not is_from_start_print %}
MAYBE_HOME
{% endif %}
G0 Z{chamber_heater_air_circulation_z_pos} F{z_speed}
G0 Y{chamber_heater_air_circulation_y_pos} F{speed}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 1 else 0}
{% else %}
M106 S{(255 * chamber_heater_air_circulation_fan_speed)}
{% endif %}
{% else %}
{% if is_from_start_print %}
G0 Z{z} F{z_speed}
{% endif %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE={chamber_temp}
{% if needs_heating %}
M140 S{chamber_heater_bed_temp}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={chamber_heater_preheating_temp}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if needs_heating %}
_CHAMBER_HEATER_EXTRA_FAN_ON
{% endif %}
{% if needs_heating %}
TEMPERATURE_WAIT SENSOR="{chamber_temp_sensor}" MINIMUM={(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% endif %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED=0
_CHAMBER_FILTER_ON AT="before_print_start"
{% endif %}
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
G28 Z
{% endif %}
{% endif %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_AFTER_PREHEATING
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% if printer["heater_generic chamber_heater"] is defined %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined and chamber_heater_control_external_heater %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
_LED_SUCCESS
{% endif %}
[gcode_macro _CHAMBER_HEATER_OFF]
gcode =
RATOS_ECHO MSG="Deactivating chamber heater..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=0
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE=0
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
_CHAMBER_HEATER_EXTRA_FAN_OFF
[delayed_gcode _CHAMBER_HEATER_CONTROL]
initial_duration = 0.
gcode =
{% set chamber_temp = printer["gcode_macro _CHAMBER_HEATER_ON"].chamber_temp|default(0)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set current_chamber_temp = printer['temperature_sensor chamber'].temperature|int %}
{% if current_chamber_temp < chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if current_chamber_temp >= chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_ON]
gcode =
{% set chamber_heater_extra_fan_speed = printer["gcode_macro RatOS"].chamber_heater_extra_fan_speed|default(0.0)|float %}
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
{% if chamber_heater_extra_fan_speed > 0 %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED={chamber_heater_extra_fan_speed}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_OFF]
gcode =
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED=0
{% endif %}
[gcode_macro _USER_CHAMBER_HEATER_BEFORE_PREHEATING]
description = Will be executed before chamber preheating, only if heating is needed.
gcode =
[gcode_macro _USER_CHAMBER_HEATER_AFTER_PREHEATING]
description = Will be executed after chamber preheating, only if heating was needed.
gcode =
[gcode_macro _LED_START_PRINTING]
gcode =
_LED_ACTION
[gcode_macro _LED_START_PRINTING_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_PRINTING]
gcode =
_LED_ON TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_PAUSE]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_ON]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_OFF]
gcode =
_LED_STANDBY
[gcode_macro _LED_LOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_LOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_RUNOUT]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_CLOG]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_UNLOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_UNLOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_DEACTIVATE_TOOLHEAD]
gcode =
_LED_OFF TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_STANDBY]
gcode =
_LED_STANDBY TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_WAKEUP]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_MOTORS_OFF]
gcode =
_LED_STANDBY
_LED_VAOC_OFF
[gcode_macro _LED_INPUT_SHAPER_START]
gcode =
_LED_ACTION
[gcode_macro _LED_INPUT_SHAPER_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_START]
gcode =
_LED_ACTION
[gcode_macro _LED_BEACON_CALIBRATION_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_VAOC_ON]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=1.0 GREEN=1.0 BLUE=1.0
{% endif %}
[gcode_macro _LED_VAOC_OFF]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=0.0 GREEN=0.0 BLUE=0.0
{% endif %}
[gcode_macro _LED_ACTION]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_action %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SUCCESS]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_success %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_HEATING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_heating %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_COOLING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_cooling %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ERROR]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_error %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ON]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_on %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_OFF]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_off %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_STANDBY]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_standby %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
{% if toolhead >= 0 %}
{% if printer['neopixel nozzle_led_t%s' % toolhead] is defined %}
SET_LED LED={'nozzle_led_t%s' % toolhead} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% else %}
{% if printer['neopixel nozzle_led_t0'] is defined %}
SET_LED LED={'nozzle_led_t0'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% if printer['neopixel nozzle_led_t1'] is defined %}
SET_LED LED={'nozzle_led_t1'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% endif %}
_USER_LED_SET { rawparams }
[gcode_macro _USER_LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
[gcode_macro LOAD_FILAMENT]
description = Loads new filament. Note: be careful with PETG, make sure you inspect the tip of your filament before loading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% if filament_name == '' or filament_type == '' %}
{% set filament_name = 'unknown' %}
{% set filament_type = 'unknown' %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_LOAD_FILAMENT TEMP={temp} NAME={filament_name} TYPE={filament_type}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_LOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME={filament_name} TYPE={filament_type}
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _DEFAULT_LOAD_FILAMENT]
description = Load filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_LOAD_FILAMENT" MSG="TEMP={temp}"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=load_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
_LOAD_FILAMENT TOOLHEAD=0
RESTORE_GCODE_STATE NAME=load_state
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD=0
[gcode_macro _IDEX_LOAD_FILAMENT]
description = Load filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_LOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
_LOAD_FILAMENT TOOLHEAD={toolhead} TEMP={temp}
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into hotend.."
G92 E0
G0 E{extruder_gear_to_cooling_position_distance} F{extruder_load_speed}
G92 E0
M400
RATOS_ECHO MSG="Filament loaded into hotend."
[gcode_macro _LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set load_speed = printer["gcode_macro T%s" % toolhead].filament_load_speed|float * 60 %}
{% set filament_loading_nozzle_offset = printer["gcode_macro T%s" % toolhead].filament_loading_nozzle_offset|float %}
{% set cooling_position_to_nozzle_distance = printer["gcode_macro T%s" % toolhead].cooling_position_to_nozzle_distance|float %}
{% set purge_after_load = printer["gcode_macro T%s" % toolhead].purge_after_load|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into nozzle... Please wait!"
G92 E0
G0 E{cooling_position_to_nozzle_distance + filament_loading_nozzle_offset} F{load_speed}
G92 E0
G4 P1000
_PURGE_FILAMENT TOOLHEAD={toolhead} E={purge_after_load}
RATOS_ECHO MSG="Filament loaded into nozzle!"
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
{% set filament_grabbing_length = printer["gcode_macro T%s" % toolhead].filament_grabbing_length|float %}
{% set filament_grabbing_speed = printer["gcode_macro T%s" % toolhead].filament_grabbing_speed|float %}
{% set resume_after_insert = true if printer["gcode_macro T%s" % toolhead].resume_after_insert|default(true)|lower == 'true' else false %}
{% set enable_insert_detection = true if printer["gcode_macro T%s" % toolhead].enable_insert_detection|default(true)|lower == 'true' else false %}
{% set current_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% if enable_insert_detection %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="toolhead: {toolhead}, filament_grabbing_length: {filament_grabbing_length}, filament_grabbing_speed: {filament_grabbing_speed}, current_idex_mode: {current_idex_mode}"
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
FORCE_MOVE STEPPER={'extruder%s' % ('' if toolhead == 0 else toolhead)} DISTANCE={filament_grabbing_length} VELOCITY={filament_grabbing_speed}
M400
{% if printer.pause_resume.is_paused %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% if resume_after_insert %}
RESUME
{% endif %}
{% else %}
{% if not printer.virtual_sdcard.is_active %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
[gcode_macro _PURGE_BEFORE_UNLOAD]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set purge_before_unload = printer["gcode_macro T%s" % toolhead].purge_before_unload|float %}
DEBUG_ECHO PREFIX="_PURGE_BEFORE_UNLOAD" MSG="TOOLHEAD: {toolhead}"
{% if purge_before_unload > 0 %}
G92 E0
G0 E{purge_before_unload} F300
G92 E0
M400
{% endif %}
[gcode_macro _PURGE_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set e = params.E|int %}
{% set r = params.R|default(0)|int %}
DEBUG_ECHO PREFIX="_PURGE_FILAMENT" MSG="TOOLHEAD: {toolhead}, E: {e}"
{% if e > 0 %}
G92 E0
G0 E{e} F300
G92 E0
M400
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={0.4 if toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={0.4 if toolhead == 1 else 0}
{% else %}
M106 S{(255 * 0.4)}
{% endif %}
{% endif %}
G4 P3000
{% if r > 0 %}
G92 E0
G0 E-{r} F300
G92 E0
M400
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_PARKING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_PARKING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_LOADING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_LOADING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% if act_t == toolhead %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{loading_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CLEANING_MOVE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined and printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% set cleaning_position = loading_position %}
{% if loading_position == parking_position %}
{% if loading_position > 0 %}
{% set cleaning_position = loading_position - 30 %}
{% else %}
{% set cleaning_position = loading_position + 30 %}
{% endif %}
{% endif %}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _START_PRINT_BED_MESH]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
SET_MACRO_TRAVEL_SETTINGS
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set X=[params.X0|default(-1)|float, params.X1|default(-1)|float] %}
{% set Y=[params.Y0|default(-1)|float, params.Y1|default(-1)|float] %}
DEBUG_ECHO PREFIX="_START_PRINT_BED_MESH" MSG="idex_mode: {idex_mode}, X: {X}, Y: {Y}"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set X=[0, printable_x_max] %}
{% endif %}
{% set beacon_bed_mesh_scv = printer["gcode_macro RatOS"].beacon_bed_mesh_scv|default(25)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% if printer.configfile.settings.beacon is defined and not beacon_contact_bed_mesh %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={beacon_bed_mesh_scv}
{% endif %}
{% set default_profile = printer["gcode_macro RatOS"].bed_mesh_profile|default('ratos') %}
{% if printer["gcode_macro RatOS"].calibrate_bed_mesh|lower == 'true' %}
BED_MESH_CLEAR
{% if printer["gcode_macro RatOS"].adaptive_mesh|lower == 'true' %}
CALIBRATE_ADAPTIVE_MESH PROFILE={default_profile} X0={X[0]} X1={X[1]} Y0={Y[0]} Y1={Y[1]} T={params.T|int} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={idex_mode}
{% else %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% endif %}
BED_MESH_PROFILE LOAD={default_profile}
{% elif printer["gcode_macro RatOS"].bed_mesh_profile is defined %}
BED_MESH_CLEAR
BED_MESH_PROFILE LOAD={printer["gcode_macro RatOS"].bed_mesh_profile}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
[gcode_macro CALIBRATE_ADAPTIVE_MESH]
gcode =
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set default_profile = params.PROFILE %}
{% set x0 = params.X0|default(-1)|float %}
{% set y0 = params.Y0|default(-1)|float %}
{% set x1 = params.X1|default(-1)|float %}
{% set y1 = params.Y1|default(-1)|float %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Recieved coordinates X0={x0} Y0={y0} X1={x1} Y1={y1}"
{% if x0 >= x1 or y0 >= y1 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Invalid coordinates received. Please check your slicer settings. Falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float %}
{% set mesh_x0 = [[x0, max_x]|min, min_x]|max %}
{% set mesh_y0 = [[y0, max_y]|min, min_y]|max %}
{% set mesh_x1 = [[x1, max_x]|min, min_x]|max %}
{% set mesh_y1 = [[y1, max_y]|min, min_y]|max %}
{% if mesh_x0 == min_x and mesh_y0 == min_y and mesh_x1 == max_x and mesh_y1 == max_y %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Print is using the full bed, falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
DEPLOY_PROBE
{% endif %}
{% set probe_count_x = mesh_config.probe_count.split(",")[0]|int %}
{% if mesh_config.probe_count.split(",")|length == 2 %}
{% set probe_count_y = mesh_config.probe_count.split(",")[1]|int %}
{% else %}
{% set probe_count_y = mesh_config.probe_count.split(",")[0]|int %}
{% endif %}
{% set probe_x_step = (max_x - min_x) / probe_count_x %}
{% set probe_y_step = (max_y - min_y) / probe_count_y %}
{% set mesh_count_x = ([(mesh_x1 - mesh_x0) / probe_x_step, 3]|max)|int %}
{% set mesh_count_y = ([(mesh_y1 - mesh_y0) / probe_y_step, 3]|max)|int %}
{% set min_mesh_count = [mesh_count_x, mesh_count_y]|min %}
{% set max_mesh_count = [mesh_count_x, mesh_count_y]|max %}
{% set algorithm = mesh_config.algorithm %}
{% if algorithm|lower == 'lagrange' and max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="cannot exceed a probe_count of 6 when using lagrange interpolation. Falling back to bicubic interpolation."
{% set algorithm = 'bicubic' %}
{% endif %}
{% if algorithm|lower == 'bicubic' and min_mesh_count < 4 %}
{% if max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="invalid probe_count option when using bicubic interpolation. Combination of 3 points on one axis with more than 6 on another is not permitted. Forcing minimum mesh count to be 4."
{% set min_mesh_count = 4 %}
{% else %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="bicubic interpolation with a probe_count of less than 4 points detected. Forcing lagrange interpolation."
{% set algorithm = 'lagrange' %}
{% endif %}
{% endif %}
{% set mesh_count_x = ([min_mesh_count, mesh_count_x]|max)|int %}
{% set mesh_count_x = ([max_mesh_count, mesh_count_x]|min)|int %}
{% set mesh_count_y = ([min_mesh_count, mesh_count_y]|max)|int %}
{% set mesh_count_y = ([max_mesh_count, mesh_count_y]|min)|int %}
{% set should_prime = printer["gcode_macro RatOS"].nozzle_priming == 'primeblob' %}
{% if printer["dual_carriage"] is not defined %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% else %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% endif %}
{% if printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 != 0 and probe_first %}
{% set probe_first = false %}
{% elif printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 == 0 and not probe_first %}
{% set probe_first = true %}
{% endif %}
{% if should_prime and probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="mesh coordinates X0={mesh_x0} Y0={mesh_y0} X1={mesh_x1} Y1={mesh_y1}"
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% if should_prime and not probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
STOW_PROBE
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M84]
rename_existing = M84.1
gcode =
M84.1
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
{% if printer["dual_carriage"] is defined %}
_SET_TOOLHEAD_OFFSET T={printer["gcode_macro RatOS"].default_toolhead|int} MOVE=0
SET_GCODE_VARIABLE MACRO=SET_PRESSURE_ADVANCE VARIABLE=snyc_toolheads VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro _VAOC"] is defined %}
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started VALUE=False
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started_at_temp VALUE=False
{% endif %}
SET_GCODE_OFFSET X=0 Y=0 Z=0 MOVE=0
_IDEX_SINGLE INIT=1
{% endif %}
SET_SKEW CLEAR=1
_LED_MOTORS_OFF
[gcode_macro M104]
rename_existing = M104.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
DEBUG_ECHO PREFIX="M104" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set temperature_offset_t0 = printer["gcode_macro T0"].temperature_offset|default(0)|int %}
{% set temperature_offset_t1 = printer["gcode_macro T1"].temperature_offset|default(0)|int %}
{% set s0 = [s + temperature_offset_t0, 0]|max %}
{% set s1 = [s + temperature_offset_t1, 0]|max %}
{% if temperature_offset_t0 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t0}°C added to toolhead T0."
{% endif %}
{% if temperature_offset_t1 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t1}°C added to toolhead T1."
{% endif %}
{% else %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
M104.1 S{s0} T0
M104.1 S{s1} T1
{% else %}
M104.1 S{s} T{t}
{% endif %}
{% endif %}
[gcode_macro M109]
rename_existing = M109.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
DEBUG_ECHO PREFIX="M109" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M109" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
M109.1 S{s} T{t}
{% endif %}
[gcode_macro SET_HEATER_TEMPERATURE]
rename_existing = SET_HEATER_TEMPERATURE_BASE
gcode =
{% set heater = params.HEATER|default("") %}
{% set target = params.TARGET|default(0)|int %}
DEBUG_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="heater: {heater}, target: {target}"
{% if heater|lower == "extruder" or heater|lower == "extruder1" %}
{% set t = 0 if heater|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and target > 0 %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set target = [target + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
SET_HEATER_TEMPERATURE_BASE HEATER="{heater}" TARGET={target}
[gcode_macro TEMPERATURE_WAIT]
rename_existing = TEMPERATURE_WAIT_BASE
gcode =
{% set sensor = params.SENSOR|default("") %}
{% set minimum = params.MINIMUM|default(-1)|int %}
{% set maximum = params.MAXIMUM|default(-1)|int %}
DEBUG_ECHO PREFIX="TEMPERATURE_WAIT" MSG="sensor: {sensor}, minimum: {minimum}, maximum: {maximum}"
{% if sensor|lower == "extruder" or sensor|lower == "extruder1" %}
{% set t = 0 if sensor|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and (minimum > 0 or maximum > 0) %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% if minimum > -1 %}
{% set minimum = [minimum + temperature_offset, 0]|max %}
{% endif %}
{% if maximum > -1 %}
{% set maximum = [maximum + temperature_offset, 0]|max %}
{% endif %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% if minimum > -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum} MAXIMUM={maximum}
{% elif minimum > -1 and maximum == -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum}
{% elif minimum == -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MAXIMUM={maximum}
{% endif %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature for toolhead T{t} reached."
[gcode_macro SET_GCODE_OFFSET]
rename_existing = SET_GCODE_OFFSET_ORG
gcode =
SET_GCODE_OFFSET_ORG { rawparams }
{% if printer.configfile.settings.beacon is defined and (params.Z_ADJUST is defined or params.Z is defined) %}
_BEACON_APPLY_RUNTIME_MULTIPLIER
{% endif %}
[gcode_macro SDCARD_PRINT_FILE]
rename_existing = SDCARD_PRINT_FILE_BASE
gcode =
{% if printer["ratos"] is defined %}
PROCESS_GCODE_FILE { rawparams }
{% else %}
SDCARD_PRINT_FILE_BASE { rawparams }
{% endif %}
[gcode_macro SKEW_PROFILE]
rename_existing = SKEW_PROFILE_BASE
variable_loaded_profile = ""
gcode =
{% if params.LOAD is defined %}
{% if printer.configfile.settings["skew_correction %s" % params.LOAD] is defined %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='"{params.LOAD}"'
{% endif %}
{% endif %}
SKEW_PROFILE_BASE { rawparams }
[gcode_macro SET_SKEW]
rename_existing = SET_SKEW_BASE
gcode =
{% if params.CLEAR is defined %}
{% if params.CLEAR|default(0)|int == 1 %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='""'
{% endif %}
{% endif %}
SET_SKEW_BASE { rawparams }
[gcode_macro SET_VELOCITY_LIMIT]
rename_existing = SET_VELOCITY_LIMIT_BASE
gcode =
{% if params.ACCEL_TO_DECEL is defined %}
{% if params.ACCEL is defined %}
{% set accel = params.ACCEL|float %}
{% else %}
{% set accel = printer.toolhead.max_accel|float %}
{% endif %}
{% if params.VELOCITY is defined %}
{% set velocity = params.VELOCITY|float %}
{% else %}
{% set velocity = printer.toolhead.max_velocity|float %}
{% endif %}
{% if params.SQUARE_CORNER_VELOCITY is defined %}
{% set scv = params.SQUARE_CORNER_VELOCITY|float %}
{% else %}
{% set scv = printer.toolhead.square_corner_velocity|float %}
{% endif %}
{% set mcr = params.ACCEL_TO_DECEL|float / accel %}
DEBUG_ECHO PREFIX="SET_VELOCITY_LIMIT" MSG="ACCEL={accel}, VELOCITY={velocity}, SQUARE_CORNER_VELOCITY={scv}, MINIMUM_CRUISE_RATIO={mcr}"
SET_VELOCITY_LIMIT_BASE ACCEL={accel} VELOCITY={velocity} SQUARE_CORNER_VELOCITY={scv} MINIMUM_CRUISE_RATIO={1-mcr}
{% else %}
SET_VELOCITY_LIMIT_BASE { rawparams }
{% endif %}
[gcode_macro _START_PRINT_PARK]
gcode =
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_x = printer["gcode_macro RatOS"].start_print_park_x %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% endif %}
{% if printer["dual_carriage"] is defined and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
{% if printer["gcode_macro RatOS"].start_print_park_x is defined and printer["gcode_macro RatOS"].start_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="start_print_park_x is ignored for IDEX printers"
{% endif %}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={start_print_park_in} X={start_print_park_x}
G0 Z{z} F{z_speed}
[gcode_macro _END_PRINT_PARK]
gcode =
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro RatOS"].end_print_park_x is defined and printer["gcode_macro RatOS"].end_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="end_print_park_x is ignored for IDEX printers"
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={printer["gcode_macro RatOS"].end_print_park_in} X={printer["gcode_macro RatOS"].end_print_park_x}
[gcode_macro _PARK]
gcode =
{% set x = params.X %}
{% set location = params.LOCATION|default('back')|lower %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set nozzle_priming = printer["gcode_macro RatOS"].nozzle_priming|lower %}
CACHE_TOOLHEAD_SETTINGS KEY="park"
SET_MACRO_TRAVEL_SETTINGS
{% if x != '' %}
{% if x|float >= printer.toolhead.axis_minimum.x + 5 and x|float <= printable_x_max - 5 %}
{% set park_x = x|float %}
{% else %}
{action_respond_info('The requested X co-ordinate is outside the defined axis bounds - using defaults')}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% else %}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% set park_y = printable_y_max - 15 %}
{% if location == 'front' %}
{% set park_y = printer.toolhead.axis_minimum.y + 5 %}
{% elif location == 'center' %}
{% set park_y = printable_y_max / 2 %}
{% elif location == 'primeblob' and printer["dual_carriage"] is defined %}
{% set park_y = printable_y_max - 15 %}
{% endif %}
{% if location == 'primeblob' and printer["dual_carriage"] is not defined %}
{% if (nozzle_priming == 'primeblob' or nozzle_priming == 'primeline') %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set park_x = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set park_x = printable_x_max - 5 %}
{% else %}
{% set park_x = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set park_y = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set park_y = printable_y_max - 5 %}
{% else %}
{% set park_y = nozzle_prime_start_y|float %}
{% endif %}
{% endif %}
{% endif %}
G90
{% if printer["dual_carriage"] is not defined %}
G0 X{park_x} Y{park_y} F{speed}
{% else %}
G0 Y{park_y} F{speed}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="park"
[gcode_macro SAVE_PROBE_RESULT]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
{% set last_z_offset = 9999.9 %}
{% if printer.configfile.settings.beacon is defined %}
{% set current_z = printer.toolhead.position.z|float %}
{% if beacon_contact_prime_probing %}
{% set last_z_offset = printer.beacon.last_z_result %}
{% else %}
{% set last_z_offset = printer.beacon.last_sample.dist - current_z %}
{% endif %}
{% elif printer.configfile.settings.bltouch is defined %}
{% set config_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% elif printer.configfile.settings.probe is defined %}
{% set config_offset = printer.configfile.settings.probe.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Saving offset adjustment of {last_z_offset} in {params.VARIABLE|default('last_z_offset')}"
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE={params.VARIABLE|default('last_z_offset')} VALUE={last_z_offset}
[gcode_macro PROBE_FOR_PRIMING]
gcode =
{% set probe_for_priming_disable_mesh_constraints = true if printer["gcode_macro RatOS"].probe_for_priming_disable_mesh_constraints|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower != 'false' %}
SAVE_GCODE_STATE NAME=probe_for_priming_state
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the prime location.."
CACHE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
SET_MACRO_TRAVEL_SETTINGS
{% set t = params.TOOLHEAD|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% if idex_mode == '' %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% if t == 0 %}
{% set x_start = 5 %}
{% else %}
{% set x_start = printable_x_max - 5 %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% endif %}
{% endif %}
{% set z = printer.configfile.settings.bed_mesh.horizontal_move_z|float %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% if printer.configfile.settings.bltouch is defined %}
{% set x_offset = printer.configfile.settings.bltouch.x_offset|float %}
{% set y_offset = printer.configfile.settings.bltouch.y_offset|float %}
{% set z_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% elif printer.configfile.settings.probe is defined %}
{% set x_offset = printer.configfile.settings.probe.x_offset|float %}
{% set y_offset = printer.configfile.settings.probe.y_offset|float %}
{% set z_offset = printer.configfile.settings.probe.z_offset|float %}
{% elif printer.configfile.settings.beacon is defined %}
{% set x_offset = printer.configfile.settings.beacon.x_offset|float %}
{% set y_offset = printer.configfile.settings.beacon.y_offset|float %}
{% set z_offset = printer.configfile.settings.beacon.trigger_distance|float %}
{% else %}
{ action_raise_error("No probe, beacon or bltouch section found. Adaptive priming only works with a [probe], [beacon] or [bltouch] section defined.") }
{% endif %}
{% if z < z_offset %}
{ action_raise_error("Horizontal move Z ({z}) is below your probe's Z offset ({z_offset}). Please adjust your horizontal_move_z setting in [bed_mesh] to be above {z}.") }
{% endif %}
{% if not probe_for_priming_disable_mesh_constraints %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float - x_offset %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float - y_offset %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float - x_offset %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float - y_offset %}
{% set x_start = [[x_start, max_x]|min, min_x]|max %}
{% set y_start = [[y_start, max_y]|min, min_y]|max %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the start of the prime location at {x_start}, {y_start}"
G90
M83
G0 Z{z} F{z_speed}
G1 X{x_start} Y{y_start} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result
{% endif %}
{% if idex_mode == '' %}
{% set x_end = x_start %}
{% set y_end = y_start + 45 %}
{% else %}
{% if t==1 %}
{% set x_end = x_start - 45 %}
{% else %}
{% set x_end = x_start + 45 %}
{% endif %}
{% set y_end = y_start %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the end of the prime location at {x_end}, {y_end}"
G1 X{x_end} Y{y_end} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result
{% endif %}
RESTORE_GCODE_STATE NAME=probe_for_priming_state
RESTORE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
{% endif %}
[gcode_macro RESET_PRIME_PROBE_STATE]
gcode =
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result VALUE=None
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result_t1 VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result_t1 VALUE=None
{% endif %}
[gcode_macro PROBE_CURRENT_POSITION]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
SAVE_GCODE_STATE NAME=probe_current_position_state
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
ASSERT_PROBE_DEPLOYED
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_prime_probing %}
PROBE PROBE_METHOD=contact SAMPLES=1
{% else %}
PROBE
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
BEACON_QUERY
{% else %}
RESTORE_GCODE_STATE NAME=probe_current_position_state MOVE=1 MOVE_SPEED={printer["gcode_macro RatOS"].macro_z_speed|float}
{% endif %}
[gcode_macro PRIME_BLOB]
description = Prints a primeblob, used internally, if configured, as part of the START_PRINT macro.
variable_x_offset = 5
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="prime_blob"
SET_MACRO_TRAVEL_SETTINGS
RATOS_ECHO PREFIX="Priming" MSG="Priming nozzle with prime blob.."
{% set current_toolhead = 0 %}
{% set target_idex_mode = '' %}
{% set extruder = 'extruder' %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE is defined %}
{% set target_idex_mode = params.IDEX_MODE|default('')|lower %}
{% else %}
{ action_raise_error("IDEX_MODE parameter not found for PRIME_BLOB macro. This is likely a bug.") }
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Priming in IDEX {target_idex_mode} mode.."
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set current_toolhead = 1 if current_idex_mode=='primary' else 0 %}
{% set extruder = 'extruder1' if current_toolhead == 1 else 'extruder' %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
SAVE_GCODE_STATE NAME=prime_blob_state
{% endif %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set fan_speed = printer["gcode_macro RatOS"].nozzle_prime_bridge_fan|float %}
{% set nozzle_diameter = printer.configfile.settings[extruder].nozzle_diameter|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set has_start_offset_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) != 9999.9 %}
{% if printer["dual_carriage"] is defined %}
{% set has_start_offset_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) != 9999.9 %}
{% endif %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_z_height = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set nozzle_prime_direction = printer["gcode_macro RatOS"].nozzle_prime_direction|lower %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% if target_idex_mode == '' %}
{% set x_factor = 0 %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% set y_factor = 1 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% set y_factor = -1 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% if nozzle_prime_start_y|float < printable_y_max / 2 %}
{% set y_factor = 1 %}
{% else %}
{% set y_factor = -1 %}
{% endif %}
{% endif %}
{% if nozzle_prime_direction == 'forwards' %}
{% set y_factor = 1 %}
{% elif nozzle_prime_direction == 'backwards' %}
{% set y_factor = -1 %}
{% endif %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% else %}
{% set z = start_print_park_z_height %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% set y_factor = 0 %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set x_start = center_x / 2 + 5 %}
{% set x_factor = 1 %}
{% else %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% if current_toolhead == 0 %}
{% set x_start = 55 %}
{% set x_factor = -1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 55 %}
{% set x_factor = 1 %}
{% endif %}
{% else %}
{% if current_toolhead == 0 %}
{% set x_start = 5 %}
{% set x_factor = 1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 5 %}
{% set x_factor = -1 %}
{% endif %}
{% endif %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_x_max - 5 %}
{% endif %}
{% set z = 10 %}
{% endif %}
{% set start_z_offset = 0 %}
{% set end_z_offset = 0 %}
{% if has_start_offset_t0 %}
{% set start_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) %}
{% set end_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_end_result|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t0) ) }
{% endif %}
{% if end_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t0) ) }
{% endif %}
{% set start_z_offset = start_z_probe_result_t0 %}
{% set end_z_offset = end_z_probe_result_t0 %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if current_toolhead == 1 or both_toolheads or target_idex_mode == "copy" or target_idex_mode == "mirror" %}
{% if has_start_offset_t1 %}
{% set start_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) %}
{% set end_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_end_result_t1|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t1) ) }
{% endif %}
{% if end_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t1) ) }
{% endif %}
{% set start_z_offset = [start_z_offset, start_z_probe_result_t1]|max %}
{% set end_z_offset = [end_z_offset, start_z_probe_result_t1]|max %}
{% endif %}
{% endif %}
{% if target_idex_mode != 'copy' and target_idex_mode != 'mirror' %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% set original_start_z_offset = start_z_offset %}
{% set original_end_z_offset = end_z_offset %}
{% set start_z_offset = original_end_z_offset %}
{% set end_z_offset = original_start_z_offset %}
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={current_toolhead}
{% endif %}
DEBUG_ECHO PREFIX="PRIME_BLOB" MSG="x_start: {x_start}, y_start: {y_start}, x_factor: {x_factor}, y_factor: {y_factor}, z: {z}, start_z_offset: {start_z_offset}, end_z_offset: {end_z_offset}"
G90
M83
RATOS_ECHO PREFIX="Priming" MSG="Lifting Z to {z}.."
G0 Z{z} F{z_speed}
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% if start_print_park_in != 'primeblob' %}
G1 X{x_start} F{speed}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% endif %}
{% else %}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% if target_idex_mode=="copy" or target_idex_mode=="mirror" %}
RATOS_ECHO PREFIX="Priming" MSG="Mirroring move to {x_start}, {y_start} along the edge of the print area.."
_IDEX_MIRROR PRIMING=1
{% else %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% endif %}
G1 X{x_start} F{speed}
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Starting prime blob.."
G1 Z{0.5 + start_z_offset} F{z_speed}
G1 Y{y_start} F{speed}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
M106 S{fan_speed}
G1 Z5 F100 E5
G92 E0
RATOS_ECHO PREFIX="Priming" MSG="Bridging with {((fan_speed/255) * 100)|int}% fan speed.."
G1 F3000 X{x_start + (15 * x_factor)} Y{y_start + (15 * y_factor)} E{1 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (20 * x_factor)} Y{y_start + (20 * y_factor)} Z{3.8 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (34 * x_factor)} Y{y_start + (34 * y_factor)} Z{2.6 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (38 * x_factor)} Y{y_start + (38 * y_factor)} Z{1.4 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (42 * x_factor)} Y{y_start + (42 * y_factor)} Z{0.2 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
M106 S0
G1 F3000 X{x_start + (46 * x_factor)} Y{y_start + (46 * y_factor)} Z{0.2 + end_z_offset} E0.6
G1 F{speed} X{x_start + (50 * x_factor)} Y{y_start + (50 * y_factor)}
{% if target_idex_mode == "copy" or target_idex_mode == "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if target_idex_mode == "copy" %}
{% if first_y >= 0 %}
_IDEX_COPY DANCE=0 Y={first_y}
{% else %}
_IDEX_COPY DANCE=0 Y={params.Y1}
{% endif %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
RESTORE_GCODE_STATE NAME=prime_blob_state
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="prime_blob"
G92 E0
[gcode_macro UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% set temp = params.TEMP|default(220)|int %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_UNLOAD_FILAMENT TEMP={temp} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _LEGACY_UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set unload_speed = 5 * 60 %}
{% set unload_length = printer["gcode_macro RatOS"].filament_unload_length|float %}
M117 Unloading filament...
G0 E10 F300
G0 E-5 F3600
G4 P3000
G0 E5 F6000
G0 E-15 F6000
G0 E-{unload_length} F{unload_speed}
_CLEANING_MOVE TOOLHEAD={toolhead}
M117 Filament unloaded!
RESPOND MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _DEFAULT_UNLOAD_FILAMENT]
description = Unload filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_UNLOAD_FILAMENT" MSG="TEMP: {temp}"
_LED_UNLOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=unload_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD=0 NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TOOLHEAD=0
{% endif %}
RESTORE_GCODE_STATE NAME=unload_state
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD=0
[gcode_macro _IDEX_UNLOAD_FILAMENT]
description = Unload filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_UNLOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead}
{% endif %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Unloading filament from nozzle to cooling zone... Please wait!"
_PURGE_BEFORE_UNLOAD TOOLHEAD={toolhead}
{% if printer["gcode_macro _UNLOAD_WITHOUT_TIP_FORMING"] is defined %}
_UNLOAD_WITHOUT_TIP_FORMING TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_UNLOAD_WITH_TIP_FORMING NAME='{filament_name}' TYPE='{filament_type}'
{% endif %}
G4 P3000
[gcode_macro _UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
{% set tooolhead_sensor_to_extruder_gear_distance = printer["gcode_macro T%s" % toolhead].tooolhead_sensor_to_extruder_gear_distance|float %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER" MSG="TOOLHEAD: {toolhead}"
G0 E-{extruder_gear_to_cooling_position_distance + tooolhead_sensor_to_extruder_gear_distance + 50} F{extruder_load_speed}
RATOS_ECHO MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _UNLOAD_WITH_TIP_FORMING]
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% if filament_name != '' and filament_type != '' %}
_UNLOAD_KNOWN_FILAMENT NAME={filament_name} TYPE={filament_type}
{% else %}
_UNLOAD_UNKNOWN_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _UNLOAD_KNOWN_FILAMENT]
description = User overrideable tip forming macro if slicer filament profiles are known
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
RATOS_ECHO PREFIX="FILAMENT TYPE" MSG='{filament_type}'
RATOS_ECHO PREFIX="FILAMENT PROFILE" MSG='{filament_name}'
{% if filament_name == "Prusament PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% elif filament_name == "Nobufil PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% else %}
RATOS_ECHO PREFIX="_UNLOAD_KNOWN_FILAMENT" MSG="Filament profile not found!"
_UNLOAD_UNKNOWN_FILAMENT
{% endif %}
[gcode_macro _UNLOAD_UNKNOWN_FILAMENT]
description = User overrideable standard tip forming macro
gcode =
DEBUG_ECHO PREFIX="_UNLOAD_UNKNOWN_FILAMENT" MSG="Using standard tip forming macro!"
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
[gcode_macro _TIP_FORMING]
gcode =
{% set cooling_moves = params.COOLING_MOVES|default(4)|int %}
{% set cooling_move_length = params.COOLING_MOVE_LENGTH|default(10)|float %}
{% set start_cooling_speed = params.START_COOLING_SPEED|default(10)|float * 60 %}
{% set end_cooling_speed = params.END_COOLING_SPEED|default(50)|float * 60 %}
{% if cooling_moves == 0 %}
{% set cooling_move_length = 0 %}
{% endif %}
{% set dip = true if params.DIP|default(false)|lower == "true" else false %}
{% set dip_length = params.DIP_LENGTH|default(22)|float %}
{% set dip_speed = params.DIP_SPEED|default(30)|float * 60 %}
{% set dip_retract_speed = params.DIP_RETRACT_SPEED|default(70)|float * 60 %}
{% set retract_length = params.RETRACT_LENGTH|default(18)|float %}
{% set start_retract_speed = params.START_RETRACT_SPEED|default(120)|float * 60 %}
{% set end_retract_speed = params.END_RETRACT_SPEED|default(20)|float * 60 %}
DEBUG_ECHO PREFIX="_TIP_FORMING" MSG="cooling_moves: {cooling_moves}, cooling_move_length: {cooling_move_length}, start_cooling_speed: {start_cooling_speed}, end_cooling_speed: {end_cooling_speed}, dip: {dip}, dip_length: {dip_length}, dip_speed: {dip_speed}, dip_retract_speed: {dip_retract_speed}, retract_length: {retract_length}, start_retract_speed: {start_retract_speed}, end_retract_speed: {end_retract_speed}"
M220 S100
G92 E0
{% set retract = retract_length + cooling_move_length / 2 - 15 %}
G1 E-15 F{start_retract_speed}
G1 E-{0.7 * retract} F{1.0 * end_retract_speed}
G1 E-{0.2 * retract} F{0.5 * end_retract_speed}
G1 E-{0.1 * retract} F{0.3 * end_retract_speed}
G92 E0
{% if cooling_moves > 0 %}
{% set i = (end_cooling_speed - start_cooling_speed) / (2 * cooling_moves - 1) %}
{% for m in range(cooling_moves) %}
G1 E{cooling_move_length} F{(start_cooling_speed + i * m * 2)}
G1 E-{cooling_move_length} F{(start_cooling_speed + i * (m * 2 + 1))}
{% endfor %}
{% endif %}
G92 E0
{% if dip %}
G1 E{dip_length} F{dip_speed}
G4 P100
G1 E-{dip_length} F{dip_retract_speed}
{% endif %}
G92 E0
M400
[gcode_macro _ON_FILAMENT_SENSOR_BUTTON_PRESSED]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_SENSOR_BUTTON_PRESSED" MSG="TOOLHEAD: {toolhead}"
{% if not printer.virtual_sdcard.is_active %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_FILAMENT_END]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set clogged = true if params.CLOGGED|default(false)|lower == 'true' else false %}
{% set unload_after_runout = printer["gcode_macro T%s" % toolhead].unload_after_runout|float %}
{% if clogged %}
_LED_FILAMENT_CLOG TOOLHEAD={toolhead}
{% else %}
_LED_FILAMENT_RUNOUT TOOLHEAD={toolhead}
{% endif %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_END" MSG="TOOLHEAD: {toolhead}"
{% if printer.virtual_sdcard.is_active %}
{% if not printer.pause_resume.is_paused %}
PAUSE RUNOUT=True
{% endif %}
{% if not clogged and unload_after_runout %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% if not clogged and printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true'%}
_JOIN_SPOOL TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M600]
description = Executes a color change by pausing the printer an unloading the filament.
gcode =
PAUSE
UNLOAD_FILAMENT
RATOS_ECHO MSG="Please load new filament and resume"
[gcode_macro COLD_PULL]
description = Automated hotend cold pull.
gcode =
{% set extrusion_temp = params.EXTRUSION_TEMP|default(220)|int %}
{% set cold_pull_temp = params.COLD_PULL_TEMP|default(80)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% if printer["dual_carriage"] is not defined %}
{% set toolhead = 0 %}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead != 0 and toolhead != 1 %}
{action_raise_error("Please select toolhead! 0 = left, 1 = right toolhead")}
{% endif %}
{% endif %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
SAVE_GCODE_STATE NAME=cold_pull_state
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
RATOS_ECHO MSG="Heating T{toolhead} to {extrusion_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={extrusion_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={extrusion_temp} MAXIMUM={extrusion_temp + 2}
G4 P3000
RATOS_ECHO MSG="extruding..."
G92 E0
G1 E30 F300
G92 E0
RATOS_ECHO MSG="Heating T{toolhead} to {cold_pull_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={cold_pull_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={cold_pull_temp} MAXIMUM={cold_pull_temp + 2}
G4 P10000
RATOS_ECHO MSG="cold pull..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-40 VELOCITY=5 ACCEL=100
RATOS_ECHO MSG="eject filament..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-200 VELOCITY=20 ACCEL=500
RATOS_ECHO MSG="cooling down extruder..."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET=0
RESTORE_GCODE_STATE NAME=cold_pull_state
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
CONSOLE_ECHO TITLE="Cold pull finished!" MSG="Please remove the filament from the PTFE tube and cut the end off. Do NOT try to load it again." TYPE="warning"
[gcode_macro _USER_START_PRINT_BEFORE_HOMING]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_BED]
gcode =
[gcode_macro _USER_START_PRINT_BED_MESH]
gcode =
[gcode_macro _USER_START_PRINT_PARK]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
[gcode_macro _USER_START_PRINT_HEAT_CHAMBER]
description = Uses the extruder sensor to wait for chamber temp. Override the _START_PRINT_HEAT_CHAMBER macro to implement heated chamber handling.
gcode =
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
[gcode_macro _USER_END_PRINT_BEFORE_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_AFTER_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_PARK]
gcode =
[gcode_macro _USER_END_PRINT_FINISHED]
description = User hook for when the print is finished after gcode state has been restored.
gcode =
[gcode_macro _USER_START_PRINT]
gcode =
[gcode_macro _USER_END_START_PRINT]
gcode =
[gcode_macro _USER_START_FEATURE]
gcode =
[gcode_macro _USER_END_FEATURE]
gcode =
[gcode_macro ECHO_T_VARS]
description = Echo Toolhead variables to the console.
gcode =
{% set t = params.T|default(0) %}
RATOS_ECHO MSG="T{t} Variables"
{% for var, value in printer["gcode_macro T%s" % t].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[gcode_macro ECHO_RATOS_VARS]
description = Echo RatOS variables to the console.
gcode =
{% for var, value in printer["gcode_macro RatOS"].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[delayed_gcode RATOS_INIT]
initial_duration = 0.1
gcode =
_LED_STANDBY
CALCULATE_PRINTABLE_AREA
INITIAL_FRONTEND_UPDATE
_CHAMBER_FILTER_SANITY_CHECK
[delayed_gcode RATOS_LOGO]
initial_duration = 2
gcode =
HELLO_RATOS
[gcode_macro INITIAL_FRONTEND_UPDATE]
gcode =
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_error = printer["gcode_macro RatOS"].status_color_error|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_unknown}"'
{% endif %}
{% set t0_sensor = "undefined" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].filament_detected|lower == "true" %}
{% set t0_sensor = "detected" %}
{% else %}
{% set t0_sensor = "empty" %}
{% endif %}
{% else %}
{% set t0_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set t1_sensor = "undefined" %}
{% if printer["dual_carriage"] is defined and printer["filament_switch_sensor toolhead_filament_sensor_t1"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].filament_detected|lower == "true" %}
{% set t1_sensor = "detected" %}
{% else %}
{% set t1_sensor = "empty" %}
{% endif %}
{% else %}
{% set t1_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set svv = printer.save_variables.variables %}
{% if svv.t0_filament is defined and printer["gcode_macro T0"] is defined %}
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
{% if t0_sensor != "empty" %}
{% set t0_filament_type = svv.t0_filament[0]|default('')|string %}
{% set t0_filament_name = svv.t0_filament[1]|default('')|string %}
{% set t0_filament_temp = svv.t0_filament[2]|default(0)|float %}
{% if t0_filament_name != '' and t0_filament_type != '' and t0_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{t0_filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{t0_filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={t0_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
{% if svv.t1_filament is defined and printer["gcode_macro T1"] is defined %}
{% if printer["gcode_macro T1"].filament_name is defined and printer["gcode_macro T1"].filament_type is defined and printer["gcode_macro T1"].filament_temp is defined %}
{% if t1_sensor != "empty" %}
{% set t1_filament_type = svv.t1_filament[0]|default('')|string %}
{% set t1_filament_name = svv.t1_filament[1]|default('')|string %}
{% set t1_filament_temp = svv.t1_filament[2]|default(0)|float %}
{% if t1_filament_name != '' and t1_filament_type != '' and t1_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='"{t1_filament_name}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='"{t1_filament_type}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE={t1_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t1_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro CALCULATE_PRINTABLE_AREA]
gcode =
{% set bed_margin_x = printer["gcode_macro RatOS"].bed_margin_x %}
{% set bed_margin_y = printer["gcode_macro RatOS"].bed_margin_y %}
{% set tool = 0 if printer["gcode_macro T0"] is not defined or printer["gcode_macro T0"].active else 1 %}
{% set max_x = printer.toolhead.axis_maximum.x if printer["dual_carriage"] is defined and tool == 0 else printer.toolhead.axis_maximum.x - bed_margin_x[1] %}
{% if printer["dual_carriage"] is defined %}
{% set max_x = printer.toolhead.axis_maximum.x %}
{% endif %}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="printer.toolhead.axis_maximum.x {printer.toolhead.axis_maximum.x}"
{% set max_y = printer.toolhead.axis_maximum.y - bed_margin_y[1]%}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_x_max VALUE={max_x}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_y_max VALUE={max_y}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="Printable area calculated: X: 0,{max_x} Y: 0,{max_y}"
[gcode_macro CACHE_TOOLHEAD_SETTINGS]
variable_cache = {"global": {"accel": 1000, "ratio": 0.5, "speed": 50, "scv": 5}}
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set dummy = cache.__setitem__(key, {"accel": printer.toolhead.max_accel, "ratio": printer.toolhead.minimum_cruise_ratio, "speed": printer.toolhead.max_velocity, "scv": printer.toolhead.square_corner_velocity}) %}
SET_GCODE_VARIABLE MACRO=CACHE_TOOLHEAD_SETTINGS VARIABLE=cache VALUE="{cache | pprint | replace("\n", "") | replace("\"", "\\\"")}"
DEBUG_ECHO PREFIX="CACHE_TOOLHEAD_SETTINGS" MSG="Toolhead settings cached for {key}. {printer.toolhead.max_accel} accel, {printer.toolhead.minimum_cruise_ratio} ratio, {printer.toolhead.max_velocity} velocity, {printer.toolhead.square_corner_velocity} scv."
[gcode_macro RESTORE_TOOLHEAD_SETTINGS]
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set values = printer["gcode_macro CACHE_TOOLHEAD_SETTINGS"].cache.__getitem__(key) %}
{% if values is not defined or values == 'None' %}
{ action_raise_error("RESTORE_TOOLHEAD_SETTINGS: Toolhead settings not cached for key '" ~ key ~ "'.") }
{% endif %}
SET_VELOCITY_LIMIT ACCEL={values.accel} MINIMUM_CRUISE_RATIO={values.ratio} VELOCITY={values.speed} SQUARE_CORNER_VELOCITY={values.scv}
DEBUG_ECHO PREFIX="RESTORE_TOOLHEAD_SETTINGS" MSG="Toolhead settings restored. {values.accel} accel, {values.ratio} ratio, {values.speed} velocity, {values.scv} scv."
[gcode_macro SET_MACRO_TRAVEL_SETTINGS]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set accel = printer["gcode_macro RatOS"].macro_travel_accel %}
SET_VELOCITY_LIMIT ACCEL={accel} MINIMUM_CRUISE_RATIO=0.5 VELOCITY={speed} SQUARE_CORNER_VELOCITY={5}
DEBUG_ECHO PREFIX="SET_MACRO_TRAVEL_SETTINGS" MSG="Macro travel settings set. {accel} accel, {speed} velocity"
[gcode_macro SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% if printer["dual_carriage"] is not defined %}
SET_KINEMATIC_POSITION X={printable_x_max / 2} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
{% else %}
IDEX_SET_CENTER_KINEMATIC_POSITION
{% endif %}
[gcode_macro IDEX_SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set center_x = printable_x_max / 2 %}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x - (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x + (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
[gcode_macro VERIFY_HYBRID_INVERTED]
gcode =
{% set inverted = False %}
{% if printer.configfile.settings.ratos_hybrid_corexy is defined and printer.configfile.settings.ratos_hybrid_corexy.inverted is defined %}
{% if printer.configfile.settings.ratos_hybrid_corexy.inverted|lower == 'true' %}
{% set inverted = True %}
{% endif %}
{% endif %}
{% if inverted == False %}
{ action_emergency_stop("ratos_hybrid_corexy NOT INVERTED! Inverted hybrid core-xy bugfix not detected.") }
{% endif %}
[gcode_macro RATOS_ECHO]
gcode =
{% set prefix = "RatOS" %}
{% set debug = params.DEBUG|default(0)|int %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " | " ~ params.PREFIX %}
{% endif %}
{% set prefix = prefix ~ ":" %}
{% set msg = "" %}
{% if params.MSG is defined %}
{% set msg = params.MSG %}
{% else %}
{% set msg = "No msg parameter provided (this is a bug or unintended use)." %}
{% endif %}
{% if not debug %}
M117 {prefix} {msg}
{% endif %}
RATOS_LOG PREFIX="{prefix}" MSG="{msg}"
{% if not debug %}
RESPOND PREFIX="{prefix}" MSG="{msg}"
{% else %}
CONSOLE_ECHO TITLE="{prefix}" TYPE="debug" MSG="{msg}"
{% endif %}
[gcode_macro ENABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=True
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=prefix_filter VALUE="'{params.FILTER|default('')|lower}'"
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging enabled."
[gcode_macro DISABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=False
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging disabled."
[gcode_macro DEBUG_ECHO]
variable_enabled = False
variable_prefix_filter = ''
gcode =
{% set prefix = "DEBUG" %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " - " ~ params.PREFIX %}
{% endif %}
{% if enabled and (prefix_filter|lower == '' or prefix_filter|lower in params.PREFIX|lower) %}
RATOS_ECHO PREFIX="{prefix}" MSG="{params.MSG}" DEBUG=1
{% endif %}
[gcode_macro START_FEATURE]
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="Start {params.FEATURE} feature gcode"
{% set scv = printer.toolhead.square_corner_velocity|int|default(5) %}
{% set accel = printer.toolhead.max_accel|int|default(10000) %}
{% set ratio = printer.toolhead.minimum_cruise_ratio|float|default(0.5) %}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="scv" VALUE={scv}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="accel" VALUE={accel}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="ratio" VALUE={ratio}
_USER_START_FEATURE FEATURE="{params.FEATURE}"
[gcode_macro END_FEATURE]
variable_scv = 5
variable_accel = 10000
variable_ratio = 0.5
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="End {params.FEATURE} feature gcode"
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={scv} ACCEL={accel} MINIMUM_CRUISE_RATIO={ratio}
_USER_END_FEATURE FEATURE="{params.FEATURE}" SCV={scv} ACCEL={accel} RATIO={ratio}
[gcode_macro _ON_LAYER_CHANGE]
variable_layer_number = 0
description = INTERNAL USE ONLY. Call it from the slicers after layer change custom gcode
gcode =
{% set layer = params.LAYER|int %}
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE={layer}
SET_PRINT_STATS_INFO CURRENT_LAYER={layer}
[gcode_macro _LEARN_MORE_CALIBRATION]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/calibration" %}
{% set link_text = "RatOS Calibration Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_CHAMBER_FILTER]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter Control" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_FILAMENT]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/filaments" %}
{% set link_text = "RatOS Filament Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _CONSOLE_SAVE_CONFIG]
gcode =
M118 Click SAVE_CONFIG to save the settings to your printer.cfg.
[gcode_macro SAVE_Z_OFFSET]
gcode =
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SAVE_MULTIPLIER
{% else %}
Z_OFFSET_APPLY_PROBE
{% endif %}
[gcode_macro _LOAD_RATOS_SKEW_PROFILE]
gcode =
{% set ratos_skew_profile = printer["gcode_macro RatOS"].skew_profile|default("") %}
{% if ratos_skew_profile != "" %}
{% if printer.configfile.config["skew_correction %s" % ratos_skew_profile] is defined %}
SKEW_PROFILE LOAD={ratos_skew_profile}
GET_CURRENT_SKEW
{% else %}
{% set line_1 = '"Could not find skew profile %s!_N_Clearing skew correction."' % ratos_skew_profile %}
CONSOLE_ECHO TITLE="Missing skew profile!" TYPE="warning" MSG={line_1}
SET_SKEW CLEAR=1
{% endif %}
{% endif %}
[gcode_macro M601]
gcode =
PAUSE
[gcode_macro PAUSE]
description = Pauses the print
rename_existing = PAUSE_BASE
variable_extrude = 1.5
variable_retract = 1.5
variable_fan_speed = 0
variable_idex_mode = ""
variable_idex_toolhead = 0
variable_idex_toolhead_x = 0.0
variable_idex_toolhead_y = 0.0
variable_idex_toolhead_z = 0.0
gcode =
{% set runout_detected = true if params.RUNOUT|default(false)|lower == 'true' else false %}
_LED_PAUSE
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set idex_toolhead = 1 if idex_mode == 'primary' else 0 %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
SAVE_GCODE_STATE NAME=PAUSE_state
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_mode VALUE='"{idex_mode}"'
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead VALUE={idex_toolhead}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_x VALUE={printer.gcode_move.gcode_position.x|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_y VALUE={printer.gcode_move.gcode_position.y|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_z VALUE={printer.gcode_move.gcode_position.z|float}
DEBUG_ECHO PREFIX="PAUSE" MSG="idex_mode: {idex_mode}, idex_toolhead: {idex_toolhead}, idex_toolhead_x: {idex_toolhead_x}, idex_toolhead_y: {idex_toolhead_y}, idex_toolhead_z: {idex_toolhead_z}"
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
CACHE_TOOLHEAD_SETTINGS KEY="pause"
SET_MACRO_TRAVEL_SETTINGS
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% if current_z < (max_z - 20.0) %}
{% set z_safe = 20.0 %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
PAUSE_BASE
{% if printer["dual_carriage"] is not defined %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan"].speed|float}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
{% if idex_toolhead == 0 %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t1"].speed|float}
{% endif %}
{% endif %}
{% endif %}
M106 S0
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if idex_mode != '' %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set R = printer["gcode_macro PAUSE"].retract|float %}
{% if can_extrude %}
G91
G1 E-{R} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].pause_print_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].pause_print_park_in %}
{% if runout_detected %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].runout_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].runout_park_in %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
DEBUG_ECHO PREFIX="PAUSE" MSG="z_speed: {z_speed}, pause_print_park_x: {pause_print_park_x}, pause_print_park_in: {pause_print_park_in}, default_toolhead: {default_toolhead}"
{% if "xyz" in printer.toolhead.homed_axes %}
G91
G1 Z{z_safe} F{z_speed}
G90
{% if printer["dual_carriage"] is not defined %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% else %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
_IDEX_SINGLE X={parking_position}
{% else %}
PARK_TOOLHEAD
{% endif %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% endif %}
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="pause"
[gcode_macro RESUME]
description = Resumes the print if the printer is paused.
rename_existing = RESUME_BASE
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set target_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set target_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% endif %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if target_idex_mode != '' %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set fan_speed = printer["gcode_macro PAUSE"].fan_speed|float %}
{% if printer["dual_carriage"] is not defined %}
M106 S{(fan_speed * 255)}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% else %}
{% if params.TOOLHEAD is defined %}
{% if params.TOOLHEAD == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% else %}
{% if printer["gcode_macro PAUSE"].idex_toolhead == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% endif %}
{% endif %}
M106.1 S{fan_speed}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY DANCE=0
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR DANCE=0
{% else %}
{% if params.TOOLHEAD is defined %}
_SELECT_TOOL T={params.TOOLHEAD} X=-1 Y=-1 TOOLSHIFT=false
{% else %}
_SELECT_TOOL T={printer["gcode_macro PAUSE"].idex_toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% endif %}
{% set x = printer["gcode_macro PAUSE"].idex_toolhead_x|float %}
{% set y = printer["gcode_macro PAUSE"].idex_toolhead_y|float %}
{% set z = printer["gcode_macro PAUSE"].idex_toolhead_z|float %}
G1 X{x} Y{y} Z{z} F{speed}
{% if params.TOOLHEAD is defined %}
SAVE_GCODE_STATE NAME=PAUSE_STATE
{% endif %}
{% endif %}
{% if params.TOOLHEAD is not defined %}
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
{% if can_extrude %}
G91
G1 E{E} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1 MOVE_SPEED={speed}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
RESUME_BASE
_LED_PRINTING
[gcode_macro CANCEL_PRINT]
description = Cancels the printer
rename_existing = CANCEL_PRINT_BASE
gcode =
END_PRINT
TURN_OFF_HEATERS
CLEAR_PAUSE
CANCEL_PRINT_BASE
[gcode_macro START_PRINT]
description = Start print procedure, use this in your Slicer.
variable_post_processor_version = 2
variable_is_printing_gcode = False
variable_both_toolheads = True
variable_object_xoffset = 0
variable_first_x = -1
variable_first_y = -1
variable_total_toolshifts = 0
variable_initial_tool = 0
variable_extruder_first_layer_temp = ""
variable_extruder_other_layer_temp = ""
gcode =
{% if "xyz" in printer.toolhead.homed_axes and printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% if printer["gcode_macro _VAOC"].is_started|default(true)|lower == 'true' %}
_VAOC_END
{% endif %}
{% endif %}
_LED_START_PRINTING
CACHE_TOOLHEAD_SETTINGS KEY="start_print"
_USER_START_PRINT { rawparams }
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set bed_heat_soak_time = printer["gcode_macro RatOS"].bed_heat_soak_time|default(0)|int %}
{% set hotend_heat_soak_time = printer["gcode_macro RatOS"].hotend_heat_soak_time|default(0)|int %}
{% set z_probe_stowable = printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set X0 = params.X0|default(-1)|float %}
{% set X1 = params.X1|default(-1)|float %}
{% set Y0 = params.Y0|default(-1)|float %}
{% set Y1 = params.Y1|default(-1)|float %}
{% if first_x == -1 or first_y == -1 %}
{% set first_x = params.FIRST_X|default(-1)|float %}
{% set first_y = params.FIRST_Y|default(-1)|float %}
{% endif %}
{% set total_toolshifts = params.TOTAL_TOOLSHIFTS|default(0)|int %}
{% set initial_tool = params.INITIAL_TOOL|default(default_toolhead)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set bed_temp = params.BED_TEMP|default(printer.heater_bed.target, true)|float %}
{% set total_layer_count = params.TOTAL_LAYER_COUNT|default(0)|int %}
{% set extruder_first_layer_temp = (params.EXTRUDER_TEMP|default("")).split(",") %}
RATOS_ECHO MSG="First print coordinates X:{first_x} Y:{first_y}"
{% if params.TOTAL_LAYER_COUNT is not defined %}
{% set link_url = "https://os.ratrig.com/docs/slicers" %}
{% set link_text = "RatOS Slicer Configuration" %}
{% set line_1 = '"Your slicer gcode settings are not up to date._N_Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="Incomplete Slicer Configuration detected" TYPE="warning" MSG={line_1}
{% endif %}
SET_PRINT_STATS_INFO CURRENT_LAYER=1
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE=1
{% if total_layer_count > 0 %}
SET_PRINT_STATS_INFO TOTAL_LAYER={total_layer_count}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set swap_toolheads = true if printer["gcode_macro _IDEX_REMAP_TOOLHEADS"].enabled|default(false)|lower == 'true' else false %}
{% if swap_toolheads %}
{% set initial_tool = 0 if initial_tool == 1 else 1 %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=active VALUE=True
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=active VALUE=True
{% endif %}
{% set both_toolheads = true %}
{% if total_toolshifts == 0 %}
{% set both_toolheads = false %}
{% endif %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
{% endif %}
{% if both_toolheads and (idex_mode == "copy" or idex_mode == "mirror") %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Gcode tool changes found. Copy and mirror mode do not support toolchanges.")}
{% endif %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set both_toolheads = true %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=initial_tool VALUE={initial_tool}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_x VALUE={first_x}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_y VALUE={first_y}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=total_toolshifts VALUE={total_toolshifts}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=both_toolheads VALUE={both_toolheads}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_first_layer_temp VALUE="'{params.EXTRUDER_TEMP}'"
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_other_layer_temp VALUE="'{params.EXTRUDER_OTHER_LAYER_TEMP}'"
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE VARIABLE=toolshift_count VALUE=0
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set svv = printer.save_variables.variables %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
{% set stepper_x_position_min = printer.configfile.settings.stepper_x.position_min|float %}
{% set stepper_x_position_endstop = printer.configfile.settings.stepper_x.position_endstop|float %}
{% set dual_carriage_position_max = printer.configfile.settings.dual_carriage.position_max|float %}
{% set dual_carriage_position_endstop = printer.configfile.settings.dual_carriage.position_endstop|float %}
{% set x_parking_space = parking_position_t0 - (stepper_x_position_endstop , stepper_x_position_min)|max %}
{% set dc_parking_space = (dual_carriage_position_endstop , dual_carriage_position_max)|min - parking_position_t1 %}
{% if svv.idex_xoffset|abs >= (x_parking_space - 0.5) or svv.idex_xoffset|abs >= (dc_parking_space - 0.5) %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Toolhead x-offset is too high for the available parking space. Calibrate your X and DC endstop positions and make sure you stay below 1mm." % (copy_mode_max_width)) }
{% endif %}
{% endif %}
{% if (idex_mode == "copy" or idex_mode == "mirror") and printer.configfile.settings.ratos.enable_gcode_transform %}
{% if params.MIN_X is not defined or params.MAX_X is not defined %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Something went wrong! Missing important post processor start print parameter!") }
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE=0
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set boundary_box_min_x = params.MIN_X|default(0)|float %}
{% set boundary_box_max_x = params.MAX_X|default(printable_x_max)|float %}
{% set svv = printer.save_variables.variables %}
{% if default_toolhead == 0 %}
{% set boundary_box_max_x = boundary_box_max_x + svv.idex_xoffset %}
{% else %}
{% set boundary_box_min_x = boundary_box_min_x - svv.idex_xoffset %}
{% endif %}
{% set center_x = printable_x_max / 2.0 %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% set object_width = boundary_box_max_x - boundary_box_min_x %}
{% set copy_mode_max_width = center_x %}
{% set mirror_mode_max_width = center_x - safe_distance / 2.0 %}
DEBUG_ECHO PREFIX="START_PRINT" MSG="OBJECT_WIDTH: {object_width} BOUNDARY_BOX_MIN_X: {boundary_box_min_x} BOUNDARY_BOX_MAX_X: {boundary_box_max_x} CENTER_X: {center_x} SAFE_DISTANCE: {safe_distance}"
{% if idex_mode == "copy" and object_width > copy_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for copy mode! Max supported width is %s mm" % (copy_mode_max_width)) }
{% endif %}
{% if idex_mode == "mirror" and object_width > mirror_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for mirror mode! Max supported width is %s mm" % (mirror_mode_max_width)) }
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = (printable_x_max - boundary_box_max_x - boundary_box_min_x) / 2 %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE={object_xoffset}
{% endif %}
{% endif %}
{% set has_initial_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_initial_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined and both_toolheads %}
{% set has_secondary_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_secondary_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% endif %}
_CHAMBER_FILTER_ON AT="before_print_start"
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true' %}
{% if both_toolheads %}
RATOS_ECHO MSG="Spool join is not possible if both toolheads are in use!"
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if idex_mode == '' %}
_SET_TOOLHEAD_OFFSET T={default_toolhead} MOVE={1 if "xyz" in printer.toolhead.homed_axes else 0}
{% endif %}
{% endif %}
CLEAR_PAUSE
{% if printer["gcode_macro RatOS"].force_absolute_position|lower == 'true' %}
G90
{% endif %}
SAVE_GCODE_STATE NAME=start_print_state
G21
G90
M82
_USER_START_PRINT_BEFORE_HOMING { rawparams }
{% if z_probe_stowable == true %}
STOWABLE_PROBE_BEGIN_BATCH
{% endif %}
MAYBE_HOME
_Z_HOP
{% if idex_mode != '' and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
PARK_TOOLHEAD
{% endif %}
{% if chamber_temp > 0 %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED={printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float}
{% endif %}
{% endif %}
_CHAMBER_HEATER_ON START_CHAMBER_TEMP={start_chamber_temp} CHAMBER_TEMP={chamber_temp}
_USER_START_PRINT_HEAT_CHAMBER { rawparams } CHAMBER_TEMP={chamber_temp}
{% endif %}
_START_PRINT_BEFORE_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
RATOS_ECHO MSG="Heating bed..."
M190 S{bed_temp}
{% if bed_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking bed for {bed_heat_soak_time} seconds..."
G4 P{(bed_heat_soak_time * 1000)}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_BED { rawparams }
_START_PRINT_AFTER_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
_USER_START_PRINT_BED_MESH { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_BED_MESH X0={X0} X1={X1} Y0={Y0} Y1={Y1} T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if z_probe_stowable == true %}
STOWABLE_PROBE_END_BATCH
{% endif %}
{% if idex_mode == '' %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={extruder_first_layer_temp[1]|float}
{% endif %}
{% endif %}
_USER_START_PRINT_PARK { rawparams }
_START_PRINT_PARK
RATOS_ECHO MSG="Heating Extruder..."
{% if idex_mode == '' %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder1" MINIMUM={extruder_first_layer_temp[1]|float} MAXIMUM={extruder_first_layer_temp[1]|float + 5}
{% endif %}
{% endif %}
{% if hotend_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking hotend for {hotend_heat_soak_time} seconds..."
G4 P{(hotend_heat_soak_time * 1000)}
{% endif %}
{% if idex_mode == '' %}
_LED_PRINTING
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
_LED_PRINTING
{% else %}
{% if both_toolheads %}
_LED_PRINTING TOOLHEAD={initial_tool}
{% if toolchange_standby_temp > -1 %}
_LED_TOOLHEAD_STANDBY TOOLHEAD={0 if initial_tool == 1 else 1}
{% else %}
_LED_PRINTING TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% else %}
_LED_PRINTING TOOLHEAD={initial_tool}
_LED_DEACTIVATE_TOOLHEAD TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% endif %}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_EXTRUDER { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_AFTER_HEATING_EXTRUDER X0={X0} X1={X1} Y0={Y0} Y1={Y1} INITIAL_TOOLHEAD={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if idex_mode != '' %}
{% if not both_toolheads %}
{% if initial_tool != default_toolhead %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET=0
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if toolchange_standby_temp > -1 %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if initial_tool == 1 else 'extruder1'} TARGET={toolchange_standby_temp}
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% set x_offset = printer.toolhead.position.x|float - printer.gcode_move.gcode_position.x|float %}
{% endif %}
RESTORE_GCODE_STATE NAME=start_print_state
{% if idex_mode != '' %}
{% set act_idex_mode = printer["dual_carriage"].carriage_1|default('')|lower %}
{% if act_idex_mode == "copy" or act_idex_mode == "mirror" %}
SET_GCODE_OFFSET X={x_offset} MOVE=0
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% if idex_mode == "copy" and idex_mode != act_idex_mode %}
_IDEX_COPY DANCE=0
{% elif idex_mode == "mirror" and idex_mode != act_idex_mode %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
RATOS_ECHO MSG="Adjusting object x-offset by {(object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={object_xoffset} MOVE=0
{% endif %}
{% else %}
_SELECT_TOOL T={initial_tool} TOOLSHIFT=false
{% if initial_tool != default_toolhead %}
{% set svv = printer.save_variables.variables %}
SAVE_VARIABLE VARIABLE=idex_applied_offset VALUE={default_toolhead}
_SET_TOOLHEAD_OFFSET T={initial_tool} MOVE=0
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={initial_tool}
{% endif %}
_SET_EXTRUSION_MODE
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
SET_GCODE_VARIABLE MACRO=_SELECT_TOOL VARIABLE=last_timestamp VALUE={printer["print_stats"].print_duration}
{% endif %}
_USER_END_START_PRINT { rawparams }
G92 E0
_CHAMBER_FILTER_ON AT="after_print_start"
RATOS_ECHO MSG="Printing..."
[gcode_macro _START_PRINT_BEFORE_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set is_stowable_probe = true if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Pre-heating extruder..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={min_temp}
{% else %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET={min_temp}
{% endif %}
{% else %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
{% endif %}
{% endif %}
{% if not is_stowable_probe %}
{% if printer["dual_carriage"] is defined and act_t != default_toolhead %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
{% endif %}
RATOS_ECHO MSG="Heat soaking z probe..."
{% if auto_z_offset_calibration %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% if default_toolhead == 0 %}
_SELECT_TOOL T=0 TOOLSHIFT=false
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
{% elif default_toolhead == 1 %}
_SELECT_TOOL T=1 TOOLSHIFT=false
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
{% endif %}
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% endif %}
G0 Z2 F{z_speed}
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Waiting for extruder to be preheated..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
{% if default_toolhead == 0 %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_Z_HOP
{% endif %}
{% if auto_z_offset_calibration %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
PARK_TOOLHEAD
_CLEANING_MOVE TOOLHEAD={default_toolhead}
_SELECT_TOOL T={0 if default_toolhead == 1 else 1} X={parking_position_t0 if default_toolhead == 1 else parking_position_t1} Y=0 TOOLSHIFT=false
_CLEANING_MOVE TOOLHEAD={0 if default_toolhead == 1 else 1}
_VAOC_CALIBRATE_Z_OFFSET AUTO_Z_OFFSET=True
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=false
{% endif %}
{% set needs_rehoming = False %}
{% if printer.z_tilt is defined and not printer.z_tilt.applied %}
RATOS_ECHO MSG="Adjusting Z tilt..."
Z_TILT_ADJUST
RATOS_ECHO MSG="Rehoming Z after Z tilt adjustment..."
{% set needs_rehoming = True %}
{% endif %}
{% if printer.quad_gantry_level is defined and not printer.quad_gantry_level.applied %}
RATOS_ECHO MSG="Running quad gantry leveling..."
QUAD_GANTRY_LEVEL
RATOS_ECHO MSG="Rehoming Z after quad gantry leveling..."
{% set needs_rehoming = True %}
{% endif %}
{% if needs_rehoming %}
G28 Z
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %}
{% if beacon_contact_wipe_before_true_zero %}
_START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE
{% endif %}
_START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
G0 Z5 F{z_speed}
G0 X50 Y10 F{speed}
PROBE PROBE_METHOD=contact SAMPLES=1
BEACON_QUERY
[gcode_macro _START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_true_zero_temp = printer["gcode_macro RatOS"].beacon_contact_true_zero_temp|default(150)|int %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_true_zero_location = printer["gcode_macro RatOS"].beacon_contact_true_zero_location|default("front")|lower %}
{% set beacon_contact_true_zero_margin_x = printer["gcode_macro RatOS"].beacon_contact_true_zero_margin_x|default(30)|int %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if beacon_contact_wipe_before_true_zero %}
{% if printer.beacon.last_probe_result|lower == "ok" %}
{% set last_z_offset = printer.beacon.last_z_result %}
RATOS_ECHO MSG="Auto calibration nozzle wipe with probe result {last_z_offset}..."
G0 Z{(0.2 + last_z_offset)} F{z_speed}
G0 X70 F300
{% else %}
RATOS_ECHO MSG="Skipping auto calibration nozzle wipe because probing failed!"
{% endif %}
{% endif %}
G0 Z5 F{z_speed}
_MOVE_TO_SAFE_Z_HOME
RATOS_ECHO MSG="Heating extruder to probing temperature..."
SET_HEATER_TEMPERATURE HEATER={"extruder" if default_toolhead == 0 else "extruder1"} TARGET={beacon_contact_true_zero_temp}
TEMPERATURE_WAIT SENSOR={"extruder" if default_toolhead == 0 else "extruder1"} MINIMUM={beacon_contact_true_zero_temp} MAXIMUM={beacon_contact_true_zero_temp + 5}
RATOS_ECHO MSG="Beacon contact auto calibration..."
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
G0 Z5 F{z_speed}
[gcode_macro _START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set first_x = printer["gcode_macro START_PRINT"].first_x|default(-1)|float %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set center_x = printable_x_max / 2.0 %}
{% set center_y = printable_y_max / 2.0 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% if printer["dual_carriage"] is defined %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% endif %}
{% set X0 = params.X0|default(-1)|int %}
{% set X1 = params.X1|default(-1)|int %}
{% set Y0 = params.Y0|default(-1)|int %}
{% set Y1 = params.Y1|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% if idex_mode == '' %}
_PRIME
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
RATOS_ECHO PREFIX="IDEX" MSG="using combined prime offset for IDEX {idex_mode} mode"
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
{% if both_toolheads %}
{% if initial_toolhead == 0 %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T{initial_toolhead}"
_SELECT_TOOL T={initial_toolhead} TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% endif %}
{% endif %}
CACHE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
SET_MACRO_TRAVEL_SETTINGS
{% if (X0 > -1 and Y1 > -1) or (first_x > 0 and first_y > 0) %}
{% if printer["dual_carriage"] is defined %}
{% set acceleration = printer["gcode_macro RatOS"].toolchange_travel_accel %}
{% set max_accel = printer.toolhead.max_accel|float %}
{% set square_corner_velocity = printer.toolhead.square_corner_velocity|float %}
SET_VELOCITY_LIMIT ACCEL={acceleration} MINIMUM_CRUISE_RATIO=0 SQUARE_CORNER_VELOCITY=20
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
{% set first_z = 1 %}
{% else %}
{% set first_z = 3 %}
{% endif %}
{% if idex_mode == "mirror" %}
{% if first_y >= 0 %}
G0 Y{first_y} F{speed}
{% else %}
G0 Y{Y1} F{speed}
{% endif %}
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
_MOVE_TO_LOADING_POSITION TOOLHEAD={initial_toolhead}
_PURGE_FILAMENT TOOLHEAD={initial_toolhead} E={printer["gcode_macro RatOS"].toolchange_first_purge|default(50)|float}
_CLEANING_MOVE TOOLHEAD={initial_toolhead}
{% endif %}
{% if first_x >= 0 and first_y >= 0 %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% else %}
{% set first_x = X0 %}
{% set first_y = Y0 %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'min' %}
{% set first_x = X0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'max' %}
{% set first_x = X1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|float <= center_x %}
{% set first_x = X0 %}
{% else %}
{% set first_x = X1 %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'min' %}
{% set first_y = Y0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'max' %}
{% set first_y = Y1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|float <= center_y %}
{% set first_y = Y0 %}
{% else %}
{% set first_y = Y1 %}
{% endif %}
{% endif %}
{% endif %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% endif %}
{% endif %}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
_LOAD_RATOS_SKEW_PROFILE
[gcode_macro _PRIME]
gcode =
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
PRIME_BLOB INITIAL_TOOLHEAD={params.INITIAL_TOOLHEAD} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={params.IDEX_MODE} Y1={params.Y1}
{% else %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE == "copy" %}
_IDEX_COPY DANCE=0
{% elif params.IDEX_MODE == "mirror" %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro END_PRINT]
description = End print procedure, use this in your Slicer.
gcode =
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SAVE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = printer["gcode_macro START_PRINT"].object_xoffset|default(0)|float %}
RATOS_ECHO MSG="Adjusting object x-offset by {(0-object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={(0-object_xoffset)}
{% endif %}
{% endif %}
_USER_END_PRINT_BEFORE_HEATERS_OFF { rawparams }
_END_PRINT_BEFORE_HEATERS_OFF
TURN_OFF_HEATERS
_USER_END_PRINT_AFTER_HEATERS_OFF { rawparams }
_END_PRINT_AFTER_HEATERS_OFF
_USER_END_PRINT_PARK { rawparams }
_END_PRINT_PARK
{% if printer["gcode_macro RatOS"].skew_profile is defined %}
SET_SKEW CLEAR=1
{% endif %}
{% if printer["dual_carriage"] is not defined and printer["gcode_macro RatOS"].end_print_motors_off|lower != 'false' %}
M84
{% endif %}
M107
BED_MESH_CLEAR
RATOS_ECHO MSG="Done :)"
RESTORE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
M84
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
{% if printer["dual_carriage"] is not defined %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_expansion_compensation = true if printer["gcode_macro RatOS"].beacon_contact_expansion_compensation|default(false)|lower == 'true' else false %}
{% if beacon_contact_start_print_true_zero and beacon_contact_expansion_compensation %}
SET_GCODE_OFFSET Z=0 MOVE=0
{% endif %}
{% endif %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print"
_CHAMBER_FILTER_ON AT="print_end"
_CHAMBER_FILTER_OFF
_CHAMBER_HEATER_OFF
_USER_END_PRINT_FINISHED { rawparams }
[gcode_macro _END_PRINT_BEFORE_HEATERS_OFF]
gcode =
RATOS_ECHO MSG="Cleaning up..."
[gcode_macro _END_PRINT_AFTER_HEATERS_OFF]
gcode =
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% set z_hop = printer["gcode_macro RatOS"].end_print_park_z_hop|float %}
{% set r = printer["gcode_macro RatOS"].end_print_retract_filament|default(4)|float %}
{% if current_z < (max_z - z_hop) %}
{% set z_safe = z_hop %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
G91
G1 E-2 F3600
G0 Z{z_safe} F3600
G1 E-{(r-2)} F3600
G90
[gcode_macro _SET_EXTRUSION_MODE]
gcode =
{% if printer["gcode_macro RatOS"].relative_extrusion|lower == 'true' %}
M83
{% else %}
M82
{% endif %}
[gcode_macro GENERATE_SHAPER_GRAPHS]
description = Genarates input shaper resonances graphs for analysis. Uses the AXIS parameter for if you only want to do one axis at a time, (eg. GENERATE_SHAPER_GRAPHS AXIS=X)
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set axis = params.AXIS|default('')|lower %}
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
{% if axis != '' %}
{% if axis == 'x' %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
{% elif axis == 'y' %}
MAYBE_HOME
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% else %}
{action_raise_error("Unknown axis specified. Expected X or Y.")}
{% endif %}
{% else %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% endif %}
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Shaper graph"
[gcode_shell_command generate_shaper_graph_x]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-x.sh
timeout = 60.
verbose = True
[gcode_shell_command generate_shaper_graph_y]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-y.sh
timeout = 60.
verbose = True
[gcode_macro MEASURE_COREXY_BELT_TENSION]
description = Generates resonance graph used to ensure belts are equally tensioned.
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
MAYBE_HOME
TEST_RESONANCES AXIS=1,1 OUTPUT=raw_data NAME=belt-tension-upper FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=belt-tension-lower FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_belt_tension_graph
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Belt Tension Graph"
[gcode_shell_command generate_belt_tension_graph]
command = /home/pi/printer_data/config/RatOS/scripts/generate-belt-tension-graph.sh
timeout = 90.
verbose = True
[idle_timeout]
gcode =
{% if printer.webhooks.state|lower == 'ready' %}
{% if printer.pause_resume.is_paused|lower == 'false' %}
RATOS_ECHO PREFIX="IDLE" MSG="2 hours since last activity. Powering off heaters and motors.."
TURN_OFF_HEATERS
M84
{% endif %}
{% endif %}
timeout = 7200
[temperature_sensor raspberry_pi]
sensor_type = temperature_host
[skew_correction]
[input_shaper]
[virtual_sdcard]
path = ~/printer_data/gcodes
[display_status]
[pause_resume]
[force_move]
enable_force_move = True
[respond]
[resonance_generator]
[ratos]
allow_unknown_gcode_generator = True
[exclude_object]
[heater_bed]
heater_pin = heater_bed_heating_pin
sensor_pin = heater_bed_sensor_pin
sensor_type = EPCOS 100K B57560G104F
min_temp = 0
max_temp = 130
control = pid
pid_kp = 68.203
pid_ki = 2.842
pid_kd = 409.216
[fan]
pin = multi_pin:dual_blower_fan
shutdown_speed = 1.0
kick_start_time = 0.5
cycle_time = 0.00004
[heater_fan toolhead_cooling_fan]
pin = PD14
fan_speed = 1
heater = extruder
heater_temp = 50.0
[controller_fan controller_fan]
pin = PD13
idle_speed = 0.7
[printer]
kinematics = cartesian
max_velocity = 200
max_accel = 3000
minimum_cruise_ratio = 0.5
max_z_velocity = 15
max_z_accel = 200
square_corner_velocity = 5
[bed_mesh]
speed = 200
horizontal_move_z = 5
mesh_min = 15,15
mesh_max = 150,160
probe_count = 5,5
fade_start = 1.0
fade_end = 10.0
mesh_pps = 2,2
algorithm = bicubic
bicubic_tension = .2
[screws_tilt_adjust]
screw1 = 80, 108
screw1_name = Left Screw
screw2 = 155, 72
screw2_name = Front Right Screw
screw3 = 155, 147
screw3_name = Rear Right Screw
horizontal_move_z = 10
speed = 200
screw_thread = CCW-M4
[stepper_x]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PF9
dir_pin = !x_dir_pin
enable_pin = !PD6
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = toolboard_t0:PB6
[stepper_y]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PD3
dir_pin = y_dir_pin
enable_pin = !PD5
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = PC1
[stepper_z]
position_min = -5
position_max = 180
step_pin = PA15
dir_pin = !z0_dir_pin
enable_pin = !PC9
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 4
homing_speed = 15
endstop_pin = probe:z_virtual_endstop
[gcode_macro SCREWS_TILT_CALCULATE]
rename_existing = SCREWS_TILT_CALCULATE_ORIG
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
MAYBE_HOME
SAVE_GCODE_STATE NAME=screws_tilt_state
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
DEPLOY_PROBE
{% endif %}
SCREWS_TILT_CALCULATE_ORIG
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
STOW_PROBE
{% endif %}
G90
G0 Z120 F{printer["gcode_macro RatOS"].macro_z_speed|float * 60}
G0 Y{printable_y_max} X{printable_x_max / 2} F{printer["gcode_macro RatOS"].macro_travel_speed|float * 60}
RESTORE_GCODE_STATE NAME=screws_tilt_state
M84
[extruder]
rotation_distance = 5.57
full_steps_per_rotation = 200
filament_diameter = 1.750
max_extrude_only_velocity = 120
max_extrude_only_accel = 800
pressure_advance_smooth_time = 0.02
max_extrude_only_distance = 200
nozzle_diameter = 0.4
heater_pin = toolboard_t0:PB13
sensor_type = MAX31865
sensor_pin = toolboard_t0:PA4
min_extrude_temp = 170
min_temp = 0
max_temp = 350
pressure_advance = 0.03
step_pin = toolboard_t0:PD0
dir_pin = !toolboard_t0:e_dir_pin
enable_pin = !toolboard_t0:PD2
microsteps = 64
control = pid
pid_kp = 21.673
pid_ki = 1.338
pid_kd = 87.776
spi_software_sclk_pin = toolboard_t0:PA5
spi_software_miso_pin = toolboard_t0:PA6
spi_software_mosi_pin = toolboard_t0:PA7
[firmware_retraction]
retract_speed = 120
unretract_extra_length = 0
unretract_speed = 120
retract_length = 0.5
[adxl345 rpi]
cs_pin = rpi:None
[resonance_tester]
accel_chip_x = adxl345 toolboard_t0
accel_chip_y = adxl345 rpi
probe_points =
90,90,20
[tmc2209 stepper_x]
stealthchop_threshold = 0
interpolate = False
uart_pin = PF10
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_y]
stealthchop_threshold = 0
interpolate = False
uart_pin = PD4
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_z]
stealthchop_threshold = 0
interpolate = False
uart_pin = PC8
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 extruder]
stealthchop_threshold = 0
interpolate = False
uart_pin = toolboard_t0:PA15
run_current = 0.707
driver_tbl = 0
driver_toff = 4
driver_hend = 6
driver_hstrt = 7
sense_resistor = 0.11
[bltouch]
sensor_pin = ^toolboard_t0:bltouch_sensor_pin
control_pin = toolboard_t0:bltouch_control_pin
speed = 7
pin_move_time = 0.675
sample_retract_dist = 10
pin_up_reports_not_triggered = True
pin_up_touch_mode_reports_triggered = True
x_offset = -28
y_offset = -13
z_offset = 2.375
[gcode_macro T0]
variable_join = 0
variable_remap = 0
variable_alert = ""
variable_filament_name = ""
variable_filament_type = ""
variable_filament_temp = 0
variable_runout_sensor = ""
variable_active = True
variable_color = "7bff33"
variable_hotend_type = "HF"
variable_has_cht_nozzle = False
variable_cooling_position_to_nozzle_distance = 40
variable_tooolhead_sensor_to_extruder_gear_distance = 15
variable_extruder_gear_to_cooling_position_distance = 30
variable_filament_loading_nozzle_offset = -5
variable_filament_grabbing_length = 5
variable_filament_grabbing_speed = 1
variable_enable_insert_detection = True
variable_enable_runout_detection = True
variable_enable_clog_detection = True
variable_unload_after_runout = True
variable_purge_after_load = 0
variable_purge_before_unload = 0
variable_extruder_load_speed = 60
variable_filament_load_speed = 10
variable_standby = False
variable_temperature_offset = 0
variable_has_oozeguard = False
variable_has_front_arm_nozzle_wiper = False
variable_resume_after_insert = False
gcode =
{% set x = params.X|default(-1.0)|float %}
{% set y = params.Y|default(-1.0)|float %}
{% set z = params.Z|default(0.0)|float %}
{% set s = params.S|default(1)|int %}
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
_SELECT_TOOL T=0 X={x} Y={y} Z={z} TOOLSHIFT={s}
{% endif %}
[save_variables]
filename = /home/pi/printer_data/config/ratos-variables.cfg
[multi_pin dual_blower_fan]
pins = toolboard_t0:PA0, toolboard_t0:PA1
=======================
Config error
Traceback (most recent call last):
File "/home/pi/klipper/klippy/klippy.py", line 130, in _connect
self._read_config()
File "/home/pi/klipper/klippy/klippy.py", line 123, in _read_config
self.load_object(config, section_config.get_name(), None)
File "/home/pi/klipper/klippy/klippy.py", line 112, in load_object
self.objects[section] = init_func(config.getsection(section))
File "/home/pi/klipper/klippy/extras/fan.py", line 122, in load_config
return PrinterFan(config)
File "/home/pi/klipper/klippy/extras/fan.py", line 106, in __init__
self.fan = Fan(config)
File "/home/pi/klipper/klippy/extras/fan.py", line 24, in __init__
self.mcu_fan = ppins.setup_pin('pwm', config.get('pin'))
File "/home/pi/klipper/klippy/pins.py", line 117, in setup_pin
pin_params = self.lookup_pin(pin_desc, can_invert, can_pullup)
File "/home/pi/klipper/klippy/pins.py", line 98, in lookup_pin
pin_params = self.parse_pin(pin_desc, can_invert, can_pullup)
File "/home/pi/klipper/klippy/pins.py", line 83, in parse_pin
raise error("Unknown pin chip name '%s'" % (chip_name,))
pins.error: Unknown pin chip name 'multi_pin'
webhooks client 1964725608: New connection
webhooks client 1964725608: Client info {'program': 'Moonraker', 'version': 'v0.9.3-0-g71f9e67'}
Attempting MCU 'mcu' reset
Unable to issue reset command on MCU 'rpi'
Attempting MCU 'toolboard_t0' reset
webhooks client 1964725608: Disconnected
Restarting printer
Start printer at Wed Nov 12 17:02:07 2025 (1762966927.7 1186.6)
===== Config file =====
[mcu rpi]
serial = /tmp/klipper_host_mcu
[board_pins btt-skrat-10]
aliases =
x_step_pin=PF9,
x_dir_pin=PD7,
x_enable_pin=PD6,
x_uart_pin=PF10,
x_diag_pin=PB5,
x_endstop_pin=PB5,
y_step_pin=PD3,
y_dir_pin=PD2,
y_enable_pin=PD5,
y_uart_pin=PD4,
y_diag_pin=PC1,
y_endstop_pin=PC1,
z0_step_pin=PA15,
z0_dir_pin=PF8,
z0_enable_pin=PC9,
z0_uart_pin=PC8,
z0_diag_pin=PC0,
e_step_pin=PB10,
e_dir_pin=PE15,
e_enable_pin=PA8,
e_uart_pin=PB11,
e_diag_pin=PF5,
e_heater_pin=PE11,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PE5,
bltouch_control_pin=PE6,
probe_pin=PE5,
fan_part_cooling_pin=PD15,
fan_toolhead_cooling_pin=PD14,
fan_controller_board_pin=PD13,
heater_bed_heating_pin=PB3,
heater_bed_sensor_pin=PB2,
4p_fan_part_cooling_pin=PE9,
4p_fan_part_cooling_tach_pin=PD11,
4p_toolhead_cooling_pin=PE14,
4p_toolhead_cooling_tach_pin=PD10,
4p_controller_board_pin=PE14,
4p_controller_board_tach_pin=PD10
[mcu]
serial = /dev/RatOS/btt-skrat-10
[temperature_sensor SKRat_v1.0]
sensor_type = temperature_mcu
[adxl345 controlboard]
cs_pin = PB12
spi_bus = spi2
[board_pins toolboard_t0]
mcu = toolboard_t0
aliases =
e_step_pin=PD0,
e_dir_pin=PD1,
e_enable_pin=PD2,
e_uart_pin=PA15,
e_heater_pin=PB13,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PB8,
bltouch_control_pin=PB9,
probe_pin=PB9,
fan_part_cooling_pin=PA0,
fan_toolhead_cooling_pin=PA1,
fan_controller_board_pin=null,
heater_bed_heating_pin=null,
heater_bed_sensor_pin=null,
4p_fan_part_cooling_pin=null,
4p_fan_part_cooling_tach_pin=null,
4p_toolhead_cooling_pin=null,
4p_toolhead_cooling_tach_pin=null,
4p_controller_board_pin=null,
4p_controller_board_tach_pin=null
[mcu toolboard_t0]
serial = /dev/RatOS/btt-ebb42-12-t0
[temperature_sensor EBB42_v1.2_T0]
sensor_type = temperature_mcu
sensor_mcu = toolboard_t0
[adxl345 toolboard_t0]
axes_map = x, z, y
cs_pin = toolboard_t0:PB12
spi_software_mosi_pin = toolboard_t0:PB11
spi_software_miso_pin = toolboard_t0:PB2
spi_software_sclk_pin = toolboard_t0:PB10
[gcode_macro RatOS]
variable_homing = "endstops"
variable_z_probe = "static"
variable_sensorless_x_current = 0.6
variable_sensorless_y_current = 0.9
variable_safe_home_x = "middle"
variable_safe_home_y = "middle"
variable_driver_type_x = "tmc2209"
variable_driver_type_y = "tmc2209"
variable_stowable_probe_stop_on_error = False
variable_chamber_filter_enable = True
variable_chamber_filter_speed = 0.5
variable_chamber_filter_disable_speed = 1.0
variable_chamber_filter_enable_at = "after_print_start"
variable_chamber_filter_disable_period = 300
variable_chamber_filter_disable_bed_temp = 0
variable_chamber_heater_enable = True
variable_chamber_heater_bed_temp = 115
variable_chamber_heater_preheating_temp = 150
variable_chamber_heater_heating_temp_offset = 25
variable_chamber_heater_control_external_heater = False
variable_chamber_heater_air_circulation_enable = True
variable_chamber_heater_air_circulation_fan_speed = 0.35
variable_chamber_heater_air_circulation_y_pos = 0
variable_chamber_heater_air_circulation_z_pos = 100
variable_chamber_heater_extra_fan_speed = 1.0
variable_chamber_heater_filter_fan_speed = 1.0
variable_led_status_action = 0.0,1.0,1.0
variable_led_status_success = 0.0,1.0,0.0
variable_led_status_error = 1.0,0.0,1.0
variable_led_status_on = 1.0,1.0,1.0
variable_led_status_off = 0.0,0.0,1.0
variable_led_status_standby = 0.1,0.1,0.1
variable_led_status_heating = 1.0,0.0,0.0
variable_led_status_cooling = 0.0,0.0,1.0
variable_calibrate_bed_mesh = True
variable_adaptive_mesh = True
variable_start_print_park_in = "front"
variable_start_print_park_z_height = 50
variable_end_print_park_in = "back"
variable_pause_print_park_in = "front"
variable_end_print_park_z_hop = 20
variable_nozzle_priming = "primeblob"
variable_nozzle_prime_start_x = "max"
variable_nozzle_prime_start_y = "min"
variable_nozzle_prime_direction = "auto"
variable_nozzle_prime_bridge_fan = 102
variable_probe_for_priming_result = None
variable_probe_for_priming_end_result = None
variable_probe_for_priming_result_t1 = None
variable_probe_for_priming_end_result_t1 = None
variable_probe_for_priming_disable_mesh_constraints = False
variable_adaptive_prime_offset_threshold = -1.0
variable_last_z_offset = None
variable_runout_park_in = "front"
variable_enable_unload_tip_forming = False
variable_filament_unload_length = 150
description = RatOS variable storage macro, will echo variables to the console when run.
variable_relative_extrusion = False
variable_force_absolute_position = False
variable_preheat_extruder = True
variable_preheat_extruder_temp = 150
variable_macro_travel_speed = 200
variable_macro_travel_accel = 3000
variable_macro_z_speed = 15
variable_bed_margin_x = [0, 0]
variable_bed_margin_y = [0, 0]
variable_printable_x_min = 0
variable_printable_x_max = 0
variable_printable_y_min = 0
variable_printable_y_max = 0
variable_end_print_motors_off = True
variable_status_color_ok = "00FF00"
variable_status_color_error = "FF0000"
variable_status_color_unknown = "FFFF00"
variable_end_print_retract_filament = 10
gcode =
ECHO_RATOS_VARS
variable_homing_x = "endstop"
variable_homing_y = "endstop"
variable_x_driver_types = ["tmc2209"]
variable_x_axes = ["x"]
variable_y_driver_types = ["tmc2209"]
variable_y_axes = ["y"]
variable_z_driver_types = ["tmc2209"]
variable_z_axes = ["z"]
[ratos_homing]
axes = xyz
z_hop = 15
z_hop_speed = 15
gcode =
_LED_ON
{% set prev_stop_on_error = printer["gcode_macro RatOS"].stowable_probe_stop_on_error %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set target_idex_mode = printer["dual_carriage"].carriage_1|lower %}
_IDEX_SINGLE
_SELECT_TOOL T={default_toolhead} TOOLSHIFT=false
{% endif %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE=True
M400
G90
{% set X = true if params.X is defined else false %}
{% set Y = true if params.Y is defined else false %}
{% set Z = true if params.Z is defined else false %}
{% if printer["gcode_macro RatOS"].home_y_first|default(false)|lower == 'true' %}
HOME_Y X={X} Y={Y} Z={Z}
HOME_X X={X} Y={Y} Z={Z}
{% else %}
HOME_X X={X} Y={Y} Z={Z}
HOME_Y X={X} Y={Y} Z={Z}
{% endif %}
HOME_Z X={X} Y={Y} Z={Z}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE={prev_stop_on_error}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR
{% endif %}
{% endif %}
[gcode_macro HOME_X]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_x = printer["gcode_macro RatOS"].homing_x|lower %}
{% set homing_x = homing_x if homing_x else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_X" MSG="printable_x_max: {printable_x_max}, safe_home_x: {safe_home_x}, axis_maximum.x: {printer.toolhead.axis_maximum.x}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}"
{% if X or not Y and not Z %}
{% if homing_x == 'endstop' %}
G28 X
{% elif homing_x == 'sensorless' %}
{% if printer["dual_carriage"] is defined %}
{ action_emergency_stop("sensorless homing not supported on IDEX!") }
{% endif %}
HOME_X_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_x to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_x, homing)) }
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % (0 if default_toolhead==1 else 1)].parking_position|float %}
SET_DUAL_CARRIAGE CARRIAGE={0 if default_toolhead==1 else 1} MODE=PRIMARY
G1 X{parking_position} F{speed}
SET_DUAL_CARRIAGE CARRIAGE={default_toolhead} MODE=PRIMARY
{% endif %}
{% set x_homed = True %}
G0 X{safe_home_x} F{speed}
M400
{% endif %}
[gcode_macro HOME_Y]
gcode =
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_y = printer["gcode_macro RatOS"].homing_y|lower %}
{% set homing_y = homing_y if homing_y else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Y" MSG="printable_y_max: {printable_y_max}, safe_home_y: {safe_home_y}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}"
{% if Y or not X and not Z %}
{% if homing_y == 'endstop' %}
G28 Y
{% elif homing_y == 'sensorless' %}
HOME_Y_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_y to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_y, homing)) }
{% endif %}
{% set y_homed = True %}
G0 Y{safe_home_y} F{speed}
{% endif %}
[gcode_macro HOME_Z]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set z_probe = printer["gcode_macro RatOS"].z_probe %}
{% set beacon_contact_z_homing = true if printer["gcode_macro RatOS"].beacon_contact_z_homing|default(false)|lower == 'true' else false %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Z" MSG="x_homed: {x_homed}, y_homed: {y_homed}, z_probe: {z_probe}, beacon_contact_z_homing: {beacon_contact_z_homing}"
{% if Z or not Y and not X %}
RATOS_ECHO MSG="Homing Z"
{% if x_homed == False or y_homed == False %}
{ action_emergency_stop("X and Y must be homed before homing Z") }
{% else %}
{% if z_probe == "stowable" %}
DEPLOY_PROBE
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
STOW_PROBE
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
{% endif %}
{% endif %}
{% endif %}
[gcode_macro HOME_X_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
G4 P300
G28 X
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
[gcode_macro HOME_Y_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
G4 P300
G28 Y
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
[gcode_macro _Z_HOP]
description = Move Z axis up by Z_HOP distance at Z_HOP_SPEED. In relative mode it will move Z axis up by Z_HOP distance. In absolute mode it will move Z axis to Z_HOP distance.
gcode =
{% set z_hop = printer.configfile.config.ratos_homing.z_hop|float %}
{% set z_hop_speed = printer.configfile.config.ratos_homing.z_hop_speed|float * 60 %}
G0 Z{z_hop} F{z_hop_speed}
[gcode_macro _MOVE_TO_SAFE_Z_HOME]
description = Move to safe home position with optional Z_HOP (pass Z_HOP=True as parameter)
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% if params.Z_HOP is defined %}
_Z_HOP
{% endif %}
DEBUG_ECHO PREFIX="_MOVE_TO_SAFE_Z_HOME" MSG="axis_maximum.x: {printer.toolhead.axis_maximum.x}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}, safe_home_x: {safe_home_x}, safe_home_y: {safe_home_y}, printable_x_max: {printable_x_max}, printable_y_max: {printable_y_max}"
G0 X{safe_home_x} Y{safe_home_y} F{speed}
[gcode_macro MAYBE_HOME]
description = Only home unhomed axis
variable_is_kinematic_position_overriden = False
gcode =
{% if printer["gcode_macro MAYBE_HOME"].is_kinematic_position_overriden|lower == 'true' %}
RATOS_ECHO MSG="SET_CENTER_KINEMATIC_POSITION has been abused. Homing all axes. Please refrain from using SET_CENTER_KINEMATIC_POSITION outside of debugging purposes."
G28
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=False
{% else %}
{% set axes = '' %}
{% set isHomed = true %}
{% set axesToHome = '' %}
{% if params.X is defined %}
{% set axes = axes ~ 'X ' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% endif %}
{% if params.Y is defined %}
{% set axes = axes ~ 'Y ' %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% endif %}
{% if params.Z is defined %}
{% set axes = axes ~ 'Z ' %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if params.X is not defined and params.Y is not defined and params.Z is not defined %}
{% set axes = '' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if isHomed is false %}
RATOS_ECHO MSG="Homing {axesToHome}"
G28 {axesToHome}
{% else %}
RATOS_ECHO MSG="All requested axes already homed, skipping.."
{% endif %}
{% endif %}
[gcode_macro PID_CALIBRATE_HOTEND]
description = Perform a PID calibration test for a given extruder heater.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set temp = params.TEMP|default(220)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_HOTEND" MSG="TEMP={temp}"
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO MSG="PID calibration hotend heater T0 at {temp}°C..."
PID_CALIBRATE HEATER=extruder TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
{% if toolhead==0 or toolhead==1 %}
RATOS_ECHO MSG="PID calibration hotend heater T{toolhead} at {temp}°C..."
PID_CALIBRATE HEATER=extruder{'' if toolhead==0 else toolhead} TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_BED]
description = Perform a PID calibration test for the bed heater.
gcode =
{% set temp = params.TEMP|default(80)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_BED" MSG="TEMP={temp}"
RATOS_ECHO MSG="PID calibration bed heater at {temp}°C..."
PID_CALIBRATE HEATER=heater_bed TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_CHAMBER_HEATER]
description = Perform a PID calibration test for the chamber heater.
gcode =
{% set temp = params.TEMP|default(150)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_CHAMBER_HEATER" MSG="TEMP={temp}"
{% if printer["heater_generic chamber_heater"] is defined %}
RATOS_ECHO MSG="PID calibration chamber heater at {temp}°C..."
PID_CALIBRATE HEATER=chamber_heater TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_heater" %}
{% set link_text = "RatOS Chamber Heater" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber heater found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro INITIALIZE_PA_TUNING]
description = Start a pressure advance tuning tower.
gcode =
{% set start = params.START|default(0.0)|float %}
{% set factor = params.FACTOR|default(0.001)|float %}
{% set layer_number = printer["gcode_macro _ON_LAYER_CHANGE"].layer_number|default(0)|int %}
{% set is_printing_gcode = true if printer["gcode_macro START_PRINT"].is_printing_gcode|default(true)|lower == 'true' else false %}
{% if is_printing_gcode and layer_number < 2 %}
DEBUG_ECHO PREFIX="START_PA_TOWER" MSG="START: {start}, FACTOR: {factor}"
RATOS_ECHO MSG="Starting presssure advance tuning tower..."
TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START={start} FACTOR={factor}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro CHAMBER_FILTER_ON]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro CHAMBER_FILTER_OFF]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Deactivating chamber filter..."
_CHAMBER_FILTER_TURN_OFF
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro _CHAMBER_FILTER_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set chamber_filter_enable_at = printer["gcode_macro RatOS"].chamber_filter_enable_at|default('after_print_start')|lower %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_ON" MSG="at: {at}, chamber_filter_enable: {chamber_filter_enable}, chamber_filter_enable_at: {chamber_filter_enable_at}, chamber_filter_speed: {chamber_filter_speed}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if chamber_filter_enable_at == at %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON AT={at}
{% if chamber_filter_enable_at == "print_end" %}
_LED_CHAMBER_FILTER_ON
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_FILTER_OFF]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF" MSG="chamber_filter_enable: {chamber_filter_enable}, filter_disable_period: {filter_disable_period}, filter_disable_bed_temp: {filter_disable_bed_temp}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_period > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting {filter_disable_period} seconds before turning chamber filter off..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION={filter_disable_period}
{% endif %}
{% if filter_disable_bed_temp > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting for bed temp to cool down to {filter_disable_bed_temp}°C to turn filter off..."
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM=0 MAXIMUM={filter_disable_bed_temp}
_CHAMBER_FILTER_TURN_OFF
_LED_CHAMBER_FILTER_OFF
{% endif %}
{% endif %}
[delayed_gcode _CHAMBER_FILTER_OFF_TIMER]
gcode =
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF_TIMER" MSG="executed"
_CHAMBER_FILTER_TURN_OFF
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Chamber filter turned off!"
_LED_CHAMBER_FILTER_OFF
[gcode_macro _CHAMBER_FILTER_TURN_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_speed|default(0)|float %}
{% if at == "print_end" %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_disable_speed|default(0)|float %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION=0
SET_FAN_SPEED FAN=filter SPEED={chamber_filter_speed}
[gcode_macro _CHAMBER_FILTER_TURN_OFF]
gcode =
SET_FAN_SPEED FAN=filter SPEED=0
[gcode_macro _CHAMBER_FILTER_SANITY_CHECK]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_bed_temp > 0 and filter_disable_period > 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable, not both.")}
{% endif %}
{% if filter_disable_bed_temp == 0 and filter_disable_period == 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable.")}
{% endif %}
{% endif %}
[gcode_macro CHAMBER_HEATER_ON]
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(45)|int %}
_CHAMBER_HEATER_ON CHAMBER_TEMP={chamber_temp} IS_FROM_START_PRINT=False
[gcode_macro CHAMBER_HEATER_OFF]
gcode =
_CHAMBER_HEATER_OFF
[gcode_macro _CHAMBER_HEATER_ON]
variable_chamber_temp = 0
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set is_from_start_print = true if params.IS_FROM_START_PRINT|default(True)|lower == 'true' else false %}
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set chamber_heater_enable = true if printer["gcode_macro RatOS"].chamber_heater_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
{% set chamber_heater_preheating_temp = printer["gcode_macro RatOS"].chamber_heater_preheating_temp|default(150)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set chamber_heater_control_external_heater = true if printer["gcode_macro RatOS"].chamber_heater_control_external_heater|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_enable = true if printer["gcode_macro RatOS"].chamber_heater_air_circulation_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_fan_speed = printer["gcode_macro RatOS"].chamber_heater_air_circulation_fan_speed|default(0.35)|float %}
{% set chamber_heater_air_circulation_y_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_y_pos|default(0)|float %}
{% set chamber_heater_air_circulation_z_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_z_pos|default(100)|float %}
DEBUG_ECHO PREFIX="_CHAMBER_HEATER_ON" MSG="chamber_heater_enable: {chamber_heater_enable}, chamber_heater_preheating_temp: {chamber_heater_preheating_temp}, chamber_heater_heating_temp_offset: {chamber_heater_heating_temp_offset}, bed_temp: {bed_temp}, chamber_temp: {chamber_temp}, start_chamber_temp: {start_chamber_temp}"
{% if chamber_heater_enable and chamber_temp > 0 and chamber_heater_bed_temp > 0 %}
_LED_HEATING
RATOS_ECHO MSG="Preheating chamber to {(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}°C..."
{% set chamber_temp_sensor = "extruder" %}
{% if printer["dual_carriage"] is defined and default_toolhead == 1 %}
{% set chamber_temp_sensor = "extruder1" %}
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% set chamber_temp_sensor = "temperature_sensor chamber" %}
{% endif %}
{% set current_chamber_temp = printer['%s' % chamber_temp_sensor].temperature|int %}
{% set needs_heating = current_chamber_temp < (start_chamber_temp if start_chamber_temp > 0 else chamber_temp) %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_BEFORE_PREHEATING
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
{% if not is_from_start_print %}
MAYBE_HOME
{% endif %}
G0 Z{chamber_heater_air_circulation_z_pos} F{z_speed}
G0 Y{chamber_heater_air_circulation_y_pos} F{speed}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 1 else 0}
{% else %}
M106 S{(255 * chamber_heater_air_circulation_fan_speed)}
{% endif %}
{% else %}
{% if is_from_start_print %}
G0 Z{z} F{z_speed}
{% endif %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE={chamber_temp}
{% if needs_heating %}
M140 S{chamber_heater_bed_temp}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={chamber_heater_preheating_temp}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if needs_heating %}
_CHAMBER_HEATER_EXTRA_FAN_ON
{% endif %}
{% if needs_heating %}
TEMPERATURE_WAIT SENSOR="{chamber_temp_sensor}" MINIMUM={(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% endif %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED=0
_CHAMBER_FILTER_ON AT="before_print_start"
{% endif %}
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
G28 Z
{% endif %}
{% endif %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_AFTER_PREHEATING
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% if printer["heater_generic chamber_heater"] is defined %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined and chamber_heater_control_external_heater %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
_LED_SUCCESS
{% endif %}
[gcode_macro _CHAMBER_HEATER_OFF]
gcode =
RATOS_ECHO MSG="Deactivating chamber heater..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=0
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE=0
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
_CHAMBER_HEATER_EXTRA_FAN_OFF
[delayed_gcode _CHAMBER_HEATER_CONTROL]
initial_duration = 0.
gcode =
{% set chamber_temp = printer["gcode_macro _CHAMBER_HEATER_ON"].chamber_temp|default(0)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set current_chamber_temp = printer['temperature_sensor chamber'].temperature|int %}
{% if current_chamber_temp < chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if current_chamber_temp >= chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_ON]
gcode =
{% set chamber_heater_extra_fan_speed = printer["gcode_macro RatOS"].chamber_heater_extra_fan_speed|default(0.0)|float %}
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
{% if chamber_heater_extra_fan_speed > 0 %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED={chamber_heater_extra_fan_speed}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_OFF]
gcode =
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED=0
{% endif %}
[gcode_macro _USER_CHAMBER_HEATER_BEFORE_PREHEATING]
description = Will be executed before chamber preheating, only if heating is needed.
gcode =
[gcode_macro _USER_CHAMBER_HEATER_AFTER_PREHEATING]
description = Will be executed after chamber preheating, only if heating was needed.
gcode =
[gcode_macro _LED_START_PRINTING]
gcode =
_LED_ACTION
[gcode_macro _LED_START_PRINTING_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_PRINTING]
gcode =
_LED_ON TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_PAUSE]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_ON]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_OFF]
gcode =
_LED_STANDBY
[gcode_macro _LED_LOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_LOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_RUNOUT]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_CLOG]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_UNLOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_UNLOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_DEACTIVATE_TOOLHEAD]
gcode =
_LED_OFF TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_STANDBY]
gcode =
_LED_STANDBY TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_WAKEUP]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_MOTORS_OFF]
gcode =
_LED_STANDBY
_LED_VAOC_OFF
[gcode_macro _LED_INPUT_SHAPER_START]
gcode =
_LED_ACTION
[gcode_macro _LED_INPUT_SHAPER_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_START]
gcode =
_LED_ACTION
[gcode_macro _LED_BEACON_CALIBRATION_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_VAOC_ON]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=1.0 GREEN=1.0 BLUE=1.0
{% endif %}
[gcode_macro _LED_VAOC_OFF]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=0.0 GREEN=0.0 BLUE=0.0
{% endif %}
[gcode_macro _LED_ACTION]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_action %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SUCCESS]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_success %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_HEATING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_heating %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_COOLING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_cooling %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ERROR]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_error %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ON]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_on %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_OFF]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_off %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_STANDBY]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_standby %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
{% if toolhead >= 0 %}
{% if printer['neopixel nozzle_led_t%s' % toolhead] is defined %}
SET_LED LED={'nozzle_led_t%s' % toolhead} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% else %}
{% if printer['neopixel nozzle_led_t0'] is defined %}
SET_LED LED={'nozzle_led_t0'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% if printer['neopixel nozzle_led_t1'] is defined %}
SET_LED LED={'nozzle_led_t1'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% endif %}
_USER_LED_SET { rawparams }
[gcode_macro _USER_LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
[gcode_macro LOAD_FILAMENT]
description = Loads new filament. Note: be careful with PETG, make sure you inspect the tip of your filament before loading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% if filament_name == '' or filament_type == '' %}
{% set filament_name = 'unknown' %}
{% set filament_type = 'unknown' %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_LOAD_FILAMENT TEMP={temp} NAME={filament_name} TYPE={filament_type}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_LOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME={filament_name} TYPE={filament_type}
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _DEFAULT_LOAD_FILAMENT]
description = Load filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_LOAD_FILAMENT" MSG="TEMP={temp}"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=load_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
_LOAD_FILAMENT TOOLHEAD=0
RESTORE_GCODE_STATE NAME=load_state
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD=0
[gcode_macro _IDEX_LOAD_FILAMENT]
description = Load filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_LOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
_LOAD_FILAMENT TOOLHEAD={toolhead} TEMP={temp}
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into hotend.."
G92 E0
G0 E{extruder_gear_to_cooling_position_distance} F{extruder_load_speed}
G92 E0
M400
RATOS_ECHO MSG="Filament loaded into hotend."
[gcode_macro _LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set load_speed = printer["gcode_macro T%s" % toolhead].filament_load_speed|float * 60 %}
{% set filament_loading_nozzle_offset = printer["gcode_macro T%s" % toolhead].filament_loading_nozzle_offset|float %}
{% set cooling_position_to_nozzle_distance = printer["gcode_macro T%s" % toolhead].cooling_position_to_nozzle_distance|float %}
{% set purge_after_load = printer["gcode_macro T%s" % toolhead].purge_after_load|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into nozzle... Please wait!"
G92 E0
G0 E{cooling_position_to_nozzle_distance + filament_loading_nozzle_offset} F{load_speed}
G92 E0
G4 P1000
_PURGE_FILAMENT TOOLHEAD={toolhead} E={purge_after_load}
RATOS_ECHO MSG="Filament loaded into nozzle!"
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
{% set filament_grabbing_length = printer["gcode_macro T%s" % toolhead].filament_grabbing_length|float %}
{% set filament_grabbing_speed = printer["gcode_macro T%s" % toolhead].filament_grabbing_speed|float %}
{% set resume_after_insert = true if printer["gcode_macro T%s" % toolhead].resume_after_insert|default(true)|lower == 'true' else false %}
{% set enable_insert_detection = true if printer["gcode_macro T%s" % toolhead].enable_insert_detection|default(true)|lower == 'true' else false %}
{% set current_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% if enable_insert_detection %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="toolhead: {toolhead}, filament_grabbing_length: {filament_grabbing_length}, filament_grabbing_speed: {filament_grabbing_speed}, current_idex_mode: {current_idex_mode}"
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
FORCE_MOVE STEPPER={'extruder%s' % ('' if toolhead == 0 else toolhead)} DISTANCE={filament_grabbing_length} VELOCITY={filament_grabbing_speed}
M400
{% if printer.pause_resume.is_paused %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% if resume_after_insert %}
RESUME
{% endif %}
{% else %}
{% if not printer.virtual_sdcard.is_active %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
[gcode_macro _PURGE_BEFORE_UNLOAD]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set purge_before_unload = printer["gcode_macro T%s" % toolhead].purge_before_unload|float %}
DEBUG_ECHO PREFIX="_PURGE_BEFORE_UNLOAD" MSG="TOOLHEAD: {toolhead}"
{% if purge_before_unload > 0 %}
G92 E0
G0 E{purge_before_unload} F300
G92 E0
M400
{% endif %}
[gcode_macro _PURGE_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set e = params.E|int %}
{% set r = params.R|default(0)|int %}
DEBUG_ECHO PREFIX="_PURGE_FILAMENT" MSG="TOOLHEAD: {toolhead}, E: {e}"
{% if e > 0 %}
G92 E0
G0 E{e} F300
G92 E0
M400
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={0.4 if toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={0.4 if toolhead == 1 else 0}
{% else %}
M106 S{(255 * 0.4)}
{% endif %}
{% endif %}
G4 P3000
{% if r > 0 %}
G92 E0
G0 E-{r} F300
G92 E0
M400
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_PARKING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_PARKING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_LOADING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_LOADING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% if act_t == toolhead %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{loading_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CLEANING_MOVE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined and printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% set cleaning_position = loading_position %}
{% if loading_position == parking_position %}
{% if loading_position > 0 %}
{% set cleaning_position = loading_position - 30 %}
{% else %}
{% set cleaning_position = loading_position + 30 %}
{% endif %}
{% endif %}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _START_PRINT_BED_MESH]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
SET_MACRO_TRAVEL_SETTINGS
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set X=[params.X0|default(-1)|float, params.X1|default(-1)|float] %}
{% set Y=[params.Y0|default(-1)|float, params.Y1|default(-1)|float] %}
DEBUG_ECHO PREFIX="_START_PRINT_BED_MESH" MSG="idex_mode: {idex_mode}, X: {X}, Y: {Y}"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set X=[0, printable_x_max] %}
{% endif %}
{% set beacon_bed_mesh_scv = printer["gcode_macro RatOS"].beacon_bed_mesh_scv|default(25)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% if printer.configfile.settings.beacon is defined and not beacon_contact_bed_mesh %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={beacon_bed_mesh_scv}
{% endif %}
{% set default_profile = printer["gcode_macro RatOS"].bed_mesh_profile|default('ratos') %}
{% if printer["gcode_macro RatOS"].calibrate_bed_mesh|lower == 'true' %}
BED_MESH_CLEAR
{% if printer["gcode_macro RatOS"].adaptive_mesh|lower == 'true' %}
CALIBRATE_ADAPTIVE_MESH PROFILE={default_profile} X0={X[0]} X1={X[1]} Y0={Y[0]} Y1={Y[1]} T={params.T|int} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={idex_mode}
{% else %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% endif %}
BED_MESH_PROFILE LOAD={default_profile}
{% elif printer["gcode_macro RatOS"].bed_mesh_profile is defined %}
BED_MESH_CLEAR
BED_MESH_PROFILE LOAD={printer["gcode_macro RatOS"].bed_mesh_profile}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
[gcode_macro CALIBRATE_ADAPTIVE_MESH]
gcode =
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set default_profile = params.PROFILE %}
{% set x0 = params.X0|default(-1)|float %}
{% set y0 = params.Y0|default(-1)|float %}
{% set x1 = params.X1|default(-1)|float %}
{% set y1 = params.Y1|default(-1)|float %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Recieved coordinates X0={x0} Y0={y0} X1={x1} Y1={y1}"
{% if x0 >= x1 or y0 >= y1 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Invalid coordinates received. Please check your slicer settings. Falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float %}
{% set mesh_x0 = [[x0, max_x]|min, min_x]|max %}
{% set mesh_y0 = [[y0, max_y]|min, min_y]|max %}
{% set mesh_x1 = [[x1, max_x]|min, min_x]|max %}
{% set mesh_y1 = [[y1, max_y]|min, min_y]|max %}
{% if mesh_x0 == min_x and mesh_y0 == min_y and mesh_x1 == max_x and mesh_y1 == max_y %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Print is using the full bed, falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
DEPLOY_PROBE
{% endif %}
{% set probe_count_x = mesh_config.probe_count.split(",")[0]|int %}
{% if mesh_config.probe_count.split(",")|length == 2 %}
{% set probe_count_y = mesh_config.probe_count.split(",")[1]|int %}
{% else %}
{% set probe_count_y = mesh_config.probe_count.split(",")[0]|int %}
{% endif %}
{% set probe_x_step = (max_x - min_x) / probe_count_x %}
{% set probe_y_step = (max_y - min_y) / probe_count_y %}
{% set mesh_count_x = ([(mesh_x1 - mesh_x0) / probe_x_step, 3]|max)|int %}
{% set mesh_count_y = ([(mesh_y1 - mesh_y0) / probe_y_step, 3]|max)|int %}
{% set min_mesh_count = [mesh_count_x, mesh_count_y]|min %}
{% set max_mesh_count = [mesh_count_x, mesh_count_y]|max %}
{% set algorithm = mesh_config.algorithm %}
{% if algorithm|lower == 'lagrange' and max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="cannot exceed a probe_count of 6 when using lagrange interpolation. Falling back to bicubic interpolation."
{% set algorithm = 'bicubic' %}
{% endif %}
{% if algorithm|lower == 'bicubic' and min_mesh_count < 4 %}
{% if max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="invalid probe_count option when using bicubic interpolation. Combination of 3 points on one axis with more than 6 on another is not permitted. Forcing minimum mesh count to be 4."
{% set min_mesh_count = 4 %}
{% else %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="bicubic interpolation with a probe_count of less than 4 points detected. Forcing lagrange interpolation."
{% set algorithm = 'lagrange' %}
{% endif %}
{% endif %}
{% set mesh_count_x = ([min_mesh_count, mesh_count_x]|max)|int %}
{% set mesh_count_x = ([max_mesh_count, mesh_count_x]|min)|int %}
{% set mesh_count_y = ([min_mesh_count, mesh_count_y]|max)|int %}
{% set mesh_count_y = ([max_mesh_count, mesh_count_y]|min)|int %}
{% set should_prime = printer["gcode_macro RatOS"].nozzle_priming == 'primeblob' %}
{% if printer["dual_carriage"] is not defined %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% else %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% endif %}
{% if printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 != 0 and probe_first %}
{% set probe_first = false %}
{% elif printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 == 0 and not probe_first %}
{% set probe_first = true %}
{% endif %}
{% if should_prime and probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="mesh coordinates X0={mesh_x0} Y0={mesh_y0} X1={mesh_x1} Y1={mesh_y1}"
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% if should_prime and not probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
STOW_PROBE
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M84]
rename_existing = M84.1
gcode =
M84.1
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
{% if printer["dual_carriage"] is defined %}
_SET_TOOLHEAD_OFFSET T={printer["gcode_macro RatOS"].default_toolhead|int} MOVE=0
SET_GCODE_VARIABLE MACRO=SET_PRESSURE_ADVANCE VARIABLE=snyc_toolheads VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro _VAOC"] is defined %}
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started VALUE=False
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started_at_temp VALUE=False
{% endif %}
SET_GCODE_OFFSET X=0 Y=0 Z=0 MOVE=0
_IDEX_SINGLE INIT=1
{% endif %}
SET_SKEW CLEAR=1
_LED_MOTORS_OFF
[gcode_macro M104]
rename_existing = M104.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
DEBUG_ECHO PREFIX="M104" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set temperature_offset_t0 = printer["gcode_macro T0"].temperature_offset|default(0)|int %}
{% set temperature_offset_t1 = printer["gcode_macro T1"].temperature_offset|default(0)|int %}
{% set s0 = [s + temperature_offset_t0, 0]|max %}
{% set s1 = [s + temperature_offset_t1, 0]|max %}
{% if temperature_offset_t0 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t0}°C added to toolhead T0."
{% endif %}
{% if temperature_offset_t1 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t1}°C added to toolhead T1."
{% endif %}
{% else %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
M104.1 S{s0} T0
M104.1 S{s1} T1
{% else %}
M104.1 S{s} T{t}
{% endif %}
{% endif %}
[gcode_macro M109]
rename_existing = M109.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
DEBUG_ECHO PREFIX="M109" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M109" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
M109.1 S{s} T{t}
{% endif %}
[gcode_macro SET_HEATER_TEMPERATURE]
rename_existing = SET_HEATER_TEMPERATURE_BASE
gcode =
{% set heater = params.HEATER|default("") %}
{% set target = params.TARGET|default(0)|int %}
DEBUG_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="heater: {heater}, target: {target}"
{% if heater|lower == "extruder" or heater|lower == "extruder1" %}
{% set t = 0 if heater|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and target > 0 %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set target = [target + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
SET_HEATER_TEMPERATURE_BASE HEATER="{heater}" TARGET={target}
[gcode_macro TEMPERATURE_WAIT]
rename_existing = TEMPERATURE_WAIT_BASE
gcode =
{% set sensor = params.SENSOR|default("") %}
{% set minimum = params.MINIMUM|default(-1)|int %}
{% set maximum = params.MAXIMUM|default(-1)|int %}
DEBUG_ECHO PREFIX="TEMPERATURE_WAIT" MSG="sensor: {sensor}, minimum: {minimum}, maximum: {maximum}"
{% if sensor|lower == "extruder" or sensor|lower == "extruder1" %}
{% set t = 0 if sensor|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and (minimum > 0 or maximum > 0) %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% if minimum > -1 %}
{% set minimum = [minimum + temperature_offset, 0]|max %}
{% endif %}
{% if maximum > -1 %}
{% set maximum = [maximum + temperature_offset, 0]|max %}
{% endif %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% if minimum > -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum} MAXIMUM={maximum}
{% elif minimum > -1 and maximum == -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum}
{% elif minimum == -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MAXIMUM={maximum}
{% endif %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature for toolhead T{t} reached."
[gcode_macro SET_GCODE_OFFSET]
rename_existing = SET_GCODE_OFFSET_ORG
gcode =
SET_GCODE_OFFSET_ORG { rawparams }
{% if printer.configfile.settings.beacon is defined and (params.Z_ADJUST is defined or params.Z is defined) %}
_BEACON_APPLY_RUNTIME_MULTIPLIER
{% endif %}
[gcode_macro SDCARD_PRINT_FILE]
rename_existing = SDCARD_PRINT_FILE_BASE
gcode =
{% if printer["ratos"] is defined %}
PROCESS_GCODE_FILE { rawparams }
{% else %}
SDCARD_PRINT_FILE_BASE { rawparams }
{% endif %}
[gcode_macro SKEW_PROFILE]
rename_existing = SKEW_PROFILE_BASE
variable_loaded_profile = ""
gcode =
{% if params.LOAD is defined %}
{% if printer.configfile.settings["skew_correction %s" % params.LOAD] is defined %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='"{params.LOAD}"'
{% endif %}
{% endif %}
SKEW_PROFILE_BASE { rawparams }
[gcode_macro SET_SKEW]
rename_existing = SET_SKEW_BASE
gcode =
{% if params.CLEAR is defined %}
{% if params.CLEAR|default(0)|int == 1 %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='""'
{% endif %}
{% endif %}
SET_SKEW_BASE { rawparams }
[gcode_macro SET_VELOCITY_LIMIT]
rename_existing = SET_VELOCITY_LIMIT_BASE
gcode =
{% if params.ACCEL_TO_DECEL is defined %}
{% if params.ACCEL is defined %}
{% set accel = params.ACCEL|float %}
{% else %}
{% set accel = printer.toolhead.max_accel|float %}
{% endif %}
{% if params.VELOCITY is defined %}
{% set velocity = params.VELOCITY|float %}
{% else %}
{% set velocity = printer.toolhead.max_velocity|float %}
{% endif %}
{% if params.SQUARE_CORNER_VELOCITY is defined %}
{% set scv = params.SQUARE_CORNER_VELOCITY|float %}
{% else %}
{% set scv = printer.toolhead.square_corner_velocity|float %}
{% endif %}
{% set mcr = params.ACCEL_TO_DECEL|float / accel %}
DEBUG_ECHO PREFIX="SET_VELOCITY_LIMIT" MSG="ACCEL={accel}, VELOCITY={velocity}, SQUARE_CORNER_VELOCITY={scv}, MINIMUM_CRUISE_RATIO={mcr}"
SET_VELOCITY_LIMIT_BASE ACCEL={accel} VELOCITY={velocity} SQUARE_CORNER_VELOCITY={scv} MINIMUM_CRUISE_RATIO={1-mcr}
{% else %}
SET_VELOCITY_LIMIT_BASE { rawparams }
{% endif %}
[gcode_macro _START_PRINT_PARK]
gcode =
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_x = printer["gcode_macro RatOS"].start_print_park_x %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% endif %}
{% if printer["dual_carriage"] is defined and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
{% if printer["gcode_macro RatOS"].start_print_park_x is defined and printer["gcode_macro RatOS"].start_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="start_print_park_x is ignored for IDEX printers"
{% endif %}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={start_print_park_in} X={start_print_park_x}
G0 Z{z} F{z_speed}
[gcode_macro _END_PRINT_PARK]
gcode =
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro RatOS"].end_print_park_x is defined and printer["gcode_macro RatOS"].end_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="end_print_park_x is ignored for IDEX printers"
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={printer["gcode_macro RatOS"].end_print_park_in} X={printer["gcode_macro RatOS"].end_print_park_x}
[gcode_macro _PARK]
gcode =
{% set x = params.X %}
{% set location = params.LOCATION|default('back')|lower %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set nozzle_priming = printer["gcode_macro RatOS"].nozzle_priming|lower %}
CACHE_TOOLHEAD_SETTINGS KEY="park"
SET_MACRO_TRAVEL_SETTINGS
{% if x != '' %}
{% if x|float >= printer.toolhead.axis_minimum.x + 5 and x|float <= printable_x_max - 5 %}
{% set park_x = x|float %}
{% else %}
{action_respond_info('The requested X co-ordinate is outside the defined axis bounds - using defaults')}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% else %}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% set park_y = printable_y_max - 15 %}
{% if location == 'front' %}
{% set park_y = printer.toolhead.axis_minimum.y + 5 %}
{% elif location == 'center' %}
{% set park_y = printable_y_max / 2 %}
{% elif location == 'primeblob' and printer["dual_carriage"] is defined %}
{% set park_y = printable_y_max - 15 %}
{% endif %}
{% if location == 'primeblob' and printer["dual_carriage"] is not defined %}
{% if (nozzle_priming == 'primeblob' or nozzle_priming == 'primeline') %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set park_x = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set park_x = printable_x_max - 5 %}
{% else %}
{% set park_x = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set park_y = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set park_y = printable_y_max - 5 %}
{% else %}
{% set park_y = nozzle_prime_start_y|float %}
{% endif %}
{% endif %}
{% endif %}
G90
{% if printer["dual_carriage"] is not defined %}
G0 X{park_x} Y{park_y} F{speed}
{% else %}
G0 Y{park_y} F{speed}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="park"
[gcode_macro SAVE_PROBE_RESULT]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
{% set last_z_offset = 9999.9 %}
{% if printer.configfile.settings.beacon is defined %}
{% set current_z = printer.toolhead.position.z|float %}
{% if beacon_contact_prime_probing %}
{% set last_z_offset = printer.beacon.last_z_result %}
{% else %}
{% set last_z_offset = printer.beacon.last_sample.dist - current_z %}
{% endif %}
{% elif printer.configfile.settings.bltouch is defined %}
{% set config_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% elif printer.configfile.settings.probe is defined %}
{% set config_offset = printer.configfile.settings.probe.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Saving offset adjustment of {last_z_offset} in {params.VARIABLE|default('last_z_offset')}"
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE={params.VARIABLE|default('last_z_offset')} VALUE={last_z_offset}
[gcode_macro PROBE_FOR_PRIMING]
gcode =
{% set probe_for_priming_disable_mesh_constraints = true if printer["gcode_macro RatOS"].probe_for_priming_disable_mesh_constraints|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower != 'false' %}
SAVE_GCODE_STATE NAME=probe_for_priming_state
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the prime location.."
CACHE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
SET_MACRO_TRAVEL_SETTINGS
{% set t = params.TOOLHEAD|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% if idex_mode == '' %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% if t == 0 %}
{% set x_start = 5 %}
{% else %}
{% set x_start = printable_x_max - 5 %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% endif %}
{% endif %}
{% set z = printer.configfile.settings.bed_mesh.horizontal_move_z|float %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% if printer.configfile.settings.bltouch is defined %}
{% set x_offset = printer.configfile.settings.bltouch.x_offset|float %}
{% set y_offset = printer.configfile.settings.bltouch.y_offset|float %}
{% set z_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% elif printer.configfile.settings.probe is defined %}
{% set x_offset = printer.configfile.settings.probe.x_offset|float %}
{% set y_offset = printer.configfile.settings.probe.y_offset|float %}
{% set z_offset = printer.configfile.settings.probe.z_offset|float %}
{% elif printer.configfile.settings.beacon is defined %}
{% set x_offset = printer.configfile.settings.beacon.x_offset|float %}
{% set y_offset = printer.configfile.settings.beacon.y_offset|float %}
{% set z_offset = printer.configfile.settings.beacon.trigger_distance|float %}
{% else %}
{ action_raise_error("No probe, beacon or bltouch section found. Adaptive priming only works with a [probe], [beacon] or [bltouch] section defined.") }
{% endif %}
{% if z < z_offset %}
{ action_raise_error("Horizontal move Z ({z}) is below your probe's Z offset ({z_offset}). Please adjust your horizontal_move_z setting in [bed_mesh] to be above {z}.") }
{% endif %}
{% if not probe_for_priming_disable_mesh_constraints %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float - x_offset %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float - y_offset %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float - x_offset %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float - y_offset %}
{% set x_start = [[x_start, max_x]|min, min_x]|max %}
{% set y_start = [[y_start, max_y]|min, min_y]|max %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the start of the prime location at {x_start}, {y_start}"
G90
M83
G0 Z{z} F{z_speed}
G1 X{x_start} Y{y_start} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result
{% endif %}
{% if idex_mode == '' %}
{% set x_end = x_start %}
{% set y_end = y_start + 45 %}
{% else %}
{% if t==1 %}
{% set x_end = x_start - 45 %}
{% else %}
{% set x_end = x_start + 45 %}
{% endif %}
{% set y_end = y_start %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the end of the prime location at {x_end}, {y_end}"
G1 X{x_end} Y{y_end} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result
{% endif %}
RESTORE_GCODE_STATE NAME=probe_for_priming_state
RESTORE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
{% endif %}
[gcode_macro RESET_PRIME_PROBE_STATE]
gcode =
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result VALUE=None
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result_t1 VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result_t1 VALUE=None
{% endif %}
[gcode_macro PROBE_CURRENT_POSITION]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
SAVE_GCODE_STATE NAME=probe_current_position_state
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
ASSERT_PROBE_DEPLOYED
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_prime_probing %}
PROBE PROBE_METHOD=contact SAMPLES=1
{% else %}
PROBE
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
BEACON_QUERY
{% else %}
RESTORE_GCODE_STATE NAME=probe_current_position_state MOVE=1 MOVE_SPEED={printer["gcode_macro RatOS"].macro_z_speed|float}
{% endif %}
[gcode_macro PRIME_BLOB]
description = Prints a primeblob, used internally, if configured, as part of the START_PRINT macro.
variable_x_offset = 5
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="prime_blob"
SET_MACRO_TRAVEL_SETTINGS
RATOS_ECHO PREFIX="Priming" MSG="Priming nozzle with prime blob.."
{% set current_toolhead = 0 %}
{% set target_idex_mode = '' %}
{% set extruder = 'extruder' %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE is defined %}
{% set target_idex_mode = params.IDEX_MODE|default('')|lower %}
{% else %}
{ action_raise_error("IDEX_MODE parameter not found for PRIME_BLOB macro. This is likely a bug.") }
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Priming in IDEX {target_idex_mode} mode.."
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set current_toolhead = 1 if current_idex_mode=='primary' else 0 %}
{% set extruder = 'extruder1' if current_toolhead == 1 else 'extruder' %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
SAVE_GCODE_STATE NAME=prime_blob_state
{% endif %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set fan_speed = printer["gcode_macro RatOS"].nozzle_prime_bridge_fan|float %}
{% set nozzle_diameter = printer.configfile.settings[extruder].nozzle_diameter|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set has_start_offset_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) != 9999.9 %}
{% if printer["dual_carriage"] is defined %}
{% set has_start_offset_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) != 9999.9 %}
{% endif %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_z_height = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set nozzle_prime_direction = printer["gcode_macro RatOS"].nozzle_prime_direction|lower %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% if target_idex_mode == '' %}
{% set x_factor = 0 %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% set y_factor = 1 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% set y_factor = -1 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% if nozzle_prime_start_y|float < printable_y_max / 2 %}
{% set y_factor = 1 %}
{% else %}
{% set y_factor = -1 %}
{% endif %}
{% endif %}
{% if nozzle_prime_direction == 'forwards' %}
{% set y_factor = 1 %}
{% elif nozzle_prime_direction == 'backwards' %}
{% set y_factor = -1 %}
{% endif %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% else %}
{% set z = start_print_park_z_height %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% set y_factor = 0 %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set x_start = center_x / 2 + 5 %}
{% set x_factor = 1 %}
{% else %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% if current_toolhead == 0 %}
{% set x_start = 55 %}
{% set x_factor = -1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 55 %}
{% set x_factor = 1 %}
{% endif %}
{% else %}
{% if current_toolhead == 0 %}
{% set x_start = 5 %}
{% set x_factor = 1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 5 %}
{% set x_factor = -1 %}
{% endif %}
{% endif %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_x_max - 5 %}
{% endif %}
{% set z = 10 %}
{% endif %}
{% set start_z_offset = 0 %}
{% set end_z_offset = 0 %}
{% if has_start_offset_t0 %}
{% set start_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) %}
{% set end_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_end_result|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t0) ) }
{% endif %}
{% if end_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t0) ) }
{% endif %}
{% set start_z_offset = start_z_probe_result_t0 %}
{% set end_z_offset = end_z_probe_result_t0 %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if current_toolhead == 1 or both_toolheads or target_idex_mode == "copy" or target_idex_mode == "mirror" %}
{% if has_start_offset_t1 %}
{% set start_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) %}
{% set end_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_end_result_t1|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t1) ) }
{% endif %}
{% if end_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t1) ) }
{% endif %}
{% set start_z_offset = [start_z_offset, start_z_probe_result_t1]|max %}
{% set end_z_offset = [end_z_offset, start_z_probe_result_t1]|max %}
{% endif %}
{% endif %}
{% if target_idex_mode != 'copy' and target_idex_mode != 'mirror' %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% set original_start_z_offset = start_z_offset %}
{% set original_end_z_offset = end_z_offset %}
{% set start_z_offset = original_end_z_offset %}
{% set end_z_offset = original_start_z_offset %}
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={current_toolhead}
{% endif %}
DEBUG_ECHO PREFIX="PRIME_BLOB" MSG="x_start: {x_start}, y_start: {y_start}, x_factor: {x_factor}, y_factor: {y_factor}, z: {z}, start_z_offset: {start_z_offset}, end_z_offset: {end_z_offset}"
G90
M83
RATOS_ECHO PREFIX="Priming" MSG="Lifting Z to {z}.."
G0 Z{z} F{z_speed}
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% if start_print_park_in != 'primeblob' %}
G1 X{x_start} F{speed}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% endif %}
{% else %}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% if target_idex_mode=="copy" or target_idex_mode=="mirror" %}
RATOS_ECHO PREFIX="Priming" MSG="Mirroring move to {x_start}, {y_start} along the edge of the print area.."
_IDEX_MIRROR PRIMING=1
{% else %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% endif %}
G1 X{x_start} F{speed}
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Starting prime blob.."
G1 Z{0.5 + start_z_offset} F{z_speed}
G1 Y{y_start} F{speed}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
M106 S{fan_speed}
G1 Z5 F100 E5
G92 E0
RATOS_ECHO PREFIX="Priming" MSG="Bridging with {((fan_speed/255) * 100)|int}% fan speed.."
G1 F3000 X{x_start + (15 * x_factor)} Y{y_start + (15 * y_factor)} E{1 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (20 * x_factor)} Y{y_start + (20 * y_factor)} Z{3.8 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (34 * x_factor)} Y{y_start + (34 * y_factor)} Z{2.6 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (38 * x_factor)} Y{y_start + (38 * y_factor)} Z{1.4 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (42 * x_factor)} Y{y_start + (42 * y_factor)} Z{0.2 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
M106 S0
G1 F3000 X{x_start + (46 * x_factor)} Y{y_start + (46 * y_factor)} Z{0.2 + end_z_offset} E0.6
G1 F{speed} X{x_start + (50 * x_factor)} Y{y_start + (50 * y_factor)}
{% if target_idex_mode == "copy" or target_idex_mode == "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if target_idex_mode == "copy" %}
{% if first_y >= 0 %}
_IDEX_COPY DANCE=0 Y={first_y}
{% else %}
_IDEX_COPY DANCE=0 Y={params.Y1}
{% endif %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
RESTORE_GCODE_STATE NAME=prime_blob_state
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="prime_blob"
G92 E0
[gcode_macro UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% set temp = params.TEMP|default(220)|int %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_UNLOAD_FILAMENT TEMP={temp} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _LEGACY_UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set unload_speed = 5 * 60 %}
{% set unload_length = printer["gcode_macro RatOS"].filament_unload_length|float %}
M117 Unloading filament...
G0 E10 F300
G0 E-5 F3600
G4 P3000
G0 E5 F6000
G0 E-15 F6000
G0 E-{unload_length} F{unload_speed}
_CLEANING_MOVE TOOLHEAD={toolhead}
M117 Filament unloaded!
RESPOND MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _DEFAULT_UNLOAD_FILAMENT]
description = Unload filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_UNLOAD_FILAMENT" MSG="TEMP: {temp}"
_LED_UNLOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=unload_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD=0 NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TOOLHEAD=0
{% endif %}
RESTORE_GCODE_STATE NAME=unload_state
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD=0
[gcode_macro _IDEX_UNLOAD_FILAMENT]
description = Unload filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_UNLOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead}
{% endif %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Unloading filament from nozzle to cooling zone... Please wait!"
_PURGE_BEFORE_UNLOAD TOOLHEAD={toolhead}
{% if printer["gcode_macro _UNLOAD_WITHOUT_TIP_FORMING"] is defined %}
_UNLOAD_WITHOUT_TIP_FORMING TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_UNLOAD_WITH_TIP_FORMING NAME='{filament_name}' TYPE='{filament_type}'
{% endif %}
G4 P3000
[gcode_macro _UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
{% set tooolhead_sensor_to_extruder_gear_distance = printer["gcode_macro T%s" % toolhead].tooolhead_sensor_to_extruder_gear_distance|float %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER" MSG="TOOLHEAD: {toolhead}"
G0 E-{extruder_gear_to_cooling_position_distance + tooolhead_sensor_to_extruder_gear_distance + 50} F{extruder_load_speed}
RATOS_ECHO MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _UNLOAD_WITH_TIP_FORMING]
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% if filament_name != '' and filament_type != '' %}
_UNLOAD_KNOWN_FILAMENT NAME={filament_name} TYPE={filament_type}
{% else %}
_UNLOAD_UNKNOWN_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _UNLOAD_KNOWN_FILAMENT]
description = User overrideable tip forming macro if slicer filament profiles are known
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
RATOS_ECHO PREFIX="FILAMENT TYPE" MSG='{filament_type}'
RATOS_ECHO PREFIX="FILAMENT PROFILE" MSG='{filament_name}'
{% if filament_name == "Prusament PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% elif filament_name == "Nobufil PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% else %}
RATOS_ECHO PREFIX="_UNLOAD_KNOWN_FILAMENT" MSG="Filament profile not found!"
_UNLOAD_UNKNOWN_FILAMENT
{% endif %}
[gcode_macro _UNLOAD_UNKNOWN_FILAMENT]
description = User overrideable standard tip forming macro
gcode =
DEBUG_ECHO PREFIX="_UNLOAD_UNKNOWN_FILAMENT" MSG="Using standard tip forming macro!"
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
[gcode_macro _TIP_FORMING]
gcode =
{% set cooling_moves = params.COOLING_MOVES|default(4)|int %}
{% set cooling_move_length = params.COOLING_MOVE_LENGTH|default(10)|float %}
{% set start_cooling_speed = params.START_COOLING_SPEED|default(10)|float * 60 %}
{% set end_cooling_speed = params.END_COOLING_SPEED|default(50)|float * 60 %}
{% if cooling_moves == 0 %}
{% set cooling_move_length = 0 %}
{% endif %}
{% set dip = true if params.DIP|default(false)|lower == "true" else false %}
{% set dip_length = params.DIP_LENGTH|default(22)|float %}
{% set dip_speed = params.DIP_SPEED|default(30)|float * 60 %}
{% set dip_retract_speed = params.DIP_RETRACT_SPEED|default(70)|float * 60 %}
{% set retract_length = params.RETRACT_LENGTH|default(18)|float %}
{% set start_retract_speed = params.START_RETRACT_SPEED|default(120)|float * 60 %}
{% set end_retract_speed = params.END_RETRACT_SPEED|default(20)|float * 60 %}
DEBUG_ECHO PREFIX="_TIP_FORMING" MSG="cooling_moves: {cooling_moves}, cooling_move_length: {cooling_move_length}, start_cooling_speed: {start_cooling_speed}, end_cooling_speed: {end_cooling_speed}, dip: {dip}, dip_length: {dip_length}, dip_speed: {dip_speed}, dip_retract_speed: {dip_retract_speed}, retract_length: {retract_length}, start_retract_speed: {start_retract_speed}, end_retract_speed: {end_retract_speed}"
M220 S100
G92 E0
{% set retract = retract_length + cooling_move_length / 2 - 15 %}
G1 E-15 F{start_retract_speed}
G1 E-{0.7 * retract} F{1.0 * end_retract_speed}
G1 E-{0.2 * retract} F{0.5 * end_retract_speed}
G1 E-{0.1 * retract} F{0.3 * end_retract_speed}
G92 E0
{% if cooling_moves > 0 %}
{% set i = (end_cooling_speed - start_cooling_speed) / (2 * cooling_moves - 1) %}
{% for m in range(cooling_moves) %}
G1 E{cooling_move_length} F{(start_cooling_speed + i * m * 2)}
G1 E-{cooling_move_length} F{(start_cooling_speed + i * (m * 2 + 1))}
{% endfor %}
{% endif %}
G92 E0
{% if dip %}
G1 E{dip_length} F{dip_speed}
G4 P100
G1 E-{dip_length} F{dip_retract_speed}
{% endif %}
G92 E0
M400
[gcode_macro _ON_FILAMENT_SENSOR_BUTTON_PRESSED]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_SENSOR_BUTTON_PRESSED" MSG="TOOLHEAD: {toolhead}"
{% if not printer.virtual_sdcard.is_active %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_FILAMENT_END]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set clogged = true if params.CLOGGED|default(false)|lower == 'true' else false %}
{% set unload_after_runout = printer["gcode_macro T%s" % toolhead].unload_after_runout|float %}
{% if clogged %}
_LED_FILAMENT_CLOG TOOLHEAD={toolhead}
{% else %}
_LED_FILAMENT_RUNOUT TOOLHEAD={toolhead}
{% endif %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_END" MSG="TOOLHEAD: {toolhead}"
{% if printer.virtual_sdcard.is_active %}
{% if not printer.pause_resume.is_paused %}
PAUSE RUNOUT=True
{% endif %}
{% if not clogged and unload_after_runout %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% if not clogged and printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true'%}
_JOIN_SPOOL TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M600]
description = Executes a color change by pausing the printer an unloading the filament.
gcode =
PAUSE
UNLOAD_FILAMENT
RATOS_ECHO MSG="Please load new filament and resume"
[gcode_macro COLD_PULL]
description = Automated hotend cold pull.
gcode =
{% set extrusion_temp = params.EXTRUSION_TEMP|default(220)|int %}
{% set cold_pull_temp = params.COLD_PULL_TEMP|default(80)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% if printer["dual_carriage"] is not defined %}
{% set toolhead = 0 %}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead != 0 and toolhead != 1 %}
{action_raise_error("Please select toolhead! 0 = left, 1 = right toolhead")}
{% endif %}
{% endif %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
SAVE_GCODE_STATE NAME=cold_pull_state
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
RATOS_ECHO MSG="Heating T{toolhead} to {extrusion_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={extrusion_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={extrusion_temp} MAXIMUM={extrusion_temp + 2}
G4 P3000
RATOS_ECHO MSG="extruding..."
G92 E0
G1 E30 F300
G92 E0
RATOS_ECHO MSG="Heating T{toolhead} to {cold_pull_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={cold_pull_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={cold_pull_temp} MAXIMUM={cold_pull_temp + 2}
G4 P10000
RATOS_ECHO MSG="cold pull..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-40 VELOCITY=5 ACCEL=100
RATOS_ECHO MSG="eject filament..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-200 VELOCITY=20 ACCEL=500
RATOS_ECHO MSG="cooling down extruder..."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET=0
RESTORE_GCODE_STATE NAME=cold_pull_state
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
CONSOLE_ECHO TITLE="Cold pull finished!" MSG="Please remove the filament from the PTFE tube and cut the end off. Do NOT try to load it again." TYPE="warning"
[gcode_macro _USER_START_PRINT_BEFORE_HOMING]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_BED]
gcode =
[gcode_macro _USER_START_PRINT_BED_MESH]
gcode =
[gcode_macro _USER_START_PRINT_PARK]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
[gcode_macro _USER_START_PRINT_HEAT_CHAMBER]
description = Uses the extruder sensor to wait for chamber temp. Override the _START_PRINT_HEAT_CHAMBER macro to implement heated chamber handling.
gcode =
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
[gcode_macro _USER_END_PRINT_BEFORE_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_AFTER_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_PARK]
gcode =
[gcode_macro _USER_END_PRINT_FINISHED]
description = User hook for when the print is finished after gcode state has been restored.
gcode =
[gcode_macro _USER_START_PRINT]
gcode =
[gcode_macro _USER_END_START_PRINT]
gcode =
[gcode_macro _USER_START_FEATURE]
gcode =
[gcode_macro _USER_END_FEATURE]
gcode =
[gcode_macro ECHO_T_VARS]
description = Echo Toolhead variables to the console.
gcode =
{% set t = params.T|default(0) %}
RATOS_ECHO MSG="T{t} Variables"
{% for var, value in printer["gcode_macro T%s" % t].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[gcode_macro ECHO_RATOS_VARS]
description = Echo RatOS variables to the console.
gcode =
{% for var, value in printer["gcode_macro RatOS"].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[delayed_gcode RATOS_INIT]
initial_duration = 0.1
gcode =
_LED_STANDBY
CALCULATE_PRINTABLE_AREA
INITIAL_FRONTEND_UPDATE
_CHAMBER_FILTER_SANITY_CHECK
[delayed_gcode RATOS_LOGO]
initial_duration = 2
gcode =
HELLO_RATOS
[gcode_macro INITIAL_FRONTEND_UPDATE]
gcode =
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_error = printer["gcode_macro RatOS"].status_color_error|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_unknown}"'
{% endif %}
{% set t0_sensor = "undefined" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].filament_detected|lower == "true" %}
{% set t0_sensor = "detected" %}
{% else %}
{% set t0_sensor = "empty" %}
{% endif %}
{% else %}
{% set t0_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set t1_sensor = "undefined" %}
{% if printer["dual_carriage"] is defined and printer["filament_switch_sensor toolhead_filament_sensor_t1"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].filament_detected|lower == "true" %}
{% set t1_sensor = "detected" %}
{% else %}
{% set t1_sensor = "empty" %}
{% endif %}
{% else %}
{% set t1_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set svv = printer.save_variables.variables %}
{% if svv.t0_filament is defined and printer["gcode_macro T0"] is defined %}
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
{% if t0_sensor != "empty" %}
{% set t0_filament_type = svv.t0_filament[0]|default('')|string %}
{% set t0_filament_name = svv.t0_filament[1]|default('')|string %}
{% set t0_filament_temp = svv.t0_filament[2]|default(0)|float %}
{% if t0_filament_name != '' and t0_filament_type != '' and t0_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{t0_filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{t0_filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={t0_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
{% if svv.t1_filament is defined and printer["gcode_macro T1"] is defined %}
{% if printer["gcode_macro T1"].filament_name is defined and printer["gcode_macro T1"].filament_type is defined and printer["gcode_macro T1"].filament_temp is defined %}
{% if t1_sensor != "empty" %}
{% set t1_filament_type = svv.t1_filament[0]|default('')|string %}
{% set t1_filament_name = svv.t1_filament[1]|default('')|string %}
{% set t1_filament_temp = svv.t1_filament[2]|default(0)|float %}
{% if t1_filament_name != '' and t1_filament_type != '' and t1_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='"{t1_filament_name}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='"{t1_filament_type}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE={t1_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t1_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro CALCULATE_PRINTABLE_AREA]
gcode =
{% set bed_margin_x = printer["gcode_macro RatOS"].bed_margin_x %}
{% set bed_margin_y = printer["gcode_macro RatOS"].bed_margin_y %}
{% set tool = 0 if printer["gcode_macro T0"] is not defined or printer["gcode_macro T0"].active else 1 %}
{% set max_x = printer.toolhead.axis_maximum.x if printer["dual_carriage"] is defined and tool == 0 else printer.toolhead.axis_maximum.x - bed_margin_x[1] %}
{% if printer["dual_carriage"] is defined %}
{% set max_x = printer.toolhead.axis_maximum.x %}
{% endif %}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="printer.toolhead.axis_maximum.x {printer.toolhead.axis_maximum.x}"
{% set max_y = printer.toolhead.axis_maximum.y - bed_margin_y[1]%}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_x_max VALUE={max_x}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_y_max VALUE={max_y}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="Printable area calculated: X: 0,{max_x} Y: 0,{max_y}"
[gcode_macro CACHE_TOOLHEAD_SETTINGS]
variable_cache = {"global": {"accel": 1000, "ratio": 0.5, "speed": 50, "scv": 5}}
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set dummy = cache.__setitem__(key, {"accel": printer.toolhead.max_accel, "ratio": printer.toolhead.minimum_cruise_ratio, "speed": printer.toolhead.max_velocity, "scv": printer.toolhead.square_corner_velocity}) %}
SET_GCODE_VARIABLE MACRO=CACHE_TOOLHEAD_SETTINGS VARIABLE=cache VALUE="{cache | pprint | replace("\n", "") | replace("\"", "\\\"")}"
DEBUG_ECHO PREFIX="CACHE_TOOLHEAD_SETTINGS" MSG="Toolhead settings cached for {key}. {printer.toolhead.max_accel} accel, {printer.toolhead.minimum_cruise_ratio} ratio, {printer.toolhead.max_velocity} velocity, {printer.toolhead.square_corner_velocity} scv."
[gcode_macro RESTORE_TOOLHEAD_SETTINGS]
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set values = printer["gcode_macro CACHE_TOOLHEAD_SETTINGS"].cache.__getitem__(key) %}
{% if values is not defined or values == 'None' %}
{ action_raise_error("RESTORE_TOOLHEAD_SETTINGS: Toolhead settings not cached for key '" ~ key ~ "'.") }
{% endif %}
SET_VELOCITY_LIMIT ACCEL={values.accel} MINIMUM_CRUISE_RATIO={values.ratio} VELOCITY={values.speed} SQUARE_CORNER_VELOCITY={values.scv}
DEBUG_ECHO PREFIX="RESTORE_TOOLHEAD_SETTINGS" MSG="Toolhead settings restored. {values.accel} accel, {values.ratio} ratio, {values.speed} velocity, {values.scv} scv."
[gcode_macro SET_MACRO_TRAVEL_SETTINGS]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set accel = printer["gcode_macro RatOS"].macro_travel_accel %}
SET_VELOCITY_LIMIT ACCEL={accel} MINIMUM_CRUISE_RATIO=0.5 VELOCITY={speed} SQUARE_CORNER_VELOCITY={5}
DEBUG_ECHO PREFIX="SET_MACRO_TRAVEL_SETTINGS" MSG="Macro travel settings set. {accel} accel, {speed} velocity"
[gcode_macro SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% if printer["dual_carriage"] is not defined %}
SET_KINEMATIC_POSITION X={printable_x_max / 2} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
{% else %}
IDEX_SET_CENTER_KINEMATIC_POSITION
{% endif %}
[gcode_macro IDEX_SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set center_x = printable_x_max / 2 %}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x - (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x + (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
[gcode_macro VERIFY_HYBRID_INVERTED]
gcode =
{% set inverted = False %}
{% if printer.configfile.settings.ratos_hybrid_corexy is defined and printer.configfile.settings.ratos_hybrid_corexy.inverted is defined %}
{% if printer.configfile.settings.ratos_hybrid_corexy.inverted|lower == 'true' %}
{% set inverted = True %}
{% endif %}
{% endif %}
{% if inverted == False %}
{ action_emergency_stop("ratos_hybrid_corexy NOT INVERTED! Inverted hybrid core-xy bugfix not detected.") }
{% endif %}
[gcode_macro RATOS_ECHO]
gcode =
{% set prefix = "RatOS" %}
{% set debug = params.DEBUG|default(0)|int %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " | " ~ params.PREFIX %}
{% endif %}
{% set prefix = prefix ~ ":" %}
{% set msg = "" %}
{% if params.MSG is defined %}
{% set msg = params.MSG %}
{% else %}
{% set msg = "No msg parameter provided (this is a bug or unintended use)." %}
{% endif %}
{% if not debug %}
M117 {prefix} {msg}
{% endif %}
RATOS_LOG PREFIX="{prefix}" MSG="{msg}"
{% if not debug %}
RESPOND PREFIX="{prefix}" MSG="{msg}"
{% else %}
CONSOLE_ECHO TITLE="{prefix}" TYPE="debug" MSG="{msg}"
{% endif %}
[gcode_macro ENABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=True
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=prefix_filter VALUE="'{params.FILTER|default('')|lower}'"
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging enabled."
[gcode_macro DISABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=False
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging disabled."
[gcode_macro DEBUG_ECHO]
variable_enabled = False
variable_prefix_filter = ''
gcode =
{% set prefix = "DEBUG" %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " - " ~ params.PREFIX %}
{% endif %}
{% if enabled and (prefix_filter|lower == '' or prefix_filter|lower in params.PREFIX|lower) %}
RATOS_ECHO PREFIX="{prefix}" MSG="{params.MSG}" DEBUG=1
{% endif %}
[gcode_macro START_FEATURE]
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="Start {params.FEATURE} feature gcode"
{% set scv = printer.toolhead.square_corner_velocity|int|default(5) %}
{% set accel = printer.toolhead.max_accel|int|default(10000) %}
{% set ratio = printer.toolhead.minimum_cruise_ratio|float|default(0.5) %}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="scv" VALUE={scv}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="accel" VALUE={accel}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="ratio" VALUE={ratio}
_USER_START_FEATURE FEATURE="{params.FEATURE}"
[gcode_macro END_FEATURE]
variable_scv = 5
variable_accel = 10000
variable_ratio = 0.5
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="End {params.FEATURE} feature gcode"
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={scv} ACCEL={accel} MINIMUM_CRUISE_RATIO={ratio}
_USER_END_FEATURE FEATURE="{params.FEATURE}" SCV={scv} ACCEL={accel} RATIO={ratio}
[gcode_macro _ON_LAYER_CHANGE]
variable_layer_number = 0
description = INTERNAL USE ONLY. Call it from the slicers after layer change custom gcode
gcode =
{% set layer = params.LAYER|int %}
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE={layer}
SET_PRINT_STATS_INFO CURRENT_LAYER={layer}
[gcode_macro _LEARN_MORE_CALIBRATION]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/calibration" %}
{% set link_text = "RatOS Calibration Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_CHAMBER_FILTER]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter Control" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_FILAMENT]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/filaments" %}
{% set link_text = "RatOS Filament Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _CONSOLE_SAVE_CONFIG]
gcode =
M118 Click SAVE_CONFIG to save the settings to your printer.cfg.
[gcode_macro SAVE_Z_OFFSET]
gcode =
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SAVE_MULTIPLIER
{% else %}
Z_OFFSET_APPLY_PROBE
{% endif %}
[gcode_macro _LOAD_RATOS_SKEW_PROFILE]
gcode =
{% set ratos_skew_profile = printer["gcode_macro RatOS"].skew_profile|default("") %}
{% if ratos_skew_profile != "" %}
{% if printer.configfile.config["skew_correction %s" % ratos_skew_profile] is defined %}
SKEW_PROFILE LOAD={ratos_skew_profile}
GET_CURRENT_SKEW
{% else %}
{% set line_1 = '"Could not find skew profile %s!_N_Clearing skew correction."' % ratos_skew_profile %}
CONSOLE_ECHO TITLE="Missing skew profile!" TYPE="warning" MSG={line_1}
SET_SKEW CLEAR=1
{% endif %}
{% endif %}
[gcode_macro M601]
gcode =
PAUSE
[gcode_macro PAUSE]
description = Pauses the print
rename_existing = PAUSE_BASE
variable_extrude = 1.5
variable_retract = 1.5
variable_fan_speed = 0
variable_idex_mode = ""
variable_idex_toolhead = 0
variable_idex_toolhead_x = 0.0
variable_idex_toolhead_y = 0.0
variable_idex_toolhead_z = 0.0
gcode =
{% set runout_detected = true if params.RUNOUT|default(false)|lower == 'true' else false %}
_LED_PAUSE
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set idex_toolhead = 1 if idex_mode == 'primary' else 0 %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
SAVE_GCODE_STATE NAME=PAUSE_state
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_mode VALUE='"{idex_mode}"'
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead VALUE={idex_toolhead}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_x VALUE={printer.gcode_move.gcode_position.x|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_y VALUE={printer.gcode_move.gcode_position.y|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_z VALUE={printer.gcode_move.gcode_position.z|float}
DEBUG_ECHO PREFIX="PAUSE" MSG="idex_mode: {idex_mode}, idex_toolhead: {idex_toolhead}, idex_toolhead_x: {idex_toolhead_x}, idex_toolhead_y: {idex_toolhead_y}, idex_toolhead_z: {idex_toolhead_z}"
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
CACHE_TOOLHEAD_SETTINGS KEY="pause"
SET_MACRO_TRAVEL_SETTINGS
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% if current_z < (max_z - 20.0) %}
{% set z_safe = 20.0 %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
PAUSE_BASE
{% if printer["dual_carriage"] is not defined %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan"].speed|float}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
{% if idex_toolhead == 0 %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t1"].speed|float}
{% endif %}
{% endif %}
{% endif %}
M106 S0
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if idex_mode != '' %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set R = printer["gcode_macro PAUSE"].retract|float %}
{% if can_extrude %}
G91
G1 E-{R} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].pause_print_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].pause_print_park_in %}
{% if runout_detected %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].runout_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].runout_park_in %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
DEBUG_ECHO PREFIX="PAUSE" MSG="z_speed: {z_speed}, pause_print_park_x: {pause_print_park_x}, pause_print_park_in: {pause_print_park_in}, default_toolhead: {default_toolhead}"
{% if "xyz" in printer.toolhead.homed_axes %}
G91
G1 Z{z_safe} F{z_speed}
G90
{% if printer["dual_carriage"] is not defined %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% else %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
_IDEX_SINGLE X={parking_position}
{% else %}
PARK_TOOLHEAD
{% endif %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% endif %}
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="pause"
[gcode_macro RESUME]
description = Resumes the print if the printer is paused.
rename_existing = RESUME_BASE
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set target_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set target_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% endif %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if target_idex_mode != '' %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set fan_speed = printer["gcode_macro PAUSE"].fan_speed|float %}
{% if printer["dual_carriage"] is not defined %}
M106 S{(fan_speed * 255)}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% else %}
{% if params.TOOLHEAD is defined %}
{% if params.TOOLHEAD == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% else %}
{% if printer["gcode_macro PAUSE"].idex_toolhead == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% endif %}
{% endif %}
M106.1 S{fan_speed}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY DANCE=0
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR DANCE=0
{% else %}
{% if params.TOOLHEAD is defined %}
_SELECT_TOOL T={params.TOOLHEAD} X=-1 Y=-1 TOOLSHIFT=false
{% else %}
_SELECT_TOOL T={printer["gcode_macro PAUSE"].idex_toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% endif %}
{% set x = printer["gcode_macro PAUSE"].idex_toolhead_x|float %}
{% set y = printer["gcode_macro PAUSE"].idex_toolhead_y|float %}
{% set z = printer["gcode_macro PAUSE"].idex_toolhead_z|float %}
G1 X{x} Y{y} Z{z} F{speed}
{% if params.TOOLHEAD is defined %}
SAVE_GCODE_STATE NAME=PAUSE_STATE
{% endif %}
{% endif %}
{% if params.TOOLHEAD is not defined %}
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
{% if can_extrude %}
G91
G1 E{E} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1 MOVE_SPEED={speed}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
RESUME_BASE
_LED_PRINTING
[gcode_macro CANCEL_PRINT]
description = Cancels the printer
rename_existing = CANCEL_PRINT_BASE
gcode =
END_PRINT
TURN_OFF_HEATERS
CLEAR_PAUSE
CANCEL_PRINT_BASE
[gcode_macro START_PRINT]
description = Start print procedure, use this in your Slicer.
variable_post_processor_version = 2
variable_is_printing_gcode = False
variable_both_toolheads = True
variable_object_xoffset = 0
variable_first_x = -1
variable_first_y = -1
variable_total_toolshifts = 0
variable_initial_tool = 0
variable_extruder_first_layer_temp = ""
variable_extruder_other_layer_temp = ""
gcode =
{% if "xyz" in printer.toolhead.homed_axes and printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% if printer["gcode_macro _VAOC"].is_started|default(true)|lower == 'true' %}
_VAOC_END
{% endif %}
{% endif %}
_LED_START_PRINTING
CACHE_TOOLHEAD_SETTINGS KEY="start_print"
_USER_START_PRINT { rawparams }
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set bed_heat_soak_time = printer["gcode_macro RatOS"].bed_heat_soak_time|default(0)|int %}
{% set hotend_heat_soak_time = printer["gcode_macro RatOS"].hotend_heat_soak_time|default(0)|int %}
{% set z_probe_stowable = printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set X0 = params.X0|default(-1)|float %}
{% set X1 = params.X1|default(-1)|float %}
{% set Y0 = params.Y0|default(-1)|float %}
{% set Y1 = params.Y1|default(-1)|float %}
{% if first_x == -1 or first_y == -1 %}
{% set first_x = params.FIRST_X|default(-1)|float %}
{% set first_y = params.FIRST_Y|default(-1)|float %}
{% endif %}
{% set total_toolshifts = params.TOTAL_TOOLSHIFTS|default(0)|int %}
{% set initial_tool = params.INITIAL_TOOL|default(default_toolhead)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set bed_temp = params.BED_TEMP|default(printer.heater_bed.target, true)|float %}
{% set total_layer_count = params.TOTAL_LAYER_COUNT|default(0)|int %}
{% set extruder_first_layer_temp = (params.EXTRUDER_TEMP|default("")).split(",") %}
RATOS_ECHO MSG="First print coordinates X:{first_x} Y:{first_y}"
{% if params.TOTAL_LAYER_COUNT is not defined %}
{% set link_url = "https://os.ratrig.com/docs/slicers" %}
{% set link_text = "RatOS Slicer Configuration" %}
{% set line_1 = '"Your slicer gcode settings are not up to date._N_Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="Incomplete Slicer Configuration detected" TYPE="warning" MSG={line_1}
{% endif %}
SET_PRINT_STATS_INFO CURRENT_LAYER=1
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE=1
{% if total_layer_count > 0 %}
SET_PRINT_STATS_INFO TOTAL_LAYER={total_layer_count}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set swap_toolheads = true if printer["gcode_macro _IDEX_REMAP_TOOLHEADS"].enabled|default(false)|lower == 'true' else false %}
{% if swap_toolheads %}
{% set initial_tool = 0 if initial_tool == 1 else 1 %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=active VALUE=True
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=active VALUE=True
{% endif %}
{% set both_toolheads = true %}
{% if total_toolshifts == 0 %}
{% set both_toolheads = false %}
{% endif %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
{% endif %}
{% if both_toolheads and (idex_mode == "copy" or idex_mode == "mirror") %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Gcode tool changes found. Copy and mirror mode do not support toolchanges.")}
{% endif %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set both_toolheads = true %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=initial_tool VALUE={initial_tool}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_x VALUE={first_x}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_y VALUE={first_y}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=total_toolshifts VALUE={total_toolshifts}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=both_toolheads VALUE={both_toolheads}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_first_layer_temp VALUE="'{params.EXTRUDER_TEMP}'"
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_other_layer_temp VALUE="'{params.EXTRUDER_OTHER_LAYER_TEMP}'"
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE VARIABLE=toolshift_count VALUE=0
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set svv = printer.save_variables.variables %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
{% set stepper_x_position_min = printer.configfile.settings.stepper_x.position_min|float %}
{% set stepper_x_position_endstop = printer.configfile.settings.stepper_x.position_endstop|float %}
{% set dual_carriage_position_max = printer.configfile.settings.dual_carriage.position_max|float %}
{% set dual_carriage_position_endstop = printer.configfile.settings.dual_carriage.position_endstop|float %}
{% set x_parking_space = parking_position_t0 - (stepper_x_position_endstop , stepper_x_position_min)|max %}
{% set dc_parking_space = (dual_carriage_position_endstop , dual_carriage_position_max)|min - parking_position_t1 %}
{% if svv.idex_xoffset|abs >= (x_parking_space - 0.5) or svv.idex_xoffset|abs >= (dc_parking_space - 0.5) %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Toolhead x-offset is too high for the available parking space. Calibrate your X and DC endstop positions and make sure you stay below 1mm." % (copy_mode_max_width)) }
{% endif %}
{% endif %}
{% if (idex_mode == "copy" or idex_mode == "mirror") and printer.configfile.settings.ratos.enable_gcode_transform %}
{% if params.MIN_X is not defined or params.MAX_X is not defined %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Something went wrong! Missing important post processor start print parameter!") }
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE=0
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set boundary_box_min_x = params.MIN_X|default(0)|float %}
{% set boundary_box_max_x = params.MAX_X|default(printable_x_max)|float %}
{% set svv = printer.save_variables.variables %}
{% if default_toolhead == 0 %}
{% set boundary_box_max_x = boundary_box_max_x + svv.idex_xoffset %}
{% else %}
{% set boundary_box_min_x = boundary_box_min_x - svv.idex_xoffset %}
{% endif %}
{% set center_x = printable_x_max / 2.0 %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% set object_width = boundary_box_max_x - boundary_box_min_x %}
{% set copy_mode_max_width = center_x %}
{% set mirror_mode_max_width = center_x - safe_distance / 2.0 %}
DEBUG_ECHO PREFIX="START_PRINT" MSG="OBJECT_WIDTH: {object_width} BOUNDARY_BOX_MIN_X: {boundary_box_min_x} BOUNDARY_BOX_MAX_X: {boundary_box_max_x} CENTER_X: {center_x} SAFE_DISTANCE: {safe_distance}"
{% if idex_mode == "copy" and object_width > copy_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for copy mode! Max supported width is %s mm" % (copy_mode_max_width)) }
{% endif %}
{% if idex_mode == "mirror" and object_width > mirror_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for mirror mode! Max supported width is %s mm" % (mirror_mode_max_width)) }
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = (printable_x_max - boundary_box_max_x - boundary_box_min_x) / 2 %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE={object_xoffset}
{% endif %}
{% endif %}
{% set has_initial_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_initial_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined and both_toolheads %}
{% set has_secondary_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_secondary_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% endif %}
_CHAMBER_FILTER_ON AT="before_print_start"
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true' %}
{% if both_toolheads %}
RATOS_ECHO MSG="Spool join is not possible if both toolheads are in use!"
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if idex_mode == '' %}
_SET_TOOLHEAD_OFFSET T={default_toolhead} MOVE={1 if "xyz" in printer.toolhead.homed_axes else 0}
{% endif %}
{% endif %}
CLEAR_PAUSE
{% if printer["gcode_macro RatOS"].force_absolute_position|lower == 'true' %}
G90
{% endif %}
SAVE_GCODE_STATE NAME=start_print_state
G21
G90
M82
_USER_START_PRINT_BEFORE_HOMING { rawparams }
{% if z_probe_stowable == true %}
STOWABLE_PROBE_BEGIN_BATCH
{% endif %}
MAYBE_HOME
_Z_HOP
{% if idex_mode != '' and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
PARK_TOOLHEAD
{% endif %}
{% if chamber_temp > 0 %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED={printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float}
{% endif %}
{% endif %}
_CHAMBER_HEATER_ON START_CHAMBER_TEMP={start_chamber_temp} CHAMBER_TEMP={chamber_temp}
_USER_START_PRINT_HEAT_CHAMBER { rawparams } CHAMBER_TEMP={chamber_temp}
{% endif %}
_START_PRINT_BEFORE_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
RATOS_ECHO MSG="Heating bed..."
M190 S{bed_temp}
{% if bed_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking bed for {bed_heat_soak_time} seconds..."
G4 P{(bed_heat_soak_time * 1000)}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_BED { rawparams }
_START_PRINT_AFTER_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
_USER_START_PRINT_BED_MESH { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_BED_MESH X0={X0} X1={X1} Y0={Y0} Y1={Y1} T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if z_probe_stowable == true %}
STOWABLE_PROBE_END_BATCH
{% endif %}
{% if idex_mode == '' %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={extruder_first_layer_temp[1]|float}
{% endif %}
{% endif %}
_USER_START_PRINT_PARK { rawparams }
_START_PRINT_PARK
RATOS_ECHO MSG="Heating Extruder..."
{% if idex_mode == '' %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder1" MINIMUM={extruder_first_layer_temp[1]|float} MAXIMUM={extruder_first_layer_temp[1]|float + 5}
{% endif %}
{% endif %}
{% if hotend_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking hotend for {hotend_heat_soak_time} seconds..."
G4 P{(hotend_heat_soak_time * 1000)}
{% endif %}
{% if idex_mode == '' %}
_LED_PRINTING
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
_LED_PRINTING
{% else %}
{% if both_toolheads %}
_LED_PRINTING TOOLHEAD={initial_tool}
{% if toolchange_standby_temp > -1 %}
_LED_TOOLHEAD_STANDBY TOOLHEAD={0 if initial_tool == 1 else 1}
{% else %}
_LED_PRINTING TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% else %}
_LED_PRINTING TOOLHEAD={initial_tool}
_LED_DEACTIVATE_TOOLHEAD TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% endif %}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_EXTRUDER { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_AFTER_HEATING_EXTRUDER X0={X0} X1={X1} Y0={Y0} Y1={Y1} INITIAL_TOOLHEAD={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if idex_mode != '' %}
{% if not both_toolheads %}
{% if initial_tool != default_toolhead %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET=0
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if toolchange_standby_temp > -1 %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if initial_tool == 1 else 'extruder1'} TARGET={toolchange_standby_temp}
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% set x_offset = printer.toolhead.position.x|float - printer.gcode_move.gcode_position.x|float %}
{% endif %}
RESTORE_GCODE_STATE NAME=start_print_state
{% if idex_mode != '' %}
{% set act_idex_mode = printer["dual_carriage"].carriage_1|default('')|lower %}
{% if act_idex_mode == "copy" or act_idex_mode == "mirror" %}
SET_GCODE_OFFSET X={x_offset} MOVE=0
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% if idex_mode == "copy" and idex_mode != act_idex_mode %}
_IDEX_COPY DANCE=0
{% elif idex_mode == "mirror" and idex_mode != act_idex_mode %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
RATOS_ECHO MSG="Adjusting object x-offset by {(object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={object_xoffset} MOVE=0
{% endif %}
{% else %}
_SELECT_TOOL T={initial_tool} TOOLSHIFT=false
{% if initial_tool != default_toolhead %}
{% set svv = printer.save_variables.variables %}
SAVE_VARIABLE VARIABLE=idex_applied_offset VALUE={default_toolhead}
_SET_TOOLHEAD_OFFSET T={initial_tool} MOVE=0
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={initial_tool}
{% endif %}
_SET_EXTRUSION_MODE
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
SET_GCODE_VARIABLE MACRO=_SELECT_TOOL VARIABLE=last_timestamp VALUE={printer["print_stats"].print_duration}
{% endif %}
_USER_END_START_PRINT { rawparams }
G92 E0
_CHAMBER_FILTER_ON AT="after_print_start"
RATOS_ECHO MSG="Printing..."
[gcode_macro _START_PRINT_BEFORE_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set is_stowable_probe = true if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Pre-heating extruder..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={min_temp}
{% else %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET={min_temp}
{% endif %}
{% else %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
{% endif %}
{% endif %}
{% if not is_stowable_probe %}
{% if printer["dual_carriage"] is defined and act_t != default_toolhead %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
{% endif %}
RATOS_ECHO MSG="Heat soaking z probe..."
{% if auto_z_offset_calibration %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% if default_toolhead == 0 %}
_SELECT_TOOL T=0 TOOLSHIFT=false
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
{% elif default_toolhead == 1 %}
_SELECT_TOOL T=1 TOOLSHIFT=false
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
{% endif %}
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% endif %}
G0 Z2 F{z_speed}
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Waiting for extruder to be preheated..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
{% if default_toolhead == 0 %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_Z_HOP
{% endif %}
{% if auto_z_offset_calibration %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
PARK_TOOLHEAD
_CLEANING_MOVE TOOLHEAD={default_toolhead}
_SELECT_TOOL T={0 if default_toolhead == 1 else 1} X={parking_position_t0 if default_toolhead == 1 else parking_position_t1} Y=0 TOOLSHIFT=false
_CLEANING_MOVE TOOLHEAD={0 if default_toolhead == 1 else 1}
_VAOC_CALIBRATE_Z_OFFSET AUTO_Z_OFFSET=True
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=false
{% endif %}
{% set needs_rehoming = False %}
{% if printer.z_tilt is defined and not printer.z_tilt.applied %}
RATOS_ECHO MSG="Adjusting Z tilt..."
Z_TILT_ADJUST
RATOS_ECHO MSG="Rehoming Z after Z tilt adjustment..."
{% set needs_rehoming = True %}
{% endif %}
{% if printer.quad_gantry_level is defined and not printer.quad_gantry_level.applied %}
RATOS_ECHO MSG="Running quad gantry leveling..."
QUAD_GANTRY_LEVEL
RATOS_ECHO MSG="Rehoming Z after quad gantry leveling..."
{% set needs_rehoming = True %}
{% endif %}
{% if needs_rehoming %}
G28 Z
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %}
{% if beacon_contact_wipe_before_true_zero %}
_START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE
{% endif %}
_START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
G0 Z5 F{z_speed}
G0 X50 Y10 F{speed}
PROBE PROBE_METHOD=contact SAMPLES=1
BEACON_QUERY
[gcode_macro _START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_true_zero_temp = printer["gcode_macro RatOS"].beacon_contact_true_zero_temp|default(150)|int %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_true_zero_location = printer["gcode_macro RatOS"].beacon_contact_true_zero_location|default("front")|lower %}
{% set beacon_contact_true_zero_margin_x = printer["gcode_macro RatOS"].beacon_contact_true_zero_margin_x|default(30)|int %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if beacon_contact_wipe_before_true_zero %}
{% if printer.beacon.last_probe_result|lower == "ok" %}
{% set last_z_offset = printer.beacon.last_z_result %}
RATOS_ECHO MSG="Auto calibration nozzle wipe with probe result {last_z_offset}..."
G0 Z{(0.2 + last_z_offset)} F{z_speed}
G0 X70 F300
{% else %}
RATOS_ECHO MSG="Skipping auto calibration nozzle wipe because probing failed!"
{% endif %}
{% endif %}
G0 Z5 F{z_speed}
_MOVE_TO_SAFE_Z_HOME
RATOS_ECHO MSG="Heating extruder to probing temperature..."
SET_HEATER_TEMPERATURE HEATER={"extruder" if default_toolhead == 0 else "extruder1"} TARGET={beacon_contact_true_zero_temp}
TEMPERATURE_WAIT SENSOR={"extruder" if default_toolhead == 0 else "extruder1"} MINIMUM={beacon_contact_true_zero_temp} MAXIMUM={beacon_contact_true_zero_temp + 5}
RATOS_ECHO MSG="Beacon contact auto calibration..."
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
G0 Z5 F{z_speed}
[gcode_macro _START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set first_x = printer["gcode_macro START_PRINT"].first_x|default(-1)|float %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set center_x = printable_x_max / 2.0 %}
{% set center_y = printable_y_max / 2.0 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% if printer["dual_carriage"] is defined %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% endif %}
{% set X0 = params.X0|default(-1)|int %}
{% set X1 = params.X1|default(-1)|int %}
{% set Y0 = params.Y0|default(-1)|int %}
{% set Y1 = params.Y1|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% if idex_mode == '' %}
_PRIME
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
RATOS_ECHO PREFIX="IDEX" MSG="using combined prime offset for IDEX {idex_mode} mode"
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
{% if both_toolheads %}
{% if initial_toolhead == 0 %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T{initial_toolhead}"
_SELECT_TOOL T={initial_toolhead} TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% endif %}
{% endif %}
CACHE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
SET_MACRO_TRAVEL_SETTINGS
{% if (X0 > -1 and Y1 > -1) or (first_x > 0 and first_y > 0) %}
{% if printer["dual_carriage"] is defined %}
{% set acceleration = printer["gcode_macro RatOS"].toolchange_travel_accel %}
{% set max_accel = printer.toolhead.max_accel|float %}
{% set square_corner_velocity = printer.toolhead.square_corner_velocity|float %}
SET_VELOCITY_LIMIT ACCEL={acceleration} MINIMUM_CRUISE_RATIO=0 SQUARE_CORNER_VELOCITY=20
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
{% set first_z = 1 %}
{% else %}
{% set first_z = 3 %}
{% endif %}
{% if idex_mode == "mirror" %}
{% if first_y >= 0 %}
G0 Y{first_y} F{speed}
{% else %}
G0 Y{Y1} F{speed}
{% endif %}
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
_MOVE_TO_LOADING_POSITION TOOLHEAD={initial_toolhead}
_PURGE_FILAMENT TOOLHEAD={initial_toolhead} E={printer["gcode_macro RatOS"].toolchange_first_purge|default(50)|float}
_CLEANING_MOVE TOOLHEAD={initial_toolhead}
{% endif %}
{% if first_x >= 0 and first_y >= 0 %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% else %}
{% set first_x = X0 %}
{% set first_y = Y0 %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'min' %}
{% set first_x = X0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'max' %}
{% set first_x = X1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|float <= center_x %}
{% set first_x = X0 %}
{% else %}
{% set first_x = X1 %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'min' %}
{% set first_y = Y0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'max' %}
{% set first_y = Y1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|float <= center_y %}
{% set first_y = Y0 %}
{% else %}
{% set first_y = Y1 %}
{% endif %}
{% endif %}
{% endif %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% endif %}
{% endif %}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
_LOAD_RATOS_SKEW_PROFILE
[gcode_macro _PRIME]
gcode =
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
PRIME_BLOB INITIAL_TOOLHEAD={params.INITIAL_TOOLHEAD} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={params.IDEX_MODE} Y1={params.Y1}
{% else %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE == "copy" %}
_IDEX_COPY DANCE=0
{% elif params.IDEX_MODE == "mirror" %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro END_PRINT]
description = End print procedure, use this in your Slicer.
gcode =
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SAVE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = printer["gcode_macro START_PRINT"].object_xoffset|default(0)|float %}
RATOS_ECHO MSG="Adjusting object x-offset by {(0-object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={(0-object_xoffset)}
{% endif %}
{% endif %}
_USER_END_PRINT_BEFORE_HEATERS_OFF { rawparams }
_END_PRINT_BEFORE_HEATERS_OFF
TURN_OFF_HEATERS
_USER_END_PRINT_AFTER_HEATERS_OFF { rawparams }
_END_PRINT_AFTER_HEATERS_OFF
_USER_END_PRINT_PARK { rawparams }
_END_PRINT_PARK
{% if printer["gcode_macro RatOS"].skew_profile is defined %}
SET_SKEW CLEAR=1
{% endif %}
{% if printer["dual_carriage"] is not defined and printer["gcode_macro RatOS"].end_print_motors_off|lower != 'false' %}
M84
{% endif %}
M107
BED_MESH_CLEAR
RATOS_ECHO MSG="Done :)"
RESTORE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
M84
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
{% if printer["dual_carriage"] is not defined %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_expansion_compensation = true if printer["gcode_macro RatOS"].beacon_contact_expansion_compensation|default(false)|lower == 'true' else false %}
{% if beacon_contact_start_print_true_zero and beacon_contact_expansion_compensation %}
SET_GCODE_OFFSET Z=0 MOVE=0
{% endif %}
{% endif %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print"
_CHAMBER_FILTER_ON AT="print_end"
_CHAMBER_FILTER_OFF
_CHAMBER_HEATER_OFF
_USER_END_PRINT_FINISHED { rawparams }
[gcode_macro _END_PRINT_BEFORE_HEATERS_OFF]
gcode =
RATOS_ECHO MSG="Cleaning up..."
[gcode_macro _END_PRINT_AFTER_HEATERS_OFF]
gcode =
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% set z_hop = printer["gcode_macro RatOS"].end_print_park_z_hop|float %}
{% set r = printer["gcode_macro RatOS"].end_print_retract_filament|default(4)|float %}
{% if current_z < (max_z - z_hop) %}
{% set z_safe = z_hop %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
G91
G1 E-2 F3600
G0 Z{z_safe} F3600
G1 E-{(r-2)} F3600
G90
[gcode_macro _SET_EXTRUSION_MODE]
gcode =
{% if printer["gcode_macro RatOS"].relative_extrusion|lower == 'true' %}
M83
{% else %}
M82
{% endif %}
[gcode_macro GENERATE_SHAPER_GRAPHS]
description = Genarates input shaper resonances graphs for analysis. Uses the AXIS parameter for if you only want to do one axis at a time, (eg. GENERATE_SHAPER_GRAPHS AXIS=X)
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set axis = params.AXIS|default('')|lower %}
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
{% if axis != '' %}
{% if axis == 'x' %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
{% elif axis == 'y' %}
MAYBE_HOME
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% else %}
{action_raise_error("Unknown axis specified. Expected X or Y.")}
{% endif %}
{% else %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% endif %}
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Shaper graph"
[gcode_shell_command generate_shaper_graph_x]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-x.sh
timeout = 60.
verbose = True
[gcode_shell_command generate_shaper_graph_y]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-y.sh
timeout = 60.
verbose = True
[gcode_macro MEASURE_COREXY_BELT_TENSION]
description = Generates resonance graph used to ensure belts are equally tensioned.
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
MAYBE_HOME
TEST_RESONANCES AXIS=1,1 OUTPUT=raw_data NAME=belt-tension-upper FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=belt-tension-lower FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_belt_tension_graph
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Belt Tension Graph"
[gcode_shell_command generate_belt_tension_graph]
command = /home/pi/printer_data/config/RatOS/scripts/generate-belt-tension-graph.sh
timeout = 90.
verbose = True
[idle_timeout]
gcode =
{% if printer.webhooks.state|lower == 'ready' %}
{% if printer.pause_resume.is_paused|lower == 'false' %}
RATOS_ECHO PREFIX="IDLE" MSG="2 hours since last activity. Powering off heaters and motors.."
TURN_OFF_HEATERS
M84
{% endif %}
{% endif %}
timeout = 7200
[temperature_sensor raspberry_pi]
sensor_type = temperature_host
[skew_correction]
[input_shaper]
[virtual_sdcard]
path = ~/printer_data/gcodes
[display_status]
[pause_resume]
[force_move]
enable_force_move = True
[respond]
[resonance_generator]
[ratos]
allow_unknown_gcode_generator = True
[exclude_object]
[heater_bed]
heater_pin = heater_bed_heating_pin
sensor_pin = heater_bed_sensor_pin
sensor_type = EPCOS 100K B57560G104F
min_temp = 0
max_temp = 130
control = pid
pid_kp = 68.203
pid_ki = 2.842
pid_kd = 409.216
[fan]
pin = multi_pin:dual_blower_fan
shutdown_speed = 1.0
kick_start_time = 0.5
cycle_time = 0.00004
[heater_fan toolhead_cooling_fan]
pin = PD14
fan_speed = 1
heater = extruder
heater_temp = 50.0
[controller_fan controller_fan]
pin = PD13
idle_speed = 0.7
[printer]
kinematics = cartesian
max_velocity = 200
max_accel = 3000
minimum_cruise_ratio = 0.5
max_z_velocity = 15
max_z_accel = 200
square_corner_velocity = 5
[bed_mesh]
speed = 200
horizontal_move_z = 5
mesh_min = 15,15
mesh_max = 150,160
probe_count = 5,5
fade_start = 1.0
fade_end = 10.0
mesh_pps = 2,2
algorithm = bicubic
bicubic_tension = .2
[screws_tilt_adjust]
screw1 = 80, 108
screw1_name = Left Screw
screw2 = 155, 72
screw2_name = Front Right Screw
screw3 = 155, 147
screw3_name = Rear Right Screw
horizontal_move_z = 10
speed = 200
screw_thread = CCW-M4
[stepper_x]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PF9
dir_pin = !x_dir_pin
enable_pin = !PD6
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = toolboard_t0:PB6
[stepper_y]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PD3
dir_pin = y_dir_pin
enable_pin = !PD5
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = PC1
[stepper_z]
position_min = -5
position_max = 180
step_pin = PA15
dir_pin = !z0_dir_pin
enable_pin = !PC9
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 4
homing_speed = 15
endstop_pin = probe:z_virtual_endstop
[gcode_macro SCREWS_TILT_CALCULATE]
rename_existing = SCREWS_TILT_CALCULATE_ORIG
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
MAYBE_HOME
SAVE_GCODE_STATE NAME=screws_tilt_state
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
DEPLOY_PROBE
{% endif %}
SCREWS_TILT_CALCULATE_ORIG
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
STOW_PROBE
{% endif %}
G90
G0 Z120 F{printer["gcode_macro RatOS"].macro_z_speed|float * 60}
G0 Y{printable_y_max} X{printable_x_max / 2} F{printer["gcode_macro RatOS"].macro_travel_speed|float * 60}
RESTORE_GCODE_STATE NAME=screws_tilt_state
M84
[extruder]
rotation_distance = 5.57
full_steps_per_rotation = 200
filament_diameter = 1.750
max_extrude_only_velocity = 120
max_extrude_only_accel = 800
pressure_advance_smooth_time = 0.02
max_extrude_only_distance = 200
nozzle_diameter = 0.4
heater_pin = toolboard_t0:PB13
sensor_type = MAX31865
sensor_pin = toolboard_t0:PA4
min_extrude_temp = 170
min_temp = 0
max_temp = 350
pressure_advance = 0.03
step_pin = toolboard_t0:PD0
dir_pin = !toolboard_t0:e_dir_pin
enable_pin = !toolboard_t0:PD2
microsteps = 64
control = pid
pid_kp = 21.673
pid_ki = 1.338
pid_kd = 87.776
spi_software_sclk_pin = toolboard_t0:PA5
spi_software_miso_pin = toolboard_t0:PA6
spi_software_mosi_pin = toolboard_t0:PA7
[firmware_retraction]
retract_speed = 120
unretract_extra_length = 0
unretract_speed = 120
retract_length = 0.5
[adxl345 rpi]
cs_pin = rpi:None
[resonance_tester]
accel_chip_x = adxl345 toolboard_t0
accel_chip_y = adxl345 rpi
probe_points =
90,90,20
[tmc2209 stepper_x]
stealthchop_threshold = 0
interpolate = False
uart_pin = PF10
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_y]
stealthchop_threshold = 0
interpolate = False
uart_pin = PD4
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_z]
stealthchop_threshold = 0
interpolate = False
uart_pin = PC8
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 extruder]
stealthchop_threshold = 0
interpolate = False
uart_pin = toolboard_t0:PA15
run_current = 0.707
driver_tbl = 0
driver_toff = 4
driver_hend = 6
driver_hstrt = 7
sense_resistor = 0.11
[bltouch]
sensor_pin = ^toolboard_t0:bltouch_sensor_pin
control_pin = toolboard_t0:bltouch_control_pin
speed = 7
pin_move_time = 0.675
sample_retract_dist = 10
pin_up_reports_not_triggered = True
pin_up_touch_mode_reports_triggered = True
x_offset = -28
y_offset = -13
z_offset = 2.375
[gcode_macro T0]
variable_join = 0
variable_remap = 0
variable_alert = ""
variable_filament_name = ""
variable_filament_type = ""
variable_filament_temp = 0
variable_runout_sensor = ""
variable_active = True
variable_color = "7bff33"
variable_hotend_type = "HF"
variable_has_cht_nozzle = False
variable_cooling_position_to_nozzle_distance = 40
variable_tooolhead_sensor_to_extruder_gear_distance = 15
variable_extruder_gear_to_cooling_position_distance = 30
variable_filament_loading_nozzle_offset = -5
variable_filament_grabbing_length = 5
variable_filament_grabbing_speed = 1
variable_enable_insert_detection = True
variable_enable_runout_detection = True
variable_enable_clog_detection = True
variable_unload_after_runout = True
variable_purge_after_load = 0
variable_purge_before_unload = 0
variable_extruder_load_speed = 60
variable_filament_load_speed = 10
variable_standby = False
variable_temperature_offset = 0
variable_has_oozeguard = False
variable_has_front_arm_nozzle_wiper = False
variable_resume_after_insert = False
gcode =
{% set x = params.X|default(-1.0)|float %}
{% set y = params.Y|default(-1.0)|float %}
{% set z = params.Z|default(0.0)|float %}
{% set s = params.S|default(1)|int %}
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
_SELECT_TOOL T=0 X={x} Y={y} Z={z} TOOLSHIFT={s}
{% endif %}
[save_variables]
filename = /home/pi/printer_data/config/ratos-variables.cfg
[multi_pin dual_blower_fan]
pins = toolboard_t0:PA0, toolboard_t0:PA1
=======================
Config error
Traceback (most recent call last):
File "/home/pi/klipper/klippy/klippy.py", line 130, in _connect
self._read_config()
File "/home/pi/klipper/klippy/klippy.py", line 123, in _read_config
self.load_object(config, section_config.get_name(), None)
File "/home/pi/klipper/klippy/klippy.py", line 112, in load_object
self.objects[section] = init_func(config.getsection(section))
File "/home/pi/klipper/klippy/extras/fan.py", line 122, in load_config
return PrinterFan(config)
File "/home/pi/klipper/klippy/extras/fan.py", line 106, in __init__
self.fan = Fan(config)
File "/home/pi/klipper/klippy/extras/fan.py", line 24, in __init__
self.mcu_fan = ppins.setup_pin('pwm', config.get('pin'))
File "/home/pi/klipper/klippy/pins.py", line 117, in setup_pin
pin_params = self.lookup_pin(pin_desc, can_invert, can_pullup)
File "/home/pi/klipper/klippy/pins.py", line 98, in lookup_pin
pin_params = self.parse_pin(pin_desc, can_invert, can_pullup)
File "/home/pi/klipper/klippy/pins.py", line 83, in parse_pin
raise error("Unknown pin chip name '%s'" % (chip_name,))
pins.error: Unknown pin chip name 'multi_pin'
webhooks client 1964469840: New connection
webhooks client 1964469840: Client info {'program': 'Moonraker', 'version': 'v0.9.3-0-g71f9e67'}
Attempting MCU 'mcu' reset
Unable to issue reset command on MCU 'rpi'
Attempting MCU 'toolboard_t0' reset
webhooks client 1964469840: Disconnected
Restarting printer
Start printer at Wed Nov 12 22:29:32 2025 (1762986572.7 20831.6)
===== Config file =====
[mcu rpi]
serial = /tmp/klipper_host_mcu
[board_pins btt-skrat-10]
aliases =
x_step_pin=PF9,
x_dir_pin=PD7,
x_enable_pin=PD6,
x_uart_pin=PF10,
x_diag_pin=PB5,
x_endstop_pin=PB5,
y_step_pin=PD3,
y_dir_pin=PD2,
y_enable_pin=PD5,
y_uart_pin=PD4,
y_diag_pin=PC1,
y_endstop_pin=PC1,
z0_step_pin=PA15,
z0_dir_pin=PF8,
z0_enable_pin=PC9,
z0_uart_pin=PC8,
z0_diag_pin=PC0,
e_step_pin=PB10,
e_dir_pin=PE15,
e_enable_pin=PA8,
e_uart_pin=PB11,
e_diag_pin=PF5,
e_heater_pin=PE11,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PE5,
bltouch_control_pin=PE6,
probe_pin=PE5,
fan_part_cooling_pin=PD15,
fan_toolhead_cooling_pin=PD14,
fan_controller_board_pin=PD13,
heater_bed_heating_pin=PB3,
heater_bed_sensor_pin=PB2,
4p_fan_part_cooling_pin=PE9,
4p_fan_part_cooling_tach_pin=PD11,
4p_toolhead_cooling_pin=PE14,
4p_toolhead_cooling_tach_pin=PD10,
4p_controller_board_pin=PE14,
4p_controller_board_tach_pin=PD10
[mcu]
serial = /dev/RatOS/btt-skrat-10
[temperature_sensor SKRat_v1.0]
sensor_type = temperature_mcu
[adxl345 controlboard]
cs_pin = PB12
spi_bus = spi2
[board_pins toolboard_t0]
mcu = toolboard_t0
aliases =
e_step_pin=PD0,
e_dir_pin=PD1,
e_enable_pin=PD2,
e_uart_pin=PA15,
e_heater_pin=PB13,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PB8,
bltouch_control_pin=PB9,
probe_pin=PB9,
fan_part_cooling_pin=PA0,
fan_toolhead_cooling_pin=PA1,
fan_controller_board_pin=null,
heater_bed_heating_pin=null,
heater_bed_sensor_pin=null,
4p_fan_part_cooling_pin=null,
4p_fan_part_cooling_tach_pin=null,
4p_toolhead_cooling_pin=null,
4p_toolhead_cooling_tach_pin=null,
4p_controller_board_pin=null,
4p_controller_board_tach_pin=null
[mcu toolboard_t0]
serial = /dev/RatOS/btt-ebb42-12-t0
[temperature_sensor EBB42_v1.2_T0]
sensor_type = temperature_mcu
sensor_mcu = toolboard_t0
[adxl345 toolboard_t0]
axes_map = x, z, y
cs_pin = toolboard_t0:PB12
spi_software_mosi_pin = toolboard_t0:PB11
spi_software_miso_pin = toolboard_t0:PB2
spi_software_sclk_pin = toolboard_t0:PB10
[gcode_macro RatOS]
variable_homing = "endstops"
variable_z_probe = "static"
variable_sensorless_x_current = 0.6
variable_sensorless_y_current = 0.9
variable_safe_home_x = "middle"
variable_safe_home_y = "middle"
variable_driver_type_x = "tmc2209"
variable_driver_type_y = "tmc2209"
variable_stowable_probe_stop_on_error = False
variable_chamber_filter_enable = True
variable_chamber_filter_speed = 0.5
variable_chamber_filter_disable_speed = 1.0
variable_chamber_filter_enable_at = "after_print_start"
variable_chamber_filter_disable_period = 300
variable_chamber_filter_disable_bed_temp = 0
variable_chamber_heater_enable = True
variable_chamber_heater_bed_temp = 115
variable_chamber_heater_preheating_temp = 150
variable_chamber_heater_heating_temp_offset = 25
variable_chamber_heater_control_external_heater = False
variable_chamber_heater_air_circulation_enable = True
variable_chamber_heater_air_circulation_fan_speed = 0.35
variable_chamber_heater_air_circulation_y_pos = 0
variable_chamber_heater_air_circulation_z_pos = 100
variable_chamber_heater_extra_fan_speed = 1.0
variable_chamber_heater_filter_fan_speed = 1.0
variable_led_status_action = 0.0,1.0,1.0
variable_led_status_success = 0.0,1.0,0.0
variable_led_status_error = 1.0,0.0,1.0
variable_led_status_on = 1.0,1.0,1.0
variable_led_status_off = 0.0,0.0,1.0
variable_led_status_standby = 0.1,0.1,0.1
variable_led_status_heating = 1.0,0.0,0.0
variable_led_status_cooling = 0.0,0.0,1.0
variable_calibrate_bed_mesh = True
variable_adaptive_mesh = True
variable_start_print_park_in = "front"
variable_start_print_park_z_height = 50
variable_end_print_park_in = "back"
variable_pause_print_park_in = "front"
variable_end_print_park_z_hop = 20
variable_nozzle_priming = "primeblob"
variable_nozzle_prime_start_x = "max"
variable_nozzle_prime_start_y = "min"
variable_nozzle_prime_direction = "auto"
variable_nozzle_prime_bridge_fan = 102
variable_probe_for_priming_result = None
variable_probe_for_priming_end_result = None
variable_probe_for_priming_result_t1 = None
variable_probe_for_priming_end_result_t1 = None
variable_probe_for_priming_disable_mesh_constraints = False
variable_adaptive_prime_offset_threshold = -1.0
variable_last_z_offset = None
variable_runout_park_in = "front"
variable_enable_unload_tip_forming = False
variable_filament_unload_length = 150
description = RatOS variable storage macro, will echo variables to the console when run.
variable_relative_extrusion = False
variable_force_absolute_position = False
variable_preheat_extruder = True
variable_preheat_extruder_temp = 150
variable_macro_travel_speed = 200
variable_macro_travel_accel = 3000
variable_macro_z_speed = 15
variable_bed_margin_x = [0, 0]
variable_bed_margin_y = [0, 0]
variable_printable_x_min = 0
variable_printable_x_max = 0
variable_printable_y_min = 0
variable_printable_y_max = 0
variable_end_print_motors_off = True
variable_status_color_ok = "00FF00"
variable_status_color_error = "FF0000"
variable_status_color_unknown = "FFFF00"
variable_end_print_retract_filament = 10
gcode =
ECHO_RATOS_VARS
variable_homing_x = "endstop"
variable_homing_y = "endstop"
variable_x_driver_types = ["tmc2209"]
variable_x_axes = ["x"]
variable_y_driver_types = ["tmc2209"]
variable_y_axes = ["y"]
variable_z_driver_types = ["tmc2209"]
variable_z_axes = ["z"]
[ratos_homing]
axes = xyz
z_hop = 15
z_hop_speed = 15
gcode =
_LED_ON
{% set prev_stop_on_error = printer["gcode_macro RatOS"].stowable_probe_stop_on_error %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set target_idex_mode = printer["dual_carriage"].carriage_1|lower %}
_IDEX_SINGLE
_SELECT_TOOL T={default_toolhead} TOOLSHIFT=false
{% endif %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE=True
M400
G90
{% set X = true if params.X is defined else false %}
{% set Y = true if params.Y is defined else false %}
{% set Z = true if params.Z is defined else false %}
{% if printer["gcode_macro RatOS"].home_y_first|default(false)|lower == 'true' %}
HOME_Y X={X} Y={Y} Z={Z}
HOME_X X={X} Y={Y} Z={Z}
{% else %}
HOME_X X={X} Y={Y} Z={Z}
HOME_Y X={X} Y={Y} Z={Z}
{% endif %}
HOME_Z X={X} Y={Y} Z={Z}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE={prev_stop_on_error}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR
{% endif %}
{% endif %}
[gcode_macro HOME_X]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_x = printer["gcode_macro RatOS"].homing_x|lower %}
{% set homing_x = homing_x if homing_x else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_X" MSG="printable_x_max: {printable_x_max}, safe_home_x: {safe_home_x}, axis_maximum.x: {printer.toolhead.axis_maximum.x}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}"
{% if X or not Y and not Z %}
{% if homing_x == 'endstop' %}
G28 X
{% elif homing_x == 'sensorless' %}
{% if printer["dual_carriage"] is defined %}
{ action_emergency_stop("sensorless homing not supported on IDEX!") }
{% endif %}
HOME_X_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_x to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_x, homing)) }
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % (0 if default_toolhead==1 else 1)].parking_position|float %}
SET_DUAL_CARRIAGE CARRIAGE={0 if default_toolhead==1 else 1} MODE=PRIMARY
G1 X{parking_position} F{speed}
SET_DUAL_CARRIAGE CARRIAGE={default_toolhead} MODE=PRIMARY
{% endif %}
{% set x_homed = True %}
G0 X{safe_home_x} F{speed}
M400
{% endif %}
[gcode_macro HOME_Y]
gcode =
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_y = printer["gcode_macro RatOS"].homing_y|lower %}
{% set homing_y = homing_y if homing_y else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Y" MSG="printable_y_max: {printable_y_max}, safe_home_y: {safe_home_y}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}"
{% if Y or not X and not Z %}
{% if homing_y == 'endstop' %}
G28 Y
{% elif homing_y == 'sensorless' %}
HOME_Y_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_y to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_y, homing)) }
{% endif %}
{% set y_homed = True %}
G0 Y{safe_home_y} F{speed}
{% endif %}
[gcode_macro HOME_Z]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set z_probe = printer["gcode_macro RatOS"].z_probe %}
{% set beacon_contact_z_homing = true if printer["gcode_macro RatOS"].beacon_contact_z_homing|default(false)|lower == 'true' else false %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Z" MSG="x_homed: {x_homed}, y_homed: {y_homed}, z_probe: {z_probe}, beacon_contact_z_homing: {beacon_contact_z_homing}"
{% if Z or not Y and not X %}
RATOS_ECHO MSG="Homing Z"
{% if x_homed == False or y_homed == False %}
{ action_emergency_stop("X and Y must be homed before homing Z") }
{% else %}
{% if z_probe == "stowable" %}
DEPLOY_PROBE
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
STOW_PROBE
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
{% endif %}
{% endif %}
{% endif %}
[gcode_macro HOME_X_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
G4 P300
G28 X
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
[gcode_macro HOME_Y_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
G4 P300
G28 Y
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
[gcode_macro _Z_HOP]
description = Move Z axis up by Z_HOP distance at Z_HOP_SPEED. In relative mode it will move Z axis up by Z_HOP distance. In absolute mode it will move Z axis to Z_HOP distance.
gcode =
{% set z_hop = printer.configfile.config.ratos_homing.z_hop|float %}
{% set z_hop_speed = printer.configfile.config.ratos_homing.z_hop_speed|float * 60 %}
G0 Z{z_hop} F{z_hop_speed}
[gcode_macro _MOVE_TO_SAFE_Z_HOME]
description = Move to safe home position with optional Z_HOP (pass Z_HOP=True as parameter)
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% if params.Z_HOP is defined %}
_Z_HOP
{% endif %}
DEBUG_ECHO PREFIX="_MOVE_TO_SAFE_Z_HOME" MSG="axis_maximum.x: {printer.toolhead.axis_maximum.x}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}, safe_home_x: {safe_home_x}, safe_home_y: {safe_home_y}, printable_x_max: {printable_x_max}, printable_y_max: {printable_y_max}"
G0 X{safe_home_x} Y{safe_home_y} F{speed}
[gcode_macro MAYBE_HOME]
description = Only home unhomed axis
variable_is_kinematic_position_overriden = False
gcode =
{% if printer["gcode_macro MAYBE_HOME"].is_kinematic_position_overriden|lower == 'true' %}
RATOS_ECHO MSG="SET_CENTER_KINEMATIC_POSITION has been abused. Homing all axes. Please refrain from using SET_CENTER_KINEMATIC_POSITION outside of debugging purposes."
G28
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=False
{% else %}
{% set axes = '' %}
{% set isHomed = true %}
{% set axesToHome = '' %}
{% if params.X is defined %}
{% set axes = axes ~ 'X ' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% endif %}
{% if params.Y is defined %}
{% set axes = axes ~ 'Y ' %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% endif %}
{% if params.Z is defined %}
{% set axes = axes ~ 'Z ' %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if params.X is not defined and params.Y is not defined and params.Z is not defined %}
{% set axes = '' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if isHomed is false %}
RATOS_ECHO MSG="Homing {axesToHome}"
G28 {axesToHome}
{% else %}
RATOS_ECHO MSG="All requested axes already homed, skipping.."
{% endif %}
{% endif %}
[gcode_macro PID_CALIBRATE_HOTEND]
description = Perform a PID calibration test for a given extruder heater.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set temp = params.TEMP|default(220)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_HOTEND" MSG="TEMP={temp}"
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO MSG="PID calibration hotend heater T0 at {temp}°C..."
PID_CALIBRATE HEATER=extruder TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
{% if toolhead==0 or toolhead==1 %}
RATOS_ECHO MSG="PID calibration hotend heater T{toolhead} at {temp}°C..."
PID_CALIBRATE HEATER=extruder{'' if toolhead==0 else toolhead} TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_BED]
description = Perform a PID calibration test for the bed heater.
gcode =
{% set temp = params.TEMP|default(80)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_BED" MSG="TEMP={temp}"
RATOS_ECHO MSG="PID calibration bed heater at {temp}°C..."
PID_CALIBRATE HEATER=heater_bed TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_CHAMBER_HEATER]
description = Perform a PID calibration test for the chamber heater.
gcode =
{% set temp = params.TEMP|default(150)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_CHAMBER_HEATER" MSG="TEMP={temp}"
{% if printer["heater_generic chamber_heater"] is defined %}
RATOS_ECHO MSG="PID calibration chamber heater at {temp}°C..."
PID_CALIBRATE HEATER=chamber_heater TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_heater" %}
{% set link_text = "RatOS Chamber Heater" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber heater found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro INITIALIZE_PA_TUNING]
description = Start a pressure advance tuning tower.
gcode =
{% set start = params.START|default(0.0)|float %}
{% set factor = params.FACTOR|default(0.001)|float %}
{% set layer_number = printer["gcode_macro _ON_LAYER_CHANGE"].layer_number|default(0)|int %}
{% set is_printing_gcode = true if printer["gcode_macro START_PRINT"].is_printing_gcode|default(true)|lower == 'true' else false %}
{% if is_printing_gcode and layer_number < 2 %}
DEBUG_ECHO PREFIX="START_PA_TOWER" MSG="START: {start}, FACTOR: {factor}"
RATOS_ECHO MSG="Starting presssure advance tuning tower..."
TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START={start} FACTOR={factor}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro CHAMBER_FILTER_ON]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro CHAMBER_FILTER_OFF]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Deactivating chamber filter..."
_CHAMBER_FILTER_TURN_OFF
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro _CHAMBER_FILTER_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set chamber_filter_enable_at = printer["gcode_macro RatOS"].chamber_filter_enable_at|default('after_print_start')|lower %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_ON" MSG="at: {at}, chamber_filter_enable: {chamber_filter_enable}, chamber_filter_enable_at: {chamber_filter_enable_at}, chamber_filter_speed: {chamber_filter_speed}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if chamber_filter_enable_at == at %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON AT={at}
{% if chamber_filter_enable_at == "print_end" %}
_LED_CHAMBER_FILTER_ON
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_FILTER_OFF]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF" MSG="chamber_filter_enable: {chamber_filter_enable}, filter_disable_period: {filter_disable_period}, filter_disable_bed_temp: {filter_disable_bed_temp}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_period > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting {filter_disable_period} seconds before turning chamber filter off..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION={filter_disable_period}
{% endif %}
{% if filter_disable_bed_temp > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting for bed temp to cool down to {filter_disable_bed_temp}°C to turn filter off..."
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM=0 MAXIMUM={filter_disable_bed_temp}
_CHAMBER_FILTER_TURN_OFF
_LED_CHAMBER_FILTER_OFF
{% endif %}
{% endif %}
[delayed_gcode _CHAMBER_FILTER_OFF_TIMER]
gcode =
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF_TIMER" MSG="executed"
_CHAMBER_FILTER_TURN_OFF
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Chamber filter turned off!"
_LED_CHAMBER_FILTER_OFF
[gcode_macro _CHAMBER_FILTER_TURN_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_speed|default(0)|float %}
{% if at == "print_end" %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_disable_speed|default(0)|float %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION=0
SET_FAN_SPEED FAN=filter SPEED={chamber_filter_speed}
[gcode_macro _CHAMBER_FILTER_TURN_OFF]
gcode =
SET_FAN_SPEED FAN=filter SPEED=0
[gcode_macro _CHAMBER_FILTER_SANITY_CHECK]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_bed_temp > 0 and filter_disable_period > 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable, not both.")}
{% endif %}
{% if filter_disable_bed_temp == 0 and filter_disable_period == 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable.")}
{% endif %}
{% endif %}
[gcode_macro CHAMBER_HEATER_ON]
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(45)|int %}
_CHAMBER_HEATER_ON CHAMBER_TEMP={chamber_temp} IS_FROM_START_PRINT=False
[gcode_macro CHAMBER_HEATER_OFF]
gcode =
_CHAMBER_HEATER_OFF
[gcode_macro _CHAMBER_HEATER_ON]
variable_chamber_temp = 0
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set is_from_start_print = true if params.IS_FROM_START_PRINT|default(True)|lower == 'true' else false %}
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set chamber_heater_enable = true if printer["gcode_macro RatOS"].chamber_heater_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
{% set chamber_heater_preheating_temp = printer["gcode_macro RatOS"].chamber_heater_preheating_temp|default(150)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set chamber_heater_control_external_heater = true if printer["gcode_macro RatOS"].chamber_heater_control_external_heater|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_enable = true if printer["gcode_macro RatOS"].chamber_heater_air_circulation_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_fan_speed = printer["gcode_macro RatOS"].chamber_heater_air_circulation_fan_speed|default(0.35)|float %}
{% set chamber_heater_air_circulation_y_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_y_pos|default(0)|float %}
{% set chamber_heater_air_circulation_z_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_z_pos|default(100)|float %}
DEBUG_ECHO PREFIX="_CHAMBER_HEATER_ON" MSG="chamber_heater_enable: {chamber_heater_enable}, chamber_heater_preheating_temp: {chamber_heater_preheating_temp}, chamber_heater_heating_temp_offset: {chamber_heater_heating_temp_offset}, bed_temp: {bed_temp}, chamber_temp: {chamber_temp}, start_chamber_temp: {start_chamber_temp}"
{% if chamber_heater_enable and chamber_temp > 0 and chamber_heater_bed_temp > 0 %}
_LED_HEATING
RATOS_ECHO MSG="Preheating chamber to {(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}°C..."
{% set chamber_temp_sensor = "extruder" %}
{% if printer["dual_carriage"] is defined and default_toolhead == 1 %}
{% set chamber_temp_sensor = "extruder1" %}
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% set chamber_temp_sensor = "temperature_sensor chamber" %}
{% endif %}
{% set current_chamber_temp = printer['%s' % chamber_temp_sensor].temperature|int %}
{% set needs_heating = current_chamber_temp < (start_chamber_temp if start_chamber_temp > 0 else chamber_temp) %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_BEFORE_PREHEATING
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
{% if not is_from_start_print %}
MAYBE_HOME
{% endif %}
G0 Z{chamber_heater_air_circulation_z_pos} F{z_speed}
G0 Y{chamber_heater_air_circulation_y_pos} F{speed}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 1 else 0}
{% else %}
M106 S{(255 * chamber_heater_air_circulation_fan_speed)}
{% endif %}
{% else %}
{% if is_from_start_print %}
G0 Z{z} F{z_speed}
{% endif %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE={chamber_temp}
{% if needs_heating %}
M140 S{chamber_heater_bed_temp}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={chamber_heater_preheating_temp}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if needs_heating %}
_CHAMBER_HEATER_EXTRA_FAN_ON
{% endif %}
{% if needs_heating %}
TEMPERATURE_WAIT SENSOR="{chamber_temp_sensor}" MINIMUM={(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% endif %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED=0
_CHAMBER_FILTER_ON AT="before_print_start"
{% endif %}
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
G28 Z
{% endif %}
{% endif %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_AFTER_PREHEATING
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% if printer["heater_generic chamber_heater"] is defined %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined and chamber_heater_control_external_heater %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
_LED_SUCCESS
{% endif %}
[gcode_macro _CHAMBER_HEATER_OFF]
gcode =
RATOS_ECHO MSG="Deactivating chamber heater..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=0
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE=0
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
_CHAMBER_HEATER_EXTRA_FAN_OFF
[delayed_gcode _CHAMBER_HEATER_CONTROL]
initial_duration = 0.
gcode =
{% set chamber_temp = printer["gcode_macro _CHAMBER_HEATER_ON"].chamber_temp|default(0)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set current_chamber_temp = printer['temperature_sensor chamber'].temperature|int %}
{% if current_chamber_temp < chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if current_chamber_temp >= chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_ON]
gcode =
{% set chamber_heater_extra_fan_speed = printer["gcode_macro RatOS"].chamber_heater_extra_fan_speed|default(0.0)|float %}
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
{% if chamber_heater_extra_fan_speed > 0 %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED={chamber_heater_extra_fan_speed}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_OFF]
gcode =
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED=0
{% endif %}
[gcode_macro _USER_CHAMBER_HEATER_BEFORE_PREHEATING]
description = Will be executed before chamber preheating, only if heating is needed.
gcode =
[gcode_macro _USER_CHAMBER_HEATER_AFTER_PREHEATING]
description = Will be executed after chamber preheating, only if heating was needed.
gcode =
[gcode_macro _LED_START_PRINTING]
gcode =
_LED_ACTION
[gcode_macro _LED_START_PRINTING_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_PRINTING]
gcode =
_LED_ON TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_PAUSE]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_ON]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_OFF]
gcode =
_LED_STANDBY
[gcode_macro _LED_LOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_LOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_RUNOUT]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_CLOG]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_UNLOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_UNLOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_DEACTIVATE_TOOLHEAD]
gcode =
_LED_OFF TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_STANDBY]
gcode =
_LED_STANDBY TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_WAKEUP]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_MOTORS_OFF]
gcode =
_LED_STANDBY
_LED_VAOC_OFF
[gcode_macro _LED_INPUT_SHAPER_START]
gcode =
_LED_ACTION
[gcode_macro _LED_INPUT_SHAPER_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_START]
gcode =
_LED_ACTION
[gcode_macro _LED_BEACON_CALIBRATION_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_VAOC_ON]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=1.0 GREEN=1.0 BLUE=1.0
{% endif %}
[gcode_macro _LED_VAOC_OFF]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=0.0 GREEN=0.0 BLUE=0.0
{% endif %}
[gcode_macro _LED_ACTION]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_action %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SUCCESS]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_success %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_HEATING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_heating %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_COOLING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_cooling %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ERROR]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_error %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ON]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_on %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_OFF]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_off %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_STANDBY]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_standby %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
{% if toolhead >= 0 %}
{% if printer['neopixel nozzle_led_t%s' % toolhead] is defined %}
SET_LED LED={'nozzle_led_t%s' % toolhead} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% else %}
{% if printer['neopixel nozzle_led_t0'] is defined %}
SET_LED LED={'nozzle_led_t0'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% if printer['neopixel nozzle_led_t1'] is defined %}
SET_LED LED={'nozzle_led_t1'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% endif %}
_USER_LED_SET { rawparams }
[gcode_macro _USER_LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
[gcode_macro LOAD_FILAMENT]
description = Loads new filament. Note: be careful with PETG, make sure you inspect the tip of your filament before loading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% if filament_name == '' or filament_type == '' %}
{% set filament_name = 'unknown' %}
{% set filament_type = 'unknown' %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_LOAD_FILAMENT TEMP={temp} NAME={filament_name} TYPE={filament_type}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_LOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME={filament_name} TYPE={filament_type}
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _DEFAULT_LOAD_FILAMENT]
description = Load filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_LOAD_FILAMENT" MSG="TEMP={temp}"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=load_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
_LOAD_FILAMENT TOOLHEAD=0
RESTORE_GCODE_STATE NAME=load_state
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD=0
[gcode_macro _IDEX_LOAD_FILAMENT]
description = Load filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_LOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
_LOAD_FILAMENT TOOLHEAD={toolhead} TEMP={temp}
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into hotend.."
G92 E0
G0 E{extruder_gear_to_cooling_position_distance} F{extruder_load_speed}
G92 E0
M400
RATOS_ECHO MSG="Filament loaded into hotend."
[gcode_macro _LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set load_speed = printer["gcode_macro T%s" % toolhead].filament_load_speed|float * 60 %}
{% set filament_loading_nozzle_offset = printer["gcode_macro T%s" % toolhead].filament_loading_nozzle_offset|float %}
{% set cooling_position_to_nozzle_distance = printer["gcode_macro T%s" % toolhead].cooling_position_to_nozzle_distance|float %}
{% set purge_after_load = printer["gcode_macro T%s" % toolhead].purge_after_load|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into nozzle... Please wait!"
G92 E0
G0 E{cooling_position_to_nozzle_distance + filament_loading_nozzle_offset} F{load_speed}
G92 E0
G4 P1000
_PURGE_FILAMENT TOOLHEAD={toolhead} E={purge_after_load}
RATOS_ECHO MSG="Filament loaded into nozzle!"
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
{% set filament_grabbing_length = printer["gcode_macro T%s" % toolhead].filament_grabbing_length|float %}
{% set filament_grabbing_speed = printer["gcode_macro T%s" % toolhead].filament_grabbing_speed|float %}
{% set resume_after_insert = true if printer["gcode_macro T%s" % toolhead].resume_after_insert|default(true)|lower == 'true' else false %}
{% set enable_insert_detection = true if printer["gcode_macro T%s" % toolhead].enable_insert_detection|default(true)|lower == 'true' else false %}
{% set current_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% if enable_insert_detection %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="toolhead: {toolhead}, filament_grabbing_length: {filament_grabbing_length}, filament_grabbing_speed: {filament_grabbing_speed}, current_idex_mode: {current_idex_mode}"
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
FORCE_MOVE STEPPER={'extruder%s' % ('' if toolhead == 0 else toolhead)} DISTANCE={filament_grabbing_length} VELOCITY={filament_grabbing_speed}
M400
{% if printer.pause_resume.is_paused %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% if resume_after_insert %}
RESUME
{% endif %}
{% else %}
{% if not printer.virtual_sdcard.is_active %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
[gcode_macro _PURGE_BEFORE_UNLOAD]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set purge_before_unload = printer["gcode_macro T%s" % toolhead].purge_before_unload|float %}
DEBUG_ECHO PREFIX="_PURGE_BEFORE_UNLOAD" MSG="TOOLHEAD: {toolhead}"
{% if purge_before_unload > 0 %}
G92 E0
G0 E{purge_before_unload} F300
G92 E0
M400
{% endif %}
[gcode_macro _PURGE_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set e = params.E|int %}
{% set r = params.R|default(0)|int %}
DEBUG_ECHO PREFIX="_PURGE_FILAMENT" MSG="TOOLHEAD: {toolhead}, E: {e}"
{% if e > 0 %}
G92 E0
G0 E{e} F300
G92 E0
M400
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={0.4 if toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={0.4 if toolhead == 1 else 0}
{% else %}
M106 S{(255 * 0.4)}
{% endif %}
{% endif %}
G4 P3000
{% if r > 0 %}
G92 E0
G0 E-{r} F300
G92 E0
M400
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_PARKING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_PARKING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_LOADING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_LOADING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% if act_t == toolhead %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{loading_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CLEANING_MOVE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined and printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% set cleaning_position = loading_position %}
{% if loading_position == parking_position %}
{% if loading_position > 0 %}
{% set cleaning_position = loading_position - 30 %}
{% else %}
{% set cleaning_position = loading_position + 30 %}
{% endif %}
{% endif %}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _START_PRINT_BED_MESH]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
SET_MACRO_TRAVEL_SETTINGS
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set X=[params.X0|default(-1)|float, params.X1|default(-1)|float] %}
{% set Y=[params.Y0|default(-1)|float, params.Y1|default(-1)|float] %}
DEBUG_ECHO PREFIX="_START_PRINT_BED_MESH" MSG="idex_mode: {idex_mode}, X: {X}, Y: {Y}"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set X=[0, printable_x_max] %}
{% endif %}
{% set beacon_bed_mesh_scv = printer["gcode_macro RatOS"].beacon_bed_mesh_scv|default(25)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% if printer.configfile.settings.beacon is defined and not beacon_contact_bed_mesh %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={beacon_bed_mesh_scv}
{% endif %}
{% set default_profile = printer["gcode_macro RatOS"].bed_mesh_profile|default('ratos') %}
{% if printer["gcode_macro RatOS"].calibrate_bed_mesh|lower == 'true' %}
BED_MESH_CLEAR
{% if printer["gcode_macro RatOS"].adaptive_mesh|lower == 'true' %}
CALIBRATE_ADAPTIVE_MESH PROFILE={default_profile} X0={X[0]} X1={X[1]} Y0={Y[0]} Y1={Y[1]} T={params.T|int} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={idex_mode}
{% else %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% endif %}
BED_MESH_PROFILE LOAD={default_profile}
{% elif printer["gcode_macro RatOS"].bed_mesh_profile is defined %}
BED_MESH_CLEAR
BED_MESH_PROFILE LOAD={printer["gcode_macro RatOS"].bed_mesh_profile}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
[gcode_macro CALIBRATE_ADAPTIVE_MESH]
gcode =
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set default_profile = params.PROFILE %}
{% set x0 = params.X0|default(-1)|float %}
{% set y0 = params.Y0|default(-1)|float %}
{% set x1 = params.X1|default(-1)|float %}
{% set y1 = params.Y1|default(-1)|float %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Recieved coordinates X0={x0} Y0={y0} X1={x1} Y1={y1}"
{% if x0 >= x1 or y0 >= y1 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Invalid coordinates received. Please check your slicer settings. Falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float %}
{% set mesh_x0 = [[x0, max_x]|min, min_x]|max %}
{% set mesh_y0 = [[y0, max_y]|min, min_y]|max %}
{% set mesh_x1 = [[x1, max_x]|min, min_x]|max %}
{% set mesh_y1 = [[y1, max_y]|min, min_y]|max %}
{% if mesh_x0 == min_x and mesh_y0 == min_y and mesh_x1 == max_x and mesh_y1 == max_y %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Print is using the full bed, falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
DEPLOY_PROBE
{% endif %}
{% set probe_count_x = mesh_config.probe_count.split(",")[0]|int %}
{% if mesh_config.probe_count.split(",")|length == 2 %}
{% set probe_count_y = mesh_config.probe_count.split(",")[1]|int %}
{% else %}
{% set probe_count_y = mesh_config.probe_count.split(",")[0]|int %}
{% endif %}
{% set probe_x_step = (max_x - min_x) / probe_count_x %}
{% set probe_y_step = (max_y - min_y) / probe_count_y %}
{% set mesh_count_x = ([(mesh_x1 - mesh_x0) / probe_x_step, 3]|max)|int %}
{% set mesh_count_y = ([(mesh_y1 - mesh_y0) / probe_y_step, 3]|max)|int %}
{% set min_mesh_count = [mesh_count_x, mesh_count_y]|min %}
{% set max_mesh_count = [mesh_count_x, mesh_count_y]|max %}
{% set algorithm = mesh_config.algorithm %}
{% if algorithm|lower == 'lagrange' and max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="cannot exceed a probe_count of 6 when using lagrange interpolation. Falling back to bicubic interpolation."
{% set algorithm = 'bicubic' %}
{% endif %}
{% if algorithm|lower == 'bicubic' and min_mesh_count < 4 %}
{% if max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="invalid probe_count option when using bicubic interpolation. Combination of 3 points on one axis with more than 6 on another is not permitted. Forcing minimum mesh count to be 4."
{% set min_mesh_count = 4 %}
{% else %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="bicubic interpolation with a probe_count of less than 4 points detected. Forcing lagrange interpolation."
{% set algorithm = 'lagrange' %}
{% endif %}
{% endif %}
{% set mesh_count_x = ([min_mesh_count, mesh_count_x]|max)|int %}
{% set mesh_count_x = ([max_mesh_count, mesh_count_x]|min)|int %}
{% set mesh_count_y = ([min_mesh_count, mesh_count_y]|max)|int %}
{% set mesh_count_y = ([max_mesh_count, mesh_count_y]|min)|int %}
{% set should_prime = printer["gcode_macro RatOS"].nozzle_priming == 'primeblob' %}
{% if printer["dual_carriage"] is not defined %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% else %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% endif %}
{% if printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 != 0 and probe_first %}
{% set probe_first = false %}
{% elif printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 == 0 and not probe_first %}
{% set probe_first = true %}
{% endif %}
{% if should_prime and probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="mesh coordinates X0={mesh_x0} Y0={mesh_y0} X1={mesh_x1} Y1={mesh_y1}"
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% if should_prime and not probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
STOW_PROBE
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M84]
rename_existing = M84.1
gcode =
M84.1
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
{% if printer["dual_carriage"] is defined %}
_SET_TOOLHEAD_OFFSET T={printer["gcode_macro RatOS"].default_toolhead|int} MOVE=0
SET_GCODE_VARIABLE MACRO=SET_PRESSURE_ADVANCE VARIABLE=snyc_toolheads VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro _VAOC"] is defined %}
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started VALUE=False
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started_at_temp VALUE=False
{% endif %}
SET_GCODE_OFFSET X=0 Y=0 Z=0 MOVE=0
_IDEX_SINGLE INIT=1
{% endif %}
SET_SKEW CLEAR=1
_LED_MOTORS_OFF
[gcode_macro M104]
rename_existing = M104.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
DEBUG_ECHO PREFIX="M104" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set temperature_offset_t0 = printer["gcode_macro T0"].temperature_offset|default(0)|int %}
{% set temperature_offset_t1 = printer["gcode_macro T1"].temperature_offset|default(0)|int %}
{% set s0 = [s + temperature_offset_t0, 0]|max %}
{% set s1 = [s + temperature_offset_t1, 0]|max %}
{% if temperature_offset_t0 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t0}°C added to toolhead T0."
{% endif %}
{% if temperature_offset_t1 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t1}°C added to toolhead T1."
{% endif %}
{% else %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
M104.1 S{s0} T0
M104.1 S{s1} T1
{% else %}
M104.1 S{s} T{t}
{% endif %}
{% endif %}
[gcode_macro M109]
rename_existing = M109.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
DEBUG_ECHO PREFIX="M109" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M109" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
M109.1 S{s} T{t}
{% endif %}
[gcode_macro SET_HEATER_TEMPERATURE]
rename_existing = SET_HEATER_TEMPERATURE_BASE
gcode =
{% set heater = params.HEATER|default("") %}
{% set target = params.TARGET|default(0)|int %}
DEBUG_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="heater: {heater}, target: {target}"
{% if heater|lower == "extruder" or heater|lower == "extruder1" %}
{% set t = 0 if heater|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and target > 0 %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set target = [target + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
SET_HEATER_TEMPERATURE_BASE HEATER="{heater}" TARGET={target}
[gcode_macro TEMPERATURE_WAIT]
rename_existing = TEMPERATURE_WAIT_BASE
gcode =
{% set sensor = params.SENSOR|default("") %}
{% set minimum = params.MINIMUM|default(-1)|int %}
{% set maximum = params.MAXIMUM|default(-1)|int %}
DEBUG_ECHO PREFIX="TEMPERATURE_WAIT" MSG="sensor: {sensor}, minimum: {minimum}, maximum: {maximum}"
{% if sensor|lower == "extruder" or sensor|lower == "extruder1" %}
{% set t = 0 if sensor|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and (minimum > 0 or maximum > 0) %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% if minimum > -1 %}
{% set minimum = [minimum + temperature_offset, 0]|max %}
{% endif %}
{% if maximum > -1 %}
{% set maximum = [maximum + temperature_offset, 0]|max %}
{% endif %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% if minimum > -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum} MAXIMUM={maximum}
{% elif minimum > -1 and maximum == -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum}
{% elif minimum == -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MAXIMUM={maximum}
{% endif %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature for toolhead T{t} reached."
[gcode_macro SET_GCODE_OFFSET]
rename_existing = SET_GCODE_OFFSET_ORG
gcode =
SET_GCODE_OFFSET_ORG { rawparams }
{% if printer.configfile.settings.beacon is defined and (params.Z_ADJUST is defined or params.Z is defined) %}
_BEACON_APPLY_RUNTIME_MULTIPLIER
{% endif %}
[gcode_macro SDCARD_PRINT_FILE]
rename_existing = SDCARD_PRINT_FILE_BASE
gcode =
{% if printer["ratos"] is defined %}
PROCESS_GCODE_FILE { rawparams }
{% else %}
SDCARD_PRINT_FILE_BASE { rawparams }
{% endif %}
[gcode_macro SKEW_PROFILE]
rename_existing = SKEW_PROFILE_BASE
variable_loaded_profile = ""
gcode =
{% if params.LOAD is defined %}
{% if printer.configfile.settings["skew_correction %s" % params.LOAD] is defined %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='"{params.LOAD}"'
{% endif %}
{% endif %}
SKEW_PROFILE_BASE { rawparams }
[gcode_macro SET_SKEW]
rename_existing = SET_SKEW_BASE
gcode =
{% if params.CLEAR is defined %}
{% if params.CLEAR|default(0)|int == 1 %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='""'
{% endif %}
{% endif %}
SET_SKEW_BASE { rawparams }
[gcode_macro SET_VELOCITY_LIMIT]
rename_existing = SET_VELOCITY_LIMIT_BASE
gcode =
{% if params.ACCEL_TO_DECEL is defined %}
{% if params.ACCEL is defined %}
{% set accel = params.ACCEL|float %}
{% else %}
{% set accel = printer.toolhead.max_accel|float %}
{% endif %}
{% if params.VELOCITY is defined %}
{% set velocity = params.VELOCITY|float %}
{% else %}
{% set velocity = printer.toolhead.max_velocity|float %}
{% endif %}
{% if params.SQUARE_CORNER_VELOCITY is defined %}
{% set scv = params.SQUARE_CORNER_VELOCITY|float %}
{% else %}
{% set scv = printer.toolhead.square_corner_velocity|float %}
{% endif %}
{% set mcr = params.ACCEL_TO_DECEL|float / accel %}
DEBUG_ECHO PREFIX="SET_VELOCITY_LIMIT" MSG="ACCEL={accel}, VELOCITY={velocity}, SQUARE_CORNER_VELOCITY={scv}, MINIMUM_CRUISE_RATIO={mcr}"
SET_VELOCITY_LIMIT_BASE ACCEL={accel} VELOCITY={velocity} SQUARE_CORNER_VELOCITY={scv} MINIMUM_CRUISE_RATIO={1-mcr}
{% else %}
SET_VELOCITY_LIMIT_BASE { rawparams }
{% endif %}
[gcode_macro _START_PRINT_PARK]
gcode =
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_x = printer["gcode_macro RatOS"].start_print_park_x %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% endif %}
{% if printer["dual_carriage"] is defined and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
{% if printer["gcode_macro RatOS"].start_print_park_x is defined and printer["gcode_macro RatOS"].start_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="start_print_park_x is ignored for IDEX printers"
{% endif %}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={start_print_park_in} X={start_print_park_x}
G0 Z{z} F{z_speed}
[gcode_macro _END_PRINT_PARK]
gcode =
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro RatOS"].end_print_park_x is defined and printer["gcode_macro RatOS"].end_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="end_print_park_x is ignored for IDEX printers"
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={printer["gcode_macro RatOS"].end_print_park_in} X={printer["gcode_macro RatOS"].end_print_park_x}
[gcode_macro _PARK]
gcode =
{% set x = params.X %}
{% set location = params.LOCATION|default('back')|lower %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set nozzle_priming = printer["gcode_macro RatOS"].nozzle_priming|lower %}
CACHE_TOOLHEAD_SETTINGS KEY="park"
SET_MACRO_TRAVEL_SETTINGS
{% if x != '' %}
{% if x|float >= printer.toolhead.axis_minimum.x + 5 and x|float <= printable_x_max - 5 %}
{% set park_x = x|float %}
{% else %}
{action_respond_info('The requested X co-ordinate is outside the defined axis bounds - using defaults')}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% else %}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% set park_y = printable_y_max - 15 %}
{% if location == 'front' %}
{% set park_y = printer.toolhead.axis_minimum.y + 5 %}
{% elif location == 'center' %}
{% set park_y = printable_y_max / 2 %}
{% elif location == 'primeblob' and printer["dual_carriage"] is defined %}
{% set park_y = printable_y_max - 15 %}
{% endif %}
{% if location == 'primeblob' and printer["dual_carriage"] is not defined %}
{% if (nozzle_priming == 'primeblob' or nozzle_priming == 'primeline') %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set park_x = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set park_x = printable_x_max - 5 %}
{% else %}
{% set park_x = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set park_y = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set park_y = printable_y_max - 5 %}
{% else %}
{% set park_y = nozzle_prime_start_y|float %}
{% endif %}
{% endif %}
{% endif %}
G90
{% if printer["dual_carriage"] is not defined %}
G0 X{park_x} Y{park_y} F{speed}
{% else %}
G0 Y{park_y} F{speed}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="park"
[gcode_macro SAVE_PROBE_RESULT]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
{% set last_z_offset = 9999.9 %}
{% if printer.configfile.settings.beacon is defined %}
{% set current_z = printer.toolhead.position.z|float %}
{% if beacon_contact_prime_probing %}
{% set last_z_offset = printer.beacon.last_z_result %}
{% else %}
{% set last_z_offset = printer.beacon.last_sample.dist - current_z %}
{% endif %}
{% elif printer.configfile.settings.bltouch is defined %}
{% set config_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% elif printer.configfile.settings.probe is defined %}
{% set config_offset = printer.configfile.settings.probe.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Saving offset adjustment of {last_z_offset} in {params.VARIABLE|default('last_z_offset')}"
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE={params.VARIABLE|default('last_z_offset')} VALUE={last_z_offset}
[gcode_macro PROBE_FOR_PRIMING]
gcode =
{% set probe_for_priming_disable_mesh_constraints = true if printer["gcode_macro RatOS"].probe_for_priming_disable_mesh_constraints|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower != 'false' %}
SAVE_GCODE_STATE NAME=probe_for_priming_state
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the prime location.."
CACHE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
SET_MACRO_TRAVEL_SETTINGS
{% set t = params.TOOLHEAD|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% if idex_mode == '' %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% if t == 0 %}
{% set x_start = 5 %}
{% else %}
{% set x_start = printable_x_max - 5 %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% endif %}
{% endif %}
{% set z = printer.configfile.settings.bed_mesh.horizontal_move_z|float %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% if printer.configfile.settings.bltouch is defined %}
{% set x_offset = printer.configfile.settings.bltouch.x_offset|float %}
{% set y_offset = printer.configfile.settings.bltouch.y_offset|float %}
{% set z_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% elif printer.configfile.settings.probe is defined %}
{% set x_offset = printer.configfile.settings.probe.x_offset|float %}
{% set y_offset = printer.configfile.settings.probe.y_offset|float %}
{% set z_offset = printer.configfile.settings.probe.z_offset|float %}
{% elif printer.configfile.settings.beacon is defined %}
{% set x_offset = printer.configfile.settings.beacon.x_offset|float %}
{% set y_offset = printer.configfile.settings.beacon.y_offset|float %}
{% set z_offset = printer.configfile.settings.beacon.trigger_distance|float %}
{% else %}
{ action_raise_error("No probe, beacon or bltouch section found. Adaptive priming only works with a [probe], [beacon] or [bltouch] section defined.") }
{% endif %}
{% if z < z_offset %}
{ action_raise_error("Horizontal move Z ({z}) is below your probe's Z offset ({z_offset}). Please adjust your horizontal_move_z setting in [bed_mesh] to be above {z}.") }
{% endif %}
{% if not probe_for_priming_disable_mesh_constraints %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float - x_offset %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float - y_offset %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float - x_offset %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float - y_offset %}
{% set x_start = [[x_start, max_x]|min, min_x]|max %}
{% set y_start = [[y_start, max_y]|min, min_y]|max %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the start of the prime location at {x_start}, {y_start}"
G90
M83
G0 Z{z} F{z_speed}
G1 X{x_start} Y{y_start} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result
{% endif %}
{% if idex_mode == '' %}
{% set x_end = x_start %}
{% set y_end = y_start + 45 %}
{% else %}
{% if t==1 %}
{% set x_end = x_start - 45 %}
{% else %}
{% set x_end = x_start + 45 %}
{% endif %}
{% set y_end = y_start %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the end of the prime location at {x_end}, {y_end}"
G1 X{x_end} Y{y_end} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result
{% endif %}
RESTORE_GCODE_STATE NAME=probe_for_priming_state
RESTORE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
{% endif %}
[gcode_macro RESET_PRIME_PROBE_STATE]
gcode =
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result VALUE=None
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result_t1 VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result_t1 VALUE=None
{% endif %}
[gcode_macro PROBE_CURRENT_POSITION]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
SAVE_GCODE_STATE NAME=probe_current_position_state
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
ASSERT_PROBE_DEPLOYED
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_prime_probing %}
PROBE PROBE_METHOD=contact SAMPLES=1
{% else %}
PROBE
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
BEACON_QUERY
{% else %}
RESTORE_GCODE_STATE NAME=probe_current_position_state MOVE=1 MOVE_SPEED={printer["gcode_macro RatOS"].macro_z_speed|float}
{% endif %}
[gcode_macro PRIME_BLOB]
description = Prints a primeblob, used internally, if configured, as part of the START_PRINT macro.
variable_x_offset = 5
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="prime_blob"
SET_MACRO_TRAVEL_SETTINGS
RATOS_ECHO PREFIX="Priming" MSG="Priming nozzle with prime blob.."
{% set current_toolhead = 0 %}
{% set target_idex_mode = '' %}
{% set extruder = 'extruder' %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE is defined %}
{% set target_idex_mode = params.IDEX_MODE|default('')|lower %}
{% else %}
{ action_raise_error("IDEX_MODE parameter not found for PRIME_BLOB macro. This is likely a bug.") }
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Priming in IDEX {target_idex_mode} mode.."
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set current_toolhead = 1 if current_idex_mode=='primary' else 0 %}
{% set extruder = 'extruder1' if current_toolhead == 1 else 'extruder' %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
SAVE_GCODE_STATE NAME=prime_blob_state
{% endif %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set fan_speed = printer["gcode_macro RatOS"].nozzle_prime_bridge_fan|float %}
{% set nozzle_diameter = printer.configfile.settings[extruder].nozzle_diameter|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set has_start_offset_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) != 9999.9 %}
{% if printer["dual_carriage"] is defined %}
{% set has_start_offset_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) != 9999.9 %}
{% endif %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_z_height = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set nozzle_prime_direction = printer["gcode_macro RatOS"].nozzle_prime_direction|lower %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% if target_idex_mode == '' %}
{% set x_factor = 0 %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% set y_factor = 1 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% set y_factor = -1 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% if nozzle_prime_start_y|float < printable_y_max / 2 %}
{% set y_factor = 1 %}
{% else %}
{% set y_factor = -1 %}
{% endif %}
{% endif %}
{% if nozzle_prime_direction == 'forwards' %}
{% set y_factor = 1 %}
{% elif nozzle_prime_direction == 'backwards' %}
{% set y_factor = -1 %}
{% endif %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% else %}
{% set z = start_print_park_z_height %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% set y_factor = 0 %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set x_start = center_x / 2 + 5 %}
{% set x_factor = 1 %}
{% else %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% if current_toolhead == 0 %}
{% set x_start = 55 %}
{% set x_factor = -1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 55 %}
{% set x_factor = 1 %}
{% endif %}
{% else %}
{% if current_toolhead == 0 %}
{% set x_start = 5 %}
{% set x_factor = 1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 5 %}
{% set x_factor = -1 %}
{% endif %}
{% endif %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_x_max - 5 %}
{% endif %}
{% set z = 10 %}
{% endif %}
{% set start_z_offset = 0 %}
{% set end_z_offset = 0 %}
{% if has_start_offset_t0 %}
{% set start_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) %}
{% set end_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_end_result|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t0) ) }
{% endif %}
{% if end_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t0) ) }
{% endif %}
{% set start_z_offset = start_z_probe_result_t0 %}
{% set end_z_offset = end_z_probe_result_t0 %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if current_toolhead == 1 or both_toolheads or target_idex_mode == "copy" or target_idex_mode == "mirror" %}
{% if has_start_offset_t1 %}
{% set start_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) %}
{% set end_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_end_result_t1|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t1) ) }
{% endif %}
{% if end_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t1) ) }
{% endif %}
{% set start_z_offset = [start_z_offset, start_z_probe_result_t1]|max %}
{% set end_z_offset = [end_z_offset, start_z_probe_result_t1]|max %}
{% endif %}
{% endif %}
{% if target_idex_mode != 'copy' and target_idex_mode != 'mirror' %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% set original_start_z_offset = start_z_offset %}
{% set original_end_z_offset = end_z_offset %}
{% set start_z_offset = original_end_z_offset %}
{% set end_z_offset = original_start_z_offset %}
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={current_toolhead}
{% endif %}
DEBUG_ECHO PREFIX="PRIME_BLOB" MSG="x_start: {x_start}, y_start: {y_start}, x_factor: {x_factor}, y_factor: {y_factor}, z: {z}, start_z_offset: {start_z_offset}, end_z_offset: {end_z_offset}"
G90
M83
RATOS_ECHO PREFIX="Priming" MSG="Lifting Z to {z}.."
G0 Z{z} F{z_speed}
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% if start_print_park_in != 'primeblob' %}
G1 X{x_start} F{speed}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% endif %}
{% else %}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% if target_idex_mode=="copy" or target_idex_mode=="mirror" %}
RATOS_ECHO PREFIX="Priming" MSG="Mirroring move to {x_start}, {y_start} along the edge of the print area.."
_IDEX_MIRROR PRIMING=1
{% else %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% endif %}
G1 X{x_start} F{speed}
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Starting prime blob.."
G1 Z{0.5 + start_z_offset} F{z_speed}
G1 Y{y_start} F{speed}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
M106 S{fan_speed}
G1 Z5 F100 E5
G92 E0
RATOS_ECHO PREFIX="Priming" MSG="Bridging with {((fan_speed/255) * 100)|int}% fan speed.."
G1 F3000 X{x_start + (15 * x_factor)} Y{y_start + (15 * y_factor)} E{1 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (20 * x_factor)} Y{y_start + (20 * y_factor)} Z{3.8 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (34 * x_factor)} Y{y_start + (34 * y_factor)} Z{2.6 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (38 * x_factor)} Y{y_start + (38 * y_factor)} Z{1.4 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (42 * x_factor)} Y{y_start + (42 * y_factor)} Z{0.2 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
M106 S0
G1 F3000 X{x_start + (46 * x_factor)} Y{y_start + (46 * y_factor)} Z{0.2 + end_z_offset} E0.6
G1 F{speed} X{x_start + (50 * x_factor)} Y{y_start + (50 * y_factor)}
{% if target_idex_mode == "copy" or target_idex_mode == "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if target_idex_mode == "copy" %}
{% if first_y >= 0 %}
_IDEX_COPY DANCE=0 Y={first_y}
{% else %}
_IDEX_COPY DANCE=0 Y={params.Y1}
{% endif %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
RESTORE_GCODE_STATE NAME=prime_blob_state
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="prime_blob"
G92 E0
[gcode_macro UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% set temp = params.TEMP|default(220)|int %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_UNLOAD_FILAMENT TEMP={temp} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _LEGACY_UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set unload_speed = 5 * 60 %}
{% set unload_length = printer["gcode_macro RatOS"].filament_unload_length|float %}
M117 Unloading filament...
G0 E10 F300
G0 E-5 F3600
G4 P3000
G0 E5 F6000
G0 E-15 F6000
G0 E-{unload_length} F{unload_speed}
_CLEANING_MOVE TOOLHEAD={toolhead}
M117 Filament unloaded!
RESPOND MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _DEFAULT_UNLOAD_FILAMENT]
description = Unload filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_UNLOAD_FILAMENT" MSG="TEMP: {temp}"
_LED_UNLOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=unload_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD=0 NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TOOLHEAD=0
{% endif %}
RESTORE_GCODE_STATE NAME=unload_state
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD=0
[gcode_macro _IDEX_UNLOAD_FILAMENT]
description = Unload filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_UNLOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead}
{% endif %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Unloading filament from nozzle to cooling zone... Please wait!"
_PURGE_BEFORE_UNLOAD TOOLHEAD={toolhead}
{% if printer["gcode_macro _UNLOAD_WITHOUT_TIP_FORMING"] is defined %}
_UNLOAD_WITHOUT_TIP_FORMING TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_UNLOAD_WITH_TIP_FORMING NAME='{filament_name}' TYPE='{filament_type}'
{% endif %}
G4 P3000
[gcode_macro _UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
{% set tooolhead_sensor_to_extruder_gear_distance = printer["gcode_macro T%s" % toolhead].tooolhead_sensor_to_extruder_gear_distance|float %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER" MSG="TOOLHEAD: {toolhead}"
G0 E-{extruder_gear_to_cooling_position_distance + tooolhead_sensor_to_extruder_gear_distance + 50} F{extruder_load_speed}
RATOS_ECHO MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _UNLOAD_WITH_TIP_FORMING]
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% if filament_name != '' and filament_type != '' %}
_UNLOAD_KNOWN_FILAMENT NAME={filament_name} TYPE={filament_type}
{% else %}
_UNLOAD_UNKNOWN_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _UNLOAD_KNOWN_FILAMENT]
description = User overrideable tip forming macro if slicer filament profiles are known
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
RATOS_ECHO PREFIX="FILAMENT TYPE" MSG='{filament_type}'
RATOS_ECHO PREFIX="FILAMENT PROFILE" MSG='{filament_name}'
{% if filament_name == "Prusament PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% elif filament_name == "Nobufil PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% else %}
RATOS_ECHO PREFIX="_UNLOAD_KNOWN_FILAMENT" MSG="Filament profile not found!"
_UNLOAD_UNKNOWN_FILAMENT
{% endif %}
[gcode_macro _UNLOAD_UNKNOWN_FILAMENT]
description = User overrideable standard tip forming macro
gcode =
DEBUG_ECHO PREFIX="_UNLOAD_UNKNOWN_FILAMENT" MSG="Using standard tip forming macro!"
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
[gcode_macro _TIP_FORMING]
gcode =
{% set cooling_moves = params.COOLING_MOVES|default(4)|int %}
{% set cooling_move_length = params.COOLING_MOVE_LENGTH|default(10)|float %}
{% set start_cooling_speed = params.START_COOLING_SPEED|default(10)|float * 60 %}
{% set end_cooling_speed = params.END_COOLING_SPEED|default(50)|float * 60 %}
{% if cooling_moves == 0 %}
{% set cooling_move_length = 0 %}
{% endif %}
{% set dip = true if params.DIP|default(false)|lower == "true" else false %}
{% set dip_length = params.DIP_LENGTH|default(22)|float %}
{% set dip_speed = params.DIP_SPEED|default(30)|float * 60 %}
{% set dip_retract_speed = params.DIP_RETRACT_SPEED|default(70)|float * 60 %}
{% set retract_length = params.RETRACT_LENGTH|default(18)|float %}
{% set start_retract_speed = params.START_RETRACT_SPEED|default(120)|float * 60 %}
{% set end_retract_speed = params.END_RETRACT_SPEED|default(20)|float * 60 %}
DEBUG_ECHO PREFIX="_TIP_FORMING" MSG="cooling_moves: {cooling_moves}, cooling_move_length: {cooling_move_length}, start_cooling_speed: {start_cooling_speed}, end_cooling_speed: {end_cooling_speed}, dip: {dip}, dip_length: {dip_length}, dip_speed: {dip_speed}, dip_retract_speed: {dip_retract_speed}, retract_length: {retract_length}, start_retract_speed: {start_retract_speed}, end_retract_speed: {end_retract_speed}"
M220 S100
G92 E0
{% set retract = retract_length + cooling_move_length / 2 - 15 %}
G1 E-15 F{start_retract_speed}
G1 E-{0.7 * retract} F{1.0 * end_retract_speed}
G1 E-{0.2 * retract} F{0.5 * end_retract_speed}
G1 E-{0.1 * retract} F{0.3 * end_retract_speed}
G92 E0
{% if cooling_moves > 0 %}
{% set i = (end_cooling_speed - start_cooling_speed) / (2 * cooling_moves - 1) %}
{% for m in range(cooling_moves) %}
G1 E{cooling_move_length} F{(start_cooling_speed + i * m * 2)}
G1 E-{cooling_move_length} F{(start_cooling_speed + i * (m * 2 + 1))}
{% endfor %}
{% endif %}
G92 E0
{% if dip %}
G1 E{dip_length} F{dip_speed}
G4 P100
G1 E-{dip_length} F{dip_retract_speed}
{% endif %}
G92 E0
M400
[gcode_macro _ON_FILAMENT_SENSOR_BUTTON_PRESSED]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_SENSOR_BUTTON_PRESSED" MSG="TOOLHEAD: {toolhead}"
{% if not printer.virtual_sdcard.is_active %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_FILAMENT_END]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set clogged = true if params.CLOGGED|default(false)|lower == 'true' else false %}
{% set unload_after_runout = printer["gcode_macro T%s" % toolhead].unload_after_runout|float %}
{% if clogged %}
_LED_FILAMENT_CLOG TOOLHEAD={toolhead}
{% else %}
_LED_FILAMENT_RUNOUT TOOLHEAD={toolhead}
{% endif %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_END" MSG="TOOLHEAD: {toolhead}"
{% if printer.virtual_sdcard.is_active %}
{% if not printer.pause_resume.is_paused %}
PAUSE RUNOUT=True
{% endif %}
{% if not clogged and unload_after_runout %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% if not clogged and printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true'%}
_JOIN_SPOOL TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M600]
description = Executes a color change by pausing the printer an unloading the filament.
gcode =
PAUSE
UNLOAD_FILAMENT
RATOS_ECHO MSG="Please load new filament and resume"
[gcode_macro COLD_PULL]
description = Automated hotend cold pull.
gcode =
{% set extrusion_temp = params.EXTRUSION_TEMP|default(220)|int %}
{% set cold_pull_temp = params.COLD_PULL_TEMP|default(80)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% if printer["dual_carriage"] is not defined %}
{% set toolhead = 0 %}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead != 0 and toolhead != 1 %}
{action_raise_error("Please select toolhead! 0 = left, 1 = right toolhead")}
{% endif %}
{% endif %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
SAVE_GCODE_STATE NAME=cold_pull_state
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
RATOS_ECHO MSG="Heating T{toolhead} to {extrusion_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={extrusion_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={extrusion_temp} MAXIMUM={extrusion_temp + 2}
G4 P3000
RATOS_ECHO MSG="extruding..."
G92 E0
G1 E30 F300
G92 E0
RATOS_ECHO MSG="Heating T{toolhead} to {cold_pull_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={cold_pull_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={cold_pull_temp} MAXIMUM={cold_pull_temp + 2}
G4 P10000
RATOS_ECHO MSG="cold pull..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-40 VELOCITY=5 ACCEL=100
RATOS_ECHO MSG="eject filament..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-200 VELOCITY=20 ACCEL=500
RATOS_ECHO MSG="cooling down extruder..."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET=0
RESTORE_GCODE_STATE NAME=cold_pull_state
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
CONSOLE_ECHO TITLE="Cold pull finished!" MSG="Please remove the filament from the PTFE tube and cut the end off. Do NOT try to load it again." TYPE="warning"
[gcode_macro _USER_START_PRINT_BEFORE_HOMING]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_BED]
gcode =
[gcode_macro _USER_START_PRINT_BED_MESH]
gcode =
[gcode_macro _USER_START_PRINT_PARK]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
[gcode_macro _USER_START_PRINT_HEAT_CHAMBER]
description = Uses the extruder sensor to wait for chamber temp. Override the _START_PRINT_HEAT_CHAMBER macro to implement heated chamber handling.
gcode =
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
[gcode_macro _USER_END_PRINT_BEFORE_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_AFTER_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_PARK]
gcode =
[gcode_macro _USER_END_PRINT_FINISHED]
description = User hook for when the print is finished after gcode state has been restored.
gcode =
[gcode_macro _USER_START_PRINT]
gcode =
[gcode_macro _USER_END_START_PRINT]
gcode =
[gcode_macro _USER_START_FEATURE]
gcode =
[gcode_macro _USER_END_FEATURE]
gcode =
[gcode_macro ECHO_T_VARS]
description = Echo Toolhead variables to the console.
gcode =
{% set t = params.T|default(0) %}
RATOS_ECHO MSG="T{t} Variables"
{% for var, value in printer["gcode_macro T%s" % t].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[gcode_macro ECHO_RATOS_VARS]
description = Echo RatOS variables to the console.
gcode =
{% for var, value in printer["gcode_macro RatOS"].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[delayed_gcode RATOS_INIT]
initial_duration = 0.1
gcode =
_LED_STANDBY
CALCULATE_PRINTABLE_AREA
INITIAL_FRONTEND_UPDATE
_CHAMBER_FILTER_SANITY_CHECK
[delayed_gcode RATOS_LOGO]
initial_duration = 2
gcode =
HELLO_RATOS
[gcode_macro INITIAL_FRONTEND_UPDATE]
gcode =
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_error = printer["gcode_macro RatOS"].status_color_error|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_unknown}"'
{% endif %}
{% set t0_sensor = "undefined" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].filament_detected|lower == "true" %}
{% set t0_sensor = "detected" %}
{% else %}
{% set t0_sensor = "empty" %}
{% endif %}
{% else %}
{% set t0_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set t1_sensor = "undefined" %}
{% if printer["dual_carriage"] is defined and printer["filament_switch_sensor toolhead_filament_sensor_t1"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].filament_detected|lower == "true" %}
{% set t1_sensor = "detected" %}
{% else %}
{% set t1_sensor = "empty" %}
{% endif %}
{% else %}
{% set t1_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set svv = printer.save_variables.variables %}
{% if svv.t0_filament is defined and printer["gcode_macro T0"] is defined %}
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
{% if t0_sensor != "empty" %}
{% set t0_filament_type = svv.t0_filament[0]|default('')|string %}
{% set t0_filament_name = svv.t0_filament[1]|default('')|string %}
{% set t0_filament_temp = svv.t0_filament[2]|default(0)|float %}
{% if t0_filament_name != '' and t0_filament_type != '' and t0_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{t0_filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{t0_filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={t0_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
{% if svv.t1_filament is defined and printer["gcode_macro T1"] is defined %}
{% if printer["gcode_macro T1"].filament_name is defined and printer["gcode_macro T1"].filament_type is defined and printer["gcode_macro T1"].filament_temp is defined %}
{% if t1_sensor != "empty" %}
{% set t1_filament_type = svv.t1_filament[0]|default('')|string %}
{% set t1_filament_name = svv.t1_filament[1]|default('')|string %}
{% set t1_filament_temp = svv.t1_filament[2]|default(0)|float %}
{% if t1_filament_name != '' and t1_filament_type != '' and t1_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='"{t1_filament_name}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='"{t1_filament_type}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE={t1_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t1_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro CALCULATE_PRINTABLE_AREA]
gcode =
{% set bed_margin_x = printer["gcode_macro RatOS"].bed_margin_x %}
{% set bed_margin_y = printer["gcode_macro RatOS"].bed_margin_y %}
{% set tool = 0 if printer["gcode_macro T0"] is not defined or printer["gcode_macro T0"].active else 1 %}
{% set max_x = printer.toolhead.axis_maximum.x if printer["dual_carriage"] is defined and tool == 0 else printer.toolhead.axis_maximum.x - bed_margin_x[1] %}
{% if printer["dual_carriage"] is defined %}
{% set max_x = printer.toolhead.axis_maximum.x %}
{% endif %}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="printer.toolhead.axis_maximum.x {printer.toolhead.axis_maximum.x}"
{% set max_y = printer.toolhead.axis_maximum.y - bed_margin_y[1]%}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_x_max VALUE={max_x}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_y_max VALUE={max_y}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="Printable area calculated: X: 0,{max_x} Y: 0,{max_y}"
[gcode_macro CACHE_TOOLHEAD_SETTINGS]
variable_cache = {"global": {"accel": 1000, "ratio": 0.5, "speed": 50, "scv": 5}}
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set dummy = cache.__setitem__(key, {"accel": printer.toolhead.max_accel, "ratio": printer.toolhead.minimum_cruise_ratio, "speed": printer.toolhead.max_velocity, "scv": printer.toolhead.square_corner_velocity}) %}
SET_GCODE_VARIABLE MACRO=CACHE_TOOLHEAD_SETTINGS VARIABLE=cache VALUE="{cache | pprint | replace("\n", "") | replace("\"", "\\\"")}"
DEBUG_ECHO PREFIX="CACHE_TOOLHEAD_SETTINGS" MSG="Toolhead settings cached for {key}. {printer.toolhead.max_accel} accel, {printer.toolhead.minimum_cruise_ratio} ratio, {printer.toolhead.max_velocity} velocity, {printer.toolhead.square_corner_velocity} scv."
[gcode_macro RESTORE_TOOLHEAD_SETTINGS]
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set values = printer["gcode_macro CACHE_TOOLHEAD_SETTINGS"].cache.__getitem__(key) %}
{% if values is not defined or values == 'None' %}
{ action_raise_error("RESTORE_TOOLHEAD_SETTINGS: Toolhead settings not cached for key '" ~ key ~ "'.") }
{% endif %}
SET_VELOCITY_LIMIT ACCEL={values.accel} MINIMUM_CRUISE_RATIO={values.ratio} VELOCITY={values.speed} SQUARE_CORNER_VELOCITY={values.scv}
DEBUG_ECHO PREFIX="RESTORE_TOOLHEAD_SETTINGS" MSG="Toolhead settings restored. {values.accel} accel, {values.ratio} ratio, {values.speed} velocity, {values.scv} scv."
[gcode_macro SET_MACRO_TRAVEL_SETTINGS]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set accel = printer["gcode_macro RatOS"].macro_travel_accel %}
SET_VELOCITY_LIMIT ACCEL={accel} MINIMUM_CRUISE_RATIO=0.5 VELOCITY={speed} SQUARE_CORNER_VELOCITY={5}
DEBUG_ECHO PREFIX="SET_MACRO_TRAVEL_SETTINGS" MSG="Macro travel settings set. {accel} accel, {speed} velocity"
[gcode_macro SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% if printer["dual_carriage"] is not defined %}
SET_KINEMATIC_POSITION X={printable_x_max / 2} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
{% else %}
IDEX_SET_CENTER_KINEMATIC_POSITION
{% endif %}
[gcode_macro IDEX_SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set center_x = printable_x_max / 2 %}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x - (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x + (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
[gcode_macro VERIFY_HYBRID_INVERTED]
gcode =
{% set inverted = False %}
{% if printer.configfile.settings.ratos_hybrid_corexy is defined and printer.configfile.settings.ratos_hybrid_corexy.inverted is defined %}
{% if printer.configfile.settings.ratos_hybrid_corexy.inverted|lower == 'true' %}
{% set inverted = True %}
{% endif %}
{% endif %}
{% if inverted == False %}
{ action_emergency_stop("ratos_hybrid_corexy NOT INVERTED! Inverted hybrid core-xy bugfix not detected.") }
{% endif %}
[gcode_macro RATOS_ECHO]
gcode =
{% set prefix = "RatOS" %}
{% set debug = params.DEBUG|default(0)|int %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " | " ~ params.PREFIX %}
{% endif %}
{% set prefix = prefix ~ ":" %}
{% set msg = "" %}
{% if params.MSG is defined %}
{% set msg = params.MSG %}
{% else %}
{% set msg = "No msg parameter provided (this is a bug or unintended use)." %}
{% endif %}
{% if not debug %}
M117 {prefix} {msg}
{% endif %}
RATOS_LOG PREFIX="{prefix}" MSG="{msg}"
{% if not debug %}
RESPOND PREFIX="{prefix}" MSG="{msg}"
{% else %}
CONSOLE_ECHO TITLE="{prefix}" TYPE="debug" MSG="{msg}"
{% endif %}
[gcode_macro ENABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=True
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=prefix_filter VALUE="'{params.FILTER|default('')|lower}'"
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging enabled."
[gcode_macro DISABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=False
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging disabled."
[gcode_macro DEBUG_ECHO]
variable_enabled = False
variable_prefix_filter = ''
gcode =
{% set prefix = "DEBUG" %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " - " ~ params.PREFIX %}
{% endif %}
{% if enabled and (prefix_filter|lower == '' or prefix_filter|lower in params.PREFIX|lower) %}
RATOS_ECHO PREFIX="{prefix}" MSG="{params.MSG}" DEBUG=1
{% endif %}
[gcode_macro START_FEATURE]
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="Start {params.FEATURE} feature gcode"
{% set scv = printer.toolhead.square_corner_velocity|int|default(5) %}
{% set accel = printer.toolhead.max_accel|int|default(10000) %}
{% set ratio = printer.toolhead.minimum_cruise_ratio|float|default(0.5) %}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="scv" VALUE={scv}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="accel" VALUE={accel}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="ratio" VALUE={ratio}
_USER_START_FEATURE FEATURE="{params.FEATURE}"
[gcode_macro END_FEATURE]
variable_scv = 5
variable_accel = 10000
variable_ratio = 0.5
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="End {params.FEATURE} feature gcode"
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={scv} ACCEL={accel} MINIMUM_CRUISE_RATIO={ratio}
_USER_END_FEATURE FEATURE="{params.FEATURE}" SCV={scv} ACCEL={accel} RATIO={ratio}
[gcode_macro _ON_LAYER_CHANGE]
variable_layer_number = 0
description = INTERNAL USE ONLY. Call it from the slicers after layer change custom gcode
gcode =
{% set layer = params.LAYER|int %}
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE={layer}
SET_PRINT_STATS_INFO CURRENT_LAYER={layer}
[gcode_macro _LEARN_MORE_CALIBRATION]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/calibration" %}
{% set link_text = "RatOS Calibration Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_CHAMBER_FILTER]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter Control" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_FILAMENT]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/filaments" %}
{% set link_text = "RatOS Filament Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _CONSOLE_SAVE_CONFIG]
gcode =
M118 Click SAVE_CONFIG to save the settings to your printer.cfg.
[gcode_macro SAVE_Z_OFFSET]
gcode =
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SAVE_MULTIPLIER
{% else %}
Z_OFFSET_APPLY_PROBE
{% endif %}
[gcode_macro _LOAD_RATOS_SKEW_PROFILE]
gcode =
{% set ratos_skew_profile = printer["gcode_macro RatOS"].skew_profile|default("") %}
{% if ratos_skew_profile != "" %}
{% if printer.configfile.config["skew_correction %s" % ratos_skew_profile] is defined %}
SKEW_PROFILE LOAD={ratos_skew_profile}
GET_CURRENT_SKEW
{% else %}
{% set line_1 = '"Could not find skew profile %s!_N_Clearing skew correction."' % ratos_skew_profile %}
CONSOLE_ECHO TITLE="Missing skew profile!" TYPE="warning" MSG={line_1}
SET_SKEW CLEAR=1
{% endif %}
{% endif %}
[gcode_macro M601]
gcode =
PAUSE
[gcode_macro PAUSE]
description = Pauses the print
rename_existing = PAUSE_BASE
variable_extrude = 1.5
variable_retract = 1.5
variable_fan_speed = 0
variable_idex_mode = ""
variable_idex_toolhead = 0
variable_idex_toolhead_x = 0.0
variable_idex_toolhead_y = 0.0
variable_idex_toolhead_z = 0.0
gcode =
{% set runout_detected = true if params.RUNOUT|default(false)|lower == 'true' else false %}
_LED_PAUSE
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set idex_toolhead = 1 if idex_mode == 'primary' else 0 %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
SAVE_GCODE_STATE NAME=PAUSE_state
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_mode VALUE='"{idex_mode}"'
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead VALUE={idex_toolhead}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_x VALUE={printer.gcode_move.gcode_position.x|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_y VALUE={printer.gcode_move.gcode_position.y|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_z VALUE={printer.gcode_move.gcode_position.z|float}
DEBUG_ECHO PREFIX="PAUSE" MSG="idex_mode: {idex_mode}, idex_toolhead: {idex_toolhead}, idex_toolhead_x: {idex_toolhead_x}, idex_toolhead_y: {idex_toolhead_y}, idex_toolhead_z: {idex_toolhead_z}"
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
CACHE_TOOLHEAD_SETTINGS KEY="pause"
SET_MACRO_TRAVEL_SETTINGS
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% if current_z < (max_z - 20.0) %}
{% set z_safe = 20.0 %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
PAUSE_BASE
{% if printer["dual_carriage"] is not defined %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan"].speed|float}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
{% if idex_toolhead == 0 %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t1"].speed|float}
{% endif %}
{% endif %}
{% endif %}
M106 S0
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if idex_mode != '' %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set R = printer["gcode_macro PAUSE"].retract|float %}
{% if can_extrude %}
G91
G1 E-{R} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].pause_print_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].pause_print_park_in %}
{% if runout_detected %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].runout_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].runout_park_in %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
DEBUG_ECHO PREFIX="PAUSE" MSG="z_speed: {z_speed}, pause_print_park_x: {pause_print_park_x}, pause_print_park_in: {pause_print_park_in}, default_toolhead: {default_toolhead}"
{% if "xyz" in printer.toolhead.homed_axes %}
G91
G1 Z{z_safe} F{z_speed}
G90
{% if printer["dual_carriage"] is not defined %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% else %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
_IDEX_SINGLE X={parking_position}
{% else %}
PARK_TOOLHEAD
{% endif %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% endif %}
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="pause"
[gcode_macro RESUME]
description = Resumes the print if the printer is paused.
rename_existing = RESUME_BASE
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set target_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set target_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% endif %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if target_idex_mode != '' %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set fan_speed = printer["gcode_macro PAUSE"].fan_speed|float %}
{% if printer["dual_carriage"] is not defined %}
M106 S{(fan_speed * 255)}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% else %}
{% if params.TOOLHEAD is defined %}
{% if params.TOOLHEAD == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% else %}
{% if printer["gcode_macro PAUSE"].idex_toolhead == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% endif %}
{% endif %}
M106.1 S{fan_speed}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY DANCE=0
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR DANCE=0
{% else %}
{% if params.TOOLHEAD is defined %}
_SELECT_TOOL T={params.TOOLHEAD} X=-1 Y=-1 TOOLSHIFT=false
{% else %}
_SELECT_TOOL T={printer["gcode_macro PAUSE"].idex_toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% endif %}
{% set x = printer["gcode_macro PAUSE"].idex_toolhead_x|float %}
{% set y = printer["gcode_macro PAUSE"].idex_toolhead_y|float %}
{% set z = printer["gcode_macro PAUSE"].idex_toolhead_z|float %}
G1 X{x} Y{y} Z{z} F{speed}
{% if params.TOOLHEAD is defined %}
SAVE_GCODE_STATE NAME=PAUSE_STATE
{% endif %}
{% endif %}
{% if params.TOOLHEAD is not defined %}
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
{% if can_extrude %}
G91
G1 E{E} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1 MOVE_SPEED={speed}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
RESUME_BASE
_LED_PRINTING
[gcode_macro CANCEL_PRINT]
description = Cancels the printer
rename_existing = CANCEL_PRINT_BASE
gcode =
END_PRINT
TURN_OFF_HEATERS
CLEAR_PAUSE
CANCEL_PRINT_BASE
[gcode_macro START_PRINT]
description = Start print procedure, use this in your Slicer.
variable_post_processor_version = 2
variable_is_printing_gcode = False
variable_both_toolheads = True
variable_object_xoffset = 0
variable_first_x = -1
variable_first_y = -1
variable_total_toolshifts = 0
variable_initial_tool = 0
variable_extruder_first_layer_temp = ""
variable_extruder_other_layer_temp = ""
gcode =
{% if "xyz" in printer.toolhead.homed_axes and printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% if printer["gcode_macro _VAOC"].is_started|default(true)|lower == 'true' %}
_VAOC_END
{% endif %}
{% endif %}
_LED_START_PRINTING
CACHE_TOOLHEAD_SETTINGS KEY="start_print"
_USER_START_PRINT { rawparams }
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set bed_heat_soak_time = printer["gcode_macro RatOS"].bed_heat_soak_time|default(0)|int %}
{% set hotend_heat_soak_time = printer["gcode_macro RatOS"].hotend_heat_soak_time|default(0)|int %}
{% set z_probe_stowable = printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set X0 = params.X0|default(-1)|float %}
{% set X1 = params.X1|default(-1)|float %}
{% set Y0 = params.Y0|default(-1)|float %}
{% set Y1 = params.Y1|default(-1)|float %}
{% if first_x == -1 or first_y == -1 %}
{% set first_x = params.FIRST_X|default(-1)|float %}
{% set first_y = params.FIRST_Y|default(-1)|float %}
{% endif %}
{% set total_toolshifts = params.TOTAL_TOOLSHIFTS|default(0)|int %}
{% set initial_tool = params.INITIAL_TOOL|default(default_toolhead)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set bed_temp = params.BED_TEMP|default(printer.heater_bed.target, true)|float %}
{% set total_layer_count = params.TOTAL_LAYER_COUNT|default(0)|int %}
{% set extruder_first_layer_temp = (params.EXTRUDER_TEMP|default("")).split(",") %}
RATOS_ECHO MSG="First print coordinates X:{first_x} Y:{first_y}"
{% if params.TOTAL_LAYER_COUNT is not defined %}
{% set link_url = "https://os.ratrig.com/docs/slicers" %}
{% set link_text = "RatOS Slicer Configuration" %}
{% set line_1 = '"Your slicer gcode settings are not up to date._N_Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="Incomplete Slicer Configuration detected" TYPE="warning" MSG={line_1}
{% endif %}
SET_PRINT_STATS_INFO CURRENT_LAYER=1
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE=1
{% if total_layer_count > 0 %}
SET_PRINT_STATS_INFO TOTAL_LAYER={total_layer_count}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set swap_toolheads = true if printer["gcode_macro _IDEX_REMAP_TOOLHEADS"].enabled|default(false)|lower == 'true' else false %}
{% if swap_toolheads %}
{% set initial_tool = 0 if initial_tool == 1 else 1 %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=active VALUE=True
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=active VALUE=True
{% endif %}
{% set both_toolheads = true %}
{% if total_toolshifts == 0 %}
{% set both_toolheads = false %}
{% endif %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
{% endif %}
{% if both_toolheads and (idex_mode == "copy" or idex_mode == "mirror") %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Gcode tool changes found. Copy and mirror mode do not support toolchanges.")}
{% endif %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set both_toolheads = true %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=initial_tool VALUE={initial_tool}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_x VALUE={first_x}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_y VALUE={first_y}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=total_toolshifts VALUE={total_toolshifts}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=both_toolheads VALUE={both_toolheads}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_first_layer_temp VALUE="'{params.EXTRUDER_TEMP}'"
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_other_layer_temp VALUE="'{params.EXTRUDER_OTHER_LAYER_TEMP}'"
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE VARIABLE=toolshift_count VALUE=0
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set svv = printer.save_variables.variables %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
{% set stepper_x_position_min = printer.configfile.settings.stepper_x.position_min|float %}
{% set stepper_x_position_endstop = printer.configfile.settings.stepper_x.position_endstop|float %}
{% set dual_carriage_position_max = printer.configfile.settings.dual_carriage.position_max|float %}
{% set dual_carriage_position_endstop = printer.configfile.settings.dual_carriage.position_endstop|float %}
{% set x_parking_space = parking_position_t0 - (stepper_x_position_endstop , stepper_x_position_min)|max %}
{% set dc_parking_space = (dual_carriage_position_endstop , dual_carriage_position_max)|min - parking_position_t1 %}
{% if svv.idex_xoffset|abs >= (x_parking_space - 0.5) or svv.idex_xoffset|abs >= (dc_parking_space - 0.5) %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Toolhead x-offset is too high for the available parking space. Calibrate your X and DC endstop positions and make sure you stay below 1mm." % (copy_mode_max_width)) }
{% endif %}
{% endif %}
{% if (idex_mode == "copy" or idex_mode == "mirror") and printer.configfile.settings.ratos.enable_gcode_transform %}
{% if params.MIN_X is not defined or params.MAX_X is not defined %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Something went wrong! Missing important post processor start print parameter!") }
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE=0
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set boundary_box_min_x = params.MIN_X|default(0)|float %}
{% set boundary_box_max_x = params.MAX_X|default(printable_x_max)|float %}
{% set svv = printer.save_variables.variables %}
{% if default_toolhead == 0 %}
{% set boundary_box_max_x = boundary_box_max_x + svv.idex_xoffset %}
{% else %}
{% set boundary_box_min_x = boundary_box_min_x - svv.idex_xoffset %}
{% endif %}
{% set center_x = printable_x_max / 2.0 %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% set object_width = boundary_box_max_x - boundary_box_min_x %}
{% set copy_mode_max_width = center_x %}
{% set mirror_mode_max_width = center_x - safe_distance / 2.0 %}
DEBUG_ECHO PREFIX="START_PRINT" MSG="OBJECT_WIDTH: {object_width} BOUNDARY_BOX_MIN_X: {boundary_box_min_x} BOUNDARY_BOX_MAX_X: {boundary_box_max_x} CENTER_X: {center_x} SAFE_DISTANCE: {safe_distance}"
{% if idex_mode == "copy" and object_width > copy_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for copy mode! Max supported width is %s mm" % (copy_mode_max_width)) }
{% endif %}
{% if idex_mode == "mirror" and object_width > mirror_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for mirror mode! Max supported width is %s mm" % (mirror_mode_max_width)) }
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = (printable_x_max - boundary_box_max_x - boundary_box_min_x) / 2 %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE={object_xoffset}
{% endif %}
{% endif %}
{% set has_initial_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_initial_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined and both_toolheads %}
{% set has_secondary_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_secondary_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% endif %}
_CHAMBER_FILTER_ON AT="before_print_start"
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true' %}
{% if both_toolheads %}
RATOS_ECHO MSG="Spool join is not possible if both toolheads are in use!"
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if idex_mode == '' %}
_SET_TOOLHEAD_OFFSET T={default_toolhead} MOVE={1 if "xyz" in printer.toolhead.homed_axes else 0}
{% endif %}
{% endif %}
CLEAR_PAUSE
{% if printer["gcode_macro RatOS"].force_absolute_position|lower == 'true' %}
G90
{% endif %}
SAVE_GCODE_STATE NAME=start_print_state
G21
G90
M82
_USER_START_PRINT_BEFORE_HOMING { rawparams }
{% if z_probe_stowable == true %}
STOWABLE_PROBE_BEGIN_BATCH
{% endif %}
MAYBE_HOME
_Z_HOP
{% if idex_mode != '' and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
PARK_TOOLHEAD
{% endif %}
{% if chamber_temp > 0 %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED={printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float}
{% endif %}
{% endif %}
_CHAMBER_HEATER_ON START_CHAMBER_TEMP={start_chamber_temp} CHAMBER_TEMP={chamber_temp}
_USER_START_PRINT_HEAT_CHAMBER { rawparams } CHAMBER_TEMP={chamber_temp}
{% endif %}
_START_PRINT_BEFORE_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
RATOS_ECHO MSG="Heating bed..."
M190 S{bed_temp}
{% if bed_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking bed for {bed_heat_soak_time} seconds..."
G4 P{(bed_heat_soak_time * 1000)}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_BED { rawparams }
_START_PRINT_AFTER_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
_USER_START_PRINT_BED_MESH { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_BED_MESH X0={X0} X1={X1} Y0={Y0} Y1={Y1} T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if z_probe_stowable == true %}
STOWABLE_PROBE_END_BATCH
{% endif %}
{% if idex_mode == '' %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={extruder_first_layer_temp[1]|float}
{% endif %}
{% endif %}
_USER_START_PRINT_PARK { rawparams }
_START_PRINT_PARK
RATOS_ECHO MSG="Heating Extruder..."
{% if idex_mode == '' %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder1" MINIMUM={extruder_first_layer_temp[1]|float} MAXIMUM={extruder_first_layer_temp[1]|float + 5}
{% endif %}
{% endif %}
{% if hotend_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking hotend for {hotend_heat_soak_time} seconds..."
G4 P{(hotend_heat_soak_time * 1000)}
{% endif %}
{% if idex_mode == '' %}
_LED_PRINTING
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
_LED_PRINTING
{% else %}
{% if both_toolheads %}
_LED_PRINTING TOOLHEAD={initial_tool}
{% if toolchange_standby_temp > -1 %}
_LED_TOOLHEAD_STANDBY TOOLHEAD={0 if initial_tool == 1 else 1}
{% else %}
_LED_PRINTING TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% else %}
_LED_PRINTING TOOLHEAD={initial_tool}
_LED_DEACTIVATE_TOOLHEAD TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% endif %}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_EXTRUDER { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_AFTER_HEATING_EXTRUDER X0={X0} X1={X1} Y0={Y0} Y1={Y1} INITIAL_TOOLHEAD={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if idex_mode != '' %}
{% if not both_toolheads %}
{% if initial_tool != default_toolhead %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET=0
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if toolchange_standby_temp > -1 %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if initial_tool == 1 else 'extruder1'} TARGET={toolchange_standby_temp}
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% set x_offset = printer.toolhead.position.x|float - printer.gcode_move.gcode_position.x|float %}
{% endif %}
RESTORE_GCODE_STATE NAME=start_print_state
{% if idex_mode != '' %}
{% set act_idex_mode = printer["dual_carriage"].carriage_1|default('')|lower %}
{% if act_idex_mode == "copy" or act_idex_mode == "mirror" %}
SET_GCODE_OFFSET X={x_offset} MOVE=0
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% if idex_mode == "copy" and idex_mode != act_idex_mode %}
_IDEX_COPY DANCE=0
{% elif idex_mode == "mirror" and idex_mode != act_idex_mode %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
RATOS_ECHO MSG="Adjusting object x-offset by {(object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={object_xoffset} MOVE=0
{% endif %}
{% else %}
_SELECT_TOOL T={initial_tool} TOOLSHIFT=false
{% if initial_tool != default_toolhead %}
{% set svv = printer.save_variables.variables %}
SAVE_VARIABLE VARIABLE=idex_applied_offset VALUE={default_toolhead}
_SET_TOOLHEAD_OFFSET T={initial_tool} MOVE=0
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={initial_tool}
{% endif %}
_SET_EXTRUSION_MODE
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
SET_GCODE_VARIABLE MACRO=_SELECT_TOOL VARIABLE=last_timestamp VALUE={printer["print_stats"].print_duration}
{% endif %}
_USER_END_START_PRINT { rawparams }
G92 E0
_CHAMBER_FILTER_ON AT="after_print_start"
RATOS_ECHO MSG="Printing..."
[gcode_macro _START_PRINT_BEFORE_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set is_stowable_probe = true if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Pre-heating extruder..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={min_temp}
{% else %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET={min_temp}
{% endif %}
{% else %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
{% endif %}
{% endif %}
{% if not is_stowable_probe %}
{% if printer["dual_carriage"] is defined and act_t != default_toolhead %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
{% endif %}
RATOS_ECHO MSG="Heat soaking z probe..."
{% if auto_z_offset_calibration %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% if default_toolhead == 0 %}
_SELECT_TOOL T=0 TOOLSHIFT=false
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
{% elif default_toolhead == 1 %}
_SELECT_TOOL T=1 TOOLSHIFT=false
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
{% endif %}
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% endif %}
G0 Z2 F{z_speed}
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Waiting for extruder to be preheated..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
{% if default_toolhead == 0 %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_Z_HOP
{% endif %}
{% if auto_z_offset_calibration %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
PARK_TOOLHEAD
_CLEANING_MOVE TOOLHEAD={default_toolhead}
_SELECT_TOOL T={0 if default_toolhead == 1 else 1} X={parking_position_t0 if default_toolhead == 1 else parking_position_t1} Y=0 TOOLSHIFT=false
_CLEANING_MOVE TOOLHEAD={0 if default_toolhead == 1 else 1}
_VAOC_CALIBRATE_Z_OFFSET AUTO_Z_OFFSET=True
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=false
{% endif %}
{% set needs_rehoming = False %}
{% if printer.z_tilt is defined and not printer.z_tilt.applied %}
RATOS_ECHO MSG="Adjusting Z tilt..."
Z_TILT_ADJUST
RATOS_ECHO MSG="Rehoming Z after Z tilt adjustment..."
{% set needs_rehoming = True %}
{% endif %}
{% if printer.quad_gantry_level is defined and not printer.quad_gantry_level.applied %}
RATOS_ECHO MSG="Running quad gantry leveling..."
QUAD_GANTRY_LEVEL
RATOS_ECHO MSG="Rehoming Z after quad gantry leveling..."
{% set needs_rehoming = True %}
{% endif %}
{% if needs_rehoming %}
G28 Z
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %}
{% if beacon_contact_wipe_before_true_zero %}
_START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE
{% endif %}
_START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
G0 Z5 F{z_speed}
G0 X50 Y10 F{speed}
PROBE PROBE_METHOD=contact SAMPLES=1
BEACON_QUERY
[gcode_macro _START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_true_zero_temp = printer["gcode_macro RatOS"].beacon_contact_true_zero_temp|default(150)|int %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_true_zero_location = printer["gcode_macro RatOS"].beacon_contact_true_zero_location|default("front")|lower %}
{% set beacon_contact_true_zero_margin_x = printer["gcode_macro RatOS"].beacon_contact_true_zero_margin_x|default(30)|int %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if beacon_contact_wipe_before_true_zero %}
{% if printer.beacon.last_probe_result|lower == "ok" %}
{% set last_z_offset = printer.beacon.last_z_result %}
RATOS_ECHO MSG="Auto calibration nozzle wipe with probe result {last_z_offset}..."
G0 Z{(0.2 + last_z_offset)} F{z_speed}
G0 X70 F300
{% else %}
RATOS_ECHO MSG="Skipping auto calibration nozzle wipe because probing failed!"
{% endif %}
{% endif %}
G0 Z5 F{z_speed}
_MOVE_TO_SAFE_Z_HOME
RATOS_ECHO MSG="Heating extruder to probing temperature..."
SET_HEATER_TEMPERATURE HEATER={"extruder" if default_toolhead == 0 else "extruder1"} TARGET={beacon_contact_true_zero_temp}
TEMPERATURE_WAIT SENSOR={"extruder" if default_toolhead == 0 else "extruder1"} MINIMUM={beacon_contact_true_zero_temp} MAXIMUM={beacon_contact_true_zero_temp + 5}
RATOS_ECHO MSG="Beacon contact auto calibration..."
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
G0 Z5 F{z_speed}
[gcode_macro _START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set first_x = printer["gcode_macro START_PRINT"].first_x|default(-1)|float %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set center_x = printable_x_max / 2.0 %}
{% set center_y = printable_y_max / 2.0 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% if printer["dual_carriage"] is defined %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% endif %}
{% set X0 = params.X0|default(-1)|int %}
{% set X1 = params.X1|default(-1)|int %}
{% set Y0 = params.Y0|default(-1)|int %}
{% set Y1 = params.Y1|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% if idex_mode == '' %}
_PRIME
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
RATOS_ECHO PREFIX="IDEX" MSG="using combined prime offset for IDEX {idex_mode} mode"
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
{% if both_toolheads %}
{% if initial_toolhead == 0 %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T{initial_toolhead}"
_SELECT_TOOL T={initial_toolhead} TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% endif %}
{% endif %}
CACHE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
SET_MACRO_TRAVEL_SETTINGS
{% if (X0 > -1 and Y1 > -1) or (first_x > 0 and first_y > 0) %}
{% if printer["dual_carriage"] is defined %}
{% set acceleration = printer["gcode_macro RatOS"].toolchange_travel_accel %}
{% set max_accel = printer.toolhead.max_accel|float %}
{% set square_corner_velocity = printer.toolhead.square_corner_velocity|float %}
SET_VELOCITY_LIMIT ACCEL={acceleration} MINIMUM_CRUISE_RATIO=0 SQUARE_CORNER_VELOCITY=20
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
{% set first_z = 1 %}
{% else %}
{% set first_z = 3 %}
{% endif %}
{% if idex_mode == "mirror" %}
{% if first_y >= 0 %}
G0 Y{first_y} F{speed}
{% else %}
G0 Y{Y1} F{speed}
{% endif %}
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
_MOVE_TO_LOADING_POSITION TOOLHEAD={initial_toolhead}
_PURGE_FILAMENT TOOLHEAD={initial_toolhead} E={printer["gcode_macro RatOS"].toolchange_first_purge|default(50)|float}
_CLEANING_MOVE TOOLHEAD={initial_toolhead}
{% endif %}
{% if first_x >= 0 and first_y >= 0 %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% else %}
{% set first_x = X0 %}
{% set first_y = Y0 %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'min' %}
{% set first_x = X0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'max' %}
{% set first_x = X1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|float <= center_x %}
{% set first_x = X0 %}
{% else %}
{% set first_x = X1 %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'min' %}
{% set first_y = Y0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'max' %}
{% set first_y = Y1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|float <= center_y %}
{% set first_y = Y0 %}
{% else %}
{% set first_y = Y1 %}
{% endif %}
{% endif %}
{% endif %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% endif %}
{% endif %}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
_LOAD_RATOS_SKEW_PROFILE
[gcode_macro _PRIME]
gcode =
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
PRIME_BLOB INITIAL_TOOLHEAD={params.INITIAL_TOOLHEAD} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={params.IDEX_MODE} Y1={params.Y1}
{% else %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE == "copy" %}
_IDEX_COPY DANCE=0
{% elif params.IDEX_MODE == "mirror" %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro END_PRINT]
description = End print procedure, use this in your Slicer.
gcode =
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SAVE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = printer["gcode_macro START_PRINT"].object_xoffset|default(0)|float %}
RATOS_ECHO MSG="Adjusting object x-offset by {(0-object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={(0-object_xoffset)}
{% endif %}
{% endif %}
_USER_END_PRINT_BEFORE_HEATERS_OFF { rawparams }
_END_PRINT_BEFORE_HEATERS_OFF
TURN_OFF_HEATERS
_USER_END_PRINT_AFTER_HEATERS_OFF { rawparams }
_END_PRINT_AFTER_HEATERS_OFF
_USER_END_PRINT_PARK { rawparams }
_END_PRINT_PARK
{% if printer["gcode_macro RatOS"].skew_profile is defined %}
SET_SKEW CLEAR=1
{% endif %}
{% if printer["dual_carriage"] is not defined and printer["gcode_macro RatOS"].end_print_motors_off|lower != 'false' %}
M84
{% endif %}
M107
BED_MESH_CLEAR
RATOS_ECHO MSG="Done :)"
RESTORE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
M84
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
{% if printer["dual_carriage"] is not defined %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_expansion_compensation = true if printer["gcode_macro RatOS"].beacon_contact_expansion_compensation|default(false)|lower == 'true' else false %}
{% if beacon_contact_start_print_true_zero and beacon_contact_expansion_compensation %}
SET_GCODE_OFFSET Z=0 MOVE=0
{% endif %}
{% endif %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print"
_CHAMBER_FILTER_ON AT="print_end"
_CHAMBER_FILTER_OFF
_CHAMBER_HEATER_OFF
_USER_END_PRINT_FINISHED { rawparams }
[gcode_macro _END_PRINT_BEFORE_HEATERS_OFF]
gcode =
RATOS_ECHO MSG="Cleaning up..."
[gcode_macro _END_PRINT_AFTER_HEATERS_OFF]
gcode =
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% set z_hop = printer["gcode_macro RatOS"].end_print_park_z_hop|float %}
{% set r = printer["gcode_macro RatOS"].end_print_retract_filament|default(4)|float %}
{% if current_z < (max_z - z_hop) %}
{% set z_safe = z_hop %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
G91
G1 E-2 F3600
G0 Z{z_safe} F3600
G1 E-{(r-2)} F3600
G90
[gcode_macro _SET_EXTRUSION_MODE]
gcode =
{% if printer["gcode_macro RatOS"].relative_extrusion|lower == 'true' %}
M83
{% else %}
M82
{% endif %}
[gcode_macro GENERATE_SHAPER_GRAPHS]
description = Genarates input shaper resonances graphs for analysis. Uses the AXIS parameter for if you only want to do one axis at a time, (eg. GENERATE_SHAPER_GRAPHS AXIS=X)
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set axis = params.AXIS|default('')|lower %}
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
{% if axis != '' %}
{% if axis == 'x' %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
{% elif axis == 'y' %}
MAYBE_HOME
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% else %}
{action_raise_error("Unknown axis specified. Expected X or Y.")}
{% endif %}
{% else %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% endif %}
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Shaper graph"
[gcode_shell_command generate_shaper_graph_x]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-x.sh
timeout = 60.
verbose = True
[gcode_shell_command generate_shaper_graph_y]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-y.sh
timeout = 60.
verbose = True
[gcode_macro MEASURE_COREXY_BELT_TENSION]
description = Generates resonance graph used to ensure belts are equally tensioned.
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
MAYBE_HOME
TEST_RESONANCES AXIS=1,1 OUTPUT=raw_data NAME=belt-tension-upper FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=belt-tension-lower FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_belt_tension_graph
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Belt Tension Graph"
[gcode_shell_command generate_belt_tension_graph]
command = /home/pi/printer_data/config/RatOS/scripts/generate-belt-tension-graph.sh
timeout = 90.
verbose = True
[idle_timeout]
gcode =
{% if printer.webhooks.state|lower == 'ready' %}
{% if printer.pause_resume.is_paused|lower == 'false' %}
RATOS_ECHO PREFIX="IDLE" MSG="2 hours since last activity. Powering off heaters and motors.."
TURN_OFF_HEATERS
M84
{% endif %}
{% endif %}
timeout = 7200
[temperature_sensor raspberry_pi]
sensor_type = temperature_host
[skew_correction]
[input_shaper]
[virtual_sdcard]
path = ~/printer_data/gcodes
[display_status]
[pause_resume]
[force_move]
enable_force_move = True
[respond]
[resonance_generator]
[ratos]
allow_unknown_gcode_generator = True
[exclude_object]
[heater_bed]
heater_pin = heater_bed_heating_pin
sensor_pin = heater_bed_sensor_pin
sensor_type = EPCOS 100K B57560G104F
min_temp = 0
max_temp = 130
control = pid
pid_kp = 68.203
pid_ki = 2.842
pid_kd = 409.216
[fan]
pin = multi_pin:dual_blower_fan
shutdown_speed = 1.0
kick_start_time = 0.5
cycle_time = 0.00004
[heater_fan toolhead_cooling_fan]
pin = PD14
fan_speed = 1
heater = extruder
heater_temp = 50.0
[controller_fan controller_fan]
pin = PD13
idle_speed = 0.7
[printer]
kinematics = cartesian
max_velocity = 200
max_accel = 3000
minimum_cruise_ratio = 0.5
max_z_velocity = 15
max_z_accel = 200
square_corner_velocity = 5
[bed_mesh]
speed = 200
horizontal_move_z = 5
mesh_min = 15,15
mesh_max = 150,160
probe_count = 5,5
fade_start = 1.0
fade_end = 10.0
mesh_pps = 2,2
algorithm = bicubic
bicubic_tension = .2
[screws_tilt_adjust]
screw1 = 80, 108
screw1_name = Left Screw
screw2 = 155, 72
screw2_name = Front Right Screw
screw3 = 155, 147
screw3_name = Rear Right Screw
horizontal_move_z = 10
speed = 200
screw_thread = CCW-M4
[stepper_x]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PF9
dir_pin = !x_dir_pin
enable_pin = !PD6
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = toolboard_t0:PB6
[stepper_y]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PD3
dir_pin = y_dir_pin
enable_pin = !PD5
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = PC1
[stepper_z]
position_min = -5
position_max = 180
step_pin = PA15
dir_pin = !z0_dir_pin
enable_pin = !PC9
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 4
homing_speed = 15
endstop_pin = probe:z_virtual_endstop
[gcode_macro SCREWS_TILT_CALCULATE]
rename_existing = SCREWS_TILT_CALCULATE_ORIG
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
MAYBE_HOME
SAVE_GCODE_STATE NAME=screws_tilt_state
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
DEPLOY_PROBE
{% endif %}
SCREWS_TILT_CALCULATE_ORIG
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
STOW_PROBE
{% endif %}
G90
G0 Z120 F{printer["gcode_macro RatOS"].macro_z_speed|float * 60}
G0 Y{printable_y_max} X{printable_x_max / 2} F{printer["gcode_macro RatOS"].macro_travel_speed|float * 60}
RESTORE_GCODE_STATE NAME=screws_tilt_state
M84
[extruder]
rotation_distance = 5.57
full_steps_per_rotation = 200
filament_diameter = 1.750
max_extrude_only_velocity = 120
max_extrude_only_accel = 800
pressure_advance_smooth_time = 0.02
max_extrude_only_distance = 200
nozzle_diameter = 0.4
heater_pin = toolboard_t0:PB13
sensor_type = MAX31865
sensor_pin = toolboard_t0:PA4
min_extrude_temp = 170
min_temp = 0
max_temp = 350
pressure_advance = 0.03
step_pin = toolboard_t0:PD0
dir_pin = !toolboard_t0:e_dir_pin
enable_pin = !toolboard_t0:PD2
microsteps = 64
control = pid
pid_kp = 21.673
pid_ki = 1.338
pid_kd = 87.776
spi_software_sclk_pin = toolboard_t0:PA5
spi_software_miso_pin = toolboard_t0:PA6
spi_software_mosi_pin = toolboard_t0:PA7
[firmware_retraction]
retract_speed = 120
unretract_extra_length = 0
unretract_speed = 120
retract_length = 0.5
[adxl345 rpi]
cs_pin = rpi:None
[resonance_tester]
accel_chip_x = adxl345 toolboard_t0
accel_chip_y = adxl345 rpi
probe_points =
90,90,20
[tmc2209 stepper_x]
stealthchop_threshold = 0
interpolate = False
uart_pin = PF10
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_y]
stealthchop_threshold = 0
interpolate = False
uart_pin = PD4
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_z]
stealthchop_threshold = 0
interpolate = False
uart_pin = PC8
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 extruder]
stealthchop_threshold = 0
interpolate = False
uart_pin = toolboard_t0:PA15
run_current = 0.707
driver_tbl = 0
driver_toff = 4
driver_hend = 6
driver_hstrt = 7
sense_resistor = 0.11
[bltouch]
sensor_pin = ^toolboard_t0:bltouch_sensor_pin
control_pin = toolboard_t0:bltouch_control_pin
speed = 7
pin_move_time = 0.675
sample_retract_dist = 10
pin_up_reports_not_triggered = True
pin_up_touch_mode_reports_triggered = True
x_offset = -28
y_offset = -13
z_offset = 2.375
[gcode_macro T0]
variable_join = 0
variable_remap = 0
variable_alert = ""
variable_filament_name = ""
variable_filament_type = ""
variable_filament_temp = 0
variable_runout_sensor = ""
variable_active = True
variable_color = "7bff33"
variable_hotend_type = "HF"
variable_has_cht_nozzle = False
variable_cooling_position_to_nozzle_distance = 40
variable_tooolhead_sensor_to_extruder_gear_distance = 15
variable_extruder_gear_to_cooling_position_distance = 30
variable_filament_loading_nozzle_offset = -5
variable_filament_grabbing_length = 5
variable_filament_grabbing_speed = 1
variable_enable_insert_detection = True
variable_enable_runout_detection = True
variable_enable_clog_detection = True
variable_unload_after_runout = True
variable_purge_after_load = 0
variable_purge_before_unload = 0
variable_extruder_load_speed = 60
variable_filament_load_speed = 10
variable_standby = False
variable_temperature_offset = 0
variable_has_oozeguard = False
variable_has_front_arm_nozzle_wiper = False
variable_resume_after_insert = False
gcode =
{% set x = params.X|default(-1.0)|float %}
{% set y = params.Y|default(-1.0)|float %}
{% set z = params.Z|default(0.0)|float %}
{% set s = params.S|default(1)|int %}
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
_SELECT_TOOL T=0 X={x} Y={y} Z={z} TOOLSHIFT={s}
{% endif %}
[save_variables]
filename = /home/pi/printer_data/config/ratos-variables.cfg
[multi_pin dual_blower_fan]
pins = toolboard_t0:PA0, toolboard_t0:PA1
=======================
Config error
Traceback (most recent call last):
File "/home/pi/klipper/klippy/klippy.py", line 130, in _connect
self._read_config()
File "/home/pi/klipper/klippy/klippy.py", line 123, in _read_config
self.load_object(config, section_config.get_name(), None)
File "/home/pi/klipper/klippy/klippy.py", line 112, in load_object
self.objects[section] = init_func(config.getsection(section))
File "/home/pi/klipper/klippy/extras/fan.py", line 122, in load_config
return PrinterFan(config)
File "/home/pi/klipper/klippy/extras/fan.py", line 106, in __init__
self.fan = Fan(config)
File "/home/pi/klipper/klippy/extras/fan.py", line 24, in __init__
self.mcu_fan = ppins.setup_pin('pwm', config.get('pin'))
File "/home/pi/klipper/klippy/pins.py", line 117, in setup_pin
pin_params = self.lookup_pin(pin_desc, can_invert, can_pullup)
File "/home/pi/klipper/klippy/pins.py", line 98, in lookup_pin
pin_params = self.parse_pin(pin_desc, can_invert, can_pullup)
File "/home/pi/klipper/klippy/pins.py", line 83, in parse_pin
raise error("Unknown pin chip name '%s'" % (chip_name,))
pins.error: Unknown pin chip name 'multi_pin'
webhooks client 1970848144: New connection
webhooks client 1970848144: Client info {'program': 'Moonraker', 'version': 'v0.9.3-0-g71f9e67'}
Attempting MCU 'mcu' reset
Unable to issue reset command on MCU 'rpi'
Attempting MCU 'toolboard_t0' reset
webhooks client 1970848144: Disconnected
Restarting printer
Start printer at Wed Nov 12 22:30:42 2025 (1762986642.3 20901.2)
===== Config file =====
[mcu rpi]
serial = /tmp/klipper_host_mcu
[board_pins btt-skrat-10]
aliases =
x_step_pin=PF9,
x_dir_pin=PD7,
x_enable_pin=PD6,
x_uart_pin=PF10,
x_diag_pin=PB5,
x_endstop_pin=PB5,
y_step_pin=PD3,
y_dir_pin=PD2,
y_enable_pin=PD5,
y_uart_pin=PD4,
y_diag_pin=PC1,
y_endstop_pin=PC1,
z0_step_pin=PA15,
z0_dir_pin=PF8,
z0_enable_pin=PC9,
z0_uart_pin=PC8,
z0_diag_pin=PC0,
e_step_pin=PB10,
e_dir_pin=PE15,
e_enable_pin=PA8,
e_uart_pin=PB11,
e_diag_pin=PF5,
e_heater_pin=PE11,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PE5,
bltouch_control_pin=PE6,
probe_pin=PE5,
fan_part_cooling_pin=PD15,
fan_toolhead_cooling_pin=PD14,
fan_controller_board_pin=PD13,
heater_bed_heating_pin=PB3,
heater_bed_sensor_pin=PB2,
4p_fan_part_cooling_pin=PE9,
4p_fan_part_cooling_tach_pin=PD11,
4p_toolhead_cooling_pin=PE14,
4p_toolhead_cooling_tach_pin=PD10,
4p_controller_board_pin=PE14,
4p_controller_board_tach_pin=PD10
[mcu]
serial = /dev/RatOS/btt-skrat-10
[temperature_sensor SKRat_v1.0]
sensor_type = temperature_mcu
[adxl345 controlboard]
cs_pin = PB12
spi_bus = spi2
[board_pins toolboard_t0]
mcu = toolboard_t0
aliases =
e_step_pin=PD0,
e_dir_pin=PD1,
e_enable_pin=PD2,
e_uart_pin=PA15,
e_heater_pin=PB13,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PB8,
bltouch_control_pin=PB9,
probe_pin=PB9,
fan_part_cooling_pin=PA0,
fan_toolhead_cooling_pin=PA1,
fan_controller_board_pin=null,
heater_bed_heating_pin=null,
heater_bed_sensor_pin=null,
4p_fan_part_cooling_pin=null,
4p_fan_part_cooling_tach_pin=null,
4p_toolhead_cooling_pin=null,
4p_toolhead_cooling_tach_pin=null,
4p_controller_board_pin=null,
4p_controller_board_tach_pin=null
[mcu toolboard_t0]
serial = /dev/RatOS/btt-ebb42-12-t0
[temperature_sensor EBB42_v1.2_T0]
sensor_type = temperature_mcu
sensor_mcu = toolboard_t0
[adxl345 toolboard_t0]
axes_map = x, z, y
cs_pin = toolboard_t0:PB12
spi_software_mosi_pin = toolboard_t0:PB11
spi_software_miso_pin = toolboard_t0:PB2
spi_software_sclk_pin = toolboard_t0:PB10
[gcode_macro RatOS]
variable_homing = "endstops"
variable_z_probe = "static"
variable_sensorless_x_current = 0.6
variable_sensorless_y_current = 0.9
variable_safe_home_x = "middle"
variable_safe_home_y = "middle"
variable_driver_type_x = "tmc2209"
variable_driver_type_y = "tmc2209"
variable_stowable_probe_stop_on_error = False
variable_chamber_filter_enable = True
variable_chamber_filter_speed = 0.5
variable_chamber_filter_disable_speed = 1.0
variable_chamber_filter_enable_at = "after_print_start"
variable_chamber_filter_disable_period = 300
variable_chamber_filter_disable_bed_temp = 0
variable_chamber_heater_enable = True
variable_chamber_heater_bed_temp = 115
variable_chamber_heater_preheating_temp = 150
variable_chamber_heater_heating_temp_offset = 25
variable_chamber_heater_control_external_heater = False
variable_chamber_heater_air_circulation_enable = True
variable_chamber_heater_air_circulation_fan_speed = 0.35
variable_chamber_heater_air_circulation_y_pos = 0
variable_chamber_heater_air_circulation_z_pos = 100
variable_chamber_heater_extra_fan_speed = 1.0
variable_chamber_heater_filter_fan_speed = 1.0
variable_led_status_action = 0.0,1.0,1.0
variable_led_status_success = 0.0,1.0,0.0
variable_led_status_error = 1.0,0.0,1.0
variable_led_status_on = 1.0,1.0,1.0
variable_led_status_off = 0.0,0.0,1.0
variable_led_status_standby = 0.1,0.1,0.1
variable_led_status_heating = 1.0,0.0,0.0
variable_led_status_cooling = 0.0,0.0,1.0
variable_calibrate_bed_mesh = True
variable_adaptive_mesh = True
variable_start_print_park_in = "front"
variable_start_print_park_z_height = 50
variable_end_print_park_in = "back"
variable_pause_print_park_in = "front"
variable_end_print_park_z_hop = 20
variable_nozzle_priming = "primeblob"
variable_nozzle_prime_start_x = "max"
variable_nozzle_prime_start_y = "min"
variable_nozzle_prime_direction = "auto"
variable_nozzle_prime_bridge_fan = 102
variable_probe_for_priming_result = None
variable_probe_for_priming_end_result = None
variable_probe_for_priming_result_t1 = None
variable_probe_for_priming_end_result_t1 = None
variable_probe_for_priming_disable_mesh_constraints = False
variable_adaptive_prime_offset_threshold = -1.0
variable_last_z_offset = None
variable_runout_park_in = "front"
variable_enable_unload_tip_forming = False
variable_filament_unload_length = 150
description = RatOS variable storage macro, will echo variables to the console when run.
variable_relative_extrusion = False
variable_force_absolute_position = False
variable_preheat_extruder = True
variable_preheat_extruder_temp = 150
variable_macro_travel_speed = 200
variable_macro_travel_accel = 3000
variable_macro_z_speed = 15
variable_bed_margin_x = [0, 0]
variable_bed_margin_y = [0, 0]
variable_printable_x_min = 0
variable_printable_x_max = 0
variable_printable_y_min = 0
variable_printable_y_max = 0
variable_end_print_motors_off = True
variable_status_color_ok = "00FF00"
variable_status_color_error = "FF0000"
variable_status_color_unknown = "FFFF00"
variable_end_print_retract_filament = 10
gcode =
ECHO_RATOS_VARS
variable_homing_x = "endstop"
variable_homing_y = "endstop"
variable_x_driver_types = ["tmc2209"]
variable_x_axes = ["x"]
variable_y_driver_types = ["tmc2209"]
variable_y_axes = ["y"]
variable_z_driver_types = ["tmc2209"]
variable_z_axes = ["z"]
[ratos_homing]
axes = xyz
z_hop = 15
z_hop_speed = 15
gcode =
_LED_ON
{% set prev_stop_on_error = printer["gcode_macro RatOS"].stowable_probe_stop_on_error %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set target_idex_mode = printer["dual_carriage"].carriage_1|lower %}
_IDEX_SINGLE
_SELECT_TOOL T={default_toolhead} TOOLSHIFT=false
{% endif %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE=True
M400
G90
{% set X = true if params.X is defined else false %}
{% set Y = true if params.Y is defined else false %}
{% set Z = true if params.Z is defined else false %}
{% if printer["gcode_macro RatOS"].home_y_first|default(false)|lower == 'true' %}
HOME_Y X={X} Y={Y} Z={Z}
HOME_X X={X} Y={Y} Z={Z}
{% else %}
HOME_X X={X} Y={Y} Z={Z}
HOME_Y X={X} Y={Y} Z={Z}
{% endif %}
HOME_Z X={X} Y={Y} Z={Z}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE={prev_stop_on_error}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR
{% endif %}
{% endif %}
[gcode_macro HOME_X]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_x = printer["gcode_macro RatOS"].homing_x|lower %}
{% set homing_x = homing_x if homing_x else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_X" MSG="printable_x_max: {printable_x_max}, safe_home_x: {safe_home_x}, axis_maximum.x: {printer.toolhead.axis_maximum.x}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}"
{% if X or not Y and not Z %}
{% if homing_x == 'endstop' %}
G28 X
{% elif homing_x == 'sensorless' %}
{% if printer["dual_carriage"] is defined %}
{ action_emergency_stop("sensorless homing not supported on IDEX!") }
{% endif %}
HOME_X_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_x to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_x, homing)) }
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % (0 if default_toolhead==1 else 1)].parking_position|float %}
SET_DUAL_CARRIAGE CARRIAGE={0 if default_toolhead==1 else 1} MODE=PRIMARY
G1 X{parking_position} F{speed}
SET_DUAL_CARRIAGE CARRIAGE={default_toolhead} MODE=PRIMARY
{% endif %}
{% set x_homed = True %}
G0 X{safe_home_x} F{speed}
M400
{% endif %}
[gcode_macro HOME_Y]
gcode =
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_y = printer["gcode_macro RatOS"].homing_y|lower %}
{% set homing_y = homing_y if homing_y else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Y" MSG="printable_y_max: {printable_y_max}, safe_home_y: {safe_home_y}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}"
{% if Y or not X and not Z %}
{% if homing_y == 'endstop' %}
G28 Y
{% elif homing_y == 'sensorless' %}
HOME_Y_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_y to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_y, homing)) }
{% endif %}
{% set y_homed = True %}
G0 Y{safe_home_y} F{speed}
{% endif %}
[gcode_macro HOME_Z]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set z_probe = printer["gcode_macro RatOS"].z_probe %}
{% set beacon_contact_z_homing = true if printer["gcode_macro RatOS"].beacon_contact_z_homing|default(false)|lower == 'true' else false %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Z" MSG="x_homed: {x_homed}, y_homed: {y_homed}, z_probe: {z_probe}, beacon_contact_z_homing: {beacon_contact_z_homing}"
{% if Z or not Y and not X %}
RATOS_ECHO MSG="Homing Z"
{% if x_homed == False or y_homed == False %}
{ action_emergency_stop("X and Y must be homed before homing Z") }
{% else %}
{% if z_probe == "stowable" %}
DEPLOY_PROBE
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
STOW_PROBE
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
{% endif %}
{% endif %}
{% endif %}
[gcode_macro HOME_X_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
G4 P300
G28 X
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
[gcode_macro HOME_Y_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
G4 P300
G28 Y
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
[gcode_macro _Z_HOP]
description = Move Z axis up by Z_HOP distance at Z_HOP_SPEED. In relative mode it will move Z axis up by Z_HOP distance. In absolute mode it will move Z axis to Z_HOP distance.
gcode =
{% set z_hop = printer.configfile.config.ratos_homing.z_hop|float %}
{% set z_hop_speed = printer.configfile.config.ratos_homing.z_hop_speed|float * 60 %}
G0 Z{z_hop} F{z_hop_speed}
[gcode_macro _MOVE_TO_SAFE_Z_HOME]
description = Move to safe home position with optional Z_HOP (pass Z_HOP=True as parameter)
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% if params.Z_HOP is defined %}
_Z_HOP
{% endif %}
DEBUG_ECHO PREFIX="_MOVE_TO_SAFE_Z_HOME" MSG="axis_maximum.x: {printer.toolhead.axis_maximum.x}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}, safe_home_x: {safe_home_x}, safe_home_y: {safe_home_y}, printable_x_max: {printable_x_max}, printable_y_max: {printable_y_max}"
G0 X{safe_home_x} Y{safe_home_y} F{speed}
[gcode_macro MAYBE_HOME]
description = Only home unhomed axis
variable_is_kinematic_position_overriden = False
gcode =
{% if printer["gcode_macro MAYBE_HOME"].is_kinematic_position_overriden|lower == 'true' %}
RATOS_ECHO MSG="SET_CENTER_KINEMATIC_POSITION has been abused. Homing all axes. Please refrain from using SET_CENTER_KINEMATIC_POSITION outside of debugging purposes."
G28
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=False
{% else %}
{% set axes = '' %}
{% set isHomed = true %}
{% set axesToHome = '' %}
{% if params.X is defined %}
{% set axes = axes ~ 'X ' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% endif %}
{% if params.Y is defined %}
{% set axes = axes ~ 'Y ' %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% endif %}
{% if params.Z is defined %}
{% set axes = axes ~ 'Z ' %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if params.X is not defined and params.Y is not defined and params.Z is not defined %}
{% set axes = '' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if isHomed is false %}
RATOS_ECHO MSG="Homing {axesToHome}"
G28 {axesToHome}
{% else %}
RATOS_ECHO MSG="All requested axes already homed, skipping.."
{% endif %}
{% endif %}
[gcode_macro PID_CALIBRATE_HOTEND]
description = Perform a PID calibration test for a given extruder heater.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set temp = params.TEMP|default(220)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_HOTEND" MSG="TEMP={temp}"
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO MSG="PID calibration hotend heater T0 at {temp}°C..."
PID_CALIBRATE HEATER=extruder TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
{% if toolhead==0 or toolhead==1 %}
RATOS_ECHO MSG="PID calibration hotend heater T{toolhead} at {temp}°C..."
PID_CALIBRATE HEATER=extruder{'' if toolhead==0 else toolhead} TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_BED]
description = Perform a PID calibration test for the bed heater.
gcode =
{% set temp = params.TEMP|default(80)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_BED" MSG="TEMP={temp}"
RATOS_ECHO MSG="PID calibration bed heater at {temp}°C..."
PID_CALIBRATE HEATER=heater_bed TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_CHAMBER_HEATER]
description = Perform a PID calibration test for the chamber heater.
gcode =
{% set temp = params.TEMP|default(150)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_CHAMBER_HEATER" MSG="TEMP={temp}"
{% if printer["heater_generic chamber_heater"] is defined %}
RATOS_ECHO MSG="PID calibration chamber heater at {temp}°C..."
PID_CALIBRATE HEATER=chamber_heater TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_heater" %}
{% set link_text = "RatOS Chamber Heater" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber heater found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro INITIALIZE_PA_TUNING]
description = Start a pressure advance tuning tower.
gcode =
{% set start = params.START|default(0.0)|float %}
{% set factor = params.FACTOR|default(0.001)|float %}
{% set layer_number = printer["gcode_macro _ON_LAYER_CHANGE"].layer_number|default(0)|int %}
{% set is_printing_gcode = true if printer["gcode_macro START_PRINT"].is_printing_gcode|default(true)|lower == 'true' else false %}
{% if is_printing_gcode and layer_number < 2 %}
DEBUG_ECHO PREFIX="START_PA_TOWER" MSG="START: {start}, FACTOR: {factor}"
RATOS_ECHO MSG="Starting presssure advance tuning tower..."
TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START={start} FACTOR={factor}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro CHAMBER_FILTER_ON]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro CHAMBER_FILTER_OFF]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Deactivating chamber filter..."
_CHAMBER_FILTER_TURN_OFF
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro _CHAMBER_FILTER_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set chamber_filter_enable_at = printer["gcode_macro RatOS"].chamber_filter_enable_at|default('after_print_start')|lower %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_ON" MSG="at: {at}, chamber_filter_enable: {chamber_filter_enable}, chamber_filter_enable_at: {chamber_filter_enable_at}, chamber_filter_speed: {chamber_filter_speed}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if chamber_filter_enable_at == at %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON AT={at}
{% if chamber_filter_enable_at == "print_end" %}
_LED_CHAMBER_FILTER_ON
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_FILTER_OFF]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF" MSG="chamber_filter_enable: {chamber_filter_enable}, filter_disable_period: {filter_disable_period}, filter_disable_bed_temp: {filter_disable_bed_temp}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_period > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting {filter_disable_period} seconds before turning chamber filter off..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION={filter_disable_period}
{% endif %}
{% if filter_disable_bed_temp > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting for bed temp to cool down to {filter_disable_bed_temp}°C to turn filter off..."
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM=0 MAXIMUM={filter_disable_bed_temp}
_CHAMBER_FILTER_TURN_OFF
_LED_CHAMBER_FILTER_OFF
{% endif %}
{% endif %}
[delayed_gcode _CHAMBER_FILTER_OFF_TIMER]
gcode =
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF_TIMER" MSG="executed"
_CHAMBER_FILTER_TURN_OFF
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Chamber filter turned off!"
_LED_CHAMBER_FILTER_OFF
[gcode_macro _CHAMBER_FILTER_TURN_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_speed|default(0)|float %}
{% if at == "print_end" %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_disable_speed|default(0)|float %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION=0
SET_FAN_SPEED FAN=filter SPEED={chamber_filter_speed}
[gcode_macro _CHAMBER_FILTER_TURN_OFF]
gcode =
SET_FAN_SPEED FAN=filter SPEED=0
[gcode_macro _CHAMBER_FILTER_SANITY_CHECK]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_bed_temp > 0 and filter_disable_period > 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable, not both.")}
{% endif %}
{% if filter_disable_bed_temp == 0 and filter_disable_period == 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable.")}
{% endif %}
{% endif %}
[gcode_macro CHAMBER_HEATER_ON]
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(45)|int %}
_CHAMBER_HEATER_ON CHAMBER_TEMP={chamber_temp} IS_FROM_START_PRINT=False
[gcode_macro CHAMBER_HEATER_OFF]
gcode =
_CHAMBER_HEATER_OFF
[gcode_macro _CHAMBER_HEATER_ON]
variable_chamber_temp = 0
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set is_from_start_print = true if params.IS_FROM_START_PRINT|default(True)|lower == 'true' else false %}
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set chamber_heater_enable = true if printer["gcode_macro RatOS"].chamber_heater_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
{% set chamber_heater_preheating_temp = printer["gcode_macro RatOS"].chamber_heater_preheating_temp|default(150)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set chamber_heater_control_external_heater = true if printer["gcode_macro RatOS"].chamber_heater_control_external_heater|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_enable = true if printer["gcode_macro RatOS"].chamber_heater_air_circulation_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_fan_speed = printer["gcode_macro RatOS"].chamber_heater_air_circulation_fan_speed|default(0.35)|float %}
{% set chamber_heater_air_circulation_y_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_y_pos|default(0)|float %}
{% set chamber_heater_air_circulation_z_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_z_pos|default(100)|float %}
DEBUG_ECHO PREFIX="_CHAMBER_HEATER_ON" MSG="chamber_heater_enable: {chamber_heater_enable}, chamber_heater_preheating_temp: {chamber_heater_preheating_temp}, chamber_heater_heating_temp_offset: {chamber_heater_heating_temp_offset}, bed_temp: {bed_temp}, chamber_temp: {chamber_temp}, start_chamber_temp: {start_chamber_temp}"
{% if chamber_heater_enable and chamber_temp > 0 and chamber_heater_bed_temp > 0 %}
_LED_HEATING
RATOS_ECHO MSG="Preheating chamber to {(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}°C..."
{% set chamber_temp_sensor = "extruder" %}
{% if printer["dual_carriage"] is defined and default_toolhead == 1 %}
{% set chamber_temp_sensor = "extruder1" %}
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% set chamber_temp_sensor = "temperature_sensor chamber" %}
{% endif %}
{% set current_chamber_temp = printer['%s' % chamber_temp_sensor].temperature|int %}
{% set needs_heating = current_chamber_temp < (start_chamber_temp if start_chamber_temp > 0 else chamber_temp) %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_BEFORE_PREHEATING
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
{% if not is_from_start_print %}
MAYBE_HOME
{% endif %}
G0 Z{chamber_heater_air_circulation_z_pos} F{z_speed}
G0 Y{chamber_heater_air_circulation_y_pos} F{speed}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 1 else 0}
{% else %}
M106 S{(255 * chamber_heater_air_circulation_fan_speed)}
{% endif %}
{% else %}
{% if is_from_start_print %}
G0 Z{z} F{z_speed}
{% endif %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE={chamber_temp}
{% if needs_heating %}
M140 S{chamber_heater_bed_temp}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={chamber_heater_preheating_temp}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if needs_heating %}
_CHAMBER_HEATER_EXTRA_FAN_ON
{% endif %}
{% if needs_heating %}
TEMPERATURE_WAIT SENSOR="{chamber_temp_sensor}" MINIMUM={(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% endif %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED=0
_CHAMBER_FILTER_ON AT="before_print_start"
{% endif %}
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
G28 Z
{% endif %}
{% endif %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_AFTER_PREHEATING
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% if printer["heater_generic chamber_heater"] is defined %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined and chamber_heater_control_external_heater %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
_LED_SUCCESS
{% endif %}
[gcode_macro _CHAMBER_HEATER_OFF]
gcode =
RATOS_ECHO MSG="Deactivating chamber heater..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=0
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE=0
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
_CHAMBER_HEATER_EXTRA_FAN_OFF
[delayed_gcode _CHAMBER_HEATER_CONTROL]
initial_duration = 0.
gcode =
{% set chamber_temp = printer["gcode_macro _CHAMBER_HEATER_ON"].chamber_temp|default(0)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set current_chamber_temp = printer['temperature_sensor chamber'].temperature|int %}
{% if current_chamber_temp < chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if current_chamber_temp >= chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_ON]
gcode =
{% set chamber_heater_extra_fan_speed = printer["gcode_macro RatOS"].chamber_heater_extra_fan_speed|default(0.0)|float %}
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
{% if chamber_heater_extra_fan_speed > 0 %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED={chamber_heater_extra_fan_speed}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_OFF]
gcode =
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED=0
{% endif %}
[gcode_macro _USER_CHAMBER_HEATER_BEFORE_PREHEATING]
description = Will be executed before chamber preheating, only if heating is needed.
gcode =
[gcode_macro _USER_CHAMBER_HEATER_AFTER_PREHEATING]
description = Will be executed after chamber preheating, only if heating was needed.
gcode =
[gcode_macro _LED_START_PRINTING]
gcode =
_LED_ACTION
[gcode_macro _LED_START_PRINTING_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_PRINTING]
gcode =
_LED_ON TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_PAUSE]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_ON]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_OFF]
gcode =
_LED_STANDBY
[gcode_macro _LED_LOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_LOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_RUNOUT]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_CLOG]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_UNLOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_UNLOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_DEACTIVATE_TOOLHEAD]
gcode =
_LED_OFF TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_STANDBY]
gcode =
_LED_STANDBY TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_WAKEUP]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_MOTORS_OFF]
gcode =
_LED_STANDBY
_LED_VAOC_OFF
[gcode_macro _LED_INPUT_SHAPER_START]
gcode =
_LED_ACTION
[gcode_macro _LED_INPUT_SHAPER_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_START]
gcode =
_LED_ACTION
[gcode_macro _LED_BEACON_CALIBRATION_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_VAOC_ON]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=1.0 GREEN=1.0 BLUE=1.0
{% endif %}
[gcode_macro _LED_VAOC_OFF]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=0.0 GREEN=0.0 BLUE=0.0
{% endif %}
[gcode_macro _LED_ACTION]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_action %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SUCCESS]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_success %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_HEATING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_heating %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_COOLING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_cooling %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ERROR]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_error %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ON]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_on %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_OFF]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_off %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_STANDBY]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_standby %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
{% if toolhead >= 0 %}
{% if printer['neopixel nozzle_led_t%s' % toolhead] is defined %}
SET_LED LED={'nozzle_led_t%s' % toolhead} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% else %}
{% if printer['neopixel nozzle_led_t0'] is defined %}
SET_LED LED={'nozzle_led_t0'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% if printer['neopixel nozzle_led_t1'] is defined %}
SET_LED LED={'nozzle_led_t1'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% endif %}
_USER_LED_SET { rawparams }
[gcode_macro _USER_LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
[gcode_macro LOAD_FILAMENT]
description = Loads new filament. Note: be careful with PETG, make sure you inspect the tip of your filament before loading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% if filament_name == '' or filament_type == '' %}
{% set filament_name = 'unknown' %}
{% set filament_type = 'unknown' %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_LOAD_FILAMENT TEMP={temp} NAME={filament_name} TYPE={filament_type}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_LOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME={filament_name} TYPE={filament_type}
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _DEFAULT_LOAD_FILAMENT]
description = Load filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_LOAD_FILAMENT" MSG="TEMP={temp}"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=load_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
_LOAD_FILAMENT TOOLHEAD=0
RESTORE_GCODE_STATE NAME=load_state
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD=0
[gcode_macro _IDEX_LOAD_FILAMENT]
description = Load filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_LOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
_LOAD_FILAMENT TOOLHEAD={toolhead} TEMP={temp}
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into hotend.."
G92 E0
G0 E{extruder_gear_to_cooling_position_distance} F{extruder_load_speed}
G92 E0
M400
RATOS_ECHO MSG="Filament loaded into hotend."
[gcode_macro _LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set load_speed = printer["gcode_macro T%s" % toolhead].filament_load_speed|float * 60 %}
{% set filament_loading_nozzle_offset = printer["gcode_macro T%s" % toolhead].filament_loading_nozzle_offset|float %}
{% set cooling_position_to_nozzle_distance = printer["gcode_macro T%s" % toolhead].cooling_position_to_nozzle_distance|float %}
{% set purge_after_load = printer["gcode_macro T%s" % toolhead].purge_after_load|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into nozzle... Please wait!"
G92 E0
G0 E{cooling_position_to_nozzle_distance + filament_loading_nozzle_offset} F{load_speed}
G92 E0
G4 P1000
_PURGE_FILAMENT TOOLHEAD={toolhead} E={purge_after_load}
RATOS_ECHO MSG="Filament loaded into nozzle!"
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
{% set filament_grabbing_length = printer["gcode_macro T%s" % toolhead].filament_grabbing_length|float %}
{% set filament_grabbing_speed = printer["gcode_macro T%s" % toolhead].filament_grabbing_speed|float %}
{% set resume_after_insert = true if printer["gcode_macro T%s" % toolhead].resume_after_insert|default(true)|lower == 'true' else false %}
{% set enable_insert_detection = true if printer["gcode_macro T%s" % toolhead].enable_insert_detection|default(true)|lower == 'true' else false %}
{% set current_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% if enable_insert_detection %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="toolhead: {toolhead}, filament_grabbing_length: {filament_grabbing_length}, filament_grabbing_speed: {filament_grabbing_speed}, current_idex_mode: {current_idex_mode}"
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
FORCE_MOVE STEPPER={'extruder%s' % ('' if toolhead == 0 else toolhead)} DISTANCE={filament_grabbing_length} VELOCITY={filament_grabbing_speed}
M400
{% if printer.pause_resume.is_paused %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% if resume_after_insert %}
RESUME
{% endif %}
{% else %}
{% if not printer.virtual_sdcard.is_active %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
[gcode_macro _PURGE_BEFORE_UNLOAD]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set purge_before_unload = printer["gcode_macro T%s" % toolhead].purge_before_unload|float %}
DEBUG_ECHO PREFIX="_PURGE_BEFORE_UNLOAD" MSG="TOOLHEAD: {toolhead}"
{% if purge_before_unload > 0 %}
G92 E0
G0 E{purge_before_unload} F300
G92 E0
M400
{% endif %}
[gcode_macro _PURGE_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set e = params.E|int %}
{% set r = params.R|default(0)|int %}
DEBUG_ECHO PREFIX="_PURGE_FILAMENT" MSG="TOOLHEAD: {toolhead}, E: {e}"
{% if e > 0 %}
G92 E0
G0 E{e} F300
G92 E0
M400
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={0.4 if toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={0.4 if toolhead == 1 else 0}
{% else %}
M106 S{(255 * 0.4)}
{% endif %}
{% endif %}
G4 P3000
{% if r > 0 %}
G92 E0
G0 E-{r} F300
G92 E0
M400
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_PARKING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_PARKING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_LOADING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_LOADING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% if act_t == toolhead %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{loading_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CLEANING_MOVE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined and printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% set cleaning_position = loading_position %}
{% if loading_position == parking_position %}
{% if loading_position > 0 %}
{% set cleaning_position = loading_position - 30 %}
{% else %}
{% set cleaning_position = loading_position + 30 %}
{% endif %}
{% endif %}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _START_PRINT_BED_MESH]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
SET_MACRO_TRAVEL_SETTINGS
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set X=[params.X0|default(-1)|float, params.X1|default(-1)|float] %}
{% set Y=[params.Y0|default(-1)|float, params.Y1|default(-1)|float] %}
DEBUG_ECHO PREFIX="_START_PRINT_BED_MESH" MSG="idex_mode: {idex_mode}, X: {X}, Y: {Y}"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set X=[0, printable_x_max] %}
{% endif %}
{% set beacon_bed_mesh_scv = printer["gcode_macro RatOS"].beacon_bed_mesh_scv|default(25)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% if printer.configfile.settings.beacon is defined and not beacon_contact_bed_mesh %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={beacon_bed_mesh_scv}
{% endif %}
{% set default_profile = printer["gcode_macro RatOS"].bed_mesh_profile|default('ratos') %}
{% if printer["gcode_macro RatOS"].calibrate_bed_mesh|lower == 'true' %}
BED_MESH_CLEAR
{% if printer["gcode_macro RatOS"].adaptive_mesh|lower == 'true' %}
CALIBRATE_ADAPTIVE_MESH PROFILE={default_profile} X0={X[0]} X1={X[1]} Y0={Y[0]} Y1={Y[1]} T={params.T|int} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={idex_mode}
{% else %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% endif %}
BED_MESH_PROFILE LOAD={default_profile}
{% elif printer["gcode_macro RatOS"].bed_mesh_profile is defined %}
BED_MESH_CLEAR
BED_MESH_PROFILE LOAD={printer["gcode_macro RatOS"].bed_mesh_profile}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
[gcode_macro CALIBRATE_ADAPTIVE_MESH]
gcode =
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set default_profile = params.PROFILE %}
{% set x0 = params.X0|default(-1)|float %}
{% set y0 = params.Y0|default(-1)|float %}
{% set x1 = params.X1|default(-1)|float %}
{% set y1 = params.Y1|default(-1)|float %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Recieved coordinates X0={x0} Y0={y0} X1={x1} Y1={y1}"
{% if x0 >= x1 or y0 >= y1 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Invalid coordinates received. Please check your slicer settings. Falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float %}
{% set mesh_x0 = [[x0, max_x]|min, min_x]|max %}
{% set mesh_y0 = [[y0, max_y]|min, min_y]|max %}
{% set mesh_x1 = [[x1, max_x]|min, min_x]|max %}
{% set mesh_y1 = [[y1, max_y]|min, min_y]|max %}
{% if mesh_x0 == min_x and mesh_y0 == min_y and mesh_x1 == max_x and mesh_y1 == max_y %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Print is using the full bed, falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
DEPLOY_PROBE
{% endif %}
{% set probe_count_x = mesh_config.probe_count.split(",")[0]|int %}
{% if mesh_config.probe_count.split(",")|length == 2 %}
{% set probe_count_y = mesh_config.probe_count.split(",")[1]|int %}
{% else %}
{% set probe_count_y = mesh_config.probe_count.split(",")[0]|int %}
{% endif %}
{% set probe_x_step = (max_x - min_x) / probe_count_x %}
{% set probe_y_step = (max_y - min_y) / probe_count_y %}
{% set mesh_count_x = ([(mesh_x1 - mesh_x0) / probe_x_step, 3]|max)|int %}
{% set mesh_count_y = ([(mesh_y1 - mesh_y0) / probe_y_step, 3]|max)|int %}
{% set min_mesh_count = [mesh_count_x, mesh_count_y]|min %}
{% set max_mesh_count = [mesh_count_x, mesh_count_y]|max %}
{% set algorithm = mesh_config.algorithm %}
{% if algorithm|lower == 'lagrange' and max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="cannot exceed a probe_count of 6 when using lagrange interpolation. Falling back to bicubic interpolation."
{% set algorithm = 'bicubic' %}
{% endif %}
{% if algorithm|lower == 'bicubic' and min_mesh_count < 4 %}
{% if max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="invalid probe_count option when using bicubic interpolation. Combination of 3 points on one axis with more than 6 on another is not permitted. Forcing minimum mesh count to be 4."
{% set min_mesh_count = 4 %}
{% else %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="bicubic interpolation with a probe_count of less than 4 points detected. Forcing lagrange interpolation."
{% set algorithm = 'lagrange' %}
{% endif %}
{% endif %}
{% set mesh_count_x = ([min_mesh_count, mesh_count_x]|max)|int %}
{% set mesh_count_x = ([max_mesh_count, mesh_count_x]|min)|int %}
{% set mesh_count_y = ([min_mesh_count, mesh_count_y]|max)|int %}
{% set mesh_count_y = ([max_mesh_count, mesh_count_y]|min)|int %}
{% set should_prime = printer["gcode_macro RatOS"].nozzle_priming == 'primeblob' %}
{% if printer["dual_carriage"] is not defined %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% else %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% endif %}
{% if printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 != 0 and probe_first %}
{% set probe_first = false %}
{% elif printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 == 0 and not probe_first %}
{% set probe_first = true %}
{% endif %}
{% if should_prime and probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="mesh coordinates X0={mesh_x0} Y0={mesh_y0} X1={mesh_x1} Y1={mesh_y1}"
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% if should_prime and not probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
STOW_PROBE
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M84]
rename_existing = M84.1
gcode =
M84.1
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
{% if printer["dual_carriage"] is defined %}
_SET_TOOLHEAD_OFFSET T={printer["gcode_macro RatOS"].default_toolhead|int} MOVE=0
SET_GCODE_VARIABLE MACRO=SET_PRESSURE_ADVANCE VARIABLE=snyc_toolheads VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro _VAOC"] is defined %}
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started VALUE=False
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started_at_temp VALUE=False
{% endif %}
SET_GCODE_OFFSET X=0 Y=0 Z=0 MOVE=0
_IDEX_SINGLE INIT=1
{% endif %}
SET_SKEW CLEAR=1
_LED_MOTORS_OFF
[gcode_macro M104]
rename_existing = M104.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
DEBUG_ECHO PREFIX="M104" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set temperature_offset_t0 = printer["gcode_macro T0"].temperature_offset|default(0)|int %}
{% set temperature_offset_t1 = printer["gcode_macro T1"].temperature_offset|default(0)|int %}
{% set s0 = [s + temperature_offset_t0, 0]|max %}
{% set s1 = [s + temperature_offset_t1, 0]|max %}
{% if temperature_offset_t0 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t0}°C added to toolhead T0."
{% endif %}
{% if temperature_offset_t1 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t1}°C added to toolhead T1."
{% endif %}
{% else %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
M104.1 S{s0} T0
M104.1 S{s1} T1
{% else %}
M104.1 S{s} T{t}
{% endif %}
{% endif %}
[gcode_macro M109]
rename_existing = M109.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
DEBUG_ECHO PREFIX="M109" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M109" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
M109.1 S{s} T{t}
{% endif %}
[gcode_macro SET_HEATER_TEMPERATURE]
rename_existing = SET_HEATER_TEMPERATURE_BASE
gcode =
{% set heater = params.HEATER|default("") %}
{% set target = params.TARGET|default(0)|int %}
DEBUG_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="heater: {heater}, target: {target}"
{% if heater|lower == "extruder" or heater|lower == "extruder1" %}
{% set t = 0 if heater|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and target > 0 %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set target = [target + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
SET_HEATER_TEMPERATURE_BASE HEATER="{heater}" TARGET={target}
[gcode_macro TEMPERATURE_WAIT]
rename_existing = TEMPERATURE_WAIT_BASE
gcode =
{% set sensor = params.SENSOR|default("") %}
{% set minimum = params.MINIMUM|default(-1)|int %}
{% set maximum = params.MAXIMUM|default(-1)|int %}
DEBUG_ECHO PREFIX="TEMPERATURE_WAIT" MSG="sensor: {sensor}, minimum: {minimum}, maximum: {maximum}"
{% if sensor|lower == "extruder" or sensor|lower == "extruder1" %}
{% set t = 0 if sensor|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and (minimum > 0 or maximum > 0) %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% if minimum > -1 %}
{% set minimum = [minimum + temperature_offset, 0]|max %}
{% endif %}
{% if maximum > -1 %}
{% set maximum = [maximum + temperature_offset, 0]|max %}
{% endif %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% if minimum > -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum} MAXIMUM={maximum}
{% elif minimum > -1 and maximum == -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum}
{% elif minimum == -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MAXIMUM={maximum}
{% endif %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature for toolhead T{t} reached."
[gcode_macro SET_GCODE_OFFSET]
rename_existing = SET_GCODE_OFFSET_ORG
gcode =
SET_GCODE_OFFSET_ORG { rawparams }
{% if printer.configfile.settings.beacon is defined and (params.Z_ADJUST is defined or params.Z is defined) %}
_BEACON_APPLY_RUNTIME_MULTIPLIER
{% endif %}
[gcode_macro SDCARD_PRINT_FILE]
rename_existing = SDCARD_PRINT_FILE_BASE
gcode =
{% if printer["ratos"] is defined %}
PROCESS_GCODE_FILE { rawparams }
{% else %}
SDCARD_PRINT_FILE_BASE { rawparams }
{% endif %}
[gcode_macro SKEW_PROFILE]
rename_existing = SKEW_PROFILE_BASE
variable_loaded_profile = ""
gcode =
{% if params.LOAD is defined %}
{% if printer.configfile.settings["skew_correction %s" % params.LOAD] is defined %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='"{params.LOAD}"'
{% endif %}
{% endif %}
SKEW_PROFILE_BASE { rawparams }
[gcode_macro SET_SKEW]
rename_existing = SET_SKEW_BASE
gcode =
{% if params.CLEAR is defined %}
{% if params.CLEAR|default(0)|int == 1 %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='""'
{% endif %}
{% endif %}
SET_SKEW_BASE { rawparams }
[gcode_macro SET_VELOCITY_LIMIT]
rename_existing = SET_VELOCITY_LIMIT_BASE
gcode =
{% if params.ACCEL_TO_DECEL is defined %}
{% if params.ACCEL is defined %}
{% set accel = params.ACCEL|float %}
{% else %}
{% set accel = printer.toolhead.max_accel|float %}
{% endif %}
{% if params.VELOCITY is defined %}
{% set velocity = params.VELOCITY|float %}
{% else %}
{% set velocity = printer.toolhead.max_velocity|float %}
{% endif %}
{% if params.SQUARE_CORNER_VELOCITY is defined %}
{% set scv = params.SQUARE_CORNER_VELOCITY|float %}
{% else %}
{% set scv = printer.toolhead.square_corner_velocity|float %}
{% endif %}
{% set mcr = params.ACCEL_TO_DECEL|float / accel %}
DEBUG_ECHO PREFIX="SET_VELOCITY_LIMIT" MSG="ACCEL={accel}, VELOCITY={velocity}, SQUARE_CORNER_VELOCITY={scv}, MINIMUM_CRUISE_RATIO={mcr}"
SET_VELOCITY_LIMIT_BASE ACCEL={accel} VELOCITY={velocity} SQUARE_CORNER_VELOCITY={scv} MINIMUM_CRUISE_RATIO={1-mcr}
{% else %}
SET_VELOCITY_LIMIT_BASE { rawparams }
{% endif %}
[gcode_macro _START_PRINT_PARK]
gcode =
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_x = printer["gcode_macro RatOS"].start_print_park_x %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% endif %}
{% if printer["dual_carriage"] is defined and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
{% if printer["gcode_macro RatOS"].start_print_park_x is defined and printer["gcode_macro RatOS"].start_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="start_print_park_x is ignored for IDEX printers"
{% endif %}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={start_print_park_in} X={start_print_park_x}
G0 Z{z} F{z_speed}
[gcode_macro _END_PRINT_PARK]
gcode =
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro RatOS"].end_print_park_x is defined and printer["gcode_macro RatOS"].end_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="end_print_park_x is ignored for IDEX printers"
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={printer["gcode_macro RatOS"].end_print_park_in} X={printer["gcode_macro RatOS"].end_print_park_x}
[gcode_macro _PARK]
gcode =
{% set x = params.X %}
{% set location = params.LOCATION|default('back')|lower %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set nozzle_priming = printer["gcode_macro RatOS"].nozzle_priming|lower %}
CACHE_TOOLHEAD_SETTINGS KEY="park"
SET_MACRO_TRAVEL_SETTINGS
{% if x != '' %}
{% if x|float >= printer.toolhead.axis_minimum.x + 5 and x|float <= printable_x_max - 5 %}
{% set park_x = x|float %}
{% else %}
{action_respond_info('The requested X co-ordinate is outside the defined axis bounds - using defaults')}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% else %}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% set park_y = printable_y_max - 15 %}
{% if location == 'front' %}
{% set park_y = printer.toolhead.axis_minimum.y + 5 %}
{% elif location == 'center' %}
{% set park_y = printable_y_max / 2 %}
{% elif location == 'primeblob' and printer["dual_carriage"] is defined %}
{% set park_y = printable_y_max - 15 %}
{% endif %}
{% if location == 'primeblob' and printer["dual_carriage"] is not defined %}
{% if (nozzle_priming == 'primeblob' or nozzle_priming == 'primeline') %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set park_x = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set park_x = printable_x_max - 5 %}
{% else %}
{% set park_x = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set park_y = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set park_y = printable_y_max - 5 %}
{% else %}
{% set park_y = nozzle_prime_start_y|float %}
{% endif %}
{% endif %}
{% endif %}
G90
{% if printer["dual_carriage"] is not defined %}
G0 X{park_x} Y{park_y} F{speed}
{% else %}
G0 Y{park_y} F{speed}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="park"
[gcode_macro SAVE_PROBE_RESULT]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
{% set last_z_offset = 9999.9 %}
{% if printer.configfile.settings.beacon is defined %}
{% set current_z = printer.toolhead.position.z|float %}
{% if beacon_contact_prime_probing %}
{% set last_z_offset = printer.beacon.last_z_result %}
{% else %}
{% set last_z_offset = printer.beacon.last_sample.dist - current_z %}
{% endif %}
{% elif printer.configfile.settings.bltouch is defined %}
{% set config_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% elif printer.configfile.settings.probe is defined %}
{% set config_offset = printer.configfile.settings.probe.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Saving offset adjustment of {last_z_offset} in {params.VARIABLE|default('last_z_offset')}"
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE={params.VARIABLE|default('last_z_offset')} VALUE={last_z_offset}
[gcode_macro PROBE_FOR_PRIMING]
gcode =
{% set probe_for_priming_disable_mesh_constraints = true if printer["gcode_macro RatOS"].probe_for_priming_disable_mesh_constraints|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower != 'false' %}
SAVE_GCODE_STATE NAME=probe_for_priming_state
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the prime location.."
CACHE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
SET_MACRO_TRAVEL_SETTINGS
{% set t = params.TOOLHEAD|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% if idex_mode == '' %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% if t == 0 %}
{% set x_start = 5 %}
{% else %}
{% set x_start = printable_x_max - 5 %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% endif %}
{% endif %}
{% set z = printer.configfile.settings.bed_mesh.horizontal_move_z|float %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% if printer.configfile.settings.bltouch is defined %}
{% set x_offset = printer.configfile.settings.bltouch.x_offset|float %}
{% set y_offset = printer.configfile.settings.bltouch.y_offset|float %}
{% set z_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% elif printer.configfile.settings.probe is defined %}
{% set x_offset = printer.configfile.settings.probe.x_offset|float %}
{% set y_offset = printer.configfile.settings.probe.y_offset|float %}
{% set z_offset = printer.configfile.settings.probe.z_offset|float %}
{% elif printer.configfile.settings.beacon is defined %}
{% set x_offset = printer.configfile.settings.beacon.x_offset|float %}
{% set y_offset = printer.configfile.settings.beacon.y_offset|float %}
{% set z_offset = printer.configfile.settings.beacon.trigger_distance|float %}
{% else %}
{ action_raise_error("No probe, beacon or bltouch section found. Adaptive priming only works with a [probe], [beacon] or [bltouch] section defined.") }
{% endif %}
{% if z < z_offset %}
{ action_raise_error("Horizontal move Z ({z}) is below your probe's Z offset ({z_offset}). Please adjust your horizontal_move_z setting in [bed_mesh] to be above {z}.") }
{% endif %}
{% if not probe_for_priming_disable_mesh_constraints %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float - x_offset %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float - y_offset %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float - x_offset %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float - y_offset %}
{% set x_start = [[x_start, max_x]|min, min_x]|max %}
{% set y_start = [[y_start, max_y]|min, min_y]|max %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the start of the prime location at {x_start}, {y_start}"
G90
M83
G0 Z{z} F{z_speed}
G1 X{x_start} Y{y_start} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result
{% endif %}
{% if idex_mode == '' %}
{% set x_end = x_start %}
{% set y_end = y_start + 45 %}
{% else %}
{% if t==1 %}
{% set x_end = x_start - 45 %}
{% else %}
{% set x_end = x_start + 45 %}
{% endif %}
{% set y_end = y_start %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the end of the prime location at {x_end}, {y_end}"
G1 X{x_end} Y{y_end} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result
{% endif %}
RESTORE_GCODE_STATE NAME=probe_for_priming_state
RESTORE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
{% endif %}
[gcode_macro RESET_PRIME_PROBE_STATE]
gcode =
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result VALUE=None
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result_t1 VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result_t1 VALUE=None
{% endif %}
[gcode_macro PROBE_CURRENT_POSITION]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
SAVE_GCODE_STATE NAME=probe_current_position_state
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
ASSERT_PROBE_DEPLOYED
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_prime_probing %}
PROBE PROBE_METHOD=contact SAMPLES=1
{% else %}
PROBE
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
BEACON_QUERY
{% else %}
RESTORE_GCODE_STATE NAME=probe_current_position_state MOVE=1 MOVE_SPEED={printer["gcode_macro RatOS"].macro_z_speed|float}
{% endif %}
[gcode_macro PRIME_BLOB]
description = Prints a primeblob, used internally, if configured, as part of the START_PRINT macro.
variable_x_offset = 5
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="prime_blob"
SET_MACRO_TRAVEL_SETTINGS
RATOS_ECHO PREFIX="Priming" MSG="Priming nozzle with prime blob.."
{% set current_toolhead = 0 %}
{% set target_idex_mode = '' %}
{% set extruder = 'extruder' %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE is defined %}
{% set target_idex_mode = params.IDEX_MODE|default('')|lower %}
{% else %}
{ action_raise_error("IDEX_MODE parameter not found for PRIME_BLOB macro. This is likely a bug.") }
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Priming in IDEX {target_idex_mode} mode.."
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set current_toolhead = 1 if current_idex_mode=='primary' else 0 %}
{% set extruder = 'extruder1' if current_toolhead == 1 else 'extruder' %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
SAVE_GCODE_STATE NAME=prime_blob_state
{% endif %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set fan_speed = printer["gcode_macro RatOS"].nozzle_prime_bridge_fan|float %}
{% set nozzle_diameter = printer.configfile.settings[extruder].nozzle_diameter|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set has_start_offset_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) != 9999.9 %}
{% if printer["dual_carriage"] is defined %}
{% set has_start_offset_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) != 9999.9 %}
{% endif %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_z_height = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set nozzle_prime_direction = printer["gcode_macro RatOS"].nozzle_prime_direction|lower %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% if target_idex_mode == '' %}
{% set x_factor = 0 %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% set y_factor = 1 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% set y_factor = -1 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% if nozzle_prime_start_y|float < printable_y_max / 2 %}
{% set y_factor = 1 %}
{% else %}
{% set y_factor = -1 %}
{% endif %}
{% endif %}
{% if nozzle_prime_direction == 'forwards' %}
{% set y_factor = 1 %}
{% elif nozzle_prime_direction == 'backwards' %}
{% set y_factor = -1 %}
{% endif %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% else %}
{% set z = start_print_park_z_height %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% set y_factor = 0 %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set x_start = center_x / 2 + 5 %}
{% set x_factor = 1 %}
{% else %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% if current_toolhead == 0 %}
{% set x_start = 55 %}
{% set x_factor = -1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 55 %}
{% set x_factor = 1 %}
{% endif %}
{% else %}
{% if current_toolhead == 0 %}
{% set x_start = 5 %}
{% set x_factor = 1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 5 %}
{% set x_factor = -1 %}
{% endif %}
{% endif %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_x_max - 5 %}
{% endif %}
{% set z = 10 %}
{% endif %}
{% set start_z_offset = 0 %}
{% set end_z_offset = 0 %}
{% if has_start_offset_t0 %}
{% set start_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) %}
{% set end_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_end_result|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t0) ) }
{% endif %}
{% if end_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t0) ) }
{% endif %}
{% set start_z_offset = start_z_probe_result_t0 %}
{% set end_z_offset = end_z_probe_result_t0 %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if current_toolhead == 1 or both_toolheads or target_idex_mode == "copy" or target_idex_mode == "mirror" %}
{% if has_start_offset_t1 %}
{% set start_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) %}
{% set end_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_end_result_t1|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t1) ) }
{% endif %}
{% if end_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t1) ) }
{% endif %}
{% set start_z_offset = [start_z_offset, start_z_probe_result_t1]|max %}
{% set end_z_offset = [end_z_offset, start_z_probe_result_t1]|max %}
{% endif %}
{% endif %}
{% if target_idex_mode != 'copy' and target_idex_mode != 'mirror' %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% set original_start_z_offset = start_z_offset %}
{% set original_end_z_offset = end_z_offset %}
{% set start_z_offset = original_end_z_offset %}
{% set end_z_offset = original_start_z_offset %}
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={current_toolhead}
{% endif %}
DEBUG_ECHO PREFIX="PRIME_BLOB" MSG="x_start: {x_start}, y_start: {y_start}, x_factor: {x_factor}, y_factor: {y_factor}, z: {z}, start_z_offset: {start_z_offset}, end_z_offset: {end_z_offset}"
G90
M83
RATOS_ECHO PREFIX="Priming" MSG="Lifting Z to {z}.."
G0 Z{z} F{z_speed}
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% if start_print_park_in != 'primeblob' %}
G1 X{x_start} F{speed}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% endif %}
{% else %}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% if target_idex_mode=="copy" or target_idex_mode=="mirror" %}
RATOS_ECHO PREFIX="Priming" MSG="Mirroring move to {x_start}, {y_start} along the edge of the print area.."
_IDEX_MIRROR PRIMING=1
{% else %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% endif %}
G1 X{x_start} F{speed}
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Starting prime blob.."
G1 Z{0.5 + start_z_offset} F{z_speed}
G1 Y{y_start} F{speed}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
M106 S{fan_speed}
G1 Z5 F100 E5
G92 E0
RATOS_ECHO PREFIX="Priming" MSG="Bridging with {((fan_speed/255) * 100)|int}% fan speed.."
G1 F3000 X{x_start + (15 * x_factor)} Y{y_start + (15 * y_factor)} E{1 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (20 * x_factor)} Y{y_start + (20 * y_factor)} Z{3.8 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (34 * x_factor)} Y{y_start + (34 * y_factor)} Z{2.6 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (38 * x_factor)} Y{y_start + (38 * y_factor)} Z{1.4 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (42 * x_factor)} Y{y_start + (42 * y_factor)} Z{0.2 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
M106 S0
G1 F3000 X{x_start + (46 * x_factor)} Y{y_start + (46 * y_factor)} Z{0.2 + end_z_offset} E0.6
G1 F{speed} X{x_start + (50 * x_factor)} Y{y_start + (50 * y_factor)}
{% if target_idex_mode == "copy" or target_idex_mode == "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if target_idex_mode == "copy" %}
{% if first_y >= 0 %}
_IDEX_COPY DANCE=0 Y={first_y}
{% else %}
_IDEX_COPY DANCE=0 Y={params.Y1}
{% endif %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
RESTORE_GCODE_STATE NAME=prime_blob_state
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="prime_blob"
G92 E0
[gcode_macro UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% set temp = params.TEMP|default(220)|int %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_UNLOAD_FILAMENT TEMP={temp} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _LEGACY_UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set unload_speed = 5 * 60 %}
{% set unload_length = printer["gcode_macro RatOS"].filament_unload_length|float %}
M117 Unloading filament...
G0 E10 F300
G0 E-5 F3600
G4 P3000
G0 E5 F6000
G0 E-15 F6000
G0 E-{unload_length} F{unload_speed}
_CLEANING_MOVE TOOLHEAD={toolhead}
M117 Filament unloaded!
RESPOND MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _DEFAULT_UNLOAD_FILAMENT]
description = Unload filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_UNLOAD_FILAMENT" MSG="TEMP: {temp}"
_LED_UNLOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=unload_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD=0 NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TOOLHEAD=0
{% endif %}
RESTORE_GCODE_STATE NAME=unload_state
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD=0
[gcode_macro _IDEX_UNLOAD_FILAMENT]
description = Unload filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_UNLOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead}
{% endif %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Unloading filament from nozzle to cooling zone... Please wait!"
_PURGE_BEFORE_UNLOAD TOOLHEAD={toolhead}
{% if printer["gcode_macro _UNLOAD_WITHOUT_TIP_FORMING"] is defined %}
_UNLOAD_WITHOUT_TIP_FORMING TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_UNLOAD_WITH_TIP_FORMING NAME='{filament_name}' TYPE='{filament_type}'
{% endif %}
G4 P3000
[gcode_macro _UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
{% set tooolhead_sensor_to_extruder_gear_distance = printer["gcode_macro T%s" % toolhead].tooolhead_sensor_to_extruder_gear_distance|float %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER" MSG="TOOLHEAD: {toolhead}"
G0 E-{extruder_gear_to_cooling_position_distance + tooolhead_sensor_to_extruder_gear_distance + 50} F{extruder_load_speed}
RATOS_ECHO MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _UNLOAD_WITH_TIP_FORMING]
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% if filament_name != '' and filament_type != '' %}
_UNLOAD_KNOWN_FILAMENT NAME={filament_name} TYPE={filament_type}
{% else %}
_UNLOAD_UNKNOWN_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _UNLOAD_KNOWN_FILAMENT]
description = User overrideable tip forming macro if slicer filament profiles are known
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
RATOS_ECHO PREFIX="FILAMENT TYPE" MSG='{filament_type}'
RATOS_ECHO PREFIX="FILAMENT PROFILE" MSG='{filament_name}'
{% if filament_name == "Prusament PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% elif filament_name == "Nobufil PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% else %}
RATOS_ECHO PREFIX="_UNLOAD_KNOWN_FILAMENT" MSG="Filament profile not found!"
_UNLOAD_UNKNOWN_FILAMENT
{% endif %}
[gcode_macro _UNLOAD_UNKNOWN_FILAMENT]
description = User overrideable standard tip forming macro
gcode =
DEBUG_ECHO PREFIX="_UNLOAD_UNKNOWN_FILAMENT" MSG="Using standard tip forming macro!"
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
[gcode_macro _TIP_FORMING]
gcode =
{% set cooling_moves = params.COOLING_MOVES|default(4)|int %}
{% set cooling_move_length = params.COOLING_MOVE_LENGTH|default(10)|float %}
{% set start_cooling_speed = params.START_COOLING_SPEED|default(10)|float * 60 %}
{% set end_cooling_speed = params.END_COOLING_SPEED|default(50)|float * 60 %}
{% if cooling_moves == 0 %}
{% set cooling_move_length = 0 %}
{% endif %}
{% set dip = true if params.DIP|default(false)|lower == "true" else false %}
{% set dip_length = params.DIP_LENGTH|default(22)|float %}
{% set dip_speed = params.DIP_SPEED|default(30)|float * 60 %}
{% set dip_retract_speed = params.DIP_RETRACT_SPEED|default(70)|float * 60 %}
{% set retract_length = params.RETRACT_LENGTH|default(18)|float %}
{% set start_retract_speed = params.START_RETRACT_SPEED|default(120)|float * 60 %}
{% set end_retract_speed = params.END_RETRACT_SPEED|default(20)|float * 60 %}
DEBUG_ECHO PREFIX="_TIP_FORMING" MSG="cooling_moves: {cooling_moves}, cooling_move_length: {cooling_move_length}, start_cooling_speed: {start_cooling_speed}, end_cooling_speed: {end_cooling_speed}, dip: {dip}, dip_length: {dip_length}, dip_speed: {dip_speed}, dip_retract_speed: {dip_retract_speed}, retract_length: {retract_length}, start_retract_speed: {start_retract_speed}, end_retract_speed: {end_retract_speed}"
M220 S100
G92 E0
{% set retract = retract_length + cooling_move_length / 2 - 15 %}
G1 E-15 F{start_retract_speed}
G1 E-{0.7 * retract} F{1.0 * end_retract_speed}
G1 E-{0.2 * retract} F{0.5 * end_retract_speed}
G1 E-{0.1 * retract} F{0.3 * end_retract_speed}
G92 E0
{% if cooling_moves > 0 %}
{% set i = (end_cooling_speed - start_cooling_speed) / (2 * cooling_moves - 1) %}
{% for m in range(cooling_moves) %}
G1 E{cooling_move_length} F{(start_cooling_speed + i * m * 2)}
G1 E-{cooling_move_length} F{(start_cooling_speed + i * (m * 2 + 1))}
{% endfor %}
{% endif %}
G92 E0
{% if dip %}
G1 E{dip_length} F{dip_speed}
G4 P100
G1 E-{dip_length} F{dip_retract_speed}
{% endif %}
G92 E0
M400
[gcode_macro _ON_FILAMENT_SENSOR_BUTTON_PRESSED]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_SENSOR_BUTTON_PRESSED" MSG="TOOLHEAD: {toolhead}"
{% if not printer.virtual_sdcard.is_active %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_FILAMENT_END]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set clogged = true if params.CLOGGED|default(false)|lower == 'true' else false %}
{% set unload_after_runout = printer["gcode_macro T%s" % toolhead].unload_after_runout|float %}
{% if clogged %}
_LED_FILAMENT_CLOG TOOLHEAD={toolhead}
{% else %}
_LED_FILAMENT_RUNOUT TOOLHEAD={toolhead}
{% endif %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_END" MSG="TOOLHEAD: {toolhead}"
{% if printer.virtual_sdcard.is_active %}
{% if not printer.pause_resume.is_paused %}
PAUSE RUNOUT=True
{% endif %}
{% if not clogged and unload_after_runout %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% if not clogged and printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true'%}
_JOIN_SPOOL TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M600]
description = Executes a color change by pausing the printer an unloading the filament.
gcode =
PAUSE
UNLOAD_FILAMENT
RATOS_ECHO MSG="Please load new filament and resume"
[gcode_macro COLD_PULL]
description = Automated hotend cold pull.
gcode =
{% set extrusion_temp = params.EXTRUSION_TEMP|default(220)|int %}
{% set cold_pull_temp = params.COLD_PULL_TEMP|default(80)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% if printer["dual_carriage"] is not defined %}
{% set toolhead = 0 %}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead != 0 and toolhead != 1 %}
{action_raise_error("Please select toolhead! 0 = left, 1 = right toolhead")}
{% endif %}
{% endif %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
SAVE_GCODE_STATE NAME=cold_pull_state
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
RATOS_ECHO MSG="Heating T{toolhead} to {extrusion_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={extrusion_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={extrusion_temp} MAXIMUM={extrusion_temp + 2}
G4 P3000
RATOS_ECHO MSG="extruding..."
G92 E0
G1 E30 F300
G92 E0
RATOS_ECHO MSG="Heating T{toolhead} to {cold_pull_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={cold_pull_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={cold_pull_temp} MAXIMUM={cold_pull_temp + 2}
G4 P10000
RATOS_ECHO MSG="cold pull..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-40 VELOCITY=5 ACCEL=100
RATOS_ECHO MSG="eject filament..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-200 VELOCITY=20 ACCEL=500
RATOS_ECHO MSG="cooling down extruder..."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET=0
RESTORE_GCODE_STATE NAME=cold_pull_state
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
CONSOLE_ECHO TITLE="Cold pull finished!" MSG="Please remove the filament from the PTFE tube and cut the end off. Do NOT try to load it again." TYPE="warning"
[gcode_macro _USER_START_PRINT_BEFORE_HOMING]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_BED]
gcode =
[gcode_macro _USER_START_PRINT_BED_MESH]
gcode =
[gcode_macro _USER_START_PRINT_PARK]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
[gcode_macro _USER_START_PRINT_HEAT_CHAMBER]
description = Uses the extruder sensor to wait for chamber temp. Override the _START_PRINT_HEAT_CHAMBER macro to implement heated chamber handling.
gcode =
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
[gcode_macro _USER_END_PRINT_BEFORE_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_AFTER_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_PARK]
gcode =
[gcode_macro _USER_END_PRINT_FINISHED]
description = User hook for when the print is finished after gcode state has been restored.
gcode =
[gcode_macro _USER_START_PRINT]
gcode =
[gcode_macro _USER_END_START_PRINT]
gcode =
[gcode_macro _USER_START_FEATURE]
gcode =
[gcode_macro _USER_END_FEATURE]
gcode =
[gcode_macro ECHO_T_VARS]
description = Echo Toolhead variables to the console.
gcode =
{% set t = params.T|default(0) %}
RATOS_ECHO MSG="T{t} Variables"
{% for var, value in printer["gcode_macro T%s" % t].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[gcode_macro ECHO_RATOS_VARS]
description = Echo RatOS variables to the console.
gcode =
{% for var, value in printer["gcode_macro RatOS"].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[delayed_gcode RATOS_INIT]
initial_duration = 0.1
gcode =
_LED_STANDBY
CALCULATE_PRINTABLE_AREA
INITIAL_FRONTEND_UPDATE
_CHAMBER_FILTER_SANITY_CHECK
[delayed_gcode RATOS_LOGO]
initial_duration = 2
gcode =
HELLO_RATOS
[gcode_macro INITIAL_FRONTEND_UPDATE]
gcode =
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_error = printer["gcode_macro RatOS"].status_color_error|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_unknown}"'
{% endif %}
{% set t0_sensor = "undefined" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].filament_detected|lower == "true" %}
{% set t0_sensor = "detected" %}
{% else %}
{% set t0_sensor = "empty" %}
{% endif %}
{% else %}
{% set t0_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set t1_sensor = "undefined" %}
{% if printer["dual_carriage"] is defined and printer["filament_switch_sensor toolhead_filament_sensor_t1"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].filament_detected|lower == "true" %}
{% set t1_sensor = "detected" %}
{% else %}
{% set t1_sensor = "empty" %}
{% endif %}
{% else %}
{% set t1_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set svv = printer.save_variables.variables %}
{% if svv.t0_filament is defined and printer["gcode_macro T0"] is defined %}
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
{% if t0_sensor != "empty" %}
{% set t0_filament_type = svv.t0_filament[0]|default('')|string %}
{% set t0_filament_name = svv.t0_filament[1]|default('')|string %}
{% set t0_filament_temp = svv.t0_filament[2]|default(0)|float %}
{% if t0_filament_name != '' and t0_filament_type != '' and t0_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{t0_filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{t0_filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={t0_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
{% if svv.t1_filament is defined and printer["gcode_macro T1"] is defined %}
{% if printer["gcode_macro T1"].filament_name is defined and printer["gcode_macro T1"].filament_type is defined and printer["gcode_macro T1"].filament_temp is defined %}
{% if t1_sensor != "empty" %}
{% set t1_filament_type = svv.t1_filament[0]|default('')|string %}
{% set t1_filament_name = svv.t1_filament[1]|default('')|string %}
{% set t1_filament_temp = svv.t1_filament[2]|default(0)|float %}
{% if t1_filament_name != '' and t1_filament_type != '' and t1_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='"{t1_filament_name}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='"{t1_filament_type}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE={t1_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t1_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro CALCULATE_PRINTABLE_AREA]
gcode =
{% set bed_margin_x = printer["gcode_macro RatOS"].bed_margin_x %}
{% set bed_margin_y = printer["gcode_macro RatOS"].bed_margin_y %}
{% set tool = 0 if printer["gcode_macro T0"] is not defined or printer["gcode_macro T0"].active else 1 %}
{% set max_x = printer.toolhead.axis_maximum.x if printer["dual_carriage"] is defined and tool == 0 else printer.toolhead.axis_maximum.x - bed_margin_x[1] %}
{% if printer["dual_carriage"] is defined %}
{% set max_x = printer.toolhead.axis_maximum.x %}
{% endif %}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="printer.toolhead.axis_maximum.x {printer.toolhead.axis_maximum.x}"
{% set max_y = printer.toolhead.axis_maximum.y - bed_margin_y[1]%}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_x_max VALUE={max_x}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_y_max VALUE={max_y}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="Printable area calculated: X: 0,{max_x} Y: 0,{max_y}"
[gcode_macro CACHE_TOOLHEAD_SETTINGS]
variable_cache = {"global": {"accel": 1000, "ratio": 0.5, "speed": 50, "scv": 5}}
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set dummy = cache.__setitem__(key, {"accel": printer.toolhead.max_accel, "ratio": printer.toolhead.minimum_cruise_ratio, "speed": printer.toolhead.max_velocity, "scv": printer.toolhead.square_corner_velocity}) %}
SET_GCODE_VARIABLE MACRO=CACHE_TOOLHEAD_SETTINGS VARIABLE=cache VALUE="{cache | pprint | replace("\n", "") | replace("\"", "\\\"")}"
DEBUG_ECHO PREFIX="CACHE_TOOLHEAD_SETTINGS" MSG="Toolhead settings cached for {key}. {printer.toolhead.max_accel} accel, {printer.toolhead.minimum_cruise_ratio} ratio, {printer.toolhead.max_velocity} velocity, {printer.toolhead.square_corner_velocity} scv."
[gcode_macro RESTORE_TOOLHEAD_SETTINGS]
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set values = printer["gcode_macro CACHE_TOOLHEAD_SETTINGS"].cache.__getitem__(key) %}
{% if values is not defined or values == 'None' %}
{ action_raise_error("RESTORE_TOOLHEAD_SETTINGS: Toolhead settings not cached for key '" ~ key ~ "'.") }
{% endif %}
SET_VELOCITY_LIMIT ACCEL={values.accel} MINIMUM_CRUISE_RATIO={values.ratio} VELOCITY={values.speed} SQUARE_CORNER_VELOCITY={values.scv}
DEBUG_ECHO PREFIX="RESTORE_TOOLHEAD_SETTINGS" MSG="Toolhead settings restored. {values.accel} accel, {values.ratio} ratio, {values.speed} velocity, {values.scv} scv."
[gcode_macro SET_MACRO_TRAVEL_SETTINGS]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set accel = printer["gcode_macro RatOS"].macro_travel_accel %}
SET_VELOCITY_LIMIT ACCEL={accel} MINIMUM_CRUISE_RATIO=0.5 VELOCITY={speed} SQUARE_CORNER_VELOCITY={5}
DEBUG_ECHO PREFIX="SET_MACRO_TRAVEL_SETTINGS" MSG="Macro travel settings set. {accel} accel, {speed} velocity"
[gcode_macro SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% if printer["dual_carriage"] is not defined %}
SET_KINEMATIC_POSITION X={printable_x_max / 2} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
{% else %}
IDEX_SET_CENTER_KINEMATIC_POSITION
{% endif %}
[gcode_macro IDEX_SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set center_x = printable_x_max / 2 %}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x - (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x + (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
[gcode_macro VERIFY_HYBRID_INVERTED]
gcode =
{% set inverted = False %}
{% if printer.configfile.settings.ratos_hybrid_corexy is defined and printer.configfile.settings.ratos_hybrid_corexy.inverted is defined %}
{% if printer.configfile.settings.ratos_hybrid_corexy.inverted|lower == 'true' %}
{% set inverted = True %}
{% endif %}
{% endif %}
{% if inverted == False %}
{ action_emergency_stop("ratos_hybrid_corexy NOT INVERTED! Inverted hybrid core-xy bugfix not detected.") }
{% endif %}
[gcode_macro RATOS_ECHO]
gcode =
{% set prefix = "RatOS" %}
{% set debug = params.DEBUG|default(0)|int %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " | " ~ params.PREFIX %}
{% endif %}
{% set prefix = prefix ~ ":" %}
{% set msg = "" %}
{% if params.MSG is defined %}
{% set msg = params.MSG %}
{% else %}
{% set msg = "No msg parameter provided (this is a bug or unintended use)." %}
{% endif %}
{% if not debug %}
M117 {prefix} {msg}
{% endif %}
RATOS_LOG PREFIX="{prefix}" MSG="{msg}"
{% if not debug %}
RESPOND PREFIX="{prefix}" MSG="{msg}"
{% else %}
CONSOLE_ECHO TITLE="{prefix}" TYPE="debug" MSG="{msg}"
{% endif %}
[gcode_macro ENABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=True
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=prefix_filter VALUE="'{params.FILTER|default('')|lower}'"
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging enabled."
[gcode_macro DISABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=False
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging disabled."
[gcode_macro DEBUG_ECHO]
variable_enabled = False
variable_prefix_filter = ''
gcode =
{% set prefix = "DEBUG" %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " - " ~ params.PREFIX %}
{% endif %}
{% if enabled and (prefix_filter|lower == '' or prefix_filter|lower in params.PREFIX|lower) %}
RATOS_ECHO PREFIX="{prefix}" MSG="{params.MSG}" DEBUG=1
{% endif %}
[gcode_macro START_FEATURE]
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="Start {params.FEATURE} feature gcode"
{% set scv = printer.toolhead.square_corner_velocity|int|default(5) %}
{% set accel = printer.toolhead.max_accel|int|default(10000) %}
{% set ratio = printer.toolhead.minimum_cruise_ratio|float|default(0.5) %}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="scv" VALUE={scv}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="accel" VALUE={accel}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="ratio" VALUE={ratio}
_USER_START_FEATURE FEATURE="{params.FEATURE}"
[gcode_macro END_FEATURE]
variable_scv = 5
variable_accel = 10000
variable_ratio = 0.5
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="End {params.FEATURE} feature gcode"
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={scv} ACCEL={accel} MINIMUM_CRUISE_RATIO={ratio}
_USER_END_FEATURE FEATURE="{params.FEATURE}" SCV={scv} ACCEL={accel} RATIO={ratio}
[gcode_macro _ON_LAYER_CHANGE]
variable_layer_number = 0
description = INTERNAL USE ONLY. Call it from the slicers after layer change custom gcode
gcode =
{% set layer = params.LAYER|int %}
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE={layer}
SET_PRINT_STATS_INFO CURRENT_LAYER={layer}
[gcode_macro _LEARN_MORE_CALIBRATION]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/calibration" %}
{% set link_text = "RatOS Calibration Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_CHAMBER_FILTER]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter Control" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_FILAMENT]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/filaments" %}
{% set link_text = "RatOS Filament Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _CONSOLE_SAVE_CONFIG]
gcode =
M118 Click SAVE_CONFIG to save the settings to your printer.cfg.
[gcode_macro SAVE_Z_OFFSET]
gcode =
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SAVE_MULTIPLIER
{% else %}
Z_OFFSET_APPLY_PROBE
{% endif %}
[gcode_macro _LOAD_RATOS_SKEW_PROFILE]
gcode =
{% set ratos_skew_profile = printer["gcode_macro RatOS"].skew_profile|default("") %}
{% if ratos_skew_profile != "" %}
{% if printer.configfile.config["skew_correction %s" % ratos_skew_profile] is defined %}
SKEW_PROFILE LOAD={ratos_skew_profile}
GET_CURRENT_SKEW
{% else %}
{% set line_1 = '"Could not find skew profile %s!_N_Clearing skew correction."' % ratos_skew_profile %}
CONSOLE_ECHO TITLE="Missing skew profile!" TYPE="warning" MSG={line_1}
SET_SKEW CLEAR=1
{% endif %}
{% endif %}
[gcode_macro M601]
gcode =
PAUSE
[gcode_macro PAUSE]
description = Pauses the print
rename_existing = PAUSE_BASE
variable_extrude = 1.5
variable_retract = 1.5
variable_fan_speed = 0
variable_idex_mode = ""
variable_idex_toolhead = 0
variable_idex_toolhead_x = 0.0
variable_idex_toolhead_y = 0.0
variable_idex_toolhead_z = 0.0
gcode =
{% set runout_detected = true if params.RUNOUT|default(false)|lower == 'true' else false %}
_LED_PAUSE
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set idex_toolhead = 1 if idex_mode == 'primary' else 0 %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
SAVE_GCODE_STATE NAME=PAUSE_state
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_mode VALUE='"{idex_mode}"'
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead VALUE={idex_toolhead}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_x VALUE={printer.gcode_move.gcode_position.x|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_y VALUE={printer.gcode_move.gcode_position.y|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_z VALUE={printer.gcode_move.gcode_position.z|float}
DEBUG_ECHO PREFIX="PAUSE" MSG="idex_mode: {idex_mode}, idex_toolhead: {idex_toolhead}, idex_toolhead_x: {idex_toolhead_x}, idex_toolhead_y: {idex_toolhead_y}, idex_toolhead_z: {idex_toolhead_z}"
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
CACHE_TOOLHEAD_SETTINGS KEY="pause"
SET_MACRO_TRAVEL_SETTINGS
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% if current_z < (max_z - 20.0) %}
{% set z_safe = 20.0 %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
PAUSE_BASE
{% if printer["dual_carriage"] is not defined %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan"].speed|float}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
{% if idex_toolhead == 0 %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t1"].speed|float}
{% endif %}
{% endif %}
{% endif %}
M106 S0
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if idex_mode != '' %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set R = printer["gcode_macro PAUSE"].retract|float %}
{% if can_extrude %}
G91
G1 E-{R} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].pause_print_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].pause_print_park_in %}
{% if runout_detected %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].runout_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].runout_park_in %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
DEBUG_ECHO PREFIX="PAUSE" MSG="z_speed: {z_speed}, pause_print_park_x: {pause_print_park_x}, pause_print_park_in: {pause_print_park_in}, default_toolhead: {default_toolhead}"
{% if "xyz" in printer.toolhead.homed_axes %}
G91
G1 Z{z_safe} F{z_speed}
G90
{% if printer["dual_carriage"] is not defined %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% else %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
_IDEX_SINGLE X={parking_position}
{% else %}
PARK_TOOLHEAD
{% endif %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% endif %}
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="pause"
[gcode_macro RESUME]
description = Resumes the print if the printer is paused.
rename_existing = RESUME_BASE
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set target_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set target_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% endif %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if target_idex_mode != '' %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set fan_speed = printer["gcode_macro PAUSE"].fan_speed|float %}
{% if printer["dual_carriage"] is not defined %}
M106 S{(fan_speed * 255)}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% else %}
{% if params.TOOLHEAD is defined %}
{% if params.TOOLHEAD == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% else %}
{% if printer["gcode_macro PAUSE"].idex_toolhead == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% endif %}
{% endif %}
M106.1 S{fan_speed}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY DANCE=0
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR DANCE=0
{% else %}
{% if params.TOOLHEAD is defined %}
_SELECT_TOOL T={params.TOOLHEAD} X=-1 Y=-1 TOOLSHIFT=false
{% else %}
_SELECT_TOOL T={printer["gcode_macro PAUSE"].idex_toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% endif %}
{% set x = printer["gcode_macro PAUSE"].idex_toolhead_x|float %}
{% set y = printer["gcode_macro PAUSE"].idex_toolhead_y|float %}
{% set z = printer["gcode_macro PAUSE"].idex_toolhead_z|float %}
G1 X{x} Y{y} Z{z} F{speed}
{% if params.TOOLHEAD is defined %}
SAVE_GCODE_STATE NAME=PAUSE_STATE
{% endif %}
{% endif %}
{% if params.TOOLHEAD is not defined %}
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
{% if can_extrude %}
G91
G1 E{E} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1 MOVE_SPEED={speed}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
RESUME_BASE
_LED_PRINTING
[gcode_macro CANCEL_PRINT]
description = Cancels the printer
rename_existing = CANCEL_PRINT_BASE
gcode =
END_PRINT
TURN_OFF_HEATERS
CLEAR_PAUSE
CANCEL_PRINT_BASE
[gcode_macro START_PRINT]
description = Start print procedure, use this in your Slicer.
variable_post_processor_version = 2
variable_is_printing_gcode = False
variable_both_toolheads = True
variable_object_xoffset = 0
variable_first_x = -1
variable_first_y = -1
variable_total_toolshifts = 0
variable_initial_tool = 0
variable_extruder_first_layer_temp = ""
variable_extruder_other_layer_temp = ""
gcode =
{% if "xyz" in printer.toolhead.homed_axes and printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% if printer["gcode_macro _VAOC"].is_started|default(true)|lower == 'true' %}
_VAOC_END
{% endif %}
{% endif %}
_LED_START_PRINTING
CACHE_TOOLHEAD_SETTINGS KEY="start_print"
_USER_START_PRINT { rawparams }
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set bed_heat_soak_time = printer["gcode_macro RatOS"].bed_heat_soak_time|default(0)|int %}
{% set hotend_heat_soak_time = printer["gcode_macro RatOS"].hotend_heat_soak_time|default(0)|int %}
{% set z_probe_stowable = printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set X0 = params.X0|default(-1)|float %}
{% set X1 = params.X1|default(-1)|float %}
{% set Y0 = params.Y0|default(-1)|float %}
{% set Y1 = params.Y1|default(-1)|float %}
{% if first_x == -1 or first_y == -1 %}
{% set first_x = params.FIRST_X|default(-1)|float %}
{% set first_y = params.FIRST_Y|default(-1)|float %}
{% endif %}
{% set total_toolshifts = params.TOTAL_TOOLSHIFTS|default(0)|int %}
{% set initial_tool = params.INITIAL_TOOL|default(default_toolhead)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set bed_temp = params.BED_TEMP|default(printer.heater_bed.target, true)|float %}
{% set total_layer_count = params.TOTAL_LAYER_COUNT|default(0)|int %}
{% set extruder_first_layer_temp = (params.EXTRUDER_TEMP|default("")).split(",") %}
RATOS_ECHO MSG="First print coordinates X:{first_x} Y:{first_y}"
{% if params.TOTAL_LAYER_COUNT is not defined %}
{% set link_url = "https://os.ratrig.com/docs/slicers" %}
{% set link_text = "RatOS Slicer Configuration" %}
{% set line_1 = '"Your slicer gcode settings are not up to date._N_Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="Incomplete Slicer Configuration detected" TYPE="warning" MSG={line_1}
{% endif %}
SET_PRINT_STATS_INFO CURRENT_LAYER=1
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE=1
{% if total_layer_count > 0 %}
SET_PRINT_STATS_INFO TOTAL_LAYER={total_layer_count}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set swap_toolheads = true if printer["gcode_macro _IDEX_REMAP_TOOLHEADS"].enabled|default(false)|lower == 'true' else false %}
{% if swap_toolheads %}
{% set initial_tool = 0 if initial_tool == 1 else 1 %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=active VALUE=True
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=active VALUE=True
{% endif %}
{% set both_toolheads = true %}
{% if total_toolshifts == 0 %}
{% set both_toolheads = false %}
{% endif %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
{% endif %}
{% if both_toolheads and (idex_mode == "copy" or idex_mode == "mirror") %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Gcode tool changes found. Copy and mirror mode do not support toolchanges.")}
{% endif %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set both_toolheads = true %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=initial_tool VALUE={initial_tool}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_x VALUE={first_x}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_y VALUE={first_y}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=total_toolshifts VALUE={total_toolshifts}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=both_toolheads VALUE={both_toolheads}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_first_layer_temp VALUE="'{params.EXTRUDER_TEMP}'"
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_other_layer_temp VALUE="'{params.EXTRUDER_OTHER_LAYER_TEMP}'"
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE VARIABLE=toolshift_count VALUE=0
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set svv = printer.save_variables.variables %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
{% set stepper_x_position_min = printer.configfile.settings.stepper_x.position_min|float %}
{% set stepper_x_position_endstop = printer.configfile.settings.stepper_x.position_endstop|float %}
{% set dual_carriage_position_max = printer.configfile.settings.dual_carriage.position_max|float %}
{% set dual_carriage_position_endstop = printer.configfile.settings.dual_carriage.position_endstop|float %}
{% set x_parking_space = parking_position_t0 - (stepper_x_position_endstop , stepper_x_position_min)|max %}
{% set dc_parking_space = (dual_carriage_position_endstop , dual_carriage_position_max)|min - parking_position_t1 %}
{% if svv.idex_xoffset|abs >= (x_parking_space - 0.5) or svv.idex_xoffset|abs >= (dc_parking_space - 0.5) %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Toolhead x-offset is too high for the available parking space. Calibrate your X and DC endstop positions and make sure you stay below 1mm." % (copy_mode_max_width)) }
{% endif %}
{% endif %}
{% if (idex_mode == "copy" or idex_mode == "mirror") and printer.configfile.settings.ratos.enable_gcode_transform %}
{% if params.MIN_X is not defined or params.MAX_X is not defined %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Something went wrong! Missing important post processor start print parameter!") }
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE=0
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set boundary_box_min_x = params.MIN_X|default(0)|float %}
{% set boundary_box_max_x = params.MAX_X|default(printable_x_max)|float %}
{% set svv = printer.save_variables.variables %}
{% if default_toolhead == 0 %}
{% set boundary_box_max_x = boundary_box_max_x + svv.idex_xoffset %}
{% else %}
{% set boundary_box_min_x = boundary_box_min_x - svv.idex_xoffset %}
{% endif %}
{% set center_x = printable_x_max / 2.0 %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% set object_width = boundary_box_max_x - boundary_box_min_x %}
{% set copy_mode_max_width = center_x %}
{% set mirror_mode_max_width = center_x - safe_distance / 2.0 %}
DEBUG_ECHO PREFIX="START_PRINT" MSG="OBJECT_WIDTH: {object_width} BOUNDARY_BOX_MIN_X: {boundary_box_min_x} BOUNDARY_BOX_MAX_X: {boundary_box_max_x} CENTER_X: {center_x} SAFE_DISTANCE: {safe_distance}"
{% if idex_mode == "copy" and object_width > copy_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for copy mode! Max supported width is %s mm" % (copy_mode_max_width)) }
{% endif %}
{% if idex_mode == "mirror" and object_width > mirror_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for mirror mode! Max supported width is %s mm" % (mirror_mode_max_width)) }
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = (printable_x_max - boundary_box_max_x - boundary_box_min_x) / 2 %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE={object_xoffset}
{% endif %}
{% endif %}
{% set has_initial_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_initial_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined and both_toolheads %}
{% set has_secondary_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_secondary_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% endif %}
_CHAMBER_FILTER_ON AT="before_print_start"
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true' %}
{% if both_toolheads %}
RATOS_ECHO MSG="Spool join is not possible if both toolheads are in use!"
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if idex_mode == '' %}
_SET_TOOLHEAD_OFFSET T={default_toolhead} MOVE={1 if "xyz" in printer.toolhead.homed_axes else 0}
{% endif %}
{% endif %}
CLEAR_PAUSE
{% if printer["gcode_macro RatOS"].force_absolute_position|lower == 'true' %}
G90
{% endif %}
SAVE_GCODE_STATE NAME=start_print_state
G21
G90
M82
_USER_START_PRINT_BEFORE_HOMING { rawparams }
{% if z_probe_stowable == true %}
STOWABLE_PROBE_BEGIN_BATCH
{% endif %}
MAYBE_HOME
_Z_HOP
{% if idex_mode != '' and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
PARK_TOOLHEAD
{% endif %}
{% if chamber_temp > 0 %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED={printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float}
{% endif %}
{% endif %}
_CHAMBER_HEATER_ON START_CHAMBER_TEMP={start_chamber_temp} CHAMBER_TEMP={chamber_temp}
_USER_START_PRINT_HEAT_CHAMBER { rawparams } CHAMBER_TEMP={chamber_temp}
{% endif %}
_START_PRINT_BEFORE_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
RATOS_ECHO MSG="Heating bed..."
M190 S{bed_temp}
{% if bed_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking bed for {bed_heat_soak_time} seconds..."
G4 P{(bed_heat_soak_time * 1000)}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_BED { rawparams }
_START_PRINT_AFTER_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
_USER_START_PRINT_BED_MESH { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_BED_MESH X0={X0} X1={X1} Y0={Y0} Y1={Y1} T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if z_probe_stowable == true %}
STOWABLE_PROBE_END_BATCH
{% endif %}
{% if idex_mode == '' %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={extruder_first_layer_temp[1]|float}
{% endif %}
{% endif %}
_USER_START_PRINT_PARK { rawparams }
_START_PRINT_PARK
RATOS_ECHO MSG="Heating Extruder..."
{% if idex_mode == '' %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder1" MINIMUM={extruder_first_layer_temp[1]|float} MAXIMUM={extruder_first_layer_temp[1]|float + 5}
{% endif %}
{% endif %}
{% if hotend_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking hotend for {hotend_heat_soak_time} seconds..."
G4 P{(hotend_heat_soak_time * 1000)}
{% endif %}
{% if idex_mode == '' %}
_LED_PRINTING
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
_LED_PRINTING
{% else %}
{% if both_toolheads %}
_LED_PRINTING TOOLHEAD={initial_tool}
{% if toolchange_standby_temp > -1 %}
_LED_TOOLHEAD_STANDBY TOOLHEAD={0 if initial_tool == 1 else 1}
{% else %}
_LED_PRINTING TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% else %}
_LED_PRINTING TOOLHEAD={initial_tool}
_LED_DEACTIVATE_TOOLHEAD TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% endif %}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_EXTRUDER { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_AFTER_HEATING_EXTRUDER X0={X0} X1={X1} Y0={Y0} Y1={Y1} INITIAL_TOOLHEAD={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if idex_mode != '' %}
{% if not both_toolheads %}
{% if initial_tool != default_toolhead %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET=0
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if toolchange_standby_temp > -1 %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if initial_tool == 1 else 'extruder1'} TARGET={toolchange_standby_temp}
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% set x_offset = printer.toolhead.position.x|float - printer.gcode_move.gcode_position.x|float %}
{% endif %}
RESTORE_GCODE_STATE NAME=start_print_state
{% if idex_mode != '' %}
{% set act_idex_mode = printer["dual_carriage"].carriage_1|default('')|lower %}
{% if act_idex_mode == "copy" or act_idex_mode == "mirror" %}
SET_GCODE_OFFSET X={x_offset} MOVE=0
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% if idex_mode == "copy" and idex_mode != act_idex_mode %}
_IDEX_COPY DANCE=0
{% elif idex_mode == "mirror" and idex_mode != act_idex_mode %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
RATOS_ECHO MSG="Adjusting object x-offset by {(object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={object_xoffset} MOVE=0
{% endif %}
{% else %}
_SELECT_TOOL T={initial_tool} TOOLSHIFT=false
{% if initial_tool != default_toolhead %}
{% set svv = printer.save_variables.variables %}
SAVE_VARIABLE VARIABLE=idex_applied_offset VALUE={default_toolhead}
_SET_TOOLHEAD_OFFSET T={initial_tool} MOVE=0
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={initial_tool}
{% endif %}
_SET_EXTRUSION_MODE
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
SET_GCODE_VARIABLE MACRO=_SELECT_TOOL VARIABLE=last_timestamp VALUE={printer["print_stats"].print_duration}
{% endif %}
_USER_END_START_PRINT { rawparams }
G92 E0
_CHAMBER_FILTER_ON AT="after_print_start"
RATOS_ECHO MSG="Printing..."
[gcode_macro _START_PRINT_BEFORE_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set is_stowable_probe = true if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Pre-heating extruder..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={min_temp}
{% else %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET={min_temp}
{% endif %}
{% else %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
{% endif %}
{% endif %}
{% if not is_stowable_probe %}
{% if printer["dual_carriage"] is defined and act_t != default_toolhead %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
{% endif %}
RATOS_ECHO MSG="Heat soaking z probe..."
{% if auto_z_offset_calibration %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% if default_toolhead == 0 %}
_SELECT_TOOL T=0 TOOLSHIFT=false
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
{% elif default_toolhead == 1 %}
_SELECT_TOOL T=1 TOOLSHIFT=false
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
{% endif %}
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% endif %}
G0 Z2 F{z_speed}
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Waiting for extruder to be preheated..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
{% if default_toolhead == 0 %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_Z_HOP
{% endif %}
{% if auto_z_offset_calibration %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
PARK_TOOLHEAD
_CLEANING_MOVE TOOLHEAD={default_toolhead}
_SELECT_TOOL T={0 if default_toolhead == 1 else 1} X={parking_position_t0 if default_toolhead == 1 else parking_position_t1} Y=0 TOOLSHIFT=false
_CLEANING_MOVE TOOLHEAD={0 if default_toolhead == 1 else 1}
_VAOC_CALIBRATE_Z_OFFSET AUTO_Z_OFFSET=True
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=false
{% endif %}
{% set needs_rehoming = False %}
{% if printer.z_tilt is defined and not printer.z_tilt.applied %}
RATOS_ECHO MSG="Adjusting Z tilt..."
Z_TILT_ADJUST
RATOS_ECHO MSG="Rehoming Z after Z tilt adjustment..."
{% set needs_rehoming = True %}
{% endif %}
{% if printer.quad_gantry_level is defined and not printer.quad_gantry_level.applied %}
RATOS_ECHO MSG="Running quad gantry leveling..."
QUAD_GANTRY_LEVEL
RATOS_ECHO MSG="Rehoming Z after quad gantry leveling..."
{% set needs_rehoming = True %}
{% endif %}
{% if needs_rehoming %}
G28 Z
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %}
{% if beacon_contact_wipe_before_true_zero %}
_START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE
{% endif %}
_START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
G0 Z5 F{z_speed}
G0 X50 Y10 F{speed}
PROBE PROBE_METHOD=contact SAMPLES=1
BEACON_QUERY
[gcode_macro _START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_true_zero_temp = printer["gcode_macro RatOS"].beacon_contact_true_zero_temp|default(150)|int %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_true_zero_location = printer["gcode_macro RatOS"].beacon_contact_true_zero_location|default("front")|lower %}
{% set beacon_contact_true_zero_margin_x = printer["gcode_macro RatOS"].beacon_contact_true_zero_margin_x|default(30)|int %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if beacon_contact_wipe_before_true_zero %}
{% if printer.beacon.last_probe_result|lower == "ok" %}
{% set last_z_offset = printer.beacon.last_z_result %}
RATOS_ECHO MSG="Auto calibration nozzle wipe with probe result {last_z_offset}..."
G0 Z{(0.2 + last_z_offset)} F{z_speed}
G0 X70 F300
{% else %}
RATOS_ECHO MSG="Skipping auto calibration nozzle wipe because probing failed!"
{% endif %}
{% endif %}
G0 Z5 F{z_speed}
_MOVE_TO_SAFE_Z_HOME
RATOS_ECHO MSG="Heating extruder to probing temperature..."
SET_HEATER_TEMPERATURE HEATER={"extruder" if default_toolhead == 0 else "extruder1"} TARGET={beacon_contact_true_zero_temp}
TEMPERATURE_WAIT SENSOR={"extruder" if default_toolhead == 0 else "extruder1"} MINIMUM={beacon_contact_true_zero_temp} MAXIMUM={beacon_contact_true_zero_temp + 5}
RATOS_ECHO MSG="Beacon contact auto calibration..."
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
G0 Z5 F{z_speed}
[gcode_macro _START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set first_x = printer["gcode_macro START_PRINT"].first_x|default(-1)|float %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set center_x = printable_x_max / 2.0 %}
{% set center_y = printable_y_max / 2.0 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% if printer["dual_carriage"] is defined %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% endif %}
{% set X0 = params.X0|default(-1)|int %}
{% set X1 = params.X1|default(-1)|int %}
{% set Y0 = params.Y0|default(-1)|int %}
{% set Y1 = params.Y1|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% if idex_mode == '' %}
_PRIME
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
RATOS_ECHO PREFIX="IDEX" MSG="using combined prime offset for IDEX {idex_mode} mode"
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
{% if both_toolheads %}
{% if initial_toolhead == 0 %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T{initial_toolhead}"
_SELECT_TOOL T={initial_toolhead} TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% endif %}
{% endif %}
CACHE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
SET_MACRO_TRAVEL_SETTINGS
{% if (X0 > -1 and Y1 > -1) or (first_x > 0 and first_y > 0) %}
{% if printer["dual_carriage"] is defined %}
{% set acceleration = printer["gcode_macro RatOS"].toolchange_travel_accel %}
{% set max_accel = printer.toolhead.max_accel|float %}
{% set square_corner_velocity = printer.toolhead.square_corner_velocity|float %}
SET_VELOCITY_LIMIT ACCEL={acceleration} MINIMUM_CRUISE_RATIO=0 SQUARE_CORNER_VELOCITY=20
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
{% set first_z = 1 %}
{% else %}
{% set first_z = 3 %}
{% endif %}
{% if idex_mode == "mirror" %}
{% if first_y >= 0 %}
G0 Y{first_y} F{speed}
{% else %}
G0 Y{Y1} F{speed}
{% endif %}
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
_MOVE_TO_LOADING_POSITION TOOLHEAD={initial_toolhead}
_PURGE_FILAMENT TOOLHEAD={initial_toolhead} E={printer["gcode_macro RatOS"].toolchange_first_purge|default(50)|float}
_CLEANING_MOVE TOOLHEAD={initial_toolhead}
{% endif %}
{% if first_x >= 0 and first_y >= 0 %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% else %}
{% set first_x = X0 %}
{% set first_y = Y0 %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'min' %}
{% set first_x = X0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'max' %}
{% set first_x = X1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|float <= center_x %}
{% set first_x = X0 %}
{% else %}
{% set first_x = X1 %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'min' %}
{% set first_y = Y0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'max' %}
{% set first_y = Y1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|float <= center_y %}
{% set first_y = Y0 %}
{% else %}
{% set first_y = Y1 %}
{% endif %}
{% endif %}
{% endif %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% endif %}
{% endif %}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
_LOAD_RATOS_SKEW_PROFILE
[gcode_macro _PRIME]
gcode =
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
PRIME_BLOB INITIAL_TOOLHEAD={params.INITIAL_TOOLHEAD} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={params.IDEX_MODE} Y1={params.Y1}
{% else %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE == "copy" %}
_IDEX_COPY DANCE=0
{% elif params.IDEX_MODE == "mirror" %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro END_PRINT]
description = End print procedure, use this in your Slicer.
gcode =
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SAVE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = printer["gcode_macro START_PRINT"].object_xoffset|default(0)|float %}
RATOS_ECHO MSG="Adjusting object x-offset by {(0-object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={(0-object_xoffset)}
{% endif %}
{% endif %}
_USER_END_PRINT_BEFORE_HEATERS_OFF { rawparams }
_END_PRINT_BEFORE_HEATERS_OFF
TURN_OFF_HEATERS
_USER_END_PRINT_AFTER_HEATERS_OFF { rawparams }
_END_PRINT_AFTER_HEATERS_OFF
_USER_END_PRINT_PARK { rawparams }
_END_PRINT_PARK
{% if printer["gcode_macro RatOS"].skew_profile is defined %}
SET_SKEW CLEAR=1
{% endif %}
{% if printer["dual_carriage"] is not defined and printer["gcode_macro RatOS"].end_print_motors_off|lower != 'false' %}
M84
{% endif %}
M107
BED_MESH_CLEAR
RATOS_ECHO MSG="Done :)"
RESTORE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
M84
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
{% if printer["dual_carriage"] is not defined %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_expansion_compensation = true if printer["gcode_macro RatOS"].beacon_contact_expansion_compensation|default(false)|lower == 'true' else false %}
{% if beacon_contact_start_print_true_zero and beacon_contact_expansion_compensation %}
SET_GCODE_OFFSET Z=0 MOVE=0
{% endif %}
{% endif %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print"
_CHAMBER_FILTER_ON AT="print_end"
_CHAMBER_FILTER_OFF
_CHAMBER_HEATER_OFF
_USER_END_PRINT_FINISHED { rawparams }
[gcode_macro _END_PRINT_BEFORE_HEATERS_OFF]
gcode =
RATOS_ECHO MSG="Cleaning up..."
[gcode_macro _END_PRINT_AFTER_HEATERS_OFF]
gcode =
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% set z_hop = printer["gcode_macro RatOS"].end_print_park_z_hop|float %}
{% set r = printer["gcode_macro RatOS"].end_print_retract_filament|default(4)|float %}
{% if current_z < (max_z - z_hop) %}
{% set z_safe = z_hop %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
G91
G1 E-2 F3600
G0 Z{z_safe} F3600
G1 E-{(r-2)} F3600
G90
[gcode_macro _SET_EXTRUSION_MODE]
gcode =
{% if printer["gcode_macro RatOS"].relative_extrusion|lower == 'true' %}
M83
{% else %}
M82
{% endif %}
[gcode_macro GENERATE_SHAPER_GRAPHS]
description = Genarates input shaper resonances graphs for analysis. Uses the AXIS parameter for if you only want to do one axis at a time, (eg. GENERATE_SHAPER_GRAPHS AXIS=X)
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set axis = params.AXIS|default('')|lower %}
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
{% if axis != '' %}
{% if axis == 'x' %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
{% elif axis == 'y' %}
MAYBE_HOME
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% else %}
{action_raise_error("Unknown axis specified. Expected X or Y.")}
{% endif %}
{% else %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% endif %}
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Shaper graph"
[gcode_shell_command generate_shaper_graph_x]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-x.sh
timeout = 60.
verbose = True
[gcode_shell_command generate_shaper_graph_y]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-y.sh
timeout = 60.
verbose = True
[gcode_macro MEASURE_COREXY_BELT_TENSION]
description = Generates resonance graph used to ensure belts are equally tensioned.
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
MAYBE_HOME
TEST_RESONANCES AXIS=1,1 OUTPUT=raw_data NAME=belt-tension-upper FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=belt-tension-lower FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_belt_tension_graph
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Belt Tension Graph"
[gcode_shell_command generate_belt_tension_graph]
command = /home/pi/printer_data/config/RatOS/scripts/generate-belt-tension-graph.sh
timeout = 90.
verbose = True
[idle_timeout]
gcode =
{% if printer.webhooks.state|lower == 'ready' %}
{% if printer.pause_resume.is_paused|lower == 'false' %}
RATOS_ECHO PREFIX="IDLE" MSG="2 hours since last activity. Powering off heaters and motors.."
TURN_OFF_HEATERS
M84
{% endif %}
{% endif %}
timeout = 7200
[temperature_sensor raspberry_pi]
sensor_type = temperature_host
[skew_correction]
[input_shaper]
[virtual_sdcard]
path = ~/printer_data/gcodes
[display_status]
[pause_resume]
[force_move]
enable_force_move = True
[respond]
[resonance_generator]
[ratos]
allow_unknown_gcode_generator = True
[exclude_object]
[heater_bed]
heater_pin = heater_bed_heating_pin
sensor_pin = heater_bed_sensor_pin
sensor_type = EPCOS 100K B57560G104F
min_temp = 0
max_temp = 130
control = pid
pid_kp = 68.203
pid_ki = 2.842
pid_kd = 409.216
[fan]
pin = multi_pin:dual_blower_fan
shutdown_speed = 1.0
kick_start_time = 0.5
cycle_time = 0.00004
[heater_fan toolhead_cooling_fan]
pin = PD14
fan_speed = 1
heater = extruder
heater_temp = 50.0
[controller_fan controller_fan]
pin = PD13
idle_speed = 0.7
[printer]
kinematics = cartesian
max_velocity = 200
max_accel = 3000
minimum_cruise_ratio = 0.5
max_z_velocity = 15
max_z_accel = 200
square_corner_velocity = 5
[bed_mesh]
speed = 200
horizontal_move_z = 5
mesh_min = 15,15
mesh_max = 150,160
probe_count = 5,5
fade_start = 1.0
fade_end = 10.0
mesh_pps = 2,2
algorithm = bicubic
bicubic_tension = .2
[screws_tilt_adjust]
screw1 = 80, 108
screw1_name = Left Screw
screw2 = 155, 72
screw2_name = Front Right Screw
screw3 = 155, 147
screw3_name = Rear Right Screw
horizontal_move_z = 10
speed = 200
screw_thread = CCW-M4
[stepper_x]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PF9
dir_pin = !x_dir_pin
enable_pin = !PD6
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = toolboard_t0:PB6
[stepper_y]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PD3
dir_pin = y_dir_pin
enable_pin = !PD5
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = PC1
[stepper_z]
position_min = -5
position_max = 180
step_pin = PA15
dir_pin = !z0_dir_pin
enable_pin = !PC9
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 4
homing_speed = 15
endstop_pin = probe:z_virtual_endstop
[gcode_macro SCREWS_TILT_CALCULATE]
rename_existing = SCREWS_TILT_CALCULATE_ORIG
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
MAYBE_HOME
SAVE_GCODE_STATE NAME=screws_tilt_state
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
DEPLOY_PROBE
{% endif %}
SCREWS_TILT_CALCULATE_ORIG
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
STOW_PROBE
{% endif %}
G90
G0 Z120 F{printer["gcode_macro RatOS"].macro_z_speed|float * 60}
G0 Y{printable_y_max} X{printable_x_max / 2} F{printer["gcode_macro RatOS"].macro_travel_speed|float * 60}
RESTORE_GCODE_STATE NAME=screws_tilt_state
M84
[extruder]
rotation_distance = 5.57
full_steps_per_rotation = 200
filament_diameter = 1.750
max_extrude_only_velocity = 120
max_extrude_only_accel = 800
pressure_advance_smooth_time = 0.02
max_extrude_only_distance = 200
nozzle_diameter = 0.4
heater_pin = toolboard_t0:PB13
sensor_type = MAX31865
sensor_pin = toolboard_t0:PA4
min_extrude_temp = 170
min_temp = 0
max_temp = 350
pressure_advance = 0.03
step_pin = toolboard_t0:PD0
dir_pin = !toolboard_t0:e_dir_pin
enable_pin = !toolboard_t0:PD2
microsteps = 64
control = pid
pid_kp = 21.673
pid_ki = 1.338
pid_kd = 87.776
spi_software_sclk_pin = toolboard_t0:PA5
spi_software_miso_pin = toolboard_t0:PA6
spi_software_mosi_pin = toolboard_t0:PA7
[firmware_retraction]
retract_speed = 120
unretract_extra_length = 0
unretract_speed = 120
retract_length = 0.5
[adxl345 rpi]
cs_pin = rpi:None
[resonance_tester]
accel_chip_x = adxl345 toolboard_t0
accel_chip_y = adxl345 rpi
probe_points =
90,90,20
[tmc2209 stepper_x]
stealthchop_threshold = 0
interpolate = False
uart_pin = PF10
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_y]
stealthchop_threshold = 0
interpolate = False
uart_pin = PD4
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_z]
stealthchop_threshold = 0
interpolate = False
uart_pin = PC8
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 extruder]
stealthchop_threshold = 0
interpolate = False
uart_pin = toolboard_t0:PA15
run_current = 0.707
driver_tbl = 0
driver_toff = 4
driver_hend = 6
driver_hstrt = 7
sense_resistor = 0.11
[bltouch]
sensor_pin = ^toolboard_t0:bltouch_sensor_pin
control_pin = toolboard_t0:bltouch_control_pin
speed = 7
pin_move_time = 0.675
sample_retract_dist = 10
pin_up_reports_not_triggered = True
pin_up_touch_mode_reports_triggered = True
x_offset = -28
y_offset = -13
z_offset = 2.375
[gcode_macro T0]
variable_join = 0
variable_remap = 0
variable_alert = ""
variable_filament_name = ""
variable_filament_type = ""
variable_filament_temp = 0
variable_runout_sensor = ""
variable_active = True
variable_color = "7bff33"
variable_hotend_type = "HF"
variable_has_cht_nozzle = False
variable_cooling_position_to_nozzle_distance = 40
variable_tooolhead_sensor_to_extruder_gear_distance = 15
variable_extruder_gear_to_cooling_position_distance = 30
variable_filament_loading_nozzle_offset = -5
variable_filament_grabbing_length = 5
variable_filament_grabbing_speed = 1
variable_enable_insert_detection = True
variable_enable_runout_detection = True
variable_enable_clog_detection = True
variable_unload_after_runout = True
variable_purge_after_load = 0
variable_purge_before_unload = 0
variable_extruder_load_speed = 60
variable_filament_load_speed = 10
variable_standby = False
variable_temperature_offset = 0
variable_has_oozeguard = False
variable_has_front_arm_nozzle_wiper = False
variable_resume_after_insert = False
gcode =
{% set x = params.X|default(-1.0)|float %}
{% set y = params.Y|default(-1.0)|float %}
{% set z = params.Z|default(0.0)|float %}
{% set s = params.S|default(1)|int %}
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
_SELECT_TOOL T=0 X={x} Y={y} Z={z} TOOLSHIFT={s}
{% endif %}
[save_variables]
filename = /home/pi/printer_data/config/ratos-variables.cfg
[multi_pin dual_blower_fan]
pins = toolboard_t0:PA0, toolboard_t0:PA1
=======================
Config error
Traceback (most recent call last):
File "/home/pi/klipper/klippy/klippy.py", line 130, in _connect
self._read_config()
File "/home/pi/klipper/klippy/klippy.py", line 123, in _read_config
self.load_object(config, section_config.get_name(), None)
File "/home/pi/klipper/klippy/klippy.py", line 112, in load_object
self.objects[section] = init_func(config.getsection(section))
File "/home/pi/klipper/klippy/extras/fan.py", line 122, in load_config
return PrinterFan(config)
File "/home/pi/klipper/klippy/extras/fan.py", line 106, in __init__
self.fan = Fan(config)
File "/home/pi/klipper/klippy/extras/fan.py", line 24, in __init__
self.mcu_fan = ppins.setup_pin('pwm', config.get('pin'))
File "/home/pi/klipper/klippy/pins.py", line 117, in setup_pin
pin_params = self.lookup_pin(pin_desc, can_invert, can_pullup)
File "/home/pi/klipper/klippy/pins.py", line 98, in lookup_pin
pin_params = self.parse_pin(pin_desc, can_invert, can_pullup)
File "/home/pi/klipper/klippy/pins.py", line 83, in parse_pin
raise error("Unknown pin chip name '%s'" % (chip_name,))
pins.error: Unknown pin chip name 'multi_pin'
webhooks client 1965364704: New connection
webhooks client 1965364704: Client info {'program': 'Moonraker', 'version': 'v0.9.3-0-g71f9e67'}
Attempting MCU 'mcu' reset
Unable to issue reset command on MCU 'rpi'
Attempting MCU 'toolboard_t0' reset
webhooks client 1965364704: Disconnected
Restarting printer
Start printer at Wed Nov 12 22:35:21 2025 (1762986921.6 21180.6)
Config error
Traceback (most recent call last):
File "/home/pi/klipper/klippy/klippy.py", line 130, in _connect
self._read_config()
File "/home/pi/klipper/klippy/klippy.py", line 116, in _read_config
config = pconfig.read_main_config()
File "/home/pi/klipper/klippy/configfile.py", line 483, in read_main_config
fileconfig, autosave_fileconfig = self.autosave.load_main_config()
File "/home/pi/klipper/klippy/configfile.py", line 306, in load_main_config
regular_fileconfig = cfgrdr.build_fileconfig_with_includes(
File "/home/pi/klipper/klippy/configfile.py", line 231, in build_fileconfig_with_includes
self._parse_config(data, filename, fileconfig, set())
File "/home/pi/klipper/klippy/configfile.py", line 223, in _parse_config
self._resolve_include(filename, include_spec, fileconfig,
File "/home/pi/klipper/klippy/configfile.py", line 195, in _resolve_include
raise error("Include file '%s' does not exist" % (include_glob,))
configparser.Error: Include file '/home/pi/printer_data/config/toolboard.cfg' does not exist
webhooks client 1969950384: New connection
webhooks client 1969950384: Client info {'program': 'Moonraker', 'version': 'v0.9.3-0-g71f9e67'}
webhooks client 1969950384: Disconnected
Restarting printer
Start printer at Wed Nov 12 22:36:05 2025 (1762986965.7 21224.7)
===== Config file =====
[mcu rpi]
serial = /tmp/klipper_host_mcu
[board_pins btt-skrat-10]
aliases =
x_step_pin=PF9,
x_dir_pin=PD7,
x_enable_pin=PD6,
x_uart_pin=PF10,
x_diag_pin=PB5,
x_endstop_pin=PB5,
y_step_pin=PD3,
y_dir_pin=PD2,
y_enable_pin=PD5,
y_uart_pin=PD4,
y_diag_pin=PC1,
y_endstop_pin=PC1,
z0_step_pin=PA15,
z0_dir_pin=PF8,
z0_enable_pin=PC9,
z0_uart_pin=PC8,
z0_diag_pin=PC0,
e_step_pin=PB10,
e_dir_pin=PE15,
e_enable_pin=PA8,
e_uart_pin=PB11,
e_diag_pin=PF5,
e_heater_pin=PE11,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PE5,
bltouch_control_pin=PE6,
probe_pin=PE5,
fan_part_cooling_pin=PD15,
fan_toolhead_cooling_pin=PD14,
fan_controller_board_pin=PD13,
heater_bed_heating_pin=PB3,
heater_bed_sensor_pin=PB2,
4p_fan_part_cooling_pin=PE9,
4p_fan_part_cooling_tach_pin=PD11,
4p_toolhead_cooling_pin=PE14,
4p_toolhead_cooling_tach_pin=PD10,
4p_controller_board_pin=PE14,
4p_controller_board_tach_pin=PD10
[mcu]
serial = /dev/RatOS/btt-skrat-10
[temperature_sensor SKRat_v1.0]
sensor_type = temperature_mcu
[adxl345 controlboard]
cs_pin = PB12
spi_bus = spi2
[board_pins toolboard_t0]
mcu = toolboard_t0
aliases =
e_step_pin=PD0,
e_dir_pin=PD1,
e_enable_pin=PD2,
e_uart_pin=PA15,
e_heater_pin=PB13,
e_sensor_pin=PA3,
stepper_spi_mosi_pin=null,
stepper_spi_miso_pin=null,
stepper_spi_sclk_pin=null,
adxl345_cs_pin=PB12,
bltouch_sensor_pin=PB8,
bltouch_control_pin=PB9,
probe_pin=PB9,
fan_part_cooling_pin=PA0,
fan_toolhead_cooling_pin=PA1,
fan_controller_board_pin=null,
heater_bed_heating_pin=null,
heater_bed_sensor_pin=null,
4p_fan_part_cooling_pin=null,
4p_fan_part_cooling_tach_pin=null,
4p_toolhead_cooling_pin=null,
4p_toolhead_cooling_tach_pin=null,
4p_controller_board_pin=null,
4p_controller_board_tach_pin=null
[mcu toolboard_t0]
serial = /dev/RatOS/btt-ebb42-12-t0
[temperature_sensor EBB42_v1.2_T0]
sensor_type = temperature_mcu
sensor_mcu = toolboard_t0
[adxl345 toolboard_t0]
axes_map = x, z, y
cs_pin = toolboard_t0:PB12
spi_software_mosi_pin = toolboard_t0:PB11
spi_software_miso_pin = toolboard_t0:PB2
spi_software_sclk_pin = toolboard_t0:PB10
[gcode_macro RatOS]
variable_homing = "endstops"
variable_z_probe = "static"
variable_sensorless_x_current = 0.6
variable_sensorless_y_current = 0.9
variable_safe_home_x = "middle"
variable_safe_home_y = "middle"
variable_driver_type_x = "tmc2209"
variable_driver_type_y = "tmc2209"
variable_stowable_probe_stop_on_error = False
variable_chamber_filter_enable = True
variable_chamber_filter_speed = 0.5
variable_chamber_filter_disable_speed = 1.0
variable_chamber_filter_enable_at = "after_print_start"
variable_chamber_filter_disable_period = 300
variable_chamber_filter_disable_bed_temp = 0
variable_chamber_heater_enable = True
variable_chamber_heater_bed_temp = 115
variable_chamber_heater_preheating_temp = 150
variable_chamber_heater_heating_temp_offset = 25
variable_chamber_heater_control_external_heater = False
variable_chamber_heater_air_circulation_enable = True
variable_chamber_heater_air_circulation_fan_speed = 0.35
variable_chamber_heater_air_circulation_y_pos = 0
variable_chamber_heater_air_circulation_z_pos = 100
variable_chamber_heater_extra_fan_speed = 1.0
variable_chamber_heater_filter_fan_speed = 1.0
variable_led_status_action = 0.0,1.0,1.0
variable_led_status_success = 0.0,1.0,0.0
variable_led_status_error = 1.0,0.0,1.0
variable_led_status_on = 1.0,1.0,1.0
variable_led_status_off = 0.0,0.0,1.0
variable_led_status_standby = 0.1,0.1,0.1
variable_led_status_heating = 1.0,0.0,0.0
variable_led_status_cooling = 0.0,0.0,1.0
variable_calibrate_bed_mesh = True
variable_adaptive_mesh = True
variable_start_print_park_in = "front"
variable_start_print_park_z_height = 50
variable_end_print_park_in = "back"
variable_pause_print_park_in = "front"
variable_end_print_park_z_hop = 20
variable_nozzle_priming = "primeblob"
variable_nozzle_prime_start_x = "max"
variable_nozzle_prime_start_y = "min"
variable_nozzle_prime_direction = "auto"
variable_nozzle_prime_bridge_fan = 102
variable_probe_for_priming_result = None
variable_probe_for_priming_end_result = None
variable_probe_for_priming_result_t1 = None
variable_probe_for_priming_end_result_t1 = None
variable_probe_for_priming_disable_mesh_constraints = False
variable_adaptive_prime_offset_threshold = -1.0
variable_last_z_offset = None
variable_runout_park_in = "front"
variable_enable_unload_tip_forming = False
variable_filament_unload_length = 150
description = RatOS variable storage macro, will echo variables to the console when run.
variable_relative_extrusion = False
variable_force_absolute_position = False
variable_preheat_extruder = True
variable_preheat_extruder_temp = 150
variable_macro_travel_speed = 200
variable_macro_travel_accel = 3000
variable_macro_z_speed = 15
variable_bed_margin_x = [0, 0]
variable_bed_margin_y = [0, 0]
variable_printable_x_min = 0
variable_printable_x_max = 0
variable_printable_y_min = 0
variable_printable_y_max = 0
variable_end_print_motors_off = True
variable_status_color_ok = "00FF00"
variable_status_color_error = "FF0000"
variable_status_color_unknown = "FFFF00"
variable_end_print_retract_filament = 10
gcode =
ECHO_RATOS_VARS
variable_homing_x = "endstop"
variable_homing_y = "endstop"
variable_x_driver_types = ["tmc2209"]
variable_x_axes = ["x"]
variable_y_driver_types = ["tmc2209"]
variable_y_axes = ["y"]
variable_z_driver_types = ["tmc2209"]
variable_z_axes = ["z"]
[ratos_homing]
axes = xyz
z_hop = 15
z_hop_speed = 15
gcode =
_LED_ON
{% set prev_stop_on_error = printer["gcode_macro RatOS"].stowable_probe_stop_on_error %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set target_idex_mode = printer["dual_carriage"].carriage_1|lower %}
_IDEX_SINGLE
_SELECT_TOOL T={default_toolhead} TOOLSHIFT=false
{% endif %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE=True
M400
G90
{% set X = true if params.X is defined else false %}
{% set Y = true if params.Y is defined else false %}
{% set Z = true if params.Z is defined else false %}
{% if printer["gcode_macro RatOS"].home_y_first|default(false)|lower == 'true' %}
HOME_Y X={X} Y={Y} Z={Z}
HOME_X X={X} Y={Y} Z={Z}
{% else %}
HOME_X X={X} Y={Y} Z={Z}
HOME_Y X={X} Y={Y} Z={Z}
{% endif %}
HOME_Z X={X} Y={Y} Z={Z}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE={prev_stop_on_error}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR
{% endif %}
{% endif %}
[gcode_macro HOME_X]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_x = printer["gcode_macro RatOS"].homing_x|lower %}
{% set homing_x = homing_x if homing_x else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_X" MSG="printable_x_max: {printable_x_max}, safe_home_x: {safe_home_x}, axis_maximum.x: {printer.toolhead.axis_maximum.x}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}"
{% if X or not Y and not Z %}
{% if homing_x == 'endstop' %}
G28 X
{% elif homing_x == 'sensorless' %}
{% if printer["dual_carriage"] is defined %}
{ action_emergency_stop("sensorless homing not supported on IDEX!") }
{% endif %}
HOME_X_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_x to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_x, homing)) }
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % (0 if default_toolhead==1 else 1)].parking_position|float %}
SET_DUAL_CARRIAGE CARRIAGE={0 if default_toolhead==1 else 1} MODE=PRIMARY
G1 X{parking_position} F{speed}
SET_DUAL_CARRIAGE CARRIAGE={default_toolhead} MODE=PRIMARY
{% endif %}
{% set x_homed = True %}
G0 X{safe_home_x} F{speed}
M400
{% endif %}
[gcode_macro HOME_Y]
gcode =
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set homing_y = printer["gcode_macro RatOS"].homing_y|lower %}
{% set homing_y = homing_y if homing_y else homing %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Y" MSG="printable_y_max: {printable_y_max}, safe_home_y: {safe_home_y}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}"
{% if Y or not X and not Z %}
{% if homing_y == 'endstop' %}
G28 Y
{% elif homing_y == 'sensorless' %}
HOME_Y_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_y to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_y, homing)) }
{% endif %}
{% set y_homed = True %}
G0 Y{safe_home_y} F{speed}
{% endif %}
[gcode_macro HOME_Z]
gcode =
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set z_probe = printer["gcode_macro RatOS"].z_probe %}
{% set beacon_contact_z_homing = true if printer["gcode_macro RatOS"].beacon_contact_z_homing|default(false)|lower == 'true' else false %}
{% set X = true if params.X|lower == 'true' else false %}
{% set Y = true if params.Y|lower == 'true' else false %}
{% set Z = true if params.Z|lower == 'true' else false %}
DEBUG_ECHO PREFIX="HOME_Z" MSG="x_homed: {x_homed}, y_homed: {y_homed}, z_probe: {z_probe}, beacon_contact_z_homing: {beacon_contact_z_homing}"
{% if Z or not Y and not X %}
RATOS_ECHO MSG="Homing Z"
{% if x_homed == False or y_homed == False %}
{ action_emergency_stop("X and Y must be homed before homing Z") }
{% else %}
{% if z_probe == "stowable" %}
DEPLOY_PROBE
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
STOW_PROBE
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% if printer.configfile.settings.beacon is defined and beacon_contact_z_homing %}
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
_MOVE_TO_SAFE_Z_HOME Z_HOP=True
{% else %}
G28 Z
{% endif %}
_Z_HOP
{% endif %}
{% endif %}
{% endif %}
[gcode_macro HOME_X_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
{% endif %}
G4 P300
G28 X
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_x_sensorless"
[gcode_macro HOME_Y_SENSORLESS]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
M204 S1000
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
{% endif %}
G4 P300
G28 Y
{% if printer["gcode_macro RatOS"].x_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].x_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].x_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set x_driver = printer["gcode_macro RatOS"].driver_type_x|lower ~ " stepper_x" %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config[x_driver].run_current}
{% endif %}
{% if printer["gcode_macro RatOS"].y_axes is defined %}
{% for axis in printer["gcode_macro RatOS"].y_axes %}
{% set stepper = "stepper_" ~ axis|lower %}
{% set stepper_driver = printer["gcode_macro RatOS"].y_driver_types[loop.index0] ~ " " ~ stepper %}
SET_TMC_CURRENT STEPPER={stepper} CURRENT={printer.configfile.config[stepper_driver].run_current}
{% endfor %}
{% else %}
{% set y_driver = printer["gcode_macro RatOS"].driver_type_y|lower ~ " stepper_y" %}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config[y_driver].run_current}
{% endif %}
G4 P300
RESTORE_TOOLHEAD_SETTINGS KEY="home_y_sensorless"
[gcode_macro _Z_HOP]
description = Move Z axis up by Z_HOP distance at Z_HOP_SPEED. In relative mode it will move Z axis up by Z_HOP distance. In absolute mode it will move Z axis to Z_HOP distance.
gcode =
{% set z_hop = printer.configfile.config.ratos_homing.z_hop|float %}
{% set z_hop_speed = printer.configfile.config.ratos_homing.z_hop_speed|float * 60 %}
G0 Z{z_hop} F{z_hop_speed}
[gcode_macro _MOVE_TO_SAFE_Z_HOME]
description = Move to safe home position with optional Z_HOP (pass Z_HOP=True as parameter)
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% if params.Z_HOP is defined %}
_Z_HOP
{% endif %}
DEBUG_ECHO PREFIX="_MOVE_TO_SAFE_Z_HOME" MSG="axis_maximum.x: {printer.toolhead.axis_maximum.x}, axis_maximum.y: {printer.toolhead.axis_maximum.y}, bed_margin_x: {printer['gcode_macro RatOS'].bed_margin_x}, bed_margin_y: {printer['gcode_macro RatOS'].bed_margin_y}, safe_home_x: {safe_home_x}, safe_home_y: {safe_home_y}, printable_x_max: {printable_x_max}, printable_y_max: {printable_y_max}"
G0 X{safe_home_x} Y{safe_home_y} F{speed}
[gcode_macro MAYBE_HOME]
description = Only home unhomed axis
variable_is_kinematic_position_overriden = False
gcode =
{% if printer["gcode_macro MAYBE_HOME"].is_kinematic_position_overriden|lower == 'true' %}
RATOS_ECHO MSG="SET_CENTER_KINEMATIC_POSITION has been abused. Homing all axes. Please refrain from using SET_CENTER_KINEMATIC_POSITION outside of debugging purposes."
G28
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=False
{% else %}
{% set axes = '' %}
{% set isHomed = true %}
{% set axesToHome = '' %}
{% if params.X is defined %}
{% set axes = axes ~ 'X ' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% endif %}
{% if params.Y is defined %}
{% set axes = axes ~ 'Y ' %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% endif %}
{% if params.Z is defined %}
{% set axes = axes ~ 'Z ' %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if params.X is not defined and params.Y is not defined and params.Z is not defined %}
{% set axes = '' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if isHomed is false %}
RATOS_ECHO MSG="Homing {axesToHome}"
G28 {axesToHome}
{% else %}
RATOS_ECHO MSG="All requested axes already homed, skipping.."
{% endif %}
{% endif %}
[gcode_macro PID_CALIBRATE_HOTEND]
description = Perform a PID calibration test for a given extruder heater.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set temp = params.TEMP|default(220)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_HOTEND" MSG="TEMP={temp}"
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO MSG="PID calibration hotend heater T0 at {temp}°C..."
PID_CALIBRATE HEATER=extruder TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
{% if toolhead==0 or toolhead==1 %}
RATOS_ECHO MSG="PID calibration hotend heater T{toolhead} at {temp}°C..."
PID_CALIBRATE HEATER=extruder{'' if toolhead==0 else toolhead} TARGET={temp}
_CONSOLE_SAVE_CONFIG
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_BED]
description = Perform a PID calibration test for the bed heater.
gcode =
{% set temp = params.TEMP|default(80)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_BED" MSG="TEMP={temp}"
RATOS_ECHO MSG="PID calibration bed heater at {temp}°C..."
PID_CALIBRATE HEATER=heater_bed TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
[gcode_macro PID_CALIBRATE_CHAMBER_HEATER]
description = Perform a PID calibration test for the chamber heater.
gcode =
{% set temp = params.TEMP|default(150)|int %}
DEBUG_ECHO PREFIX="PID_CALIBRATE_CHAMBER_HEATER" MSG="TEMP={temp}"
{% if printer["heater_generic chamber_heater"] is defined %}
RATOS_ECHO MSG="PID calibration chamber heater at {temp}°C..."
PID_CALIBRATE HEATER=chamber_heater TARGET={temp}
_CONSOLE_SAVE_CONFIG
_LEARN_MORE_CALIBRATION
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_heater" %}
{% set link_text = "RatOS Chamber Heater" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber heater found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro INITIALIZE_PA_TUNING]
description = Start a pressure advance tuning tower.
gcode =
{% set start = params.START|default(0.0)|float %}
{% set factor = params.FACTOR|default(0.001)|float %}
{% set layer_number = printer["gcode_macro _ON_LAYER_CHANGE"].layer_number|default(0)|int %}
{% set is_printing_gcode = true if printer["gcode_macro START_PRINT"].is_printing_gcode|default(true)|lower == 'true' else false %}
{% if is_printing_gcode and layer_number < 2 %}
DEBUG_ECHO PREFIX="START_PA_TOWER" MSG="START: {start}, FACTOR: {factor}"
RATOS_ECHO MSG="Starting presssure advance tuning tower..."
TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START={start} FACTOR={factor}
{% endif %}
_LEARN_MORE_CALIBRATION
[gcode_macro CHAMBER_FILTER_ON]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro CHAMBER_FILTER_OFF]
gcode =
{% if printer["fan_generic filter"] is defined %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Deactivating chamber filter..."
_CHAMBER_FILTER_TURN_OFF
{% else %}
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="No chamber filter found" TYPE="warning" MSG={line_1}
{% endif %}
[gcode_macro _CHAMBER_FILTER_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set chamber_filter_enable_at = printer["gcode_macro RatOS"].chamber_filter_enable_at|default('after_print_start')|lower %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_ON" MSG="at: {at}, chamber_filter_enable: {chamber_filter_enable}, chamber_filter_enable_at: {chamber_filter_enable_at}, chamber_filter_speed: {chamber_filter_speed}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if chamber_filter_enable_at == at %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Activating chamber filter..."
_CHAMBER_FILTER_TURN_ON AT={at}
{% if chamber_filter_enable_at == "print_end" %}
_LED_CHAMBER_FILTER_ON
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_FILTER_OFF]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF" MSG="chamber_filter_enable: {chamber_filter_enable}, filter_disable_period: {filter_disable_period}, filter_disable_bed_temp: {filter_disable_bed_temp}"
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_period > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting {filter_disable_period} seconds before turning chamber filter off..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION={filter_disable_period}
{% endif %}
{% if filter_disable_bed_temp > 0 %}
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Waiting for bed temp to cool down to {filter_disable_bed_temp}°C to turn filter off..."
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM=0 MAXIMUM={filter_disable_bed_temp}
_CHAMBER_FILTER_TURN_OFF
_LED_CHAMBER_FILTER_OFF
{% endif %}
{% endif %}
[delayed_gcode _CHAMBER_FILTER_OFF_TIMER]
gcode =
DEBUG_ECHO PREFIX="_CHAMBER_FILTER_OFF_TIMER" MSG="executed"
_CHAMBER_FILTER_TURN_OFF
RATOS_ECHO PREFIX="CHAMBER_FILTER" MSG="Chamber filter turned off!"
_LED_CHAMBER_FILTER_OFF
[gcode_macro _CHAMBER_FILTER_TURN_ON]
gcode =
{% set at = params.AT|default('')|lower %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_speed|default(0)|float %}
{% if at == "print_end" %}
{% set chamber_filter_speed = printer["gcode_macro RatOS"].chamber_filter_disable_speed|default(0)|float %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_FILTER_OFF_TIMER DURATION=0
SET_FAN_SPEED FAN=filter SPEED={chamber_filter_speed}
[gcode_macro _CHAMBER_FILTER_TURN_OFF]
gcode =
SET_FAN_SPEED FAN=filter SPEED=0
[gcode_macro _CHAMBER_FILTER_SANITY_CHECK]
gcode =
{% set chamber_filter_enable = true if printer["gcode_macro RatOS"].chamber_filter_enable|default(true)|lower == 'true' else false %}
{% set filter_disable_period = printer["gcode_macro RatOS"].chamber_filter_disable_period|default(0)|int %}
{% set filter_disable_bed_temp = printer["gcode_macro RatOS"].chamber_filter_disable_bed_temp|default(0)|int %}
{% if chamber_filter_enable and printer["fan_generic filter"] is defined %}
{% if filter_disable_bed_temp > 0 and filter_disable_period > 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable, not both.")}
{% endif %}
{% if filter_disable_bed_temp == 0 and filter_disable_period == 0 %}
_LEARN_MORE_CHAMBER_FILTER
{action_respond_info("Wrong chamber filter options configured! Set 'filter_disable_bed_temp' or 'filter_disable_period' variable.")}
{% endif %}
{% endif %}
[gcode_macro CHAMBER_HEATER_ON]
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(45)|int %}
_CHAMBER_HEATER_ON CHAMBER_TEMP={chamber_temp} IS_FROM_START_PRINT=False
[gcode_macro CHAMBER_HEATER_OFF]
gcode =
_CHAMBER_HEATER_OFF
[gcode_macro _CHAMBER_HEATER_ON]
variable_chamber_temp = 0
gcode =
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set is_from_start_print = true if params.IS_FROM_START_PRINT|default(True)|lower == 'true' else false %}
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set chamber_heater_enable = true if printer["gcode_macro RatOS"].chamber_heater_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
{% set chamber_heater_preheating_temp = printer["gcode_macro RatOS"].chamber_heater_preheating_temp|default(150)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set chamber_heater_control_external_heater = true if printer["gcode_macro RatOS"].chamber_heater_control_external_heater|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_enable = true if printer["gcode_macro RatOS"].chamber_heater_air_circulation_enable|default(true)|lower == 'true' else false %}
{% set chamber_heater_air_circulation_fan_speed = printer["gcode_macro RatOS"].chamber_heater_air_circulation_fan_speed|default(0.35)|float %}
{% set chamber_heater_air_circulation_y_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_y_pos|default(0)|float %}
{% set chamber_heater_air_circulation_z_pos = printer["gcode_macro RatOS"].chamber_heater_air_circulation_z_pos|default(100)|float %}
DEBUG_ECHO PREFIX="_CHAMBER_HEATER_ON" MSG="chamber_heater_enable: {chamber_heater_enable}, chamber_heater_preheating_temp: {chamber_heater_preheating_temp}, chamber_heater_heating_temp_offset: {chamber_heater_heating_temp_offset}, bed_temp: {bed_temp}, chamber_temp: {chamber_temp}, start_chamber_temp: {start_chamber_temp}"
{% if chamber_heater_enable and chamber_temp > 0 and chamber_heater_bed_temp > 0 %}
_LED_HEATING
RATOS_ECHO MSG="Preheating chamber to {(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}°C..."
{% set chamber_temp_sensor = "extruder" %}
{% if printer["dual_carriage"] is defined and default_toolhead == 1 %}
{% set chamber_temp_sensor = "extruder1" %}
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% set chamber_temp_sensor = "temperature_sensor chamber" %}
{% endif %}
{% set current_chamber_temp = printer['%s' % chamber_temp_sensor].temperature|int %}
{% set needs_heating = current_chamber_temp < (start_chamber_temp if start_chamber_temp > 0 else chamber_temp) %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_BEFORE_PREHEATING
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
{% if not is_from_start_print %}
MAYBE_HOME
{% endif %}
G0 Z{chamber_heater_air_circulation_z_pos} F{z_speed}
G0 Y{chamber_heater_air_circulation_y_pos} F{speed}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={chamber_heater_air_circulation_fan_speed if default_toolhead == 1 else 0}
{% else %}
M106 S{(255 * chamber_heater_air_circulation_fan_speed)}
{% endif %}
{% else %}
{% if is_from_start_print %}
G0 Z{z} F{z_speed}
{% endif %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE={chamber_temp}
{% if needs_heating %}
M140 S{chamber_heater_bed_temp}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={chamber_heater_preheating_temp}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if needs_heating %}
_CHAMBER_HEATER_EXTRA_FAN_ON
{% endif %}
{% if needs_heating %}
TEMPERATURE_WAIT SENSOR="{chamber_temp_sensor}" MINIMUM={(start_chamber_temp if start_chamber_temp > 0 else chamber_temp)}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% endif %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED=0
_CHAMBER_FILTER_ON AT="before_print_start"
{% endif %}
{% endif %}
{% if needs_heating %}
{% if chamber_heater_air_circulation_enable and chamber_heater_air_circulation_fan_speed > 0 %}
G28 Z
{% endif %}
{% endif %}
{% if needs_heating %}
_USER_CHAMBER_HEATER_AFTER_PREHEATING
{% endif %}
{% if printer["temperature_sensor chamber"] is defined %}
{% if printer["heater_generic chamber_heater"] is defined %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined and chamber_heater_control_external_heater %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
_LED_SUCCESS
{% endif %}
[gcode_macro _CHAMBER_HEATER_OFF]
gcode =
RATOS_ECHO MSG="Deactivating chamber heater..."
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=0
SET_GCODE_VARIABLE MACRO=_CHAMBER_HEATER_ON VARIABLE=chamber_temp VALUE=0
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
_CHAMBER_HEATER_EXTRA_FAN_OFF
[delayed_gcode _CHAMBER_HEATER_CONTROL]
initial_duration = 0.
gcode =
{% set chamber_temp = printer["gcode_macro _CHAMBER_HEATER_ON"].chamber_temp|default(0)|int %}
{% set chamber_heater_heating_temp_offset = printer["gcode_macro RatOS"].chamber_heater_heating_temp_offset|default(20)|int %}
{% set current_chamber_temp = printer['temperature_sensor chamber'].temperature|int %}
{% if current_chamber_temp < chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={(chamber_temp + chamber_heater_heating_temp_offset)}
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=1.0
{% endif %}
{% endif %}
{% if current_chamber_temp >= chamber_temp %}
{% if printer["heater_generic chamber_heater"] is defined %}
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET=0
{% endif %}
{% if printer["output_pin chamber_heater_pin"] is defined %}
SET_PIN PIN=chamber_heater_pin VALUE=0.0
{% endif %}
{% endif %}
UPDATE_DELAYED_GCODE ID=_CHAMBER_HEATER_CONTROL DURATION=5
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_ON]
gcode =
{% set chamber_heater_extra_fan_speed = printer["gcode_macro RatOS"].chamber_heater_extra_fan_speed|default(0.0)|float %}
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
{% if chamber_heater_extra_fan_speed > 0 %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED={chamber_heater_extra_fan_speed}
{% endif %}
{% endif %}
[gcode_macro _CHAMBER_HEATER_EXTRA_FAN_OFF]
gcode =
{% if printer["fan_generic chamber_heater_extra_fan"] is defined %}
SET_FAN_SPEED FAN=chamber_heater_extra_fan SPEED=0
{% endif %}
[gcode_macro _USER_CHAMBER_HEATER_BEFORE_PREHEATING]
description = Will be executed before chamber preheating, only if heating is needed.
gcode =
[gcode_macro _USER_CHAMBER_HEATER_AFTER_PREHEATING]
description = Will be executed after chamber preheating, only if heating was needed.
gcode =
[gcode_macro _LED_START_PRINTING]
gcode =
_LED_ACTION
[gcode_macro _LED_START_PRINTING_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_PRINTING]
gcode =
_LED_ON TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_PAUSE]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_ON]
gcode =
_LED_ACTION
[gcode_macro _LED_CHAMBER_FILTER_OFF]
gcode =
_LED_STANDBY
[gcode_macro _LED_LOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_LOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_RUNOUT]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_CLOG]
gcode =
_LED_ERROR TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_UNLOADING_FILAMENT]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_FILAMENT_UNLOADED]
gcode =
_LED_SUCCESS TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_DEACTIVATE_TOOLHEAD]
gcode =
_LED_OFF TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_STANDBY]
gcode =
_LED_STANDBY TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_TOOLHEAD_WAKEUP]
gcode =
_LED_ACTION TOOLHEAD={params.TOOLHEAD|default(-1)|int}
[gcode_macro _LED_MOTORS_OFF]
gcode =
_LED_STANDBY
_LED_VAOC_OFF
[gcode_macro _LED_INPUT_SHAPER_START]
gcode =
_LED_ACTION
[gcode_macro _LED_INPUT_SHAPER_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_START]
gcode =
_LED_ACTION
[gcode_macro _LED_BEACON_CALIBRATION_END]
gcode =
_LED_ON
[gcode_macro _LED_BEACON_CALIBRATION_ERROR]
gcode =
_LED_ERROR
[gcode_macro _LED_VAOC_ON]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=1.0 GREEN=1.0 BLUE=1.0
{% endif %}
[gcode_macro _LED_VAOC_OFF]
gcode =
{% if printer['neopixel vaoc_led'] is defined %}
SET_LED LED=vaoc_led RED=0.0 GREEN=0.0 BLUE=0.0
{% endif %}
[gcode_macro _LED_ACTION]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_action %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SUCCESS]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_success %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_HEATING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_heating %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_COOLING]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_cooling %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ERROR]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_error %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_ON]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_on %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_OFF]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_off %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_STANDBY]
gcode =
{% set rgb = printer["gcode_macro RatOS"].led_status_standby %}
_LED_SET TOOLHEAD={params.TOOLHEAD|default(-1)|int} R={rgb[0]} G={rgb[1]} B={rgb[2]}
[gcode_macro _LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
{% if toolhead >= 0 %}
{% if printer['neopixel nozzle_led_t%s' % toolhead] is defined %}
SET_LED LED={'nozzle_led_t%s' % toolhead} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% else %}
{% if printer['neopixel nozzle_led_t0'] is defined %}
SET_LED LED={'nozzle_led_t0'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% if printer['neopixel nozzle_led_t1'] is defined %}
SET_LED LED={'nozzle_led_t1'} RED={r} GREEN={g} BLUE={b} SYNC=0
{% endif %}
{% endif %}
_USER_LED_SET { rawparams }
[gcode_macro _USER_LED_SET]
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set r = params.R|default(0)|float %}
{% set g = params.G|default(0)|float %}
{% set b = params.B|default(0)|float %}
[gcode_macro LOAD_FILAMENT]
description = Loads new filament. Note: be careful with PETG, make sure you inspect the tip of your filament before loading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% if filament_name == '' or filament_type == '' %}
{% set filament_name = 'unknown' %}
{% set filament_type = 'unknown' %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_LOAD_FILAMENT TEMP={temp} NAME={filament_name} TYPE={filament_type}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_LOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME={filament_name} TYPE={filament_type}
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _DEFAULT_LOAD_FILAMENT]
description = Load filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_LOAD_FILAMENT" MSG="TEMP={temp}"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=load_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
_LOAD_FILAMENT TOOLHEAD=0
RESTORE_GCODE_STATE NAME=load_state
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD=0
[gcode_macro _IDEX_LOAD_FILAMENT]
description = Load filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_LOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_LOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
_LOAD_FILAMENT TOOLHEAD={toolhead} TEMP={temp}
{% if filament_name != '' and filament_type != '' %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('{filament_type}', '{filament_name}', {temp})"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='"{filament_name}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='"{filament_type}"'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE={temp}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_ok}"'
_LED_FILAMENT_LOADED TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE TOOLHEAD={toolhead}
_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_EXTRUDER_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into hotend.."
G92 E0
G0 E{extruder_gear_to_cooling_position_distance} F{extruder_load_speed}
G92 E0
M400
RATOS_ECHO MSG="Filament loaded into hotend."
[gcode_macro _LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set load_speed = printer["gcode_macro T%s" % toolhead].filament_load_speed|float * 60 %}
{% set filament_loading_nozzle_offset = printer["gcode_macro T%s" % toolhead].filament_loading_nozzle_offset|float %}
{% set cooling_position_to_nozzle_distance = printer["gcode_macro T%s" % toolhead].cooling_position_to_nozzle_distance|float %}
{% set purge_after_load = printer["gcode_macro T%s" % toolhead].purge_after_load|float %}
DEBUG_ECHO PREFIX="_LOAD_FILAMENT_FROM_COOLING_ZONE_TO_NOZZLE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Loading filament into nozzle... Please wait!"
G92 E0
G0 E{cooling_position_to_nozzle_distance + filament_loading_nozzle_offset} F{load_speed}
G92 E0
G4 P1000
_PURGE_FILAMENT TOOLHEAD={toolhead} E={purge_after_load}
RATOS_ECHO MSG="Filament loaded into nozzle!"
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
{% set filament_grabbing_length = printer["gcode_macro T%s" % toolhead].filament_grabbing_length|float %}
{% set filament_grabbing_speed = printer["gcode_macro T%s" % toolhead].filament_grabbing_speed|float %}
{% set resume_after_insert = true if printer["gcode_macro T%s" % toolhead].resume_after_insert|default(true)|lower == 'true' else false %}
{% set enable_insert_detection = true if printer["gcode_macro T%s" % toolhead].enable_insert_detection|default(true)|lower == 'true' else false %}
{% set current_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% if enable_insert_detection %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_INSERT" MSG="toolhead: {toolhead}, filament_grabbing_length: {filament_grabbing_length}, filament_grabbing_speed: {filament_grabbing_speed}, current_idex_mode: {current_idex_mode}"
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Loading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
FORCE_MOVE STEPPER={'extruder%s' % ('' if toolhead == 0 else toolhead)} DISTANCE={filament_grabbing_length} VELOCITY={filament_grabbing_speed}
M400
{% if printer.pause_resume.is_paused %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% if resume_after_insert %}
RESUME
{% endif %}
{% else %}
{% if not printer.virtual_sdcard.is_active %}
LOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_INSERT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_INSERT" MSG="TOOLHEAD: {toolhead}"
[gcode_macro _PURGE_BEFORE_UNLOAD]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set purge_before_unload = printer["gcode_macro T%s" % toolhead].purge_before_unload|float %}
DEBUG_ECHO PREFIX="_PURGE_BEFORE_UNLOAD" MSG="TOOLHEAD: {toolhead}"
{% if purge_before_unload > 0 %}
G92 E0
G0 E{purge_before_unload} F300
G92 E0
M400
{% endif %}
[gcode_macro _PURGE_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set e = params.E|int %}
{% set r = params.R|default(0)|int %}
DEBUG_ECHO PREFIX="_PURGE_FILAMENT" MSG="TOOLHEAD: {toolhead}, E: {e}"
{% if e > 0 %}
G92 E0
G0 E{e} F300
G92 E0
M400
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={0.4 if toolhead == 0 else 0}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={0.4 if toolhead == 1 else 0}
{% else %}
M106 S{(255 * 0.4)}
{% endif %}
{% endif %}
G4 P3000
{% if r > 0 %}
G92 E0
G0 E-{r} F300
G92 E0
M400
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["dual_carriage"] is defined %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED=0
SET_FAN_SPEED FAN=part_fan_t1 SPEED=0
{% else %}
M106 S0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_PARKING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_PARKING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _MOVE_TO_LOADING_POSITION]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_MOVE_TO_LOADING_POSITION" MSG="TOOLHEAD: {toolhead}"
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% if act_t == toolhead %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
G1 X{loading_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _CLEANING_MOVE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% if printer["dual_carriage"] is defined or printer["rmmu_hub"] is defined %}
{% if "xyz" in printer.toolhead.homed_axes %}
{% if printer["gcode_macro T%s" % toolhead].has_oozeguard|default(false)|lower == 'true' %}
{% if printer["gcode_macro T%s" % toolhead].parking_position is defined and printer["gcode_macro T%s" % toolhead].loading_position is defined %}
{% set loading_position = printer["gcode_macro T%s" % toolhead].loading_position|float %}
{% set parking_position = printer["gcode_macro T%s" % toolhead].parking_position|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% set cleaning_position = loading_position %}
{% if loading_position == parking_position %}
{% if loading_position > 0 %}
{% set cleaning_position = loading_position - 30 %}
{% else %}
{% set cleaning_position = loading_position + 30 %}
{% endif %}
{% endif %}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
G1 X{cleaning_position} F{speed}
G1 X{parking_position} F{speed}
M400
{% endif %}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro _START_PRINT_BED_MESH]
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
SET_MACRO_TRAVEL_SETTINGS
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set X=[params.X0|default(-1)|float, params.X1|default(-1)|float] %}
{% set Y=[params.Y0|default(-1)|float, params.Y1|default(-1)|float] %}
DEBUG_ECHO PREFIX="_START_PRINT_BED_MESH" MSG="idex_mode: {idex_mode}, X: {X}, Y: {Y}"
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set X=[0, printable_x_max] %}
{% endif %}
{% set beacon_bed_mesh_scv = printer["gcode_macro RatOS"].beacon_bed_mesh_scv|default(25)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% if printer.configfile.settings.beacon is defined and not beacon_contact_bed_mesh %}
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={beacon_bed_mesh_scv}
{% endif %}
{% set default_profile = printer["gcode_macro RatOS"].bed_mesh_profile|default('ratos') %}
{% if printer["gcode_macro RatOS"].calibrate_bed_mesh|lower == 'true' %}
BED_MESH_CLEAR
{% if printer["gcode_macro RatOS"].adaptive_mesh|lower == 'true' %}
CALIBRATE_ADAPTIVE_MESH PROFILE={default_profile} X0={X[0]} X1={X[1]} Y0={Y[0]} Y1={Y[1]} T={params.T|int} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={idex_mode}
{% else %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% endif %}
BED_MESH_PROFILE LOAD={default_profile}
{% elif printer["gcode_macro RatOS"].bed_mesh_profile is defined %}
BED_MESH_CLEAR
BED_MESH_PROFILE LOAD={printer["gcode_macro RatOS"].bed_mesh_profile}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_bed_mesh"
[gcode_macro CALIBRATE_ADAPTIVE_MESH]
gcode =
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_bed_mesh_samples = printer["gcode_macro RatOS"].beacon_contact_bed_mesh_samples|default(2)|int %}
{% set beacon_contact_bed_mesh = true if printer["gcode_macro RatOS"].beacon_contact_bed_mesh|default(false)|lower == 'true' else false %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set default_profile = params.PROFILE %}
{% set x0 = params.X0|default(-1)|float %}
{% set y0 = params.Y0|default(-1)|float %}
{% set x1 = params.X1|default(-1)|float %}
{% set y1 = params.Y1|default(-1)|float %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Recieved coordinates X0={x0} Y0={y0} X1={x1} Y1={y1}"
{% if x0 >= x1 or y0 >= y1 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Invalid coordinates received. Please check your slicer settings. Falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float %}
{% set mesh_x0 = [[x0, max_x]|min, min_x]|max %}
{% set mesh_y0 = [[y0, max_y]|min, min_y]|max %}
{% set mesh_x1 = [[x1, max_x]|min, min_x]|max %}
{% set mesh_y1 = [[y1, max_y]|min, min_y]|max %}
{% if mesh_x0 == min_x and mesh_y0 == min_y and mesh_x1 == max_x and mesh_y1 == max_y %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Print is using the full bed, falling back to full bed mesh."
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile}
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% else %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
DEPLOY_PROBE
{% endif %}
{% set probe_count_x = mesh_config.probe_count.split(",")[0]|int %}
{% if mesh_config.probe_count.split(",")|length == 2 %}
{% set probe_count_y = mesh_config.probe_count.split(",")[1]|int %}
{% else %}
{% set probe_count_y = mesh_config.probe_count.split(",")[0]|int %}
{% endif %}
{% set probe_x_step = (max_x - min_x) / probe_count_x %}
{% set probe_y_step = (max_y - min_y) / probe_count_y %}
{% set mesh_count_x = ([(mesh_x1 - mesh_x0) / probe_x_step, 3]|max)|int %}
{% set mesh_count_y = ([(mesh_y1 - mesh_y0) / probe_y_step, 3]|max)|int %}
{% set min_mesh_count = [mesh_count_x, mesh_count_y]|min %}
{% set max_mesh_count = [mesh_count_x, mesh_count_y]|max %}
{% set algorithm = mesh_config.algorithm %}
{% if algorithm|lower == 'lagrange' and max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="cannot exceed a probe_count of 6 when using lagrange interpolation. Falling back to bicubic interpolation."
{% set algorithm = 'bicubic' %}
{% endif %}
{% if algorithm|lower == 'bicubic' and min_mesh_count < 4 %}
{% if max_mesh_count > 6 %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="invalid probe_count option when using bicubic interpolation. Combination of 3 points on one axis with more than 6 on another is not permitted. Forcing minimum mesh count to be 4."
{% set min_mesh_count = 4 %}
{% else %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="bicubic interpolation with a probe_count of less than 4 points detected. Forcing lagrange interpolation."
{% set algorithm = 'lagrange' %}
{% endif %}
{% endif %}
{% set mesh_count_x = ([min_mesh_count, mesh_count_x]|max)|int %}
{% set mesh_count_x = ([max_mesh_count, mesh_count_x]|min)|int %}
{% set mesh_count_y = ([min_mesh_count, mesh_count_y]|max)|int %}
{% set mesh_count_y = ([max_mesh_count, mesh_count_y]|min)|int %}
{% set should_prime = printer["gcode_macro RatOS"].nozzle_priming == 'primeblob' %}
{% if printer["dual_carriage"] is not defined %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% else %}
{% set probe_first = printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == "min" or printer["gcode_macro RatOS"].nozzle_prime_start_y|float(printable_y_max) < printable_y_max / 2 %}
{% endif %}
{% if printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 != 0 and probe_first %}
{% set probe_first = false %}
{% elif printer.configfile.settings.beacon is defined and printer.configfile.settings.beacon.mesh_runs % 2 == 0 and not probe_first %}
{% set probe_first = true %}
{% endif %}
{% if should_prime and probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="mesh coordinates X0={mesh_x0} Y0={mesh_y0} X1={mesh_x1} Y1={mesh_y1}"
{% if printer.configfile.settings.beacon is defined and beacon_contact_bed_mesh %}
BED_MESH_CALIBRATE PROBE_METHOD=contact USE_CONTACT_AREA=1 SAMPLES={beacon_contact_bed_mesh_samples} PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% else %}
BED_MESH_CALIBRATE PROFILE={default_profile} ALGORITHM={algorithm} MESH_MIN={mesh_x0},{mesh_y0} MESH_MAX={mesh_x1},{mesh_y1} PROBE_COUNT={mesh_count_x},{mesh_count_y} RELATIVE_REFERENCE_INDEX=-1
{% if printer.configfile.settings.beacon is defined %}
_BEACON_APPLY_SCAN_COMPENSATION
{% endif %}
{% endif %}
{% if should_prime and not probe_first %}
{% if printer["dual_carriage"] is not defined %}
PROBE_FOR_PRIMING
{% else %}
{% if both_toolheads %}
PROBE_FOR_PRIMING TOOLHEAD=0 IDEX_MODE={idex_mode}
PROBE_FOR_PRIMING TOOLHEAD=1 IDEX_MODE={idex_mode}
{% else %}
PROBE_FOR_PRIMING TOOLHEAD={params.T|int} IDEX_MODE={idex_mode}
{% endif %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
STOW_PROBE
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M84]
rename_existing = M84.1
gcode =
M84.1
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
{% if printer["dual_carriage"] is defined %}
_SET_TOOLHEAD_OFFSET T={printer["gcode_macro RatOS"].default_toolhead|int} MOVE=0
SET_GCODE_VARIABLE MACRO=SET_PRESSURE_ADVANCE VARIABLE=snyc_toolheads VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro _VAOC"] is defined %}
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started VALUE=False
SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started_at_temp VALUE=False
{% endif %}
SET_GCODE_OFFSET X=0 Y=0 Z=0 MOVE=0
_IDEX_SINGLE INIT=1
{% endif %}
SET_SKEW CLEAR=1
_LED_MOTORS_OFF
[gcode_macro M104]
rename_existing = M104.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
DEBUG_ECHO PREFIX="M104" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set temperature_offset_t0 = printer["gcode_macro T0"].temperature_offset|default(0)|int %}
{% set temperature_offset_t1 = printer["gcode_macro T1"].temperature_offset|default(0)|int %}
{% set s0 = [s + temperature_offset_t0, 0]|max %}
{% set s1 = [s + temperature_offset_t1, 0]|max %}
{% if temperature_offset_t0 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t0}°C added to toolhead T0."
{% endif %}
{% if temperature_offset_t1 != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset_t1}°C added to toolhead T1."
{% endif %}
{% else %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M104" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
M104.1 S{s0} T0
M104.1 S{s1} T1
{% else %}
M104.1 S{s} T{t}
{% endif %}
{% endif %}
[gcode_macro M109]
rename_existing = M109.1
gcode =
{% set s = params.S|default(0)|int %}
{% set t = params.T|default(-1)|int %}
{% set t = 0 if t == -1 else t %}
DEBUG_ECHO PREFIX="M109" MSG="s: {s}, t: {t}"
{% if printer["gcode_macro T%s" % t] is defined %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set s = [s + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="M109" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% set is_in_standby = false %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% if toolchange_standby_temp > -1 %}
{% set is_in_standby = true if printer["gcode_macro T%s" % t].standby|default(false)|lower == 'true' else false %}
{% endif %}
{% endif %}
{% if not is_in_standby %}
M109.1 S{s} T{t}
{% endif %}
[gcode_macro SET_HEATER_TEMPERATURE]
rename_existing = SET_HEATER_TEMPERATURE_BASE
gcode =
{% set heater = params.HEATER|default("") %}
{% set target = params.TARGET|default(0)|int %}
DEBUG_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="heater: {heater}, target: {target}"
{% if heater|lower == "extruder" or heater|lower == "extruder1" %}
{% set t = 0 if heater|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and target > 0 %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% set target = [target + temperature_offset, 0]|max %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="SET_HEATER_TEMPERATURE" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
SET_HEATER_TEMPERATURE_BASE HEATER="{heater}" TARGET={target}
[gcode_macro TEMPERATURE_WAIT]
rename_existing = TEMPERATURE_WAIT_BASE
gcode =
{% set sensor = params.SENSOR|default("") %}
{% set minimum = params.MINIMUM|default(-1)|int %}
{% set maximum = params.MAXIMUM|default(-1)|int %}
DEBUG_ECHO PREFIX="TEMPERATURE_WAIT" MSG="sensor: {sensor}, minimum: {minimum}, maximum: {maximum}"
{% if sensor|lower == "extruder" or sensor|lower == "extruder1" %}
{% set t = 0 if sensor|lower == "extruder" else 1 %}
{% if printer["gcode_macro T%s" % t] is defined and (minimum > 0 or maximum > 0) %}
{% set temperature_offset = printer["gcode_macro T%s" % t].temperature_offset|default(0)|int %}
{% if minimum > -1 %}
{% set minimum = [minimum + temperature_offset, 0]|max %}
{% endif %}
{% if maximum > -1 %}
{% set maximum = [maximum + temperature_offset, 0]|max %}
{% endif %}
{% if temperature_offset != 0 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature offset of {temperature_offset}°C added to toolhead T{t}."
{% endif %}
{% endif %}
{% endif %}
{% if minimum > -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum} MAXIMUM={maximum}
{% elif minimum > -1 and maximum == -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MINIMUM: {minimum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MINIMUM={minimum}
{% elif minimum == -1 and maximum > -1 %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Waiting for sensor: {sensor}, MAXIMUM: {maximum}"
RATOS_ECHO MSG="please wait..."
TEMPERATURE_WAIT_BASE SENSOR="{sensor}" MAXIMUM={maximum}
{% endif %}
RATOS_ECHO PREFIX="TEMPERATURE_WAIT" MSG="Temperature for toolhead T{t} reached."
[gcode_macro SET_GCODE_OFFSET]
rename_existing = SET_GCODE_OFFSET_ORG
gcode =
SET_GCODE_OFFSET_ORG { rawparams }
{% if printer.configfile.settings.beacon is defined and (params.Z_ADJUST is defined or params.Z is defined) %}
_BEACON_APPLY_RUNTIME_MULTIPLIER
{% endif %}
[gcode_macro SDCARD_PRINT_FILE]
rename_existing = SDCARD_PRINT_FILE_BASE
gcode =
{% if printer["ratos"] is defined %}
PROCESS_GCODE_FILE { rawparams }
{% else %}
SDCARD_PRINT_FILE_BASE { rawparams }
{% endif %}
[gcode_macro SKEW_PROFILE]
rename_existing = SKEW_PROFILE_BASE
variable_loaded_profile = ""
gcode =
{% if params.LOAD is defined %}
{% if printer.configfile.settings["skew_correction %s" % params.LOAD] is defined %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='"{params.LOAD}"'
{% endif %}
{% endif %}
SKEW_PROFILE_BASE { rawparams }
[gcode_macro SET_SKEW]
rename_existing = SET_SKEW_BASE
gcode =
{% if params.CLEAR is defined %}
{% if params.CLEAR|default(0)|int == 1 %}
SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='""'
{% endif %}
{% endif %}
SET_SKEW_BASE { rawparams }
[gcode_macro SET_VELOCITY_LIMIT]
rename_existing = SET_VELOCITY_LIMIT_BASE
gcode =
{% if params.ACCEL_TO_DECEL is defined %}
{% if params.ACCEL is defined %}
{% set accel = params.ACCEL|float %}
{% else %}
{% set accel = printer.toolhead.max_accel|float %}
{% endif %}
{% if params.VELOCITY is defined %}
{% set velocity = params.VELOCITY|float %}
{% else %}
{% set velocity = printer.toolhead.max_velocity|float %}
{% endif %}
{% if params.SQUARE_CORNER_VELOCITY is defined %}
{% set scv = params.SQUARE_CORNER_VELOCITY|float %}
{% else %}
{% set scv = printer.toolhead.square_corner_velocity|float %}
{% endif %}
{% set mcr = params.ACCEL_TO_DECEL|float / accel %}
DEBUG_ECHO PREFIX="SET_VELOCITY_LIMIT" MSG="ACCEL={accel}, VELOCITY={velocity}, SQUARE_CORNER_VELOCITY={scv}, MINIMUM_CRUISE_RATIO={mcr}"
SET_VELOCITY_LIMIT_BASE ACCEL={accel} VELOCITY={velocity} SQUARE_CORNER_VELOCITY={scv} MINIMUM_CRUISE_RATIO={1-mcr}
{% else %}
SET_VELOCITY_LIMIT_BASE { rawparams }
{% endif %}
[gcode_macro _START_PRINT_PARK]
gcode =
{% set z = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_x = printer["gcode_macro RatOS"].start_print_park_x %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% endif %}
{% if printer["dual_carriage"] is defined and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
{% if printer["gcode_macro RatOS"].start_print_park_x is defined and printer["gcode_macro RatOS"].start_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="start_print_park_x is ignored for IDEX printers"
{% endif %}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={start_print_park_in} X={start_print_park_x}
G0 Z{z} F{z_speed}
[gcode_macro _END_PRINT_PARK]
gcode =
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro RatOS"].end_print_park_x is defined and printer["gcode_macro RatOS"].end_print_park_x != '' %}
RATOS_ECHO PREFIX="WARNING" MSG="end_print_park_x is ignored for IDEX printers"
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
PARK_TOOLHEAD
G90
{% endif %}
_PARK LOCATION={printer["gcode_macro RatOS"].end_print_park_in} X={printer["gcode_macro RatOS"].end_print_park_x}
[gcode_macro _PARK]
gcode =
{% set x = params.X %}
{% set location = params.LOCATION|default('back')|lower %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set nozzle_priming = printer["gcode_macro RatOS"].nozzle_priming|lower %}
CACHE_TOOLHEAD_SETTINGS KEY="park"
SET_MACRO_TRAVEL_SETTINGS
{% if x != '' %}
{% if x|float >= printer.toolhead.axis_minimum.x + 5 and x|float <= printable_x_max - 5 %}
{% set park_x = x|float %}
{% else %}
{action_respond_info('The requested X co-ordinate is outside the defined axis bounds - using defaults')}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% else %}
{% set park_x = printable_x_max / 2 %}
{% endif %}
{% set park_y = printable_y_max - 15 %}
{% if location == 'front' %}
{% set park_y = printer.toolhead.axis_minimum.y + 5 %}
{% elif location == 'center' %}
{% set park_y = printable_y_max / 2 %}
{% elif location == 'primeblob' and printer["dual_carriage"] is defined %}
{% set park_y = printable_y_max - 15 %}
{% endif %}
{% if location == 'primeblob' and printer["dual_carriage"] is not defined %}
{% if (nozzle_priming == 'primeblob' or nozzle_priming == 'primeline') %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set park_x = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set park_x = printable_x_max - 5 %}
{% else %}
{% set park_x = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set park_y = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set park_y = printable_y_max - 5 %}
{% else %}
{% set park_y = nozzle_prime_start_y|float %}
{% endif %}
{% endif %}
{% endif %}
G90
{% if printer["dual_carriage"] is not defined %}
G0 X{park_x} Y{park_y} F{speed}
{% else %}
G0 Y{park_y} F{speed}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="park"
[gcode_macro SAVE_PROBE_RESULT]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
{% set last_z_offset = 9999.9 %}
{% if printer.configfile.settings.beacon is defined %}
{% set current_z = printer.toolhead.position.z|float %}
{% if beacon_contact_prime_probing %}
{% set last_z_offset = printer.beacon.last_z_result %}
{% else %}
{% set last_z_offset = printer.beacon.last_sample.dist - current_z %}
{% endif %}
{% elif printer.configfile.settings.bltouch is defined %}
{% set config_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% elif printer.configfile.settings.probe is defined %}
{% set config_offset = printer.configfile.settings.probe.z_offset|float %}
{% set last_z_offset = printer.probe.last_z_result - config_offset %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Saving offset adjustment of {last_z_offset} in {params.VARIABLE|default('last_z_offset')}"
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE={params.VARIABLE|default('last_z_offset')} VALUE={last_z_offset}
[gcode_macro PROBE_FOR_PRIMING]
gcode =
{% set probe_for_priming_disable_mesh_constraints = true if printer["gcode_macro RatOS"].probe_for_priming_disable_mesh_constraints|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower != 'false' %}
SAVE_GCODE_STATE NAME=probe_for_priming_state
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the prime location.."
CACHE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
SET_MACRO_TRAVEL_SETTINGS
{% set t = params.TOOLHEAD|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% if idex_mode == '' %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% if t == 0 %}
{% set x_start = 5 %}
{% else %}
{% set x_start = printable_x_max - 5 %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% endif %}
{% endif %}
{% set z = printer.configfile.settings.bed_mesh.horizontal_move_z|float %}
{% set mesh_config = printer.configfile.config.bed_mesh %}
{% if printer.configfile.settings.bltouch is defined %}
{% set x_offset = printer.configfile.settings.bltouch.x_offset|float %}
{% set y_offset = printer.configfile.settings.bltouch.y_offset|float %}
{% set z_offset = printer.configfile.settings.bltouch.z_offset|float %}
{% elif printer.configfile.settings.probe is defined %}
{% set x_offset = printer.configfile.settings.probe.x_offset|float %}
{% set y_offset = printer.configfile.settings.probe.y_offset|float %}
{% set z_offset = printer.configfile.settings.probe.z_offset|float %}
{% elif printer.configfile.settings.beacon is defined %}
{% set x_offset = printer.configfile.settings.beacon.x_offset|float %}
{% set y_offset = printer.configfile.settings.beacon.y_offset|float %}
{% set z_offset = printer.configfile.settings.beacon.trigger_distance|float %}
{% else %}
{ action_raise_error("No probe, beacon or bltouch section found. Adaptive priming only works with a [probe], [beacon] or [bltouch] section defined.") }
{% endif %}
{% if z < z_offset %}
{ action_raise_error("Horizontal move Z ({z}) is below your probe's Z offset ({z_offset}). Please adjust your horizontal_move_z setting in [bed_mesh] to be above {z}.") }
{% endif %}
{% if not probe_for_priming_disable_mesh_constraints %}
{% set min_x = mesh_config.mesh_min.split(",")[0]|float - x_offset %}
{% set min_y = mesh_config.mesh_min.split(",")[1]|float - y_offset %}
{% set max_x = mesh_config.mesh_max.split(",")[0]|float - x_offset %}
{% set max_y = mesh_config.mesh_max.split(",")[1]|float - y_offset %}
{% set x_start = [[x_start, max_x]|min, min_x]|max %}
{% set y_start = [[y_start, max_y]|min, min_y]|max %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the start of the prime location at {x_start}, {y_start}"
G90
M83
G0 Z{z} F{z_speed}
G1 X{x_start} Y{y_start} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_result
{% endif %}
{% if idex_mode == '' %}
{% set x_end = x_start %}
{% set y_end = y_start + 45 %}
{% else %}
{% if t==1 %}
{% set x_end = x_start - 45 %}
{% else %}
{% set x_end = x_start + 45 %}
{% endif %}
{% set y_end = y_start %}
{% endif %}
RATOS_ECHO PREFIX="Adaptive Mesh" MSG="Probing the end of the prime location at {x_end}, {y_end}"
G1 X{x_end} Y{y_end} F{speed}
PROBE_CURRENT_POSITION
{% if t == 1 %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result_t1
{% else %}
SAVE_PROBE_RESULT VARIABLE=probe_for_priming_end_result
{% endif %}
RESTORE_GCODE_STATE NAME=probe_for_priming_state
RESTORE_TOOLHEAD_SETTINGS KEY="probe_for_priming"
{% endif %}
[gcode_macro RESET_PRIME_PROBE_STATE]
gcode =
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result VALUE=None
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_result_t1 VALUE=None
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=probe_for_priming_end_result_t1 VALUE=None
{% endif %}
[gcode_macro PROBE_CURRENT_POSITION]
gcode =
{% set beacon_contact_prime_probing = true if printer["gcode_macro RatOS"].beacon_contact_prime_probing|default(false)|lower == 'true' else false %}
SAVE_GCODE_STATE NAME=probe_current_position_state
{% if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
ASSERT_PROBE_DEPLOYED
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_prime_probing %}
PROBE PROBE_METHOD=contact SAMPLES=1
{% else %}
PROBE
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
BEACON_QUERY
{% else %}
RESTORE_GCODE_STATE NAME=probe_current_position_state MOVE=1 MOVE_SPEED={printer["gcode_macro RatOS"].macro_z_speed|float}
{% endif %}
[gcode_macro PRIME_BLOB]
description = Prints a primeblob, used internally, if configured, as part of the START_PRINT macro.
variable_x_offset = 5
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="prime_blob"
SET_MACRO_TRAVEL_SETTINGS
RATOS_ECHO PREFIX="Priming" MSG="Priming nozzle with prime blob.."
{% set current_toolhead = 0 %}
{% set target_idex_mode = '' %}
{% set extruder = 'extruder' %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE is defined %}
{% set target_idex_mode = params.IDEX_MODE|default('')|lower %}
{% else %}
{ action_raise_error("IDEX_MODE parameter not found for PRIME_BLOB macro. This is likely a bug.") }
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Priming in IDEX {target_idex_mode} mode.."
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set current_toolhead = 1 if current_idex_mode=='primary' else 0 %}
{% set extruder = 'extruder1' if current_toolhead == 1 else 'extruder' %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
SAVE_GCODE_STATE NAME=prime_blob_state
{% endif %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set fan_speed = printer["gcode_macro RatOS"].nozzle_prime_bridge_fan|float %}
{% set nozzle_diameter = printer.configfile.settings[extruder].nozzle_diameter|float %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set has_start_offset_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) != 9999.9 %}
{% if printer["dual_carriage"] is defined %}
{% set has_start_offset_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) != 9999.9 %}
{% endif %}
{% set start_print_park_in = printer["gcode_macro RatOS"].start_print_park_in %}
{% set start_print_park_z_height = printer["gcode_macro RatOS"].start_print_park_z_height|float %}
{% set nozzle_prime_direction = printer["gcode_macro RatOS"].nozzle_prime_direction|lower %}
{% set nozzle_prime_start_x = printer["gcode_macro RatOS"].nozzle_prime_start_x %}
{% set nozzle_prime_start_y = printer["gcode_macro RatOS"].nozzle_prime_start_y %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% if target_idex_mode == '' %}
{% set x_factor = 0 %}
{% if nozzle_prime_start_x|lower == 'min' %}
{% set x_start = 5 %}
{% elif nozzle_prime_start_x|lower == 'max' %}
{% set x_start = printable_x_max - 5 %}
{% else %}
{% set x_start = nozzle_prime_start_x|float %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% set y_factor = 1 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_y_max - 5 %}
{% set y_factor = -1 %}
{% else %}
{% set y_start = nozzle_prime_start_y|float %}
{% if nozzle_prime_start_y|float < printable_y_max / 2 %}
{% set y_factor = 1 %}
{% else %}
{% set y_factor = -1 %}
{% endif %}
{% endif %}
{% if nozzle_prime_direction == 'forwards' %}
{% set y_factor = 1 %}
{% elif nozzle_prime_direction == 'backwards' %}
{% set y_factor = -1 %}
{% endif %}
{% if start_print_park_in == 'primeblob' %}
{% set z = 3 %}
{% else %}
{% set z = start_print_park_z_height %}
{% endif %}
{% else %}
{% set center_x = printable_x_max / 2 %}
{% set y_factor = 0 %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set x_start = center_x / 2 + 5 %}
{% set x_factor = 1 %}
{% else %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% if current_toolhead == 0 %}
{% set x_start = 55 %}
{% set x_factor = -1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 55 %}
{% set x_factor = 1 %}
{% endif %}
{% else %}
{% if current_toolhead == 0 %}
{% set x_start = 5 %}
{% set x_factor = 1 %}
{% elif current_toolhead == 1 %}
{% set x_start = printable_x_max - 5 %}
{% set x_factor = -1 %}
{% endif %}
{% endif %}
{% endif %}
{% if nozzle_prime_start_y|lower == 'min' %}
{% set y_start = 5 %}
{% elif nozzle_prime_start_y|lower == 'max' %}
{% set y_start = printable_x_max - 5 %}
{% endif %}
{% set z = 10 %}
{% endif %}
{% set start_z_offset = 0 %}
{% set end_z_offset = 0 %}
{% if has_start_offset_t0 %}
{% set start_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_result|float(9999.9) %}
{% set end_z_probe_result_t0 = printer["gcode_macro RatOS"].probe_for_priming_end_result|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t0 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t0) ) }
{% endif %}
{% if end_z_probe_result_t0 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t0) ) }
{% endif %}
{% set start_z_offset = start_z_probe_result_t0 %}
{% set end_z_offset = end_z_probe_result_t0 %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if current_toolhead == 1 or both_toolheads or target_idex_mode == "copy" or target_idex_mode == "mirror" %}
{% if has_start_offset_t1 %}
{% set start_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_result_t1|float(9999.9) %}
{% set end_z_probe_result_t1 = printer["gcode_macro RatOS"].probe_for_priming_end_result_t1|float(9999.9) %}
{% if printer.configfile.settings.bltouch is not defined and printer.configfile.settings.probe is not defined and printer.configfile.settings.beacon is not defined %}
{ action_raise_error("No probe or bltouch section found. Adaptive priming only works with [probe], [beacon] or [bltouch].") }
{% endif %}
{% if start_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No start probe result found for prime area. This is likely a bug.") }
{% endif %}
{% if end_z_probe_result_t1 == 9999.9 %}
{ action_raise_error("No end probe result found for prime area. This is likely a bug.") }
{% endif %}
{% set adjustment_threshold = printer["gcode_macro RatOS"].adaptive_prime_offset_threshold|float %}
{% if start_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (start_z_probe_result_t1) ) }
{% endif %}
{% if end_z_probe_result_t1 < adjustment_threshold %}
{ action_raise_error("Abnormal probe offset detected. Needed offset of %.5f is below the offset threshold of -1mm. Please verify the probe is over the bed when probing for priming. If it isn't, you should adjust you min/max bed_mesh settings so the probe is always over the print area." % (end_z_probe_result_t1) ) }
{% endif %}
{% set start_z_offset = [start_z_offset, start_z_probe_result_t1]|max %}
{% set end_z_offset = [end_z_offset, start_z_probe_result_t1]|max %}
{% endif %}
{% endif %}
{% if target_idex_mode != 'copy' and target_idex_mode != 'mirror' %}
{% if both_toolheads and initial_toolhead != current_toolhead %}
{% set original_start_z_offset = start_z_offset %}
{% set original_end_z_offset = end_z_offset %}
{% set start_z_offset = original_end_z_offset %}
{% set end_z_offset = original_start_z_offset %}
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={current_toolhead}
{% endif %}
DEBUG_ECHO PREFIX="PRIME_BLOB" MSG="x_start: {x_start}, y_start: {y_start}, x_factor: {x_factor}, y_factor: {y_factor}, z: {z}, start_z_offset: {start_z_offset}, end_z_offset: {end_z_offset}"
G90
M83
RATOS_ECHO PREFIX="Priming" MSG="Lifting Z to {z}.."
G0 Z{z} F{z_speed}
{% if printer["dual_carriage"] is not defined %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% if start_print_park_in != 'primeblob' %}
G1 X{x_start} F{speed}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% endif %}
{% else %}
G1 Y{y_start + (15 * y_factor)} F{speed}
{% if target_idex_mode=="copy" or target_idex_mode=="mirror" %}
RATOS_ECHO PREFIX="Priming" MSG="Mirroring move to {x_start}, {y_start} along the edge of the print area.."
_IDEX_MIRROR PRIMING=1
{% else %}
RATOS_ECHO PREFIX="Priming" MSG="Moving to {x_start}, {y_start} along the edge of the print area.."
{% endif %}
G1 X{x_start} F{speed}
{% endif %}
RATOS_ECHO PREFIX="Priming" MSG="Starting prime blob.."
G1 Z{0.5 + start_z_offset} F{z_speed}
G1 Y{y_start} F{speed}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
G1 F300 E{14 / ((0.4 / nozzle_diameter) ** 2)}
M106 S{fan_speed}
G1 Z5 F100 E5
G92 E0
RATOS_ECHO PREFIX="Priming" MSG="Bridging with {((fan_speed/255) * 100)|int}% fan speed.."
G1 F3000 X{x_start + (15 * x_factor)} Y{y_start + (15 * y_factor)} E{1 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (20 * x_factor)} Y{y_start + (20 * y_factor)} Z{3.8 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (34 * x_factor)} Y{y_start + (34 * y_factor)} Z{2.6 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (38 * x_factor)} Y{y_start + (38 * y_factor)} Z{1.4 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
G1 F3000 X{x_start + (42 * x_factor)} Y{y_start + (42 * y_factor)} Z{0.2 + end_z_offset} E{0.2 / ((0.4 / nozzle_diameter) ** 2)}
M106 S0
G1 F3000 X{x_start + (46 * x_factor)} Y{y_start + (46 * y_factor)} Z{0.2 + end_z_offset} E0.6
G1 F{speed} X{x_start + (50 * x_factor)} Y{y_start + (50 * y_factor)}
{% if target_idex_mode == "copy" or target_idex_mode == "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if target_idex_mode == "copy" %}
{% if first_y >= 0 %}
_IDEX_COPY DANCE=0 Y={first_y}
{% else %}
_IDEX_COPY DANCE=0 Y={params.Y1}
{% endif %}
{% endif %}
{% if target_idex_mode != "copy" or target_idex_mode != "mirror" %}
RESTORE_GCODE_STATE NAME=prime_blob_state
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="prime_blob"
G92 E0
[gcode_macro UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
variable_ignore_min_extrude_temp = True
gcode =
_LEARN_MORE_FILAMENT
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set filament_name = params._NAME|default('')|string %}
{% set filament_type = params._TYPE|default('')|string %}
{% set temp = params.TEMP|default(220)|int %}
{% if printer["dual_carriage"] is not defined %}
_DEFAULT_UNLOAD_FILAMENT TEMP={temp} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead==0 or toolhead==1 %}
_IDEX_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
RATOS_ECHO MSG="Please select toolhead! 0 = left, 1 = right toolhead"
{% endif %}
{% endif %}
[gcode_macro _LEGACY_UNLOAD_FILAMENT]
description = Unloads the filament. Note: be careful with PETG, make sure you inspect the tip of your filament before reloading to avoid jams.
gcode =
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% set unload_speed = 5 * 60 %}
{% set unload_length = printer["gcode_macro RatOS"].filament_unload_length|float %}
M117 Unloading filament...
G0 E10 F300
G0 E-5 F3600
G4 P3000
G0 E5 F6000
G0 E-15 F6000
G0 E-{unload_length} F{unload_speed}
_CLEANING_MOVE TOOLHEAD={toolhead}
M117 Filament unloaded!
RESPOND MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _DEFAULT_UNLOAD_FILAMENT]
description = Unload filament macro for non IDEX printers.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_DEFAULT_UNLOAD_FILAMENT" MSG="TEMP: {temp}"
_LED_UNLOADING_FILAMENT TOOLHEAD=0
SAVE_GCODE_STATE NAME=unload_state
{% if printer.extruder.temperature|int < temp or printer.extruder.can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating extruder to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={temp}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD=0 NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TOOLHEAD=0
{% endif %}
RESTORE_GCODE_STATE NAME=unload_state
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD=0
[gcode_macro _IDEX_UNLOAD_FILAMENT]
description = Unload filament macro for IDEX printer.
gcode =
{% set temp = params.TEMP|default(220)|int %}
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% set enable_unload_tip_forming = true if printer["gcode_macro RatOS"].enable_unload_tip_forming|default(false)|lower == 'true' else false %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
DEBUG_ECHO PREFIX="_IDEX_UNLOAD_FILAMENT" MSG="TEMP: {temp}, TOOLHEAD: {toolhead}"
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
{% if not printer.pause_resume.is_paused %}
{% if printer[target_extruder].temperature|int < temp or printer[target_extruder].can_extrude|lower == 'false' %}
RATOS_ECHO MSG="Heating T{toolhead} to {temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={temp}
{% endif %}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={temp}
{% endif %}
G4 P3000
{% if enable_unload_tip_forming %}
_UNLOAD_FILAMENT TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_LEGACY_UNLOAD_FILAMENT TEMP={temp} TOOLHEAD={toolhead}
{% endif %}
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT" MSG="TOOLHEAD: {toolhead}"
_MOVE_TO_LOADING_POSITION TOOLHEAD={toolhead}
_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER TOOLHEAD={toolhead}
_CLEANING_MOVE TOOLHEAD={toolhead}
[gcode_macro _UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_NOZZLE_TO_COOLING_ZONE" MSG="TOOLHEAD: {toolhead}"
RATOS_ECHO MSG="Unloading filament from nozzle to cooling zone... Please wait!"
_PURGE_BEFORE_UNLOAD TOOLHEAD={toolhead}
{% if printer["gcode_macro _UNLOAD_WITHOUT_TIP_FORMING"] is defined %}
_UNLOAD_WITHOUT_TIP_FORMING TOOLHEAD={toolhead} NAME='{filament_name}' TYPE='{filament_type}'
{% else %}
_UNLOAD_WITH_TIP_FORMING NAME='{filament_name}' TYPE='{filament_type}'
{% endif %}
G4 P3000
[gcode_macro _UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set extruder_load_speed = printer["gcode_macro T%s" % toolhead].extruder_load_speed|float * 60 %}
{% set extruder_gear_to_cooling_position_distance = printer["gcode_macro T%s" % toolhead].extruder_gear_to_cooling_position_distance|float %}
{% set tooolhead_sensor_to_extruder_gear_distance = printer["gcode_macro T%s" % toolhead].tooolhead_sensor_to_extruder_gear_distance|float %}
DEBUG_ECHO PREFIX="_UNLOAD_FILAMENT_FROM_COOLING_ZONE_TO_EXTRUDER" MSG="TOOLHEAD: {toolhead}"
G0 E-{extruder_gear_to_cooling_position_distance + tooolhead_sensor_to_extruder_gear_distance + 50} F{extruder_load_speed}
RATOS_ECHO MSG="Filament unloaded! Please inspect the tip of the filament before reloading."
[gcode_macro _UNLOAD_WITH_TIP_FORMING]
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
{% if filament_name != '' and filament_type != '' %}
_UNLOAD_KNOWN_FILAMENT NAME={filament_name} TYPE={filament_type}
{% else %}
_UNLOAD_UNKNOWN_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _UNLOAD_KNOWN_FILAMENT]
description = User overrideable tip forming macro if slicer filament profiles are known
gcode =
{% set filament_name = params.NAME|default('')|string %}
{% set filament_type = params.TYPE|default('')|string %}
RATOS_ECHO PREFIX="FILAMENT TYPE" MSG='{filament_type}'
RATOS_ECHO PREFIX="FILAMENT PROFILE" MSG='{filament_name}'
{% if filament_name == "Prusament PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% elif filament_name == "Nobufil PETG @V-Minion" %}
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
{% else %}
RATOS_ECHO PREFIX="_UNLOAD_KNOWN_FILAMENT" MSG="Filament profile not found!"
_UNLOAD_UNKNOWN_FILAMENT
{% endif %}
[gcode_macro _UNLOAD_UNKNOWN_FILAMENT]
description = User overrideable standard tip forming macro
gcode =
DEBUG_ECHO PREFIX="_UNLOAD_UNKNOWN_FILAMENT" MSG="Using standard tip forming macro!"
_TIP_FORMING RETRACT_LENGTH=18 COOLING_MOVE_LENGTH=10
[gcode_macro _TIP_FORMING]
gcode =
{% set cooling_moves = params.COOLING_MOVES|default(4)|int %}
{% set cooling_move_length = params.COOLING_MOVE_LENGTH|default(10)|float %}
{% set start_cooling_speed = params.START_COOLING_SPEED|default(10)|float * 60 %}
{% set end_cooling_speed = params.END_COOLING_SPEED|default(50)|float * 60 %}
{% if cooling_moves == 0 %}
{% set cooling_move_length = 0 %}
{% endif %}
{% set dip = true if params.DIP|default(false)|lower == "true" else false %}
{% set dip_length = params.DIP_LENGTH|default(22)|float %}
{% set dip_speed = params.DIP_SPEED|default(30)|float * 60 %}
{% set dip_retract_speed = params.DIP_RETRACT_SPEED|default(70)|float * 60 %}
{% set retract_length = params.RETRACT_LENGTH|default(18)|float %}
{% set start_retract_speed = params.START_RETRACT_SPEED|default(120)|float * 60 %}
{% set end_retract_speed = params.END_RETRACT_SPEED|default(20)|float * 60 %}
DEBUG_ECHO PREFIX="_TIP_FORMING" MSG="cooling_moves: {cooling_moves}, cooling_move_length: {cooling_move_length}, start_cooling_speed: {start_cooling_speed}, end_cooling_speed: {end_cooling_speed}, dip: {dip}, dip_length: {dip_length}, dip_speed: {dip_speed}, dip_retract_speed: {dip_retract_speed}, retract_length: {retract_length}, start_retract_speed: {start_retract_speed}, end_retract_speed: {end_retract_speed}"
M220 S100
G92 E0
{% set retract = retract_length + cooling_move_length / 2 - 15 %}
G1 E-15 F{start_retract_speed}
G1 E-{0.7 * retract} F{1.0 * end_retract_speed}
G1 E-{0.2 * retract} F{0.5 * end_retract_speed}
G1 E-{0.1 * retract} F{0.3 * end_retract_speed}
G92 E0
{% if cooling_moves > 0 %}
{% set i = (end_cooling_speed - start_cooling_speed) / (2 * cooling_moves - 1) %}
{% for m in range(cooling_moves) %}
G1 E{cooling_move_length} F{(start_cooling_speed + i * m * 2)}
G1 E-{cooling_move_length} F{(start_cooling_speed + i * (m * 2 + 1))}
{% endfor %}
{% endif %}
G92 E0
{% if dip %}
G1 E{dip_length} F{dip_speed}
G4 P100
G1 E-{dip_length} F{dip_retract_speed}
{% endif %}
G92 E0
M400
[gcode_macro _ON_FILAMENT_SENSOR_BUTTON_PRESSED]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_SENSOR_BUTTON_PRESSED" MSG="TOOLHEAD: {toolhead}"
{% if not printer.virtual_sdcard.is_active %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_TOOLHEAD_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_TOOLHEAD_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_RUNOUT]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_runout_detection = true if printer["gcode_macro T%s" % toolhead].enable_runout_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_RUNOUT" MSG="TOOLHEAD: {toolhead}"
{% if enable_runout_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=false
{% endif %}
[gcode_macro _ON_BOWDEN_FILAMENT_SENSOR_CLOG]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set enable_clog_detection = true if printer["gcode_macro T%s" % toolhead].enable_clog_detection|default(true)|lower == 'true' else false %}
DEBUG_ECHO PREFIX="_ON_BOWDEN_FILAMENT_SENSOR_CLOG" MSG="TOOLHEAD: {toolhead}"
{% if enable_clog_detection %}
_ON_FILAMENT_END TOOLHEAD={toolhead} CLOGGED=true
{% endif %}
[gcode_macro _ON_FILAMENT_END]
gcode =
{% set toolhead = params.TOOLHEAD|int %}
{% set clogged = true if params.CLOGGED|default(false)|lower == 'true' else false %}
{% set unload_after_runout = printer["gcode_macro T%s" % toolhead].unload_after_runout|float %}
{% if clogged %}
_LED_FILAMENT_CLOG TOOLHEAD={toolhead}
{% else %}
_LED_FILAMENT_RUNOUT TOOLHEAD={toolhead}
{% endif %}
DEBUG_ECHO PREFIX="_ON_FILAMENT_END" MSG="TOOLHEAD: {toolhead}"
{% if printer.virtual_sdcard.is_active %}
{% if not printer.pause_resume.is_paused %}
PAUSE RUNOUT=True
{% endif %}
{% if not clogged and unload_after_runout %}
UNLOAD_FILAMENT TOOLHEAD={toolhead}
{% endif %}
{% if not clogged and printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true'%}
_JOIN_SPOOL TOOLHEAD={toolhead}
{% endif %}
{% endif %}
{% endif %}
[gcode_macro M600]
description = Executes a color change by pausing the printer an unloading the filament.
gcode =
PAUSE
UNLOAD_FILAMENT
RATOS_ECHO MSG="Please load new filament and resume"
[gcode_macro COLD_PULL]
description = Automated hotend cold pull.
gcode =
{% set extrusion_temp = params.EXTRUSION_TEMP|default(220)|int %}
{% set cold_pull_temp = params.COLD_PULL_TEMP|default(80)|int %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% if printer["dual_carriage"] is not defined %}
{% set toolhead = 0 %}
{% else %}
{% if not printer.pause_resume.is_paused %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set current_idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% if current_idex_mode == 'copy' or current_idex_mode == 'mirror' %}
{action_raise_error("Unloading filament in Copy or Mirror mode is not supported! Select single mode to proceed.")}
{% else %}
{% set paused_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% if paused_idex_mode == 'copy' or paused_idex_mode == 'mirror' %}
{% set toolhead = params.TOOLHEAD|default(-1)|int %}
{% else %}
{% set toolhead = printer["gcode_macro PAUSE"].idex_toolhead|int %}
{% endif %}
{% endif %}
{% endif %}
{% if toolhead != 0 and toolhead != 1 %}
{action_raise_error("Please select toolhead! 0 = left, 1 = right toolhead")}
{% endif %}
{% endif %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
_LED_UNLOADING_FILAMENT TOOLHEAD={toolhead}
SAVE_GCODE_STATE NAME=cold_pull_state
{% if "xyz" not in printer.toolhead.homed_axes %}
_SELECT_TOOL T={toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% set target_extruder = 'extruder%s' % ('' if toolhead == 0 else toolhead) %}
ACTIVATE_EXTRUDER EXTRUDER={target_extruder}
RATOS_ECHO MSG="Heating T{toolhead} to {extrusion_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={extrusion_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={extrusion_temp} MAXIMUM={extrusion_temp + 2}
G4 P3000
RATOS_ECHO MSG="extruding..."
G92 E0
G1 E30 F300
G92 E0
RATOS_ECHO MSG="Heating T{toolhead} to {cold_pull_temp}C... Please wait."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET={cold_pull_temp}
TEMPERATURE_WAIT SENSOR={target_extruder} MINIMUM={cold_pull_temp} MAXIMUM={cold_pull_temp + 2}
G4 P10000
RATOS_ECHO MSG="cold pull..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-40 VELOCITY=5 ACCEL=100
RATOS_ECHO MSG="eject filament..."
FORCE_MOVE STEPPER={target_extruder} DISTANCE=-200 VELOCITY=20 ACCEL=500
RATOS_ECHO MSG="cooling down extruder..."
SET_HEATER_TEMPERATURE HEATER={'extruder' if toolhead == 0 else 'extruder1'} TARGET=0
RESTORE_GCODE_STATE NAME=cold_pull_state
SAVE_VARIABLE VARIABLE=t{toolhead}_filament VALUE="('""', '""', 0)"
{% if printer["gcode_macro T%s" % toolhead].filament_name is defined and printer["gcode_macro T%s" % toolhead].filament_type is defined and printer["gcode_macro T%s" % toolhead].filament_temp is defined %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=filament_temp VALUE=0
{% endif %}
SET_GCODE_VARIABLE MACRO=T{toolhead} VARIABLE=color VALUE='"{color_unknown}"'
_LED_FILAMENT_UNLOADED TOOLHEAD={toolhead}
CONSOLE_ECHO TITLE="Cold pull finished!" MSG="Please remove the filament from the PTFE tube and cut the end off. Do NOT try to load it again." TYPE="warning"
[gcode_macro _USER_START_PRINT_BEFORE_HOMING]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_BED]
gcode =
[gcode_macro _USER_START_PRINT_BED_MESH]
gcode =
[gcode_macro _USER_START_PRINT_PARK]
gcode =
[gcode_macro _USER_START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
[gcode_macro _USER_START_PRINT_HEAT_CHAMBER]
description = Uses the extruder sensor to wait for chamber temp. Override the _START_PRINT_HEAT_CHAMBER macro to implement heated chamber handling.
gcode =
{% set chamber_heater_bed_temp = printer["gcode_macro RatOS"].chamber_heater_bed_temp|default(115)|int %}
[gcode_macro _USER_END_PRINT_BEFORE_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_AFTER_HEATERS_OFF]
gcode =
[gcode_macro _USER_END_PRINT_PARK]
gcode =
[gcode_macro _USER_END_PRINT_FINISHED]
description = User hook for when the print is finished after gcode state has been restored.
gcode =
[gcode_macro _USER_START_PRINT]
gcode =
[gcode_macro _USER_END_START_PRINT]
gcode =
[gcode_macro _USER_START_FEATURE]
gcode =
[gcode_macro _USER_END_FEATURE]
gcode =
[gcode_macro ECHO_T_VARS]
description = Echo Toolhead variables to the console.
gcode =
{% set t = params.T|default(0) %}
RATOS_ECHO MSG="T{t} Variables"
{% for var, value in printer["gcode_macro T%s" % t].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[gcode_macro ECHO_RATOS_VARS]
description = Echo RatOS variables to the console.
gcode =
{% for var, value in printer["gcode_macro RatOS"].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[delayed_gcode RATOS_INIT]
initial_duration = 0.1
gcode =
_LED_STANDBY
CALCULATE_PRINTABLE_AREA
INITIAL_FRONTEND_UPDATE
_CHAMBER_FILTER_SANITY_CHECK
[delayed_gcode RATOS_LOGO]
initial_duration = 2
gcode =
HELLO_RATOS
[gcode_macro INITIAL_FRONTEND_UPDATE]
gcode =
{% set color_ok = printer["gcode_macro RatOS"].status_color_ok|string %}
{% set color_error = printer["gcode_macro RatOS"].status_color_error|string %}
{% set color_unknown = printer["gcode_macro RatOS"].status_color_unknown|string %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_unknown}"'
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_unknown}"'
{% endif %}
{% set t0_sensor = "undefined" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t0"].filament_detected|lower == "true" %}
{% set t0_sensor = "detected" %}
{% else %}
{% set t0_sensor = "empty" %}
{% endif %}
{% else %}
{% set t0_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set t1_sensor = "undefined" %}
{% if printer["dual_carriage"] is defined and printer["filament_switch_sensor toolhead_filament_sensor_t1"] is defined %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t1"].filament_detected|lower == "true" %}
{% set t1_sensor = "detected" %}
{% else %}
{% set t1_sensor = "empty" %}
{% endif %}
{% else %}
{% set t1_sensor = "disabled" %}
{% endif %}
{% endif %}
{% set svv = printer.save_variables.variables %}
{% if svv.t0_filament is defined and printer["gcode_macro T0"] is defined %}
{% if printer["gcode_macro T0"].filament_name is defined and printer["gcode_macro T0"].filament_type is defined and printer["gcode_macro T0"].filament_temp is defined %}
{% if t0_sensor != "empty" %}
{% set t0_filament_type = svv.t0_filament[0]|default('')|string %}
{% set t0_filament_name = svv.t0_filament[1]|default('')|string %}
{% set t0_filament_temp = svv.t0_filament[2]|default(0)|float %}
{% if t0_filament_name != '' and t0_filament_type != '' and t0_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='"{t0_filament_name}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='"{t0_filament_type}"'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE={t0_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t0_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
{% if svv.t1_filament is defined and printer["gcode_macro T1"] is defined %}
{% if printer["gcode_macro T1"].filament_name is defined and printer["gcode_macro T1"].filament_type is defined and printer["gcode_macro T1"].filament_temp is defined %}
{% if t1_sensor != "empty" %}
{% set t1_filament_type = svv.t1_filament[0]|default('')|string %}
{% set t1_filament_name = svv.t1_filament[1]|default('')|string %}
{% set t1_filament_temp = svv.t1_filament[2]|default(0)|float %}
{% if t1_filament_name != '' and t1_filament_type != '' and t1_filament_temp > 0 %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=color VALUE='"{color_ok}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='"{t1_filament_name}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='"{t1_filament_type}"'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE={t1_filament_temp}
{% endif %}
{% else %}
SAVE_VARIABLE VARIABLE=t1_filament VALUE="('""', '""', 0)"
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_name VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_type VALUE='""'
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=filament_temp VALUE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro CALCULATE_PRINTABLE_AREA]
gcode =
{% set bed_margin_x = printer["gcode_macro RatOS"].bed_margin_x %}
{% set bed_margin_y = printer["gcode_macro RatOS"].bed_margin_y %}
{% set tool = 0 if printer["gcode_macro T0"] is not defined or printer["gcode_macro T0"].active else 1 %}
{% set max_x = printer.toolhead.axis_maximum.x if printer["dual_carriage"] is defined and tool == 0 else printer.toolhead.axis_maximum.x - bed_margin_x[1] %}
{% if printer["dual_carriage"] is defined %}
{% set max_x = printer.toolhead.axis_maximum.x %}
{% endif %}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="printer.toolhead.axis_maximum.x {printer.toolhead.axis_maximum.x}"
{% set max_y = printer.toolhead.axis_maximum.y - bed_margin_y[1]%}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_x_max VALUE={max_x}
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=printable_y_max VALUE={max_y}
DEBUG_ECHO PREFIX="CALCULATE_PRINTABLE_AREA" MSG="Printable area calculated: X: 0,{max_x} Y: 0,{max_y}"
[gcode_macro CACHE_TOOLHEAD_SETTINGS]
variable_cache = {"global": {"accel": 1000, "ratio": 0.5, "speed": 50, "scv": 5}}
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set dummy = cache.__setitem__(key, {"accel": printer.toolhead.max_accel, "ratio": printer.toolhead.minimum_cruise_ratio, "speed": printer.toolhead.max_velocity, "scv": printer.toolhead.square_corner_velocity}) %}
SET_GCODE_VARIABLE MACRO=CACHE_TOOLHEAD_SETTINGS VARIABLE=cache VALUE="{cache | pprint | replace("\n", "") | replace("\"", "\\\"")}"
DEBUG_ECHO PREFIX="CACHE_TOOLHEAD_SETTINGS" MSG="Toolhead settings cached for {key}. {printer.toolhead.max_accel} accel, {printer.toolhead.minimum_cruise_ratio} ratio, {printer.toolhead.max_velocity} velocity, {printer.toolhead.square_corner_velocity} scv."
[gcode_macro RESTORE_TOOLHEAD_SETTINGS]
gcode =
{% set key = "global" %}
{% if params.KEY is defined %}
{% set key = params.KEY %}
{% endif %}
{% set values = printer["gcode_macro CACHE_TOOLHEAD_SETTINGS"].cache.__getitem__(key) %}
{% if values is not defined or values == 'None' %}
{ action_raise_error("RESTORE_TOOLHEAD_SETTINGS: Toolhead settings not cached for key '" ~ key ~ "'.") }
{% endif %}
SET_VELOCITY_LIMIT ACCEL={values.accel} MINIMUM_CRUISE_RATIO={values.ratio} VELOCITY={values.speed} SQUARE_CORNER_VELOCITY={values.scv}
DEBUG_ECHO PREFIX="RESTORE_TOOLHEAD_SETTINGS" MSG="Toolhead settings restored. {values.accel} accel, {values.ratio} ratio, {values.speed} velocity, {values.scv} scv."
[gcode_macro SET_MACRO_TRAVEL_SETTINGS]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set accel = printer["gcode_macro RatOS"].macro_travel_accel %}
SET_VELOCITY_LIMIT ACCEL={accel} MINIMUM_CRUISE_RATIO=0.5 VELOCITY={speed} SQUARE_CORNER_VELOCITY={5}
DEBUG_ECHO PREFIX="SET_MACRO_TRAVEL_SETTINGS" MSG="Macro travel settings set. {accel} accel, {speed} velocity"
[gcode_macro SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% if printer["dual_carriage"] is not defined %}
SET_KINEMATIC_POSITION X={printable_x_max / 2} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
{% else %}
IDEX_SET_CENTER_KINEMATIC_POSITION
{% endif %}
[gcode_macro IDEX_SET_CENTER_KINEMATIC_POSITION]
description = FOR DEBUGGING PURPOSES ONLY. Sets the internal printer kinematic state to the center of all axes regardless of actual physical position.
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
RATOS_ECHO MSG="WARNING: ONLY USE SET_CENTER_KINEMATIC_POSITION FOR DEBUGGING PURPOSES. YOU'RE OVERRIDING THE INTERNAL POSITIONING STATE OF THE PRINTER. PROCEED WITH CAUTION AND DO A PROPER G28 WHEN DONE."
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=True
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set center_x = printable_x_max / 2 %}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x - (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
SET_KINEMATIC_POSITION X={center_x + (center_x / 2)} Y={printable_y_max / 2} Z={printer.toolhead.axis_maximum.z / 2}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
[gcode_macro VERIFY_HYBRID_INVERTED]
gcode =
{% set inverted = False %}
{% if printer.configfile.settings.ratos_hybrid_corexy is defined and printer.configfile.settings.ratos_hybrid_corexy.inverted is defined %}
{% if printer.configfile.settings.ratos_hybrid_corexy.inverted|lower == 'true' %}
{% set inverted = True %}
{% endif %}
{% endif %}
{% if inverted == False %}
{ action_emergency_stop("ratos_hybrid_corexy NOT INVERTED! Inverted hybrid core-xy bugfix not detected.") }
{% endif %}
[gcode_macro RATOS_ECHO]
gcode =
{% set prefix = "RatOS" %}
{% set debug = params.DEBUG|default(0)|int %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " | " ~ params.PREFIX %}
{% endif %}
{% set prefix = prefix ~ ":" %}
{% set msg = "" %}
{% if params.MSG is defined %}
{% set msg = params.MSG %}
{% else %}
{% set msg = "No msg parameter provided (this is a bug or unintended use)." %}
{% endif %}
{% if not debug %}
M117 {prefix} {msg}
{% endif %}
RATOS_LOG PREFIX="{prefix}" MSG="{msg}"
{% if not debug %}
RESPOND PREFIX="{prefix}" MSG="{msg}"
{% else %}
CONSOLE_ECHO TITLE="{prefix}" TYPE="debug" MSG="{msg}"
{% endif %}
[gcode_macro ENABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=True
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=prefix_filter VALUE="'{params.FILTER|default('')|lower}'"
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging enabled."
[gcode_macro DISABLE_DEBUG]
gcode =
SET_GCODE_VARIABLE MACRO=DEBUG_ECHO VARIABLE=enabled VALUE=False
RATOS_ECHO PREFIX="DEBUG" MSG="Debugging disabled."
[gcode_macro DEBUG_ECHO]
variable_enabled = False
variable_prefix_filter = ''
gcode =
{% set prefix = "DEBUG" %}
{% if params.PREFIX is defined %}
{% set prefix = prefix ~ " - " ~ params.PREFIX %}
{% endif %}
{% if enabled and (prefix_filter|lower == '' or prefix_filter|lower in params.PREFIX|lower) %}
RATOS_ECHO PREFIX="{prefix}" MSG="{params.MSG}" DEBUG=1
{% endif %}
[gcode_macro START_FEATURE]
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="Start {params.FEATURE} feature gcode"
{% set scv = printer.toolhead.square_corner_velocity|int|default(5) %}
{% set accel = printer.toolhead.max_accel|int|default(10000) %}
{% set ratio = printer.toolhead.minimum_cruise_ratio|float|default(0.5) %}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="scv" VALUE={scv}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="accel" VALUE={accel}
SET_GCODE_VARIABLE MACRO="END_FEATURE" VARIABLE="ratio" VALUE={ratio}
_USER_START_FEATURE FEATURE="{params.FEATURE}"
[gcode_macro END_FEATURE]
variable_scv = 5
variable_accel = 10000
variable_ratio = 0.5
gcode =
DEBUG_ECHO PREFIX="G-Code" MSG="End {params.FEATURE} feature gcode"
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={scv} ACCEL={accel} MINIMUM_CRUISE_RATIO={ratio}
_USER_END_FEATURE FEATURE="{params.FEATURE}" SCV={scv} ACCEL={accel} RATIO={ratio}
[gcode_macro _ON_LAYER_CHANGE]
variable_layer_number = 0
description = INTERNAL USE ONLY. Call it from the slicers after layer change custom gcode
gcode =
{% set layer = params.LAYER|int %}
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE={layer}
SET_PRINT_STATS_INFO CURRENT_LAYER={layer}
[gcode_macro _LEARN_MORE_CALIBRATION]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/calibration" %}
{% set link_text = "RatOS Calibration Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_CHAMBER_FILTER]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/chamber_filter" %}
{% set link_text = "RatOS Chamber Filter Control" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _LEARN_MORE_FILAMENT]
gcode =
{% set link_url = "https://os.ratrig.com/docs/configuration/filaments" %}
{% set link_text = "RatOS Filament Macros" %}
{% set line_1 = '"Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="INFO" MSG={line_1}
[gcode_macro _CONSOLE_SAVE_CONFIG]
gcode =
M118 Click SAVE_CONFIG to save the settings to your printer.cfg.
[gcode_macro SAVE_Z_OFFSET]
gcode =
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SAVE_MULTIPLIER
{% else %}
Z_OFFSET_APPLY_PROBE
{% endif %}
[gcode_macro _LOAD_RATOS_SKEW_PROFILE]
gcode =
{% set ratos_skew_profile = printer["gcode_macro RatOS"].skew_profile|default("") %}
{% if ratos_skew_profile != "" %}
{% if printer.configfile.config["skew_correction %s" % ratos_skew_profile] is defined %}
SKEW_PROFILE LOAD={ratos_skew_profile}
GET_CURRENT_SKEW
{% else %}
{% set line_1 = '"Could not find skew profile %s!_N_Clearing skew correction."' % ratos_skew_profile %}
CONSOLE_ECHO TITLE="Missing skew profile!" TYPE="warning" MSG={line_1}
SET_SKEW CLEAR=1
{% endif %}
{% endif %}
[gcode_macro M601]
gcode =
PAUSE
[gcode_macro PAUSE]
description = Pauses the print
rename_existing = PAUSE_BASE
variable_extrude = 1.5
variable_retract = 1.5
variable_fan_speed = 0
variable_idex_mode = ""
variable_idex_toolhead = 0
variable_idex_toolhead_x = 0.0
variable_idex_toolhead_y = 0.0
variable_idex_toolhead_z = 0.0
gcode =
{% set runout_detected = true if params.RUNOUT|default(false)|lower == 'true' else false %}
_LED_PAUSE
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set idex_toolhead = 1 if idex_mode == 'primary' else 0 %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
SAVE_GCODE_STATE NAME=PAUSE_state
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_mode VALUE='"{idex_mode}"'
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead VALUE={idex_toolhead}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_x VALUE={printer.gcode_move.gcode_position.x|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_y VALUE={printer.gcode_move.gcode_position.y|float}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=idex_toolhead_z VALUE={printer.gcode_move.gcode_position.z|float}
DEBUG_ECHO PREFIX="PAUSE" MSG="idex_mode: {idex_mode}, idex_toolhead: {idex_toolhead}, idex_toolhead_x: {idex_toolhead_x}, idex_toolhead_y: {idex_toolhead_y}, idex_toolhead_z: {idex_toolhead_z}"
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
CACHE_TOOLHEAD_SETTINGS KEY="pause"
SET_MACRO_TRAVEL_SETTINGS
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% if current_z < (max_z - 20.0) %}
{% set z_safe = 20.0 %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
PAUSE_BASE
{% if printer["dual_carriage"] is not defined %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan"].speed|float}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
{% if idex_toolhead == 0 %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t0"].speed|float}
{% else %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=fan_speed VALUE={printer["fan_generic part_fan_t1"].speed|float}
{% endif %}
{% endif %}
{% endif %}
M106 S0
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if idex_mode != '' %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set R = printer["gcode_macro PAUSE"].retract|float %}
{% if can_extrude %}
G91
G1 E-{R} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].pause_print_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].pause_print_park_in %}
{% if runout_detected %}
{% set pause_print_park_x = printer["gcode_macro RatOS"].runout_park_x %}
{% set pause_print_park_in = printer["gcode_macro RatOS"].runout_park_in %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
DEBUG_ECHO PREFIX="PAUSE" MSG="z_speed: {z_speed}, pause_print_park_x: {pause_print_park_x}, pause_print_park_in: {pause_print_park_in}, default_toolhead: {default_toolhead}"
{% if "xyz" in printer.toolhead.homed_axes %}
G91
G1 Z{z_safe} F{z_speed}
G90
{% if printer["dual_carriage"] is not defined %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% else %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
_IDEX_SINGLE X={parking_position}
{% else %}
PARK_TOOLHEAD
{% endif %}
_PARK LOCATION={pause_print_park_in} X={pause_print_park_x}
{% endif %}
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="pause"
[gcode_macro RESUME]
description = Resumes the print if the printer is paused.
rename_existing = RESUME_BASE
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set target_idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set target_idex_mode = printer["gcode_macro PAUSE"].idex_mode|lower %}
{% endif %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' else false %}
{% if target_idex_mode != '' %}
{% if target_idex_mode == 'copy' or target_idex_mode == 'mirror' %}
{% set can_extrude = true if printer['extruder'].can_extrude|lower == 'true' and printer['extruder1'].can_extrude|lower == 'true' else false %}
{% else %}
{% if printer.toolhead.extruder == 'extruder1' %}
{% set can_extrude = true if printer['extruder1'].can_extrude|lower == 'true' else false %}
{% endif %}
{% endif %}
{% endif %}
{% set fan_speed = printer["gcode_macro PAUSE"].fan_speed|float %}
{% if printer["dual_carriage"] is not defined %}
M106 S{(fan_speed * 255)}
{% else %}
{% if idex_mode == 'copy' or idex_mode == 'mirror' %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% else %}
{% if params.TOOLHEAD is defined %}
{% if params.TOOLHEAD == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% else %}
{% if printer["gcode_macro PAUSE"].idex_toolhead == 0 %}
SET_FAN_SPEED FAN=part_fan_t0 SPEED={fan_speed}
{% else %}
SET_FAN_SPEED FAN=part_fan_t1 SPEED={fan_speed}
{% endif %}
{% endif %}
{% endif %}
M106.1 S{fan_speed}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if target_idex_mode == "copy" %}
_IDEX_COPY DANCE=0
{% elif target_idex_mode == "mirror" %}
_IDEX_MIRROR DANCE=0
{% else %}
{% if params.TOOLHEAD is defined %}
_SELECT_TOOL T={params.TOOLHEAD} X=-1 Y=-1 TOOLSHIFT=false
{% else %}
_SELECT_TOOL T={printer["gcode_macro PAUSE"].idex_toolhead} X=-1 Y=-1 TOOLSHIFT=false
{% endif %}
{% endif %}
{% set x = printer["gcode_macro PAUSE"].idex_toolhead_x|float %}
{% set y = printer["gcode_macro PAUSE"].idex_toolhead_y|float %}
{% set z = printer["gcode_macro PAUSE"].idex_toolhead_z|float %}
G1 X{x} Y{y} Z{z} F{speed}
{% if params.TOOLHEAD is defined %}
SAVE_GCODE_STATE NAME=PAUSE_STATE
{% endif %}
{% endif %}
{% if params.TOOLHEAD is not defined %}
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
{% if can_extrude %}
G91
G1 E{E} F2100
G90
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is not defined %}
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1 MOVE_SPEED={speed}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
RESUME_BASE
_LED_PRINTING
[gcode_macro CANCEL_PRINT]
description = Cancels the printer
rename_existing = CANCEL_PRINT_BASE
gcode =
END_PRINT
TURN_OFF_HEATERS
CLEAR_PAUSE
CANCEL_PRINT_BASE
[gcode_macro START_PRINT]
description = Start print procedure, use this in your Slicer.
variable_post_processor_version = 2
variable_is_printing_gcode = False
variable_both_toolheads = True
variable_object_xoffset = 0
variable_first_x = -1
variable_first_y = -1
variable_total_toolshifts = 0
variable_initial_tool = 0
variable_extruder_first_layer_temp = ""
variable_extruder_other_layer_temp = ""
gcode =
{% if "xyz" in printer.toolhead.homed_axes and printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% if printer["gcode_macro _VAOC"].is_started|default(true)|lower == 'true' %}
_VAOC_END
{% endif %}
{% endif %}
_LED_START_PRINTING
CACHE_TOOLHEAD_SETTINGS KEY="start_print"
_USER_START_PRINT { rawparams }
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set bed_heat_soak_time = printer["gcode_macro RatOS"].bed_heat_soak_time|default(0)|int %}
{% set hotend_heat_soak_time = printer["gcode_macro RatOS"].hotend_heat_soak_time|default(0)|int %}
{% set z_probe_stowable = printer["gcode_macro RatOS"].z_probe|lower == 'stowable' %}
{% if printer["dual_carriage"] is defined %}
{% set toolchange_standby_temp = printer["gcode_macro RatOS"].toolchange_standby_temp|default(-1)|float %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set X0 = params.X0|default(-1)|float %}
{% set X1 = params.X1|default(-1)|float %}
{% set Y0 = params.Y0|default(-1)|float %}
{% set Y1 = params.Y1|default(-1)|float %}
{% if first_x == -1 or first_y == -1 %}
{% set first_x = params.FIRST_X|default(-1)|float %}
{% set first_y = params.FIRST_Y|default(-1)|float %}
{% endif %}
{% set total_toolshifts = params.TOTAL_TOOLSHIFTS|default(0)|int %}
{% set initial_tool = params.INITIAL_TOOL|default(default_toolhead)|int %}
{% set start_chamber_temp = params.START_CHAMBER_TEMP|default(0)|int %}
{% set chamber_temp = params.CHAMBER_TEMP|default(0)|int %}
{% set bed_temp = params.BED_TEMP|default(printer.heater_bed.target, true)|float %}
{% set total_layer_count = params.TOTAL_LAYER_COUNT|default(0)|int %}
{% set extruder_first_layer_temp = (params.EXTRUDER_TEMP|default("")).split(",") %}
RATOS_ECHO MSG="First print coordinates X:{first_x} Y:{first_y}"
{% if params.TOTAL_LAYER_COUNT is not defined %}
{% set link_url = "https://os.ratrig.com/docs/slicers" %}
{% set link_text = "RatOS Slicer Configuration" %}
{% set line_1 = '"Your slicer gcode settings are not up to date._N_Learn more about the %s"' % (link_url, link_text) %}
CONSOLE_ECHO TITLE="Incomplete Slicer Configuration detected" TYPE="warning" MSG={line_1}
{% endif %}
SET_PRINT_STATS_INFO CURRENT_LAYER=1
SET_GCODE_VARIABLE MACRO=_ON_LAYER_CHANGE VARIABLE=layer_number VALUE=1
{% if total_layer_count > 0 %}
SET_PRINT_STATS_INFO TOTAL_LAYER={total_layer_count}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set swap_toolheads = true if printer["gcode_macro _IDEX_REMAP_TOOLHEADS"].enabled|default(false)|lower == 'true' else false %}
{% if swap_toolheads %}
{% set initial_tool = 0 if initial_tool == 1 else 1 %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SET_GCODE_VARIABLE MACRO=T0 VARIABLE=active VALUE=True
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=T1 VARIABLE=active VALUE=True
{% endif %}
{% set both_toolheads = true %}
{% if total_toolshifts == 0 %}
{% set both_toolheads = false %}
{% endif %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% set parking_position = printer["gcode_macro T%s" % default_toolhead].parking_position|float %}
_IDEX_SINGLE X={parking_position}
{% endif %}
{% if both_toolheads and (idex_mode == "copy" or idex_mode == "mirror") %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Gcode tool changes found. Copy and mirror mode do not support toolchanges.")}
{% endif %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% set both_toolheads = true %}
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=initial_tool VALUE={initial_tool}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_x VALUE={first_x}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_y VALUE={first_y}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=total_toolshifts VALUE={total_toolshifts}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=both_toolheads VALUE={both_toolheads}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_first_layer_temp VALUE="'{params.EXTRUDER_TEMP}'"
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_other_layer_temp VALUE="'{params.EXTRUDER_OTHER_LAYER_TEMP}'"
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_TOOLCHANGE VARIABLE=toolshift_count VALUE=0
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set svv = printer.save_variables.variables %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
{% set stepper_x_position_min = printer.configfile.settings.stepper_x.position_min|float %}
{% set stepper_x_position_endstop = printer.configfile.settings.stepper_x.position_endstop|float %}
{% set dual_carriage_position_max = printer.configfile.settings.dual_carriage.position_max|float %}
{% set dual_carriage_position_endstop = printer.configfile.settings.dual_carriage.position_endstop|float %}
{% set x_parking_space = parking_position_t0 - (stepper_x_position_endstop , stepper_x_position_min)|max %}
{% set dc_parking_space = (dual_carriage_position_endstop , dual_carriage_position_max)|min - parking_position_t1 %}
{% if svv.idex_xoffset|abs >= (x_parking_space - 0.5) or svv.idex_xoffset|abs >= (dc_parking_space - 0.5) %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Toolhead x-offset is too high for the available parking space. Calibrate your X and DC endstop positions and make sure you stay below 1mm." % (copy_mode_max_width)) }
{% endif %}
{% endif %}
{% if (idex_mode == "copy" or idex_mode == "mirror") and printer.configfile.settings.ratos.enable_gcode_transform %}
{% if params.MIN_X is not defined or params.MAX_X is not defined %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Something went wrong! Missing important post processor start print parameter!") }
{% endif %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE=0
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set boundary_box_min_x = params.MIN_X|default(0)|float %}
{% set boundary_box_max_x = params.MAX_X|default(printable_x_max)|float %}
{% set svv = printer.save_variables.variables %}
{% if default_toolhead == 0 %}
{% set boundary_box_max_x = boundary_box_max_x + svv.idex_xoffset %}
{% else %}
{% set boundary_box_min_x = boundary_box_min_x - svv.idex_xoffset %}
{% endif %}
{% set center_x = printable_x_max / 2.0 %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% set object_width = boundary_box_max_x - boundary_box_min_x %}
{% set copy_mode_max_width = center_x %}
{% set mirror_mode_max_width = center_x - safe_distance / 2.0 %}
DEBUG_ECHO PREFIX="START_PRINT" MSG="OBJECT_WIDTH: {object_width} BOUNDARY_BOX_MIN_X: {boundary_box_min_x} BOUNDARY_BOX_MAX_X: {boundary_box_max_x} CENTER_X: {center_x} SAFE_DISTANCE: {safe_distance}"
{% if idex_mode == "copy" and object_width > copy_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for copy mode! Max supported width is %s mm" % (copy_mode_max_width)) }
{% endif %}
{% if idex_mode == "mirror" and object_width > mirror_mode_max_width %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Object is too big for mirror mode! Max supported width is %s mm" % (mirror_mode_max_width)) }
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = (printable_x_max - boundary_box_max_x - boundary_box_min_x) / 2 %}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=object_xoffset VALUE={object_xoffset}
{% endif %}
{% endif %}
{% set has_initial_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_initial_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool] is defined else false %}
{% if has_initial_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % initial_tool].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (initial_tool)) }
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined and both_toolheads %}
{% set has_secondary_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_toolhead_filament_sensor %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s filament sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% set has_secondary_bowden_filament_sensor = true if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)] is defined else false %}
{% if has_secondary_bowden_filament_sensor %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].enabled|lower == "true" %}
{% if printer["filament_switch_sensor bowden_filament_sensor_t%s" % (1 if initial_tool == 0 else 0)].filament_detected|lower != "true" %}
_LED_START_PRINTING_ERROR
{ action_raise_error("Filament not detected! Toolhead T%s bowden sensor is empty." % (1 if initial_tool == 0 else 0)) }
{% endif %}
{% endif %}
{% endif %}
{% endif %}
_CHAMBER_FILTER_ON AT="before_print_start"
{% if printer["dual_carriage"] is defined %}
{% if printer["gcode_macro _IDEX_JOIN_SPOOLS"].enabled|default(false)|lower == 'true' %}
{% if both_toolheads %}
RATOS_ECHO MSG="Spool join is not possible if both toolheads are in use!"
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% endif %}
{% endif %}
{% endif %}
{% if printer["dual_carriage"] is defined %}
{% if idex_mode == '' %}
_SET_TOOLHEAD_OFFSET T={default_toolhead} MOVE={1 if "xyz" in printer.toolhead.homed_axes else 0}
{% endif %}
{% endif %}
CLEAR_PAUSE
{% if printer["gcode_macro RatOS"].force_absolute_position|lower == 'true' %}
G90
{% endif %}
SAVE_GCODE_STATE NAME=start_print_state
G21
G90
M82
_USER_START_PRINT_BEFORE_HOMING { rawparams }
{% if z_probe_stowable == true %}
STOWABLE_PROBE_BEGIN_BATCH
{% endif %}
MAYBE_HOME
_Z_HOP
{% if idex_mode != '' and not (printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
PARK_TOOLHEAD
{% endif %}
{% if chamber_temp > 0 %}
{% if printer["fan_generic filter"] is defined %}
{% if printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float > 0 %}
SET_FAN_SPEED FAN=filter SPEED={printer["gcode_macro RatOS"].chamber_heater_filter_fan_speed|default(0)|float}
{% endif %}
{% endif %}
_CHAMBER_HEATER_ON START_CHAMBER_TEMP={start_chamber_temp} CHAMBER_TEMP={chamber_temp}
_USER_START_PRINT_HEAT_CHAMBER { rawparams } CHAMBER_TEMP={chamber_temp}
{% endif %}
_START_PRINT_BEFORE_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
RATOS_ECHO MSG="Heating bed..."
M190 S{bed_temp}
{% if bed_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking bed for {bed_heat_soak_time} seconds..."
G4 P{(bed_heat_soak_time * 1000)}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_BED { rawparams }
_START_PRINT_AFTER_HEATING_BED T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
_USER_START_PRINT_BED_MESH { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_BED_MESH X0={X0} X1={X1} Y0={Y0} Y1={Y1} T={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if z_probe_stowable == true %}
STOWABLE_PROBE_END_BATCH
{% endif %}
{% if idex_mode == '' %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={extruder_first_layer_temp[0]|float}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={extruder_first_layer_temp[1]|float}
{% endif %}
{% endif %}
_USER_START_PRINT_PARK { rawparams }
_START_PRINT_PARK
RATOS_ECHO MSG="Heating Extruder..."
{% if idex_mode == '' %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% else %}
{% if initial_tool == 0 or both_toolheads or (default_toolhead == 0 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder" MINIMUM={extruder_first_layer_temp[0]|float} MAXIMUM={extruder_first_layer_temp[0]|float + 5}
{% endif %}
{% if initial_tool == 1 or both_toolheads or (default_toolhead == 1 and printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero) %}
TEMPERATURE_WAIT SENSOR="extruder1" MINIMUM={extruder_first_layer_temp[1]|float} MAXIMUM={extruder_first_layer_temp[1]|float + 5}
{% endif %}
{% endif %}
{% if hotend_heat_soak_time > 0 %}
RATOS_ECHO MSG="Heat soaking hotend for {hotend_heat_soak_time} seconds..."
G4 P{(hotend_heat_soak_time * 1000)}
{% endif %}
{% if idex_mode == '' %}
_LED_PRINTING
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
_LED_PRINTING
{% else %}
{% if both_toolheads %}
_LED_PRINTING TOOLHEAD={initial_tool}
{% if toolchange_standby_temp > -1 %}
_LED_TOOLHEAD_STANDBY TOOLHEAD={0 if initial_tool == 1 else 1}
{% else %}
_LED_PRINTING TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% else %}
_LED_PRINTING TOOLHEAD={initial_tool}
_LED_DEACTIVATE_TOOLHEAD TOOLHEAD={0 if initial_tool == 1 else 1}
{% endif %}
{% endif %}
{% endif %}
_USER_START_PRINT_AFTER_HEATING_EXTRUDER { rawparams } X0={X0} X1={X1} Y0={Y0} Y1={Y1}
_START_PRINT_AFTER_HEATING_EXTRUDER X0={X0} X1={X1} Y0={Y0} Y1={Y1} INITIAL_TOOLHEAD={initial_tool} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode}
{% if idex_mode != '' %}
{% if not both_toolheads %}
{% if initial_tool != default_toolhead %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET=0
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if toolchange_standby_temp > -1 %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if initial_tool == 1 else 'extruder1'} TARGET={toolchange_standby_temp}
{% endif %}
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% set x_offset = printer.toolhead.position.x|float - printer.gcode_move.gcode_position.x|float %}
{% endif %}
RESTORE_GCODE_STATE NAME=start_print_state
{% if idex_mode != '' %}
{% set act_idex_mode = printer["dual_carriage"].carriage_1|default('')|lower %}
{% if act_idex_mode == "copy" or act_idex_mode == "mirror" %}
SET_GCODE_OFFSET X={x_offset} MOVE=0
{% endif %}
{% endif %}
{% if idex_mode != '' %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
{% if idex_mode == "copy" and idex_mode != act_idex_mode %}
_IDEX_COPY DANCE=0
{% elif idex_mode == "mirror" and idex_mode != act_idex_mode %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
RATOS_ECHO MSG="Adjusting object x-offset by {(object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={object_xoffset} MOVE=0
{% endif %}
{% else %}
_SELECT_TOOL T={initial_tool} TOOLSHIFT=false
{% if initial_tool != default_toolhead %}
{% set svv = printer.save_variables.variables %}
SAVE_VARIABLE VARIABLE=idex_applied_offset VALUE={default_toolhead}
_SET_TOOLHEAD_OFFSET T={initial_tool} MOVE=0
{% endif %}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
_BEACON_SET_NOZZLE_TEMP_OFFSET TOOLHEAD={initial_tool}
{% endif %}
_SET_EXTRUSION_MODE
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=True
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
SET_GCODE_VARIABLE MACRO=_SELECT_TOOL VARIABLE=last_timestamp VALUE={printer["print_stats"].print_duration}
{% endif %}
_USER_END_START_PRINT { rawparams }
G92 E0
_CHAMBER_FILTER_ON AT="after_print_start"
RATOS_ECHO MSG="Printing..."
[gcode_macro _START_PRINT_BEFORE_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set idex_mode = '' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set act_t = 1 if idex_mode == 'primary' else 0 %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set is_stowable_probe = true if printer["gcode_macro RatOS"].z_probe|lower == 'stowable' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Pre-heating extruder..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
SET_HEATER_TEMPERATURE HEATER="extruder1" TARGET={min_temp}
{% else %}
SET_HEATER_TEMPERATURE HEATER={'extruder' if default_toolhead == 0 else 'extruder1'} TARGET={min_temp}
{% endif %}
{% else %}
SET_HEATER_TEMPERATURE HEATER="extruder" TARGET={min_temp}
{% endif %}
{% endif %}
{% if not is_stowable_probe %}
{% if printer["dual_carriage"] is defined and act_t != default_toolhead %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
{% endif %}
RATOS_ECHO MSG="Heat soaking z probe..."
{% if auto_z_offset_calibration %}
{% set safe_distance = printer.configfile.settings.dual_carriage.safe_distance|float %}
{% if default_toolhead == 0 %}
_SELECT_TOOL T=0 TOOLSHIFT=false
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
{% elif default_toolhead == 1 %}
_SELECT_TOOL T=1 TOOLSHIFT=false
G1 X{safe_home_x + safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=0 MODE=PRIMARY
G1 X{safe_home_x - safe_distance / 2} F{speed}
SET_DUAL_CARRIAGE CARRIAGE=1 MODE=PRIMARY
{% endif %}
{% else %}
_MOVE_TO_SAFE_Z_HOME
{% endif %}
G0 Z2 F{z_speed}
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED]
gcode =
{% set target_idex_mode = params.IDEX_MODE|default("")|lower %}
{% set initial_toolhead = params.T|default(default_toolhead)|int %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set min_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float %}
{% set max_temp = printer["gcode_macro RatOS"].preheat_extruder_temp|float + 5 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printable_x_max / 2 %}
{% endif %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printable_y_max / 2 %}
{% endif %}
{% set auto_z_offset_calibration = False %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro _VAOC"] is defined %}
{% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %}
{% if printer["gcode_macro _VAOC"].auto_z_offset_calibration|default("false")|lower == 'true' and is_fixed %}
{% if target_idex_mode != "copy" and target_idex_mode != "mirror" %}
{% if both_toolheads or initial_toolhead != default_toolhead %}
{% set auto_z_offset_calibration = True %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if printer["gcode_macro RatOS"].preheat_extruder|lower == 'true' %}
RATOS_ECHO MSG="Waiting for extruder to be preheated..."
{% if printer["dual_carriage"] is defined %}
{% if auto_z_offset_calibration %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
{% if default_toolhead == 0 %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder1 MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% else %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={min_temp} MAXIMUM={max_temp}
{% endif %}
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
_Z_HOP
{% endif %}
{% if auto_z_offset_calibration %}
{% set parking_position_t0 = printer["gcode_macro T0"].parking_position|float %}
{% set parking_position_t1 = printer["gcode_macro T1"].parking_position|float %}
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=True
PARK_TOOLHEAD
_CLEANING_MOVE TOOLHEAD={default_toolhead}
_SELECT_TOOL T={0 if default_toolhead == 1 else 1} X={parking_position_t0 if default_toolhead == 1 else parking_position_t1} Y=0 TOOLSHIFT=false
_CLEANING_MOVE TOOLHEAD={0 if default_toolhead == 1 else 1}
_VAOC_CALIBRATE_Z_OFFSET AUTO_Z_OFFSET=True
_SELECT_TOOL T={default_toolhead} X={safe_home_x} Y={safe_home_y} TOOLSHIFT=false
{% endif %}
{% set needs_rehoming = False %}
{% if printer.z_tilt is defined and not printer.z_tilt.applied %}
RATOS_ECHO MSG="Adjusting Z tilt..."
Z_TILT_ADJUST
RATOS_ECHO MSG="Rehoming Z after Z tilt adjustment..."
{% set needs_rehoming = True %}
{% endif %}
{% if printer.quad_gantry_level is defined and not printer.quad_gantry_level.applied %}
RATOS_ECHO MSG="Running quad gantry leveling..."
QUAD_GANTRY_LEVEL
RATOS_ECHO MSG="Rehoming Z after quad gantry leveling..."
{% set needs_rehoming = True %}
{% endif %}
{% if needs_rehoming %}
G28 Z
{% endif %}
{% if printer.configfile.settings.beacon is defined and beacon_contact_start_print_true_zero %}
{% if beacon_contact_wipe_before_true_zero %}
_START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE
{% endif %}
_START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE
{% endif %}
[gcode_macro _START_PRINT_AFTER_HEATING_BED_PROBE_FOR_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
G0 Z5 F{z_speed}
G0 X50 Y10 F{speed}
PROBE PROBE_METHOD=contact SAMPLES=1
BEACON_QUERY
[gcode_macro _START_PRINT_AFTER_HEATING_CONTACT_WITH_OPTIONAL_WIPE]
gcode =
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set beacon_contact_true_zero_temp = printer["gcode_macro RatOS"].beacon_contact_true_zero_temp|default(150)|int %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_true_zero_location = printer["gcode_macro RatOS"].beacon_contact_true_zero_location|default("front")|lower %}
{% set beacon_contact_true_zero_margin_x = printer["gcode_macro RatOS"].beacon_contact_true_zero_margin_x|default(30)|int %}
{% set beacon_contact_wipe_before_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_wipe_before_true_zero|default(false)|lower == 'true' else false %}
{% if beacon_contact_wipe_before_true_zero %}
{% if printer.beacon.last_probe_result|lower == "ok" %}
{% set last_z_offset = printer.beacon.last_z_result %}
RATOS_ECHO MSG="Auto calibration nozzle wipe with probe result {last_z_offset}..."
G0 Z{(0.2 + last_z_offset)} F{z_speed}
G0 X70 F300
{% else %}
RATOS_ECHO MSG="Skipping auto calibration nozzle wipe because probing failed!"
{% endif %}
{% endif %}
G0 Z5 F{z_speed}
_MOVE_TO_SAFE_Z_HOME
RATOS_ECHO MSG="Heating extruder to probing temperature..."
SET_HEATER_TEMPERATURE HEATER={"extruder" if default_toolhead == 0 else "extruder1"} TARGET={beacon_contact_true_zero_temp}
TEMPERATURE_WAIT SENSOR={"extruder" if default_toolhead == 0 else "extruder1"} MINIMUM={beacon_contact_true_zero_temp} MAXIMUM={beacon_contact_true_zero_temp + 5}
RATOS_ECHO MSG="Beacon contact auto calibration..."
BEACON_AUTO_CALIBRATE SKIP_MODEL_CREATION=1
G0 Z5 F{z_speed}
[gcode_macro _START_PRINT_AFTER_HEATING_EXTRUDER]
gcode =
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set default_toolhead = printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
{% set first_x = printer["gcode_macro START_PRINT"].first_x|default(-1)|float %}
{% set first_y = printer["gcode_macro START_PRINT"].first_y|default(-1)|float %}
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
{% set center_x = printable_x_max / 2.0 %}
{% set center_y = printable_y_max / 2.0 %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% if printer["dual_carriage"] is defined %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% endif %}
{% set X0 = params.X0|default(-1)|int %}
{% set X1 = params.X1|default(-1)|int %}
{% set Y0 = params.Y0|default(-1)|int %}
{% set Y1 = params.Y1|default(-1)|int %}
{% set idex_mode = params.IDEX_MODE|default('')|lower %}
{% set both_toolheads = true if params.BOTH_TOOLHEADS|default(true)|lower=='true' else false %}
{% set initial_toolhead = params.INITIAL_TOOLHEAD|default(default_toolhead)|int %}
{% if idex_mode == '' %}
_PRIME
{% else %}
{% if idex_mode == "copy" or idex_mode == "mirror" %}
RATOS_ECHO PREFIX="IDEX" MSG="using combined prime offset for IDEX {idex_mode} mode"
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
{% if both_toolheads %}
{% if initial_toolhead == 0 %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T0"
_SELECT_TOOL T=0 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T1"
_SELECT_TOOL T=1 TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% else %}
RATOS_ECHO PREFIX="IDEX" MSG="using prime offset for T{initial_toolhead}"
_SELECT_TOOL T={initial_toolhead} TOOLSHIFT=false
_PRIME INITIAL_TOOLHEAD={initial_toolhead} BOTH_TOOLHEADS={both_toolheads} IDEX_MODE={idex_mode} Y1={Y1}
{% endif %}
{% endif %}
{% endif %}
CACHE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
SET_MACRO_TRAVEL_SETTINGS
{% if (X0 > -1 and Y1 > -1) or (first_x > 0 and first_y > 0) %}
{% if printer["dual_carriage"] is defined %}
{% set acceleration = printer["gcode_macro RatOS"].toolchange_travel_accel %}
{% set max_accel = printer.toolhead.max_accel|float %}
{% set square_corner_velocity = printer.toolhead.square_corner_velocity|float %}
SET_VELOCITY_LIMIT ACCEL={acceleration} MINIMUM_CRUISE_RATIO=0 SQUARE_CORNER_VELOCITY=20
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
G0 Z3 F{z_speed}
{% endif %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
{% set first_z = 1 %}
{% else %}
{% set first_z = 3 %}
{% endif %}
{% if idex_mode == "mirror" %}
{% if first_y >= 0 %}
G0 Y{first_y} F{speed}
{% else %}
G0 Y{Y1} F{speed}
{% endif %}
{% endif %}
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if printer["dual_carriage"] is defined and printer["gcode_macro RatOS"].nozzle_priming|lower == 'false' %}
_MOVE_TO_LOADING_POSITION TOOLHEAD={initial_toolhead}
_PURGE_FILAMENT TOOLHEAD={initial_toolhead} E={printer["gcode_macro RatOS"].toolchange_first_purge|default(50)|float}
_CLEANING_MOVE TOOLHEAD={initial_toolhead}
{% endif %}
{% if first_x >= 0 and first_y >= 0 %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% else %}
{% set first_x = X0 %}
{% set first_y = Y0 %}
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'min' %}
{% set first_x = X0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_x|lower == 'max' %}
{% set first_x = X1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_x|float <= center_x %}
{% set first_x = X0 %}
{% else %}
{% set first_x = X1 %}
{% endif %}
{% endif %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'min' %}
{% set first_y = Y0 %}
{% elif printer["gcode_macro RatOS"].nozzle_prime_start_y|lower == 'max' %}
{% set first_y = Y1 %}
{% else %}
{% if printer["gcode_macro RatOS"].nozzle_prime_start_y|float <= center_y %}
{% set first_y = Y0 %}
{% else %}
{% set first_y = Y1 %}
{% endif %}
{% endif %}
{% endif %}
G0 X{first_x} Y{first_y} Z{first_z} F{speed}
{% endif %}
{% endif %}
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder"
_LOAD_RATOS_SKEW_PROFILE
[gcode_macro _PRIME]
gcode =
{% if printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeblob' or printer["gcode_macro RatOS"].nozzle_priming|lower == 'primeline' %}
PRIME_BLOB INITIAL_TOOLHEAD={params.INITIAL_TOOLHEAD} BOTH_TOOLHEADS={params.BOTH_TOOLHEADS} IDEX_MODE={params.IDEX_MODE} Y1={params.Y1}
{% else %}
{% if printer["dual_carriage"] is defined %}
{% if params.IDEX_MODE == "copy" %}
_IDEX_COPY DANCE=0
{% elif params.IDEX_MODE == "mirror" %}
_IDEX_MIRROR DANCE=0
{% endif %}
{% endif %}
{% endif %}
[gcode_macro END_PRINT]
description = End print procedure, use this in your Slicer.
gcode =
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=is_printing_gcode VALUE=False
SAVE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if printer["gcode_macro RatOS"].auto_center_subject|default(false)|lower == 'true' %}
{% set object_xoffset = printer["gcode_macro START_PRINT"].object_xoffset|default(0)|float %}
RATOS_ECHO MSG="Adjusting object x-offset by {(0-object_xoffset)} mm"
SET_GCODE_OFFSET X_ADJUST={(0-object_xoffset)}
{% endif %}
{% endif %}
_USER_END_PRINT_BEFORE_HEATERS_OFF { rawparams }
_END_PRINT_BEFORE_HEATERS_OFF
TURN_OFF_HEATERS
_USER_END_PRINT_AFTER_HEATERS_OFF { rawparams }
_END_PRINT_AFTER_HEATERS_OFF
_USER_END_PRINT_PARK { rawparams }
_END_PRINT_PARK
{% if printer["gcode_macro RatOS"].skew_profile is defined %}
SET_SKEW CLEAR=1
{% endif %}
{% if printer["dual_carriage"] is not defined and printer["gcode_macro RatOS"].end_print_motors_off|lower != 'false' %}
M84
{% endif %}
M107
BED_MESH_CLEAR
RATOS_ECHO MSG="Done :)"
RESTORE_GCODE_STATE NAME=end_print_state
{% if printer["dual_carriage"] is defined %}
M84
{% endif %}
{% if printer.configfile.settings.beacon is defined %}
{% if printer["dual_carriage"] is not defined %}
{% set beacon_contact_start_print_true_zero = true if printer["gcode_macro RatOS"].beacon_contact_start_print_true_zero|default(false)|lower == 'true' else false %}
{% set beacon_contact_expansion_compensation = true if printer["gcode_macro RatOS"].beacon_contact_expansion_compensation|default(false)|lower == 'true' else false %}
{% if beacon_contact_start_print_true_zero and beacon_contact_expansion_compensation %}
SET_GCODE_OFFSET Z=0 MOVE=0
{% endif %}
{% endif %}
_BEACON_SET_NOZZLE_TEMP_OFFSET RESET=True
{% endif %}
RESTORE_TOOLHEAD_SETTINGS KEY="start_print"
_CHAMBER_FILTER_ON AT="print_end"
_CHAMBER_FILTER_OFF
_CHAMBER_HEATER_OFF
_USER_END_PRINT_FINISHED { rawparams }
[gcode_macro _END_PRINT_BEFORE_HEATERS_OFF]
gcode =
RATOS_ECHO MSG="Cleaning up..."
[gcode_macro _END_PRINT_AFTER_HEATERS_OFF]
gcode =
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set current_z = printer.toolhead.position.z|float %}
{% set z_hop = printer["gcode_macro RatOS"].end_print_park_z_hop|float %}
{% set r = printer["gcode_macro RatOS"].end_print_retract_filament|default(4)|float %}
{% if current_z < (max_z - z_hop) %}
{% set z_safe = z_hop %}
{% else %}
{% set z_safe = max_z - current_z %}
{% endif %}
G91
G1 E-2 F3600
G0 Z{z_safe} F3600
G1 E-{(r-2)} F3600
G90
[gcode_macro _SET_EXTRUSION_MODE]
gcode =
{% if printer["gcode_macro RatOS"].relative_extrusion|lower == 'true' %}
M83
{% else %}
M82
{% endif %}
[gcode_macro GENERATE_SHAPER_GRAPHS]
description = Genarates input shaper resonances graphs for analysis. Uses the AXIS parameter for if you only want to do one axis at a time, (eg. GENERATE_SHAPER_GRAPHS AXIS=X)
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set axis = params.AXIS|default('')|lower %}
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
{% if axis != '' %}
{% if axis == 'x' %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
{% elif axis == 'y' %}
MAYBE_HOME
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% else %}
{action_raise_error("Unknown axis specified. Expected X or Y.")}
{% endif %}
{% else %}
MAYBE_HOME
TEST_RESONANCES AXIS=X FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=Y FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_shaper_graph_x
RUN_SHELL_COMMAND CMD=generate_shaper_graph_y
{% endif %}
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="generate_shaper_graphs"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Shaper graph"
[gcode_shell_command generate_shaper_graph_x]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-x.sh
timeout = 60.
verbose = True
[gcode_shell_command generate_shaper_graph_y]
command = /home/pi/printer_data/config/RatOS/scripts/generate-shaper-graph-y.sh
timeout = 60.
verbose = True
[gcode_macro MEASURE_COREXY_BELT_TENSION]
description = Generates resonance graph used to ensure belts are equally tensioned.
gcode =
CACHE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
SET_MACRO_TRAVEL_SETTINGS
CACHE_IS_GRAPH_FILES
_LED_INPUT_SHAPER_START
{% set freq_start = params.FREQUENCY_START|default(10)|int %}
{% set freq_end = params.FREQUENCY_END|default(133)|int %}
{% set hz_per_sec = params.HZ_PER_SEC|default(1)|float %}
MAYBE_HOME
TEST_RESONANCES AXIS=1,1 OUTPUT=raw_data NAME=belt-tension-upper FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=belt-tension-lower FREQ_START={freq_start} FREQ_END={freq_end} HZ_PER_SEC={hz_per_sec}
RUN_SHELL_COMMAND CMD=generate_belt_tension_graph
_LED_INPUT_SHAPER_END
RESTORE_TOOLHEAD_SETTINGS KEY="measure_corexy_belt_tension"
_LEARN_MORE_CALIBRATION
SHOW_IS_GRAPH_FILES TITLE="Belt Tension Graph"
[gcode_shell_command generate_belt_tension_graph]
command = /home/pi/printer_data/config/RatOS/scripts/generate-belt-tension-graph.sh
timeout = 90.
verbose = True
[idle_timeout]
gcode =
{% if printer.webhooks.state|lower == 'ready' %}
{% if printer.pause_resume.is_paused|lower == 'false' %}
RATOS_ECHO PREFIX="IDLE" MSG="2 hours since last activity. Powering off heaters and motors.."
TURN_OFF_HEATERS
M84
{% endif %}
{% endif %}
timeout = 7200
[temperature_sensor raspberry_pi]
sensor_type = temperature_host
[skew_correction]
[input_shaper]
[virtual_sdcard]
path = ~/printer_data/gcodes
[display_status]
[pause_resume]
[force_move]
enable_force_move = True
[respond]
[resonance_generator]
[ratos]
allow_unknown_gcode_generator = True
[exclude_object]
[heater_bed]
heater_pin = heater_bed_heating_pin
sensor_pin = heater_bed_sensor_pin
sensor_type = EPCOS 100K B57560G104F
min_temp = 0
max_temp = 130
control = pid
pid_kp = 68.203
pid_ki = 2.842
pid_kd = 409.216
[fan]
pin = multi_pin:dual_blower_fan
shutdown_speed = 1.0
kick_start_time = 0.5
cycle_time = 0.00004
[heater_fan toolhead_cooling_fan]
pin = PD14
fan_speed = 1
heater = extruder
heater_temp = 50.0
[controller_fan controller_fan]
pin = PD13
idle_speed = 0.7
[printer]
kinematics = cartesian
max_velocity = 200
max_accel = 3000
minimum_cruise_ratio = 0.5
max_z_velocity = 15
max_z_accel = 200
square_corner_velocity = 5
[bed_mesh]
speed = 200
horizontal_move_z = 5
mesh_min = 15,15
mesh_max = 150,160
probe_count = 5,5
fade_start = 1.0
fade_end = 10.0
mesh_pps = 2,2
algorithm = bicubic
bicubic_tension = .2
[screws_tilt_adjust]
screw1 = 80, 108
screw1_name = Left Screw
screw2 = 155, 72
screw2_name = Front Right Screw
screw3 = 155, 147
screw3_name = Rear Right Screw
horizontal_move_z = 10
speed = 200
screw_thread = CCW-M4
[stepper_x]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PF9
dir_pin = !x_dir_pin
enable_pin = !PD6
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = toolboard_t0:PB6
[stepper_y]
position_endstop = 0
position_min = 0
position_max = 180
step_pin = PD3
dir_pin = y_dir_pin
enable_pin = !PD5
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 40
homing_speed = 80
endstop_pin = PC1
[stepper_z]
position_min = -5
position_max = 180
step_pin = PA15
dir_pin = !z0_dir_pin
enable_pin = !PC9
microsteps = 64
full_steps_per_rotation = 200
rotation_distance = 4
homing_speed = 15
endstop_pin = probe:z_virtual_endstop
[gcode_macro SCREWS_TILT_CALCULATE]
rename_existing = SCREWS_TILT_CALCULATE_ORIG
gcode =
{% set printable_x_max = printer["gcode_macro RatOS"].printable_x_max|float %}
{% set printable_y_max = printer["gcode_macro RatOS"].printable_y_max|float %}
MAYBE_HOME
SAVE_GCODE_STATE NAME=screws_tilt_state
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
DEPLOY_PROBE
{% endif %}
SCREWS_TILT_CALCULATE_ORIG
{% if printer["gcode_macro RatOS"].z_probe == 'stowable' %}
STOW_PROBE
{% endif %}
G90
G0 Z120 F{printer["gcode_macro RatOS"].macro_z_speed|float * 60}
G0 Y{printable_y_max} X{printable_x_max / 2} F{printer["gcode_macro RatOS"].macro_travel_speed|float * 60}
RESTORE_GCODE_STATE NAME=screws_tilt_state
M84
[extruder]
rotation_distance = 5.57
full_steps_per_rotation = 200
filament_diameter = 1.750
max_extrude_only_velocity = 120
max_extrude_only_accel = 800
pressure_advance_smooth_time = 0.02
max_extrude_only_distance = 200
nozzle_diameter = 0.4
heater_pin = toolboard_t0:PB13
sensor_type = MAX31865
sensor_pin = toolboard_t0:PA4
min_extrude_temp = 170
min_temp = 0
max_temp = 350
pressure_advance = 0.03
step_pin = toolboard_t0:PD0
dir_pin = !toolboard_t0:e_dir_pin
enable_pin = !toolboard_t0:PD2
microsteps = 64
control = pid
pid_kp = 21.673
pid_ki = 1.338
pid_kd = 87.776
spi_software_sclk_pin = toolboard_t0:PA5
spi_software_miso_pin = toolboard_t0:PA6
spi_software_mosi_pin = toolboard_t0:PA7
[firmware_retraction]
retract_speed = 120
unretract_extra_length = 0
unretract_speed = 120
retract_length = 0.5
[adxl345 rpi]
cs_pin = rpi:None
[resonance_tester]
accel_chip_x = adxl345 toolboard_t0
accel_chip_y = adxl345 rpi
probe_points =
90,90,20
[tmc2209 stepper_x]
stealthchop_threshold = 0
interpolate = False
uart_pin = PF10
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_y]
stealthchop_threshold = 0
interpolate = False
uart_pin = PD4
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 stepper_z]
stealthchop_threshold = 0
interpolate = False
uart_pin = PC8
run_current = 0.8
driver_tbl = 1
driver_toff = 3
driver_hend = 3
driver_hstrt = 0
sense_resistor = 0.11
[tmc2209 extruder]
stealthchop_threshold = 0
interpolate = False
uart_pin = toolboard_t0:PA15
run_current = 0.707
driver_tbl = 0
driver_toff = 4
driver_hend = 6
driver_hstrt = 7
sense_resistor = 0.11
[bltouch]
sensor_pin = ^toolboard_t0:bltouch_sensor_pin
control_pin = toolboard_t0:bltouch_control_pin
speed = 7
pin_move_time = 0.675
sample_retract_dist = 10
pin_up_reports_not_triggered = True
pin_up_touch_mode_reports_triggered = True
x_offset = -28
y_offset = -13
z_offset = 2.375
[gcode_macro T0]
variable_join = 0
variable_remap = 0
variable_alert = ""
variable_filament_name = ""
variable_filament_type = ""
variable_filament_temp = 0
variable_runout_sensor = ""
variable_active = True
variable_color = "7bff33"
variable_hotend_type = "HF"
variable_has_cht_nozzle = False
variable_cooling_position_to_nozzle_distance = 40
variable_tooolhead_sensor_to_extruder_gear_distance = 15
variable_extruder_gear_to_cooling_position_distance = 30
variable_filament_loading_nozzle_offset = -5
variable_filament_grabbing_length = 5
variable_filament_grabbing_speed = 1
variable_enable_insert_detection = True
variable_enable_runout_detection = True
variable_enable_clog_detection = True
variable_unload_after_runout = True
variable_purge_after_load = 0
variable_purge_before_unload = 0
variable_extruder_load_speed = 60
variable_filament_load_speed = 10
variable_standby = False
variable_temperature_offset = 0
variable_has_oozeguard = False
variable_has_front_arm_nozzle_wiper = False
variable_resume_after_insert = False
gcode =
{% set x = params.X|default(-1.0)|float %}
{% set y = params.Y|default(-1.0)|float %}
{% set z = params.Z|default(0.0)|float %}
{% set s = params.S|default(1)|int %}
{% if printer["gcode_macro _SELECT_TOOL"] is defined %}
_SELECT_TOOL T=0 X={x} Y={y} Z={z} TOOLSHIFT={s}
{% endif %}
[save_variables]
filename = /home/pi/printer_data/config/ratos-variables.cfg
[multi_pin dual_blower_fan]
pins = toolboard_t0:PA0, toolboard_t0:PA1
=======================
Config error
Traceback (most recent call last):
File "/home/pi/klipper/klippy/klippy.py", line 130, in _connect
self._read_config()
File "/home/pi/klipper/klippy/klippy.py", line 123, in _read_config
self.load_object(config, section_config.get_name(), None)
File "/home/pi/klipper/klippy/klippy.py", line 112, in load_object
self.objects[section] = init_func(config.getsection(section))
File "/home/pi/klipper/klippy/extras/fan.py", line 122, in load_config
return PrinterFan(config)
File "/home/pi/klipper/klippy/extras/fan.py", line 106, in __init__
self.fan = Fan(config)
File "/home/pi/klipper/klippy/extras/fan.py", line 24, in __init__
self.mcu_fan = ppins.setup_pin('pwm', config.get('pin'))
File "/home/pi/klipper/klippy/pins.py", line 117, in setup_pin
pin_params = self.lookup_pin(pin_desc, can_invert, can_pullup)
File "/home/pi/klipper/klippy/pins.py", line 98, in lookup_pin
pin_params = self.parse_pin(pin_desc, can_invert, can_pullup)
File "/home/pi/klipper/klippy/pins.py", line 83, in parse_pin
raise error("Unknown pin chip name '%s'" % (chip_name,))
pins.error: Unknown pin chip name 'multi_pin'
webhooks client 1964693344: New connection
webhooks client 1964693344: Client info {'program': 'Moonraker', 'version': 'v0.9.3-0-g71f9e67'}