forked from zellneralex/klipper_config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
printtime.cfg
171 lines (154 loc) · 7.08 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
168
169
170
171
#####################################################################
# 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:
##### get values of current print #####
{% set currenttime = printer.print_stats.total_duration %}
{% set currentprint = printer.print_stats.filament_used|float %}
##### get saved dictornary or initiate if not exist #####
{% if not printer.save_variables.variables.print_stats %}
{% set print_stats = {'time': {'total': currenttime, 'service': currenttime, 'filter': currenttime}, 'filament': currentprint}%}
{% else %}
{% set print_stats = printer.save_variables.variables.print_stats %}
{% set _dummy = print_stats.time.update({'total':(print_stats.time.total + currenttime)|int}) %}
{% set _dummy = print_stats.time.update({'service':(print_stats.time.service + currenttime)|int}) %}
{% set _dummy = print_stats.time.update({'filter':(print_stats.time.filter + currenttime)|int}) %}
{% set _dummy = print_stats.update({'filament':(print_stats.filament + currentprint)|float}) %}
{% endif %}
##### Save new values #####
SAVE_VARIABLE VARIABLE=print_stats VALUE="{print_stats}"
_DISPLAY_PRINT_TIME PREFIX=Took SECONDS={currenttime}
[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_ena.filter|lower== 'true' %}
{% 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:
{% 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")}
[gcode_macro RST_SERVICE]
description: Reset Service interval time
gcode:
{% 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")}
###########################################################################
# Display Menu #
# !!! Caution: Remove all below if you do not have a display defined !!! #
###########################################################################
[menu __main __statistic]
type: list
enable: {not printer.idle_timeout.state == "Printing" and 'printer.save_variables.variables.print_stats' in printer}
name: Satistic
[menu __main __statistic __totaltime]
type: command
enable: True
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=_CLEAR_DISPLAY DURATION=10
UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10
[menu __main __statistic __filament]
type: command
enable: True
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
enable: True
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=_CLEAR_DISPLAY DURATION=10
UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10
[menu __main __statistic __servicetime]
type: command
enable: True
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=_CLEAR_DISPLAY DURATION=10
UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10
[menu __main __statistic __rst_filter]
type: command
enable: True
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: True
name: Reset Service time
gcode:
{menu.exit()}
RST_SERVICE
UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10