forked from zellneralex/klipper_config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprinttime.cfg
193 lines (175 loc) · 6.96 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#####################################################################
# 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 saved values or initiate if not exist #####
{% if not printer.save_variables.variables.totalprintingtime %}
{% set totaltime = 0 %}
{% else %}
{% set totaltime = printer.save_variables.variables.totalprintingtime %}
{% endif %}
{% if not printer.save_variables.variables.lastservicetime %}
{% set lastservice = 0 %}
{% else %}
{% set lastservice = printer.save_variables.variables.lastservicetime %}
{% endif %}
{% if not printer.save_variables.variables.filament_used %}
{% set filament = 0.0 %}
{% else %}
{% set filament = printer.save_variables.variables.filament_used|float %}
{% endif %}
{% if not printer.save_variables.variables.filterusetime %}
{% set filteruse = 0.0 %}
{% else %}
{% set filteruse = printer.save_variables.variables.filterusetime|float %}
{% endif %}
##### get values of current print #####
{% set currenttime = printer.print_stats.total_duration %}
{% set currentprint = printer.print_stats.filament_used|float %}
##### Save new values #####
SAVE_VARIABLE VARIABLE=totalprintingtime VALUE={(totaltime + currenttime)|int}
SAVE_VARIABLE VARIABLE=lastservicetime VALUE={(lastservice + currenttime)|int}
SAVE_VARIABLE VARIABLE=filterusetime VALUE={(filteruse + currenttime)|int}
SAVE_VARIABLE VARIABLE=filament_used VALUE={(filament + currentprint)|float}
_DISPLAY_PRINT_TIME PREFIX=Took SECONDS={currenttime}
[gcode_macro _DISPLAY_PRINT_TIME]
description: Helper: Print actual stored print time
gcode:
# set default parameter value
{% set totaltime = params.SECONDS|default(-1)|int %}
{% set prefix = params.PREFIX|default(Total) %}
{% if totaltime == -1 %}
{% set totaltime = printer.save_variables.variables.totalprintingtime %}
{% endif %}
{% set hours = (totaltime / 3600)|int %}
{% set minutes = ((totaltime / 60) % 60)|int %}
{% set seconds = (totaltime % 60)|int %}
{action_respond_info("Print time %s %d:%02d:%02d" % (prefix|string,hours|int,minutes|int,seconds|int))}
M117 {prefix} {hours}:{'%02d' % (minutes|int)}:{'%02d' % (seconds|int)}
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10
[gcode_macro _SD_PRINT_STATS]
description: Helper: Print statistic of last print
gcode:
## output of data of the last print
## used at PRINT_END and CANCEL_PRINT
{% set PT = printer.print_stats.print_duration %}
{% set Ph = (PT / 3600)|int %}
{% set Pm = ((PT / 60) % 60)|int %}
{% set Ps = (PT % 60)|int %}
{% set TT = printer.print_stats.total_duration %}
{% set Th = (TT / 3600)|int %}
{% set Tm = ((TT / 60) % 60)|int %}
{% set Ts = (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|int, Pm|int, Ps|int, Th|int, Tm|int, Ts|int))}
[gcode_macro _SD_PRINTER_STATS]
description: Helper: Print statistic of printer
gcode:
## output data of the stoared statis
## use e.g at PRINT_END and CANCEL_PRINT
{% set ST= printer.save_variables.variables.lastservicetime %}
{% set Sh = (ST / 3600)|int %}
{% set Sm = ((ST / 60) % 60)|int %}
{% set Ss = (ST % 60)|int %}
{% set TT = printer.save_variables.variables.totalprintingtime %}
{% set Th = (TT / 3600)|int %}
{% set Tm = ((TT / 60) % 60)|int %}
{% set Ts = (TT % 60)|int %}
{% set FT = printer.save_variables.variables.filterusetime %}
{% set Fh = (FT / 3600)|int %}
{% set Fm = ((FT / 60) % 60)|int %}
{% set Fs = (FT % 60)|int %}
{% set Fil = printer.save_variables.variables.filament_used|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|int, Tm|int, Ts|int, Fil, Fh|int, Fm|int, Fs|int, Sh|int, Sm|int, Ss|int))}
{% if printer['gcode_macro _USER_VARIABLE'].filter|lower == 'true' %}
UPDATE_DELAYED_GCODE ID=_CHECK_FILTER DURATION=1
{% endif %}
[delayed_gcode _CHECK_FILTER]
initial_duration: 5
gcode:
{% if printer['gcode_macro _USER_VARIABLE'].filter|lower == 'true' %}
## Micro need exchange every 80h
{% set Fh = (printer.save_variables.variables.filterusetime / 3600)|int %}
{% if Fh|int >= printer['gcode_macro _USER_VARIABLE'].filter_use_time|int %}
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:
SAVE_VARIABLE VARIABLE=filterusetime VALUE=0
{action_respond_info("Flter used time reseted to zero")}
[gcode_macro RST_SERVICE]
description: Reset Service interval time
gcode:
SAVE_VARIABLE VARIABLE=lastservicetime VALUE=0
{action_respond_info("Time since last service reseted to zero")}
### klipper display menu statistic ###
[menu __main __statistic]
type: list
enable: {not printer.idle_timeout.state == "Printing" and 'save_variables' 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.totalprintingtime}
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10
[menu __main __statistic __filament]
type: command
enable: True
name: Total Filament used
gcode:
{menu.exit()}
M117 Filerment {'%.4f' % (printer.print_stats.filament_used|float / 1000.0)}m
{action_respond_info("Total Filament printed: %.4fm" % (printer.print_stats.filament_used|float / 1000.0))}
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY 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.filterusetime}
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY 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.lastservicetime}
UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10
[menu __main __statistic __rst_filter]
type: command
enable: True
name: Reset Filter time
gcode:
{menu.exit()}
RST_FILTER
[menu __main __statistic __rst_service]
type: command
enable: True
name: Reset Service time
gcode:
{menu.exit()}
RST_SERVICE