-
Notifications
You must be signed in to change notification settings - Fork 17
/
printtime.cfg
73 lines (68 loc) · 3.24 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
#####################################################################
# File location of stored varibales
######################################################################
[save_variables]
filename: /home/pi/klipper_config/.variables.stb
#####################################################################
# Macro
#####################################################################
## this macro adds the current time to the 3 storage variables
## must be added to PRINT_END - CANCEL_PRINT Macro
## works only with the use of virtual sd card!
[gcode_macro _ADD_PRINT_TIME]
gcode:
# set the variable to zero if the value is not defined yet
{% if not printer.save_variables.variables.totalprintingtime %}
SAVE_VARIABLE VARIABLE=totalprintingtime VALUE=0
{% endif %}
{% if not printer.save_variables.variables.lastservicetime %}
SAVE_VARIABLE VARIABLE=lastservicetime VALUE=0
{% endif %}
{% if not printer.save_variables.variables.filament_used %}
SAVE_VARIABLE VARIABLE=filament_used VALUE=0.0
{% endif %}
{% set totaltime = printer.save_variables.variables.totalprintingtime %}
{% set lastservice = printer.save_variables.variables.lastservicetime %}
{% set filament = printer.save_variables.variables.filament_used|float %}
{% set currenttime = printer.print_stats.total_duration %}
{% set currentprint = printer.print_stats.filament_used|float %}
SAVE_VARIABLE VARIABLE=totalprintingtime VALUE={(totaltime + currenttime)|int}
SAVE_VARIABLE VARIABLE=lastservicetime VALUE={(lastservice + currenttime)|int}
SAVE_VARIABLE VARIABLE=filament_used VALUE={(filament + currentprint)|float}
[gcode_macro _SD_PRINT_STATS]
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]
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 Fil = printer.save_variables.variables.filament_used|float / 1000.0 %}
{action_respond_info("Printer Statistic:
Total Print Time: %d:%02d:%02d
Total Filament used: %.4fm
Time since last Service: %d:%02d:%02d" %
(Th|int, Tm|int, Ts|int, Fil, Sh|int, Sm|int, Ss|int))}