-
Notifications
You must be signed in to change notification settings - Fork 0
/
heatsoak.cfg
113 lines (103 loc) · 4.44 KB
/
heatsoak.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
[respond]
[gcode_macro HEAT_SOAK]
description: heats the bed for a while
variable_target_temp: 0
variable_stage: None ## heating -> soaking -> done -> None
## in seconds
variable_check_interval: 10
variable_soak_time_remaining: 0
variable_total_time_elapsed: 0
variable_output: 118
gcode:
{% set soak_macro = printer["gcode_macro HEAT_SOAK"] %} {% set TARGET = params.TARGET | default(110) | float %}
{% set DURATION = (params.DURATION | default(10) | int) * 60 %} ## minutes to seconds
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=target_temp VALUE={ TARGET }
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=stage VALUE="'heating'"
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=soak_time_remaining VALUE={ DURATION }
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=total_time_elapsed VALUE=0
;; fire up the heater
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={ TARGET }
;; Do the lights
#STATUS_SOAKING
;; run the fans to circulate air
_FAN_SOAK
;; home the printer
G28
;; put the bed and nozzle where they're a safe distance apart
#PARKBED_MID
M84 ;; turn off steppers
;; Do the lights (again)
#STATUS_SOAKING
M{soak_macro.output|int} Soaking...
UPDATE_DELAYED_GCODE ID=heat_soaker DURATION={ check_interval }
[gcode_macro CANCEL_HEAT_SOAK]
description: cancels an in-progress HEAT_SOAK cycle
gcode:
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=stage VALUE="'cancel'"
UPDATE_DELAYED_GCODE ID=heat_soaker DURATION=1
[delayed_gcode heat_soaker]
; ## debug
; { action_respond_info( printer['gcode_macro HEAT_SOAK'] | tojson )}
gcode:
{% set soak_macro = printer["gcode_macro HEAT_SOAK"] %} {% set heat_soak = printer['gcode_macro HEAT_SOAK'] %}
## update total time elapsed
{% set total_time_elapsed = heat_soak.total_time_elapsed + heat_soak.check_interval %}
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=total_time_elapsed VALUE={ total_time_elapsed }
{% set stage = heat_soak.stage %}
{% if stage == "heating" and printer.heater_bed.temperature >= heat_soak.target_temp %}
{% set stage = "soaking" %}
{% endif %}
{% if stage == "soaking" %}
## update soak countdown
{% set soak_time_remaining = [heat_soak.soak_time_remaining - heat_soak.check_interval, 0] | max %}
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=soak_time_remaining VALUE={ soak_time_remaining }
{% if soak_time_remaining == 0 %}
{% set stage = "done" %}
{% endif %}
{% endif %}
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=stage VALUE="'{ stage }'"
{% if stage in ("done", "cancel") %}
#STATUS_READY
_FAN_SOAK_OFF
{% if stage == "cancel" %}
{% set stage = "done" %}
TURN_OFF_HEATERS
M107 ; turn off fan
M{soak_macro.output|int} { "soak cancelled after ~%.1fm" | format(total_time_elapsed / 60.0) }
#game_over_tune
{% else %}
M{soak_macro.output|int} { "soak complete after %.1fm" | format(total_time_elapsed / 60.0) }
#zelda_end_tune
{% endif %}
## reset all state vars, except stage, which may be queried via the api
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=target_temp VALUE=0
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=soak_time_remaining VALUE=0
SET_GCODE_VARIABLE MACRO=HEAT_SOAK VARIABLE=total_time_elapsed VALUE=0
{% else %}
{% set BED_TARGET = printer.heater_bed.target|float %}
{% set BED_TEMP = printer.heater_bed.temperature|float %}
{% set BED_PROGRESS = (BED_TEMP / BED_TARGET) * 255 %}
#WLED_CONTROL INTENSITY={BED_PROGRESS}
{% if total_time_elapsed % 90 == 0 %}
## output status periodically
{% if stage == "heating" %}
M{soak_macro.output|int} { "heating -- %.1fm elapsed" | format(total_time_elapsed / 60.0) }
{% elif stage == "soaking" %}
M{soak_macro.output|int} { "soaking -- %.1fm remaining" | format(soak_time_remaining / 60.0) }
{% endif %}
{% endif %}
## trigger ourselves again
UPDATE_DELAYED_GCODE ID=heat_soaker DURATION={ heat_soak.check_interval }
## dwell for 1ms to prevent from going idle
G4 P1
{% endif %}
[gcode_macro _FAN_SOAK]
gcode:
#NEVERMORE_LOW
#BED_FAN_ON
#PI_FAN_ON
#SYSTEM_FAN_ON
[gcode_macro _FAN_SOAK_OFF]
gcode:
#NEVERMORE_OFF
#BED_FAN_OFF