forked from zellneralex/klipper_config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
printtime.cfg
167 lines (149 loc) · 7.05 KB
/
printtime.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#####################################################################
# Macro
#####################################################################
## This macro stores the variables
## must be added to PRINT_END - CANCEL_PRINT Macro
## works only with the use of virtual sd card!
[gcode_macro _ADD_PRINT_TIME]
description: Helper: Store print time values in variables
gcode:
{% set time = printer.print_stats.total_duration %}
{% set filament = printer.print_stats.filament_used|float %}
{% set filtertime = time if printer['gcode_macro PRINT_START'].var.filter else 0 %}
# update saved dictornary or initiate if not exist
{% if not printer.save_variables.variables.print_stats %}
{% set print_stats = {'time': {'total': time, 'service': time, 'filter': filtertime}, 'filament': filament}%}
{% else %}
{% set print_stats = printer.save_variables.variables.print_stats %}
{% set _dummy = print_stats.time.update({'total':(print_stats.time.total + time)|int}) %}
{% set _dummy = print_stats.time.update({'service':(print_stats.time.service + time)|int}) %}
{% set _dummy = print_stats.time.update({'filter':(print_stats.time.filter + filtertime)|int}) %}
{% set _dummy = print_stats.update({'filament':(print_stats.filament + filament)|float}) %}
{% endif %}
SAVE_VARIABLE VARIABLE=print_stats VALUE="{print_stats}"
[gcode_macro _DISPLAY_PRINT_TIME]
description: Helper: Print actual stored print time
gcode:
{% set totaltime = params.SECONDS|int if 'SECONDS' in params|upper
else printer.save_variables.variables.print_stats.time.total %}
{% set prefix = params.PREFIX|default('Total') %}
{% set h,m,s = (totaltime / 3600)|int, ((totaltime / 60) % 60)|int, (totaltime % 60)|int %}
{action_respond_info("Print time %s %d:%02d:%02d" % (prefix,h,m,s))}
M117 {prefix} {h}:{'%02d' % m}:{'%02d' % s}
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10
## used at PRINT_END and CANCEL_PRINT
[gcode_macro _SD_PRINT_STATS]
description: Helper: Print statistic of last print
gcode:
{% set PT = printer.print_stats.print_duration %}
{% set Ph,Pm,Ps = (PT / 3600)|int, ((PT / 60) % 60)|int, (PT % 60)|int %}
{% set TT = printer.print_stats.total_duration %}
{% set Th,Tm,Ts = (TT / 3600)|int, ((TT / 60) % 60)|int, (TT % 60)|int %}
{% set Fil = printer.print_stats.filament_used|float / 1000.0 %}
{action_respond_info("Statistic of last Print (%s):
Name: %s
Filament: %.4fm
Print Time: %d:%02d:%02d
Total Time: %d:%02d:%02d" %
(params.R, printer.print_stats.filename, Fil, Ph, Pm, Ps, Th, Tm, Ts))}
## used at PRINT_END and CANCEL_PRINT
[gcode_macro _SD_PRINTER_STATS]
description: Helper: Print statistic of printer
gcode:
{% set ST = printer.save_variables.variables.print_stats.time.service %}
{% set Sh,Sm,Ss = (ST / 3600)|int, ((ST / 60) % 60)|int, (ST % 60)|int %}
{% set TT = printer.save_variables.variables.print_stats.time.total %}
{% set Th,Tm,Ts = (TT / 3600)|int, ((TT / 60) % 60)|int, (TT % 60)|int %}
{% set FT = printer.save_variables.variables.print_stats.time.filter %}
{% set Fh,Fm,Fs = (FT / 3600)|int, ((FT / 60) % 60)|int, (FT % 60)|int %}
{% set Fil = printer.save_variables.variables.print_stats.filament|float / 1000.0 %}
{action_respond_info("Printer Statistics:
Total Print Time: %d:%02d:%02d
Total Filament used: %.4fm
Filter use time: %d:%02d:%02d
Time since last Service: %d:%02d:%02d" %
(Th, Tm, Ts, Fil, Fh, Fm, Fs, Sh, Sm, Ss))}
_CHECK_FILTER
[gcode_macro _CHECK_FILTER]
description: Helper: Print filter exchange warning
gcode:
{% if printer['gcode_macro _USER_VARIABLE'].hw.filter.ena and
printer.save_variables.variables.print_stats %}
{% set Fh = (printer.save_variables.variables.print_stats.time.filter / 3600)|int %}
{% if Fh >= printer['gcode_macro _USER_VARIABLE'].peripheral.filter.warning %}
M117 Change Filter!
{action_respond_info("Change Filter material at Micro!")}
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10
{% endif %}
{% endif %}
[gcode_macro RST_FILTER]
description: Reset Nevermore interval time
gcode:
{% if printer.save_variables.variables.print_stats %}
{% set print_stats = printer.save_variables.variables.print_stats %}
{% set _dummy = print_stats.time.update({'filter': 0}) %}
SAVE_VARIABLE VARIABLE=print_stats VALUE="{print_stats}"
{action_respond_info("Flter used time reseted to zero")}
{% endif %}
[gcode_macro RST_SERVICE]
description: Reset Service interval time
gcode:
{% if printer.save_variables.variables.print_stats %}
{% set print_stats = printer.save_variables.variables.print_stats %}
{% set _dummy = print_stats.time.update({'service': 0}) %}
SAVE_VARIABLE VARIABLE=print_stats VALUE="{print_stats}"
{action_respond_info("Time since last service reseted to zero")}
{% endif %}
# Display Menu
# !!! Caution: I use my own menu root __voron_main !!!
# If you use a stock menu un comment this here
#[menu __main __statistic]
#type: list
#enable: {'print_stats' in printer.save_variables.variables}
#name: Satistic
#[menu __main __statistic __totaltime]
#type: command
#name: Time of Operation
#gcode:
# {menu.exit()}
# _DISPLAY_PRINT_TIME PREFIX=Total SECONDS={printer.save_variables.variables.print_stats.time.total}
# UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10
#[menu __main __statistic __filament]
#type: command
#name: Total Filament used
#gcode:
# {menu.exit()}
# M117 Filerment {'%.4f' % (printer.save_variables.variables.print_stats.filament|float / 1000.0)}m
# {action_respond_info("Total Filament printed: %.4fm" % (printer.save_variables.variables.print_stats.filament|float / 1000.0))}
# UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10
# UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10
#[menu __main __statistic __filtertime]
#type: command
#name: Time since Filter change
#gcode:
# {menu.exit()}
# _DISPLAY_PRINT_TIME PREFIX=Filter SECONDS={printer.save_variables.variables.print_stats.time.filter}
# UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10
#[menu __main __statistic __servicetime]
#type: command
#name: Time since Service
#gcode:
# {menu.exit()}
# _DISPLAY_PRINT_TIME PREFIX=Service SECONDS={printer.save_variables.variables.print_stats.time.service}
# UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10
#[menu __main __statistic __rst_filter]
#type: command
#enable: {not (printer.print_stats.state == "printing" or printer.print_stats.state == "paused")}
#name: Reset Filter time
#gcode:
# {menu.exit()}
# RST_FILTER
# UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10
#[menu __main __statistic __rst_service]
#type: command
#enable: {not (printer.print_stats.state == "printing" or printer.print_stats.state == "paused")}
#name: Reset Service time
#gcode:
# {menu.exit()}
# RST_SERVICE
# UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10