# Automatic resume after an AFC "NOT FEEDING" buffer fault # # When AFC pauses a print because the buffer stayed empty too long, # PAUSE (print/pause_resume.cfg) calls _AUTO_RESUME_ARM. After `delay` seconds # _AUTO_RESUME runs the normal RESUME: AFC clears its error, the lane check # runs, and _RESUME_PRINT purges into the Blobifier with the purge check. A # failed check (or lane check) stops that RESUME as usual, so the print stays # paused and waits for you. # # Limits, so a real problem (tangled spool, grinding extruder, clog) is not # hidden: at most `max_per_print` automatic resumes per print, and none when # the previous one was less than `min_interval` minutes of printing ago. After # that the print stays paused like before. # # Only between _PRINT_START_FINISH and the end of the print (`active`): a pause # during PRINT_START or a PA test needs CLEAR_PAUSE, not RESUME. # # Turn off: SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=enabled VALUE=False # (until the next restart; change `enabled` below to keep it off) [gcode_macro _AUTO_RESUME_CFG] description: Settings and state for the automatic resume after an AFC buffer fault variable_enabled: True variable_max_per_print: 2 # automatic resumes per print variable_min_interval: 10 # minutes of printing since the previous automatic resume variable_delay: 5 # seconds after the pause (AFC finishes its own pause first) variable_faults: ['NOT FEEDING'] # text in AFC's error message # Not 'CLOG DETECTED' (buffer stayed full: the extruder takes no filament): # that is usually a real blockage. On 2026-11-17 a nozzle blocked right after a # swap; the purge check still passed (a blocked nozzle also builds pressure), # so the automatic resume only printed air until the next CLOG pause. variable_clear_faults: ['NOT FEEDING', 'CLOG DETECTED'] # removed from AFC's queue after any resume # State (set by the macros) variable_active: False # True from _PRINT_START_FINISH to the end of the print variable_count: 0 # automatic resumes in this print variable_last_at: -1.0 # print_duration (s) of the last automatic resume, -1 = none variable_pending: '' # fault the timer is waiting to resume from gcode: RESPOND MSG="Auto-resume: {'on' if enabled else 'off'}, {'active' if active else 'not active'}, {count}/{max_per_print} used in this print" # Called by _PRINT_START_FINISH (ON=1) and _PRINT_CLEANUP (ON=0) [gcode_macro _AUTO_RESUME_ACTIVE] description: Start (ON=1) or end (ON=0) the automatic resume for a print gcode: {% set on = params.ON|default(1)|int %} SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=active VALUE={True if on else False} SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=count VALUE=0 SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=last_at VALUE=-1.0 SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=pending VALUE="''" UPDATE_DELAYED_GCODE ID=_AUTO_RESUME DURATION=0 {% if on and 'AFC' in printer %} # Old messages would be read as this print's fault: start empty AFC_CLEAR_ALL_MESSAGES {% endif %} # Called by PAUSE when it pauses a print. AFC's message queue shows its oldest # message first; _RESUME_PRINT removes a buffer fault message once resumed, so # the oldest one is this pause's. [gcode_macro _AUTO_RESUME_ARM] description: Start the automatic resume timer when AFC paused for a buffer fault and the limits allow it gcode: {% set cfg = printer["gcode_macro _AUTO_RESUME_CFG"] %} {% set has_afc = 'AFC' in printer %} {% set msg = printer.AFC.message.message|default('') if has_afc else '' %} {% set fault = (cfg.faults|select('in', msg)|list + [''])[0] %} {% set now = printer.print_stats.print_duration|float %} {% if cfg.enabled and cfg.active and has_afc and printer.AFC.error_state and fault %} {% if cfg.count >= cfg.max_per_print %} _WARN MSG="Auto-resume: not resuming after AFC {fault}, already {cfg.count} automatic resumes in this print. Check the lane, then RESUME." DISPLAY="AFC {fault}: check, then RESUME" {% elif cfg.last_at >= 0 and now - cfg.last_at < cfg.min_interval * 60 %} _WARN MSG="Auto-resume: not resuming after AFC {fault}, the last automatic resume was only {((now - cfg.last_at) / 60)|round(1)} min of printing ago. Check the lane, then RESUME." DISPLAY="AFC {fault} again: check, then RESUME" {% else %} SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=pending VALUE="'{fault}'" RESPOND MSG="Auto-resume: AFC {fault}, resuming in {cfg.delay} s with the purge check ({cfg.count + 1}/{cfg.max_per_print})" UPDATE_DELAYED_GCODE ID=_AUTO_RESUME DURATION={cfg.delay} {% endif %} {% endif %} [delayed_gcode _AUTO_RESUME] gcode: {% set cfg = printer["gcode_macro _AUTO_RESUME_CFG"] %} {% set fault = cfg.pending %} SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=pending VALUE="''" # Only when nothing changed since the pause: still paused, still AFC's # error (a manual RESUME or CANCEL in the meantime ends it) {% if fault and cfg.active and printer.print_stats.state == 'paused' and printer.pause_resume.is_paused and printer.AFC.error_state %} SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=count VALUE={cfg.count + 1} SET_GCODE_VARIABLE MACRO=_AUTO_RESUME_CFG VARIABLE=last_at VALUE={printer.print_stats.print_duration|float} RESPOND MSG="Auto-resume {cfg.count + 1}/{cfg.max_per_print} after AFC {fault}" M117 Auto-resume {cfg.count + 1}/{cfg.max_per_print}: AFC {fault} RESUME {% endif %} # Called by _RESUME_PRINT after a resume: remove a buffer fault message from # the front of AFC's queue, so the next pause reads its own message. Also a # CLOG message after a manual RESUME: left at the front, it would hide the next # NOT FEEDING message and block that automatic resume. [gcode_macro _AUTO_RESUME_CLEAR_FAULT] description: Helper: drop AFC's buffer fault message after a resume gcode: {% set cfg = printer["gcode_macro _AUTO_RESUME_CFG"] %} {% set msg = printer.AFC.message.message|default('') if 'AFC' in printer else '' %} {% if msg and cfg.clear_faults|select('in', msg)|list %} AFC_CLEAR_MESSAGE {% endif %}