-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbedfans.cfg
140 lines (117 loc) · 4.68 KB
/
bedfans.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
############### Config options ##################
[gcode_macro bedfanvars]
variable_threshold: 80 # If bed temp target is above this threshold, fans will be enabled. If temp is set to below this threshold, fans will be disabled.
variable_fast: 1.0 # Fan speed once bed temp is reached
variable_slow: 0.3 # Fan speed while bed is heating
variable_nm_fast: 1.0 # Fan speed once bed temp is reached
variable_nm_slow: 0.4 # Fan speed while bed is heating
variable_conv_fast: 1.0 # Fan speed once bed temp is reached
variable_conv_slow: 0.4 # Fan speed while bed is heating
gcode:
########## Aliases #########
[gcode_macro BedFansHeating]
gcode:
# Vars
{% set NM_SLOW = printer["gcode_macro bedfanvars"].nm_slow|float %}
{% set CONV_SLOW = printer["gcode_macro bedfanvars"].conv_slow|float %}
SET_FAN_SPEED FAN=BedFans SPEED=0
SET_FAN_SPEED FAN=Nevermore SPEED={NM_SLOW}
SET_FAN_SPEED FAN=Convection SPEED={CONV_SLOW}
[gcode_macro BedFansSlow]
gcode:
# Vars
{% set SLOW = printer["gcode_macro bedfanvars"].slow|float %}
{% set NM_SLOW = printer["gcode_macro bedfanvars"].nm_slow|float %}
{% set CONV_SLOW = printer["gcode_macro bedfanvars"].conv_slow|float %}
SET_FAN_SPEED FAN=BedFans SPEED={SLOW}
SET_FAN_SPEED FAN=Nevermore SPEED={NM_SLOW}
SET_FAN_SPEED FAN=Convection SPEED={CONV_SLOW}
[gcode_macro BedFansFast]
gcode:
# Vars
{% set FAST = printer["gcode_macro bedfanvars"].fast|float %}
{% set NM_FAST = printer["gcode_macro bedfanvars"].nm_fast|float %}
{% set CONV_FAST = printer["gcode_macro bedfanvars"].conv_fast|float %}
SET_FAN_SPEED FAN=BedFans SPEED={FAST}
SET_FAN_SPEED FAN=Nevermore SPEED={NM_FAST}
SET_FAN_SPEED FAN=Convection SPEED={CONV_FAST}
[gcode_macro BedFansOff]
gcode:
SET_FAN_SPEED FAN=BedFans SPEED=0
SET_FAN_SPEED FAN=Nevermore SPEED=0
SET_FAN_SPEED FAN=Convection SPEED=0
############ Command overrides ############
# Override, set fan speeds to low and start monitoring loop.
[gcode_macro SET_HEATER_TEMPERATURE]
rename_existing: _SET_HEATER_TEMPERATURE
gcode:
# Parameters
{% set HEATER = params.HEATER|default("None") %}
{% set TARGET = params.TARGET|default(0)|int %}
# Vars
{% set THRESHOLD = printer["gcode_macro bedfanvars"].threshold|int %}
{% if HEATER|lower == "extruder" %}
M104 S{TARGET}
{% elif HEATER|lower == "heater_bed" %}
M99140 S{TARGET}
{% else %}
{action_respond_info("Heater %s not supported" % HEATER)}
{% endif %}
# Set fans to low if heater_bed temp is requested above threshold temp, and kick off monitoring loop.
{% if HEATER|lower == "heater_bed" %}
{% if TARGET >= THRESHOLD %}
BedFansHeating
UPDATE_DELAYED_GCODE ID=bedfanloop DURATION=1
{% else %}
BedFansOff
UPDATE_DELAYED_GCODE ID=bedfanloop DURATION=0 # Cancel bed fan loop if it's running
{% endif %}
{% endif %}
# Override M190 (Wait for Bed Temperature)
# As a bonus, use TEMPERATURE_WAIT so we don't have to wait for PID to level off.
[gcode_macro M190]
rename_existing: M99190
gcode:
# Parameters
{% set S = params.S|int %}
# Vars
{% set THRESHOLD = printer["gcode_macro bedfanvars"].threshold|int %}
{% if S >= THRESHOLD %}
BedFansHeating # >= Threshold temp: Low speed fans while heating
{% else %}
BedFansOff # < Threshold temp: Turn bed fans off
{% endif %}
M140 {% for p in params
%}{'%s%s' % (p, params[p])}{%
endfor %} # Set bed temp
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM={S|int} MAXIMUM={S|int + 5} # Wait for bed temp within 5 degrees
# Post-heating fan speeds
{% if S >= THRESHOLD %}
BedFansFast # >= Threshold temp: Higher speed fans after heating finished
{% endif %}
# Replace M140 (Set Bed Temperature) to just be an alias of SET_HEATER_TEMPERATURE (which has associated bed fan logic if enabled)
[gcode_macro M140]
rename_existing: M99140
gcode:
# Parameters
{% set S = params.S|float %}
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={S}
# Replace TURN_OFF_HEATERS
[gcode_macro TURN_OFF_HEATERS]
rename_existing: _TURN_OFF_HEATERS
gcode:
BedFansOff
_TURN_OFF_HEATERS
################ Monitoring loop #####################
# Turns bed fans to "fast" speed once target bed temp is reached.
[delayed_gcode bedfanloop]
gcode:
# Vars
{% set THRESHOLD = printer["gcode_macro bedfanvars"].threshold|int %}
{% if printer.heater_bed.target >= THRESHOLD %} # Continue only if target temp greater than threshold.
{% if printer.heater_bed.temperature|int >= (printer.heater_bed.target|int - 1) %}
BedFansFast # If within 1 degree of target temp: Higher speed fans
{% else %}
UPDATE_DELAYED_GCODE ID=bedfanloop DURATION=5 # If temp not reached yet: loop again
{% endif %}
{% endif %}