Files
klipper-macros/macros/afc/lane_tools.cfg
T
mangavalkandClaude Opus 5.5 eaf9c82617 Group macros by topic, add Blobifier, fix first tool change
- Split the macro files into folders by topic (print, heating, afc,
  pressure_advance, spoolman, leds, sensors); klipper-macros.cfg is the
  one file printer.cfg includes. Macros moved unchanged; the effective
  config is identical apart from the paths of the PA shell scripts.
- Add the modified Blobifier (Turtleblobifier for AFC) and define
  [save_variables] once in save_variables.cfg instead of in both
  blobifier.cfg and the PA macros (same file, bd_pa_variables.cfg).
- PRINT_WARMUP: heat to the loaded lane's temperature before the first
  tool change. AFC skips heating when the loaded lane's tool number is
  not in the print file's temperature list, and the unload then failed
  below min_extrude_temp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 14:24:37 +02:00

101 lines
3.1 KiB
INI

# AFC lane tools: LANE_FEED_UNTIL_HUB_OPEN, LANE_FEED_ABORT
#####################################################################
## unloading help
#####################################################################
[gcode_macro LANE_FEED_UNTIL_HUB_OPEN]
variable_lane: 1
variable_step: -50
variable_max_dist: 2000
variable_moved: 0
variable_active: 0
gcode:
{% set lane = params.LANE|default(1)|int %}
{% set step = params.STEP|default(-50)|float %}
{% set max_dist = params.MAX_DIST|default(2000)|float %}
SET_GCODE_VARIABLE MACRO=LANE_FEED_UNTIL_HUB_OPEN VARIABLE=lane VALUE={lane}
SET_GCODE_VARIABLE MACRO=LANE_FEED_UNTIL_HUB_OPEN VARIABLE=step VALUE={step}
SET_GCODE_VARIABLE MACRO=LANE_FEED_UNTIL_HUB_OPEN VARIABLE=max_dist VALUE={max_dist}
SET_GCODE_VARIABLE MACRO=LANE_FEED_UNTIL_HUB_OPEN VARIABLE=moved VALUE=0
SET_GCODE_VARIABLE MACRO=LANE_FEED_UNTIL_HUB_OPEN VARIABLE=active VALUE=1
RESPOND PREFIX="info" MSG="START lane={lane} step={step} max={max_dist}"
UPDATE_DELAYED_GCODE ID=_lane_feed_loop DURATION=0.05
[delayed_gcode _lane_feed_loop]
gcode:
{% set m = printer["gcode_macro LANE_FEED_UNTIL_HUB_OPEN"] %}
{% if m.active == 1 %}
LANE_MOVE LANE=lane{m.lane} DISTANCE={m.step}
{% set new_moved = m.moved + m.step %}
SET_GCODE_VARIABLE MACRO=LANE_FEED_UNTIL_HUB_OPEN VARIABLE=moved VALUE={new_moved}
RESPOND PREFIX="info" MSG="MOVE lane={m.lane} step={m.step} moved={new_moved}"
QUERY_ENDSTOPS
UPDATE_DELAYED_GCODE ID=_lane_eval DURATION=0.03
{% else %}
RESPOND PREFIX="info" MSG="feed_loop inactive"
{% endif %}
[delayed_gcode _lane_eval]
gcode:
{% set m = printer["gcode_macro LANE_FEED_UNTIL_HUB_OPEN"] %}
{% if m.active == 1 %}
{% set hub = printer.query_endstops.last_query.get("hub", "unknown") %}
# RESPOND PREFIX="info" MSG="QUERY hub={hub} raw={printer.query_endstops.last_query.get('hub', 'MISSING')}"
# RESPOND PREFIX="info" MSG="last_query: {printer.query_endstops.last_query}"
{% if hub == "open" or hub == 0 %}
RESPOND PREFIX="info" MSG="HUB TRIGGERED → STOP"
SET_GCODE_VARIABLE MACRO=LANE_FEED_UNTIL_HUB_OPEN VARIABLE=active VALUE=0
LANE_MOVE LANE=lane{m.lane} DISTANCE=-100
{% elif m.moved|abs >= m.max_dist %}
RESPOND PREFIX="warning" MSG="MAX DIST STOP reached={m.moved}"
SET_GCODE_VARIABLE MACRO=LANE_FEED_UNTIL_HUB_OPEN VARIABLE=active VALUE=0
{% else %}
RESPOND PREFIX="info" MSG="CONTINUE"
UPDATE_DELAYED_GCODE ID=_lane_feed_loop DURATION=0.03
{% endif %}
{% else %}
RESPOND PREFIX="info" MSG="eval inactive"
{% endif %}
[gcode_macro LANE_FEED_ABORT]
gcode:
SET_GCODE_VARIABLE MACRO=LANE_FEED_UNTIL_HUB_OPEN VARIABLE=active VALUE=0
UPDATE_DELAYED_GCODE ID=_lane_feed_loop DURATION=0
UPDATE_DELAYED_GCODE ID=_lane_eval DURATION=0
RESPOND PREFIX="warning" MSG="ABORTED"
# [gcode_macro TEST_AMS_STRESS]
# gcode:
# {% for i in range(500) %}
# T0 ; Load tool 0
# G4 P5000 ; Wait 5s
# T1 ; Unload
# G4 P3000 ; Wait 3s
# {% endfor %}