Fix pause/resume chain, shared print cleanup, add CLAUDE.md

- RESUME is defined only in print/pause_resume.cfg; heat_soak.cfg's
  duplicate replaced it (no unretract, no fan restore). It now runs
  HEAT_SOAK_RESUME -> _RESUME_PRINT -> RESUME_BASE.
- PAUSE runs PAUSE_BASE first, then retracts and parks once (X20 Y345);
  a parked flag makes resume undo only what PAUSE did.
- New _PRINT_CLEANUP shared by PRINT_END and CANCEL_PRINT: heaters incl.
  iHEATER_OFF, fan, M221 S100, bdwidth off, mesh and skew cleared.
  In PRINT_END it runs after RESTORE_GCODE_STATE so the flow reset sticks.
- Add CLAUDE.md and tools/effective_config.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-10-10 15:20:28 +02:00
1 parent eaf9c82617
commit 9dc733b5bb
7 files changed
+245 -85

No files matched your search

+48 -62
View File
@@ -1,44 +1,42 @@
# PAUSE, RESUME, CANCEL_PRINT, M600 (based on the KlipperScreen recommended macros)
#
# Chain on this printer (AFC renames PAUSE/RESUME at startup):
# PAUSE -> AFC_PAUSE (saves position, z-hop) -> this PAUSE -> PAUSE_BASE
# RESUME -> AFC_RESUME -> this RESUME -> HEAT_SOAK_RESUME -> _RESUME_PRINT
# -> RESUME_BASE, then AFC restores the saved position
# RESUME is defined only here: heating/heat_soak.cfg used to define its own,
# which replaced this one completely (no unretract, no fan restore).
# https://klipperscreen.readthedocs.io/en/latest/macros/#recommended
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
variable_saved_fan_speed: 0.0
variable_parked: False # set by PAUSE, used by _RESUME_PRINT
gcode:
# SAVE_GCODE_STATE NAME=PAUSE_MACRO_state
# Save current fan speed
{% set current_fan = printer.fan.speed %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=saved_fan_speed VALUE={current_fan}
# Current position
{% set x = printer.toolhead.position.x|float %}
{% set y = printer.toolhead.position.y|float %}
# Determine target positions
{% set target_x = 340 if (x < 340 or x > 350) else x %}
{% set target_y = 340 if (y < 340 or y > 350) else y %}
# Only move if needed
{% if target_x != x or target_y != y %}
G90
G1 X{target_x} Y{target_y} F12000
{% if not printer.pause_resume.is_paused %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=saved_fan_speed VALUE={printer.fan.speed}
# Pause first, so the saved state is the print position, then retract and park
PAUSE_BASE
_TOOLHEAD_PARK_PAUSE_CANCEL
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=parked VALUE=True
# Set fan to S28 (28/255 ≈ 0.1098)
M106 S28
{% else %}
PAUSE_BASE
{% endif %}
# Pause print
PAUSE_BASE
_TOOLHEAD_PARK_PAUSE_CANCEL
# Set fan to S28 (28/255 ≈ 0.1098)
M106 S28
[gcode_macro RESUME]
description: Resume the actual running print
description: Resume the print (while HEAT_SOAK runs: skip the soak phase)
rename_existing: RESUME_BASE
variable_skip_restore: 0
gcode:
HEAT_SOAK_RESUME ON_RESUME=_RESUME_PRINT {rawparams}
[gcode_macro _RESUME_PRINT]
description: Resume after PAUSE: unretract, restore the part fan, continue the print
gcode:
{% set pause = printer["gcode_macro PAUSE"] %}
{% set extrude = printer['gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL'].extrude %}
{% set skip = printer['gcode_macro RESUME'].skip_restore|int %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
@@ -46,40 +44,28 @@ gcode:
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
M83
G1 E{extrude} F2100
{% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %}
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
#BLOBIFIER_CLEAN
#G1 Z10
# Only undo what PAUSE did; HEAT_SOAK pauses with PAUSE_BASE (no retract, no park)
{% if pause.parked %}
{% if printer.extruder.can_extrude|lower == 'true' %}
M83
G1 E{extrude} F2100
{% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %}
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
# Restore saved fan speed
{% set old_fan = printer["gcode_macro PAUSE"].saved_fan_speed %}
{% if old_fan > 0 %}
{% set fan_pwm = (old_fan * 255) | int %}
{% if fan_pwm > 255 %}
{% set fan_pwm = 255 %}
{% endif %}
M106 S{fan_pwm}
{% else %}
# Restore saved fan speed
{% set old_fan = pause.saved_fan_speed %}
{% if old_fan > 0 %}
M106 S{[(old_fan * 255)|int, 255]|min}
{% else %}
M107
{% endif %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=parked VALUE=False
{% endif %}
{% if skip == 0 %}
# RESTORE_GCODE_STATE name=PAUSE_MACRO_state
RESUME_BASE {get_params}
{% else %}
RESPOND PREFIX="AFC" MSG="Skipping RESTORE_GCODE_STATE (drift resume)"
{% endif %}
RESUME_BASE {get_params}
_status_printing
CLEAR_PAUSE
RESET_FAILURE
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=skip_restore VALUE=0
[gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL]
description: Helper: park toolhead used in PAUSE and CANCEL_PRINT
@@ -129,12 +115,12 @@ gcode:
_TOOLHEAD_PARK_PAUSE_CANCEL
{% endif %}
STOP_HEAT_SOAK
TURN_OFF_HEATERS
STOP_HEAT_SOAK
CANCEL_PRINT_BASE_KLIPPERSCREEN
# Same cleanup as PRINT_END: heaters incl. chamber heater, fan, flow, bdwidth
_PRINT_CLEANUP
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=parked VALUE=False
_status_ready
[gcode_macro M600]
#