## This config file contains macros that can be used in conjuction with tacho-enabled part fans
##
## - PREFLIGHT_CHECK, add this to the beginning of your PRINT_START macro to check your PCF fans. 
##     If either of the fans are malfunctioning, the print job will be cancelled.

[gcode_macro PCF_CHECK]
description: sub-macro of PREFLIGHT CHECK, not intended to be used outside of parent macro
gcode:
  {% if printer.fan.rpm is not none %}
    {% if printer.fan.rpm > 500 %}
      {action_respond_info("Part fan self-test: PASS")}
    {% else %}
      CANCEL_PRINT
      {action_respond_info("Part fan self-test: FAIL!")}
    {% endif %}
  {% endif %}

[gcode_macro PREFLIGHT_CHECK]
description: Use before print startup, checks the part fan for failures
gcode:
  M106 S128 ; turn on the part fan
  G4 P2000  ; wait for the fan to spin up
  M400
  PCF_CHECK ; check part fan speed
  M106 S0   ; turn off the part fan