# Flexible filament (TPU, TPE): slower long moves for the lanes holding it. # # Soft filament can buckle in the long tube at the normal 100-200 mm/s. # A poller checks the material of every lane (from Spoolman via AFC) every # 5 s and sets the lane's long-move speed: flex_speed for a flexible # material, the configured long_moves_speed again when the lane holds # something else. Only changes are sent. SET_LONG_MOVE_SPEED is runtime # only; after a Klipper restart the poller applies it again. # # Not covered: the last stretch into the extruder (tool_load_speed in # AFC/AFC_Hardware.cfg, 25 mm/s) has no runtime command and is the same # for every lane. The purge after the load is already slow (2.5 mm/s). [gcode_macro _FLEX_LANES_CFG] variable_materials: ["tpu", "tpe", "flex"] # material containing one of these (any case) is flexible variable_flex_speed: 50 # mm/s; AFC's minimum for SET_LONG_MOVE_SPEED is 50 variable_slowed: "" # runtime: comma list of lanes now at flex_speed gcode: [delayed_gcode _FLEX_LANES_POLL] initial_duration: 10 gcode: {% set cfg = printer["gcode_macro _FLEX_LANES_CFG"] %} {% if 'AFC' in printer %} {% set settings = printer.configfile.settings %} {% set default_speed = settings.afc.long_moves_speed|default(150) if 'afc' in settings else 150 %} {% set was = cfg.slowed.split(',')|reject('equalto', '')|list %} {% set now = [] %} {% for lane in printer.AFC.lanes %} {% set key = 'AFC_stepper ' ~ lane %} {% set mat = (printer[key].material if key in printer else '')|default('', true)|string %} {% set ns = namespace(flex=false) %} {% for m in cfg.materials %} {% if m in mat|lower %} {% set ns.flex = true %} {% endif %} {% endfor %} {% if ns.flex %} {% set _ = now.append(lane) %} {% if lane not in was %} SET_LONG_MOVE_SPEED LANE={lane} FWD_SPEED={cfg.flex_speed} RESPOND MSG="{lane} holds {mat}: long moves at {cfg.flex_speed} mm/s (flexible)" {% endif %} {% elif lane in was %} {% set speed = settings[key|lower].long_moves_speed|default(default_speed) if (key|lower) in settings else default_speed %} SET_LONG_MOVE_SPEED LANE={lane} FWD_SPEED={speed} RESPOND MSG="{lane} holds {mat or 'nothing'}: long moves back at {speed} mm/s" {% endif %} {% endfor %} {% if now|join(',') != was|join(',') %} SET_GCODE_VARIABLE MACRO=_FLEX_LANES_CFG VARIABLE=slowed VALUE='"{now|join(',')}"' {% endif %} {% endif %} UPDATE_DELAYED_GCODE ID=_FLEX_LANES_POLL DURATION=5