|
@@ -977,9 +977,9 @@ void get_command() {
|
977
|
977
|
) {
|
978
|
978
|
if (card_eof) {
|
979
|
979
|
SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED);
|
980
|
|
- print_job_stop_ms = millis();
|
|
980
|
+ print_job_stop(true);
|
981
|
981
|
char time[30];
|
982
|
|
- millis_t t = (print_job_stop_ms - print_job_start_ms) / 1000;
|
|
982
|
+ millis_t t = print_job_timer();
|
983
|
983
|
int hours = t / 60 / 60, minutes = (t / 60) % 60;
|
984
|
984
|
sprintf_P(time, PSTR("%i " MSG_END_HOUR " %i " MSG_END_MINUTE), hours, minutes);
|
985
|
985
|
SERIAL_ECHO_START;
|
|
@@ -3454,7 +3454,7 @@ inline void gcode_M17() {
|
3454
|
3454
|
*/
|
3455
|
3455
|
inline void gcode_M24() {
|
3456
|
3456
|
card.startFileprint();
|
3457
|
|
- print_job_start_ms = millis();
|
|
3457
|
+ print_job_start();
|
3458
|
3458
|
}
|
3459
|
3459
|
|
3460
|
3460
|
/**
|
|
@@ -3510,8 +3510,7 @@ inline void gcode_M17() {
|
3510
|
3510
|
* M31: Get the time since the start of SD Print (or last M109)
|
3511
|
3511
|
*/
|
3512
|
3512
|
inline void gcode_M31() {
|
3513
|
|
- print_job_stop_ms = millis();
|
3514
|
|
- millis_t t = (print_job_stop_ms - print_job_start_ms) / 1000;
|
|
3513
|
+ millis_t t = print_job_timer();
|
3515
|
3514
|
int min = t / 60, sec = t % 60;
|
3516
|
3515
|
char time[30];
|
3517
|
3516
|
sprintf_P(time, PSTR("%i min, %i sec"), min, sec);
|
|
@@ -3545,8 +3544,9 @@ inline void gcode_M31() {
|
3545
|
3544
|
card.setIndex(code_value_short());
|
3546
|
3545
|
|
3547
|
3546
|
card.startFileprint();
|
3548
|
|
- if (!call_procedure)
|
3549
|
|
- print_job_start_ms = millis(); //procedure calls count as normal print time.
|
|
3547
|
+
|
|
3548
|
+ // Procedure calls count as normal print time.
|
|
3549
|
+ if (!call_procedure) print_job_start();
|
3550
|
3550
|
}
|
3551
|
3551
|
}
|
3552
|
3552
|
|
|
@@ -3884,6 +3884,8 @@ inline void gcode_M104() {
|
3884
|
3884
|
setTargetHotend1(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset);
|
3885
|
3885
|
#endif
|
3886
|
3886
|
}
|
|
3887
|
+
|
|
3888
|
+ print_job_stop();
|
3887
|
3889
|
}
|
3888
|
3890
|
|
3889
|
3891
|
#if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675)
|
|
@@ -4008,11 +4010,12 @@ inline void gcode_M105() {
|
4008
|
4010
|
inline void gcode_M109() {
|
4009
|
4011
|
bool no_wait_for_cooling = true;
|
4010
|
4012
|
|
|
4013
|
+ // Start hook must happen before setTargetHotend()
|
|
4014
|
+ print_job_start();
|
|
4015
|
+
|
4011
|
4016
|
if (setTargetedHotend(109)) return;
|
4012
|
4017
|
if (marlin_debug_flags & DEBUG_DRYRUN) return;
|
4013
|
4018
|
|
4014
|
|
- LCD_MESSAGEPGM(MSG_HEATING);
|
4015
|
|
-
|
4016
|
4019
|
no_wait_for_cooling = code_seen('S');
|
4017
|
4020
|
if (no_wait_for_cooling || code_seen('R')) {
|
4018
|
4021
|
float temp = code_value();
|
|
@@ -4021,8 +4024,12 @@ inline void gcode_M109() {
|
4021
|
4024
|
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
|
4022
|
4025
|
setTargetHotend1(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset);
|
4023
|
4026
|
#endif
|
|
4027
|
+
|
|
4028
|
+ if (temp > degHotend(target_extruder)) LCD_MESSAGEPGM(MSG_HEATING);
|
4024
|
4029
|
}
|
4025
|
4030
|
|
|
4031
|
+ if (print_job_stop()) LCD_MESSAGEPGM(WELCOME_MSG);
|
|
4032
|
+
|
4026
|
4033
|
#if ENABLED(AUTOTEMP)
|
4027
|
4034
|
autotemp_enabled = code_seen('F');
|
4028
|
4035
|
if (autotemp_enabled) autotemp_factor = code_value();
|
|
@@ -4082,7 +4089,6 @@ inline void gcode_M109() {
|
4082
|
4089
|
} // while(!cancel_heatup && TEMP_CONDITIONS)
|
4083
|
4090
|
|
4084
|
4091
|
LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
|
4085
|
|
- print_job_start_ms = previous_cmd_ms;
|
4086
|
4092
|
}
|
4087
|
4093
|
|
4088
|
4094
|
#if HAS_TEMP_BED
|
|
@@ -7398,3 +7404,50 @@ void calculate_volumetric_multipliers() {
|
7398
|
7404
|
for (int i = 0; i < EXTRUDERS; i++)
|
7399
|
7405
|
volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
|
7400
|
7406
|
}
|
|
7407
|
+
|
|
7408
|
+/**
|
|
7409
|
+ * Start the print job timer
|
|
7410
|
+ *
|
|
7411
|
+ * The print job is only started if all extruders have their target temp at zero
|
|
7412
|
+ * otherwise the print job timew would be reset everytime a M109 is received.
|
|
7413
|
+ *
|
|
7414
|
+ * @param t start timer timestamp
|
|
7415
|
+ *
|
|
7416
|
+ * @return true if the timer was started at function call
|
|
7417
|
+ */
|
|
7418
|
+bool print_job_start(millis_t t /* = 0 */) {
|
|
7419
|
+ for (int i = 0; i < EXTRUDERS; i++) if (degTargetHotend(i) > 0) return false;
|
|
7420
|
+ print_job_start_ms = (t) ? t : millis();
|
|
7421
|
+ print_job_stop_ms = 0;
|
|
7422
|
+ return true;
|
|
7423
|
+}
|
|
7424
|
+
|
|
7425
|
+/**
|
|
7426
|
+ * Output the print job timer in seconds
|
|
7427
|
+ *
|
|
7428
|
+ * @return the number of seconds
|
|
7429
|
+ */
|
|
7430
|
+millis_t print_job_timer() {
|
|
7431
|
+ if (!print_job_start_ms) return 0;
|
|
7432
|
+ return (((print_job_stop_ms > print_job_start_ms)
|
|
7433
|
+ ? print_job_stop_ms : millis()) - print_job_start_ms) / 1000;
|
|
7434
|
+}
|
|
7435
|
+
|
|
7436
|
+/**
|
|
7437
|
+ * Check if the running print job has finished and stop the timer
|
|
7438
|
+ *
|
|
7439
|
+ * When the target temperature for all extruders is zero then we assume that the
|
|
7440
|
+ * print job has finished printing. There are some special conditions under which
|
|
7441
|
+ * this assumption may not be valid: If during a print job for some reason the
|
|
7442
|
+ * user decides to bring a nozzle temp down and only then heat the other afterwards.
|
|
7443
|
+ *
|
|
7444
|
+ * @param force stops the timer ignoring all pre-checks
|
|
7445
|
+ *
|
|
7446
|
+ * @return boolean true if the print job has finished printing
|
|
7447
|
+ */
|
|
7448
|
+bool print_job_stop(bool force /* = false */) {
|
|
7449
|
+ if (!print_job_start_ms) return false;
|
|
7450
|
+ if (!force) for (int i = 0; i < EXTRUDERS; i++) if (degTargetHotend(i) > 0) return false;
|
|
7451
|
+ print_job_stop_ms = millis();
|
|
7452
|
+ return true;
|
|
7453
|
+}
|