diff --git a/macros/print/print_start_end.cfg b/macros/print/print_start_end.cfg index e6b3760..2c89c9c 100644 --- a/macros/print/print_start_end.cfg +++ b/macros/print/print_start_end.cfg @@ -19,6 +19,7 @@ description: Print start before HEAT_SOAK: home while the bed heats, wait for th gcode: {% set target_bed = params.BED|int %} {% set target_chamber = params.CHAMBER|default("0")|int %} + {% set initial_tool = params.TOOL|default("0")|int %} RESET_FAILURE CLEAR_PAUSE @@ -48,6 +49,9 @@ gcode: _NOZZLE_CONTACT_TEMP RESPOND MSG="homing" HOME + {% if target_chamber > 30 %} + _UNLOAD_FOR_CHAMBER TOOL={initial_tool} + {% endif %} G1 X175 Y175 Z5 F1200 _STATUS STATE=heating_bed @@ -67,6 +71,38 @@ gcode: HEAT_SOAK HEATER='heater_bed' TARGET={target_bed} SOAKER='temperature_sensor bed_core' SOAK_TEMP={target_bed - 5} TIMEOUT=30 CANCEL='_NOTHING' {% endif %} +# With the chamber heated, a filament that stays in the toolhead path softens +# in the PTFE tube (PLA loaded, ASA print). PRINT_START would swap a lane that +# is not the first tool's anyway, so unload it now, before the chamber heats. +# AFC moves the filament back into the Box Turtle, outside the chamber. +[gcode_macro _UNLOAD_FOR_CHAMBER] +description: Before a chamber soak: unload the toolhead when its lane is not mapped to TOOL (the print's first tool) +gcode: + {% set tool = 'T' ~ params.TOOL|default(0)|int %} + {% set cur = printer.AFC.current_load if 'AFC' in printer else none %} + {% if cur and ('AFC_stepper ' ~ cur) in printer %} + {% set lane = printer['AFC_stepper ' ~ cur] %} + {% if lane.map != tool %} + RESPOND MSG="Chamber heating: unloading {cur} ({lane.material}, {lane.map}), the print starts with {tool}" + _HEAT_FOR_LOADED_LANE TOOL={params.TOOL|default(0)|int} + TOOL_UNLOAD LANE={cur} + _UNLOAD_FOR_CHAMBER_VERIFY LANE={cur} + {% endif %} + {% endif %} + +# Separate macro: rendered after TOOL_UNLOAD has run. A failed unload stops +# the print before the chamber heats. +[gcode_macro _UNLOAD_FOR_CHAMBER_VERIFY] +description: Helper for _UNLOAD_FOR_CHAMBER: stop the print when the lane is still loaded +gcode: + {% if printer.AFC.current_load %} + _ERROR MSG="Chamber heating: {params.LANE} could not be unloaded ({printer.AFC.current_load} still in the toolhead), print stopped before the chamber heats" DISPLAY="Unload failed, print stopped" + {% else %} + # The filament the retract was remembered for is gone + SAVE_VARIABLE VARIABLE=nozzle_retract VALUE=0 + M104 S150 + {% endif %} + # Beacon contact refuses a nozzle above contact_max_hotend_temperature (180C) [gcode_macro _NOZZLE_CONTACT_TEMP] description: Nozzle to 150C for Beacon contact; wait only while it is above MAXIMUM (default 170C), WAIT=1 also waits until it is at least 145C