From dab18e13f61f826516b65b93753c9875b8f9baf7 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Wed, 3 Jan 2024 03:03:10 +0700 Subject: [PATCH] enclosure fan control --- printer.cfg | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/printer.cfg b/printer.cfg index 4ab8fa9..b3aee79 100644 --- a/printer.cfg +++ b/printer.cfg @@ -294,7 +294,7 @@ activate_gcode: # Fan Control ##################################################################### -[fan] +[fan_generic part_cooling_fan] ## Print Cooling Fan - CNC_FAN0 pin: !PA4 kick_start_time: 0 @@ -492,12 +492,15 @@ gcode: [gcode_macro M106] gcode: # P0: Part cooling fan, P3: Exhaust fan - {% if params.P == 0 %} - M106 S{ (params.S | int) } - {% elif params.P == 3 %} - SET_FAN_SPEED FAN=exhaust_fan SPEED={ (params.S | int)/255.0 } - {% endif %} - + # If no P parameter is given, assume Part Cooling Fan + {% set speed = (params.S|float / 255 if params.S is defined else 1.0) %} + {% set fan_id = (params.P)|int if params.P is defined else 0 %} + {% if fan_id == 0 %} + SET_FAN_SPEED FAN=part_cooling_fan SPEED={speed} + {% elif fan_id == 3 %} + SET_FAN_SPEED FAN=exhaust_fan SPEED={speed} + {% endif %} + #*# <---------------------- SAVE_CONFIG ----------------------> #*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated. #*# @@ -512,4 +515,4 @@ gcode: #*# #*# [extruder] #*# -#*# [heater_bed] +#*# [heater_bed] \ No newline at end of file