## This is a simple include for the Nevermore. To use it with your printer, edit
## the pin definition in line 16 so it matches your printer.
## What you get:
## - a generic fan "Nevermore" which is adjustable in GCODE and in Mainsail/Fluidd
## - Commands in your 12864-controller to turn the fan on/off or adjust in 10%-steps
## - a Macro to turn the fan off some time after the print.
##
## Slicer integration: Add "SET_FAN_SPEED FAN=Nevermore SPEED=1" in your start-macro
## (or less fan depending on your needs, like SPEED=0.8)
## in your end print code, add "UPDATE_DELAYED_GCODE ID=filter_off DURATION=180"
## this keeps your Nevermore running for 180s after the print finishes to clean the chamber a bit more.

[fan_generic Nevermore]
## Nevermore - FAN5 on Octopus
## Adjust if you use a different board or a different terminal.
pin: PD13

[menu __main __control __nevermoreonoff]
type: command
name: Nevermore {'ON' if printer['fan_generic Nevermore'].speed > 0 else 'OFF'}
enable: {'fan_generic Nevermore' in printer}
gcode:
    TOGGLE_NEVERMORE

[menu __main __control __filterspeed]
type: input
enable: {'fan_generic Nevermore' in printer}
name: Filter %: {'%3d' % (menu.input*100)}%
input: {printer["fan_generic Nevermore"].speed}
input_min: 0
input_max: 1
input_step: 0.1
gcode:
    SET_FAN_SPEED FAN=Nevermore SPEED={menu.input}

[delayed_gcode filter_off]
gcode:
    SET_FAN_SPEED FAN=Nevermore SPEED=0

[gcode_macro TOGGLE_NEVERMORE]
gcode:
    {% if printer['fan_generic Nevermore'].speed > 0 %}
      SET_FAN_SPEED FAN=Nevermore SPEED=0
    {% else %}
      SET_FAN_SPEED FAN=Nevermore SPEED=1
    {% endif %}