|
@@ -298,8 +298,7 @@ const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
|
298
|
298
|
millis_t previous_cmd_ms = 0;
|
299
|
299
|
static millis_t max_inactive_time = 0;
|
300
|
300
|
static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000L;
|
301
|
|
-millis_t print_job_start_ms = 0; ///< Print job start time
|
302
|
|
-millis_t print_job_stop_ms = 0; ///< Print job stop time
|
|
301
|
+Stopwatch print_job_timer = Stopwatch();
|
303
|
302
|
static uint8_t target_extruder;
|
304
|
303
|
|
305
|
304
|
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
|
|
@@ -1011,9 +1010,9 @@ inline void get_serial_commands() {
|
1011
|
1010
|
) {
|
1012
|
1011
|
if (card_eof) {
|
1013
|
1012
|
SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED);
|
1014
|
|
- print_job_stop(true);
|
|
1013
|
+ print_job_timer.stop();
|
1015
|
1014
|
char time[30];
|
1016
|
|
- millis_t t = print_job_timer();
|
|
1015
|
+ millis_t t = print_job_timer.duration();
|
1017
|
1016
|
int hours = t / 60 / 60, minutes = (t / 60) % 60;
|
1018
|
1017
|
sprintf_P(time, PSTR("%i " MSG_END_HOUR " %i " MSG_END_MINUTE), hours, minutes);
|
1019
|
1018
|
SERIAL_ECHO_START;
|
|
@@ -3571,7 +3570,7 @@ inline void gcode_M17() {
|
3571
|
3570
|
*/
|
3572
|
3571
|
inline void gcode_M24() {
|
3573
|
3572
|
card.startFileprint();
|
3574
|
|
- print_job_start();
|
|
3573
|
+ print_job_timer.start();
|
3575
|
3574
|
}
|
3576
|
3575
|
|
3577
|
3576
|
/**
|
|
@@ -3627,7 +3626,7 @@ inline void gcode_M17() {
|
3627
|
3626
|
* M31: Get the time since the start of SD Print (or last M109)
|
3628
|
3627
|
*/
|
3629
|
3628
|
inline void gcode_M31() {
|
3630
|
|
- millis_t t = print_job_timer();
|
|
3629
|
+ millis_t t = print_job_timer.duration();
|
3631
|
3630
|
int min = t / 60, sec = t % 60;
|
3632
|
3631
|
char time[30];
|
3633
|
3632
|
sprintf_P(time, PSTR("%i min, %i sec"), min, sec);
|
|
@@ -3663,7 +3662,7 @@ inline void gcode_M31() {
|
3663
|
3662
|
card.startFileprint();
|
3664
|
3663
|
|
3665
|
3664
|
// Procedure calls count as normal print time.
|
3666
|
|
- if (!call_procedure) print_job_start();
|
|
3665
|
+ if (!call_procedure) print_job_timer.start();
|
3667
|
3666
|
}
|
3668
|
3667
|
}
|
3669
|
3668
|
|
|
@@ -4031,15 +4030,33 @@ inline void gcode_M42() {
|
4031
|
4030
|
#endif // AUTO_BED_LEVELING_FEATURE && Z_MIN_PROBE_REPEATABILITY_TEST
|
4032
|
4031
|
|
4033
|
4032
|
/**
|
|
4033
|
+ * M75: Start print timer
|
|
4034
|
+ */
|
|
4035
|
+inline void gcode_M75() {
|
|
4036
|
+ print_job_timer.start();
|
|
4037
|
+}
|
|
4038
|
+
|
|
4039
|
+/**
|
|
4040
|
+ * M76: Pause print timer
|
|
4041
|
+ */
|
|
4042
|
+inline void gcode_M76() {
|
|
4043
|
+ print_job_timer.pause();
|
|
4044
|
+}
|
|
4045
|
+
|
|
4046
|
+/**
|
|
4047
|
+ * M77: Stop print timer
|
|
4048
|
+ */
|
|
4049
|
+inline void gcode_M77() {
|
|
4050
|
+ print_job_timer.stop();
|
|
4051
|
+}
|
|
4052
|
+
|
|
4053
|
+/**
|
4034
|
4054
|
* M104: Set hot end temperature
|
4035
|
4055
|
*/
|
4036
|
4056
|
inline void gcode_M104() {
|
4037
|
4057
|
if (setTargetedHotend(104)) return;
|
4038
|
4058
|
if (DEBUGGING(DRYRUN)) return;
|
4039
|
4059
|
|
4040
|
|
- // Start hook must happen before setTargetHotend()
|
4041
|
|
- print_job_start();
|
4042
|
|
-
|
4043
|
4060
|
if (code_seen('S')) {
|
4044
|
4061
|
float temp = code_value();
|
4045
|
4062
|
setTargetHotend(temp, target_extruder);
|
|
@@ -4048,10 +4065,24 @@ inline void gcode_M104() {
|
4048
|
4065
|
setTargetHotend1(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset);
|
4049
|
4066
|
#endif
|
4050
|
4067
|
|
|
4068
|
+ /**
|
|
4069
|
+ * We use half EXTRUDE_MINTEMP here to allow nozzles to be put into hot
|
|
4070
|
+ * stand by mode, for instance in a dual extruder setup, without affecting
|
|
4071
|
+ * the running print timer.
|
|
4072
|
+ */
|
|
4073
|
+ if (temp <= (EXTRUDE_MINTEMP)/2) {
|
|
4074
|
+ print_job_timer.stop();
|
|
4075
|
+ LCD_MESSAGEPGM(WELCOME_MSG);
|
|
4076
|
+ }
|
|
4077
|
+ /**
|
|
4078
|
+ * We do not check if the timer is already running because this check will
|
|
4079
|
+ * be done for us inside the Stopwatch::start() method thus a running timer
|
|
4080
|
+ * will not restart.
|
|
4081
|
+ */
|
|
4082
|
+ else print_job_timer.start();
|
|
4083
|
+
|
4051
|
4084
|
if (temp > degHotend(target_extruder)) LCD_MESSAGEPGM(MSG_HEATING);
|
4052
|
4085
|
}
|
4053
|
|
-
|
4054
|
|
- if (print_job_stop()) LCD_MESSAGEPGM(WELCOME_MSG);
|
4055
|
4086
|
}
|
4056
|
4087
|
|
4057
|
4088
|
#if HAS_TEMP_HOTEND || HAS_TEMP_BED
|
|
@@ -4179,9 +4210,6 @@ inline void gcode_M109() {
|
4179
|
4210
|
if (setTargetedHotend(109)) return;
|
4180
|
4211
|
if (DEBUGGING(DRYRUN)) return;
|
4181
|
4212
|
|
4182
|
|
- // Start hook must happen before setTargetHotend()
|
4183
|
|
- print_job_start();
|
4184
|
|
-
|
4185
|
4213
|
no_wait_for_cooling = code_seen('S');
|
4186
|
4214
|
if (no_wait_for_cooling || code_seen('R')) {
|
4187
|
4215
|
float temp = code_value();
|
|
@@ -4191,11 +4219,25 @@ inline void gcode_M109() {
|
4191
|
4219
|
setTargetHotend1(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset);
|
4192
|
4220
|
#endif
|
4193
|
4221
|
|
|
4222
|
+ /**
|
|
4223
|
+ * We use half EXTRUDE_MINTEMP here to allow nozzles to be put into hot
|
|
4224
|
+ * stand by mode, for instance in a dual extruder setup, without affecting
|
|
4225
|
+ * the running print timer.
|
|
4226
|
+ */
|
|
4227
|
+ if (temp <= (EXTRUDE_MINTEMP)/2) {
|
|
4228
|
+ print_job_timer.stop();
|
|
4229
|
+ LCD_MESSAGEPGM(WELCOME_MSG);
|
|
4230
|
+ }
|
|
4231
|
+ /**
|
|
4232
|
+ * We do not check if the timer is already running because this check will
|
|
4233
|
+ * be done for us inside the Stopwatch::start() method thus a running timer
|
|
4234
|
+ * will not restart.
|
|
4235
|
+ */
|
|
4236
|
+ else print_job_timer.start();
|
|
4237
|
+
|
4194
|
4238
|
if (temp > degHotend(target_extruder)) LCD_MESSAGEPGM(MSG_HEATING);
|
4195
|
4239
|
}
|
4196
|
4240
|
|
4197
|
|
- if (print_job_stop()) LCD_MESSAGEPGM(WELCOME_MSG);
|
4198
|
|
-
|
4199
|
4241
|
#if ENABLED(AUTOTEMP)
|
4200
|
4242
|
autotemp_enabled = code_seen('F');
|
4201
|
4243
|
if (autotemp_enabled) autotemp_factor = code_value();
|
|
@@ -6223,6 +6265,18 @@ void process_next_command() {
|
6223
|
6265
|
break;
|
6224
|
6266
|
#endif // AUTO_BED_LEVELING_FEATURE && Z_MIN_PROBE_REPEATABILITY_TEST
|
6225
|
6267
|
|
|
6268
|
+ case 75: // Start print timer
|
|
6269
|
+ gcode_M75();
|
|
6270
|
+ break;
|
|
6271
|
+
|
|
6272
|
+ case 76: // Pause print timer
|
|
6273
|
+ gcode_M76();
|
|
6274
|
+ break;
|
|
6275
|
+
|
|
6276
|
+ case 77: // Stop print timer
|
|
6277
|
+ gcode_M77();
|
|
6278
|
+ break;
|
|
6279
|
+
|
6226
|
6280
|
#if ENABLED(M100_FREE_MEMORY_WATCHER)
|
6227
|
6281
|
case 100:
|
6228
|
6282
|
gcode_M100();
|
|
@@ -7639,50 +7693,3 @@ void calculate_volumetric_multipliers() {
|
7639
|
7693
|
for (int i = 0; i < EXTRUDERS; i++)
|
7640
|
7694
|
volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
|
7641
|
7695
|
}
|
7642
|
|
-
|
7643
|
|
-/**
|
7644
|
|
- * Start the print job timer
|
7645
|
|
- *
|
7646
|
|
- * The print job is only started if all extruders have their target temp at zero
|
7647
|
|
- * otherwise the print job timew would be reset everytime a M109 is received.
|
7648
|
|
- *
|
7649
|
|
- * @param t start timer timestamp
|
7650
|
|
- *
|
7651
|
|
- * @return true if the timer was started at function call
|
7652
|
|
- */
|
7653
|
|
-bool print_job_start(millis_t t /* = 0 */) {
|
7654
|
|
- for (int i = 0; i < EXTRUDERS; i++) if (degTargetHotend(i) > 0) return false;
|
7655
|
|
- print_job_start_ms = (t) ? t : millis();
|
7656
|
|
- print_job_stop_ms = 0;
|
7657
|
|
- return true;
|
7658
|
|
-}
|
7659
|
|
-
|
7660
|
|
-/**
|
7661
|
|
- * Check if the running print job has finished and stop the timer
|
7662
|
|
- *
|
7663
|
|
- * When the target temperature for all extruders is zero then we assume that the
|
7664
|
|
- * print job has finished printing. There are some special conditions under which
|
7665
|
|
- * this assumption may not be valid: If during a print job for some reason the
|
7666
|
|
- * user decides to bring a nozzle temp down and only then heat the other afterwards.
|
7667
|
|
- *
|
7668
|
|
- * @param force stops the timer ignoring all pre-checks
|
7669
|
|
- *
|
7670
|
|
- * @return boolean true if the print job has finished printing
|
7671
|
|
- */
|
7672
|
|
-bool print_job_stop(bool force /* = false */) {
|
7673
|
|
- if (!print_job_start_ms) return false;
|
7674
|
|
- if (!force) for (int i = 0; i < EXTRUDERS; i++) if (degTargetHotend(i) > 0) return false;
|
7675
|
|
- print_job_stop_ms = millis();
|
7676
|
|
- return true;
|
7677
|
|
-}
|
7678
|
|
-
|
7679
|
|
-/**
|
7680
|
|
- * Output the print job timer in seconds
|
7681
|
|
- *
|
7682
|
|
- * @return the number of seconds
|
7683
|
|
- */
|
7684
|
|
-millis_t print_job_timer() {
|
7685
|
|
- if (!print_job_start_ms) return 0;
|
7686
|
|
- return (((print_job_stop_ms > print_job_start_ms)
|
7687
|
|
- ? print_job_stop_ms : millis()) - print_job_start_ms) / 1000;
|
7688
|
|
-}
|