-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfan_scale.cfg
More file actions
75 lines (60 loc) · 2.14 KB
/
fan_scale.cfg
File metadata and controls
75 lines (60 loc) · 2.14 KB
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
[gcode_macro M106]
description: Override M106 with scale/offset and optional override
rename_existing: M106.1
# How much to scale the value
variable_scale: 1.0
# Any offset to add to the fan, after the value is scaled.
variable_offset: 0.0
# Used at runtime to provide override.
# DO NOT MODIFY
variable_override_active: 0
variable_override_value: 0.0
gcode:
{% set s_raw = params.S|default(255)|int %}
{% if s_raw <= 0 %}
M107
{% else %}
{% set s_norm = s_raw / 255.0 %}
{% if override_active %}
{% set s_eff = override_value %}
{% else %}
{% set s_eff = (s_norm * scale) + offset %}
{% endif %}
{% if s_eff < 0.0 %}
{% set s_eff = 0.0 %}
{% endif %}
{% if s_eff > 1.0 %}
{% set s_eff = 1.0 %}
{% endif %}
M106.1 S{s_eff * 255.0}
{% endif %}
[gcode_macro TEST_FAN_TUNING]
# Test the scale and offset parametes of the overriden M106 fan macro.
# Also allows an override value to be set. If overridden, any value set on the fan
# will use the override value, except if 0 is set, 0 is written.
# Normal operation follows this formula: new_fan = (old_fan * SCALE) + OFFSET
#
# P A R A M E T E R S :
# SCALE: float to scale the fan with
# OFFSET: float to add after scaling
# OVERRIDE: float to set as raw speed (no scaling and offset!).
# Takes effect until this macro is called again *without* OVERRIDE.
# If the macro is called parameterless, it just clears any active overrride.
#
description: Live fan tuning and override control
gcode:
{% if 'SCALE' in params %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=scale VALUE={params.SCALE|float}
{% endif %}
{% if 'OFFSET' in params %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=offset VALUE={params.OFFSET|float}
{% endif %}
{% if 'OVERRIDE' in params %}
{% set ov = params.OVERRIDE|float %}
{% if ov < 0.0 %}{% set ov = 0.0 %}{% endif %}
{% if ov > 1.0 %}{% set ov = 1.0 %}{% endif %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=override_value VALUE={ov}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=override_active VALUE=1
{% else %}
SET_GCODE_VARIABLE MACRO=M106 VARIABLE=override_active VALUE=0
{% endif %}