Skip to content

Instantly share code, notes, and snippets.

@ShaneDelmore
Last active March 11, 2025 23:46
Show Gist options
  • Select an option

  • Save ShaneDelmore/fe4f68d3a1a0c643ca43f5a1b29d8774 to your computer and use it in GitHub Desktop.

Select an option

Save ShaneDelmore/fe4f68d3a1a0c643ca43f5a1b29d8774 to your computer and use it in GitHub Desktop.
Add fan and accel multipliers to Klipper/Mainsail

Install klipper-virtual-pins

bash
cd ~
git clone https://github.com/pedrolamas/klipper-virtual-pins.git
./klipper-virtual-pins/install.sh

Add virtual pin to printer.cfg

[virtual_pins]

[output_pin fan_multiplier]
pin: virtual_pin:fan_multiplier
pwm: True
value: 1.0

Configure M106 to use fan_multiplier

[gcode_macro M106]
rename_existing: M106.1
gcode:
  {% set S = params.S|default(0)|int %}
  {% set P = params.P|default(0)|int %}
  {% set MULTIPLIER = printer['output_pin fan_multiplier'].value %}
  {% set ADJUSTED_S = (S * MULTIPLIER)|round(0)|int %}
  M106.1 P{P} S{ADJUSTED_S}
@ShaneDelmore
Copy link
Author

If you want to get fancy you could add a moonraker hook to listen to changes to the factor pins and immediately recalculate fan speed and accel but I only use these when my sliced file is changing them rapidly so they get recalculated when those change pretty quickly anyway.

@ShaneDelmore
Copy link
Author

This was tested on an FLSun T1 Pro running klipper 10. You may need slight changes on different versions of klipper or other printers but hopefully the idea is still helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment