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