Browse Source

Merge pull request #3113 from jbrazio/bugfix/3061-stop-print-time-counter

Stop print timer with M105/M109
pull/1/head
Scott Lahteine 9 years ago
parent
commit
06332f20be
  1. 5
      Marlin/Marlin.h
  2. 73
      Marlin/Marlin_main.cpp
  3. 3
      Marlin/dogm_lcd_implementation.h
  4. 3
      Marlin/temperature.cpp
  5. 11
      Marlin/ultralcd_implementation_hitachi_HD44780.h

5
Marlin/Marlin.h

@ -356,4 +356,9 @@ extern uint8_t active_extruder;
extern void calculate_volumetric_multipliers();
// Print job timer related functions
millis_t print_job_timer();
bool print_job_start(millis_t t = 0);
bool print_job_stop(bool force = false);
#endif //MARLIN_H

73
Marlin/Marlin_main.cpp

@ -977,9 +977,9 @@ void get_command() {
) {
if (card_eof) {
SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED);
print_job_stop_ms = millis();
print_job_stop(true);
char time[30];
millis_t t = (print_job_stop_ms - print_job_start_ms) / 1000;
millis_t t = print_job_timer();
int hours = t / 60 / 60, minutes = (t / 60) % 60;
sprintf_P(time, PSTR("%i " MSG_END_HOUR " %i " MSG_END_MINUTE), hours, minutes);
SERIAL_ECHO_START;
@ -3454,7 +3454,7 @@ inline void gcode_M17() {
*/
inline void gcode_M24() {
card.startFileprint();
print_job_start_ms = millis();
print_job_start();
}
/**
@ -3510,8 +3510,7 @@ inline void gcode_M17() {
* M31: Get the time since the start of SD Print (or last M109)
*/
inline void gcode_M31() {
print_job_stop_ms = millis();
millis_t t = (print_job_stop_ms - print_job_start_ms) / 1000;
millis_t t = print_job_timer();
int min = t / 60, sec = t % 60;
char time[30];
sprintf_P(time, PSTR("%i min, %i sec"), min, sec);
@ -3545,8 +3544,9 @@ inline void gcode_M31() {
card.setIndex(code_value_short());
card.startFileprint();
if (!call_procedure)
print_job_start_ms = millis(); //procedure calls count as normal print time.
// Procedure calls count as normal print time.
if (!call_procedure) print_job_start();
}
}
@ -3884,6 +3884,8 @@ inline void gcode_M104() {
setTargetHotend1(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset);
#endif
}
print_job_stop();
}
#if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675)
@ -4008,11 +4010,12 @@ inline void gcode_M105() {
inline void gcode_M109() {
bool no_wait_for_cooling = true;
// Start hook must happen before setTargetHotend()
print_job_start();
if (setTargetedHotend(109)) return;
if (marlin_debug_flags & DEBUG_DRYRUN) return;
LCD_MESSAGEPGM(MSG_HEATING);
no_wait_for_cooling = code_seen('S');
if (no_wait_for_cooling || code_seen('R')) {
float temp = code_value();
@ -4021,8 +4024,12 @@ inline void gcode_M109() {
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
setTargetHotend1(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset);
#endif
if (temp > degHotend(target_extruder)) LCD_MESSAGEPGM(MSG_HEATING);
}
if (print_job_stop()) LCD_MESSAGEPGM(WELCOME_MSG);
#if ENABLED(AUTOTEMP)
autotemp_enabled = code_seen('F');
if (autotemp_enabled) autotemp_factor = code_value();
@ -4082,7 +4089,6 @@ inline void gcode_M109() {
} // while(!cancel_heatup && TEMP_CONDITIONS)
LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
print_job_start_ms = previous_cmd_ms;
}
#if HAS_TEMP_BED
@ -7398,3 +7404,50 @@ void calculate_volumetric_multipliers() {
for (int i = 0; i < EXTRUDERS; i++)
volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
}
/**
* Start the print job timer
*
* The print job is only started if all extruders have their target temp at zero
* otherwise the print job timew would be reset everytime a M109 is received.
*
* @param t start timer timestamp
*
* @return true if the timer was started at function call
*/
bool print_job_start(millis_t t /* = 0 */) {
for (int i = 0; i < EXTRUDERS; i++) if (degTargetHotend(i) > 0) return false;
print_job_start_ms = (t) ? t : millis();
print_job_stop_ms = 0;
return true;
}
/**
* Output the print job timer in seconds
*
* @return the number of seconds
*/
millis_t print_job_timer() {
if (!print_job_start_ms) return 0;
return (((print_job_stop_ms > print_job_start_ms)
? print_job_stop_ms : millis()) - print_job_start_ms) / 1000;
}
/**
* Check if the running print job has finished and stop the timer
*
* When the target temperature for all extruders is zero then we assume that the
* print job has finished printing. There are some special conditions under which
* this assumption may not be valid: If during a print job for some reason the
* user decides to bring a nozzle temp down and only then heat the other afterwards.
*
* @param force stops the timer ignoring all pre-checks
*
* @return boolean true if the print job has finished printing
*/
bool print_job_stop(bool force /* = false */) {
if (!print_job_start_ms) return false;
if (!force) for (int i = 0; i < EXTRUDERS; i++) if (degTargetHotend(i) > 0) return false;
print_job_stop_ms = millis();
return true;
}

3
Marlin/dogm_lcd_implementation.h

@ -305,7 +305,8 @@ static void lcd_implementation_status_screen() {
u8g.setPrintPos(80,48);
if (print_job_start_ms != 0) {
uint16_t time = (millis() - print_job_start_ms) / 60000;
uint16_t time = (((print_job_stop_ms > print_job_start_ms)
? print_job_stop_ms : millis()) - print_job_start_ms) / 60000;
lcd_print(itostr2(time/60));
lcd_print(':');
lcd_print(itostr2(time%60));

3
Marlin/temperature.cpp

@ -1134,6 +1134,9 @@ void disable_all_heaters() {
for (int i = 0; i < EXTRUDERS; i++) setTargetHotend(0, i);
setTargetBed(0);
// If all heaters go down then for sure our print job has stopped
print_job_stop(true);
#define DISABLE_HEATER(NR) { \
setTargetHotend(NR, 0); \
soft_pwm[NR] = 0; \

11
Marlin/ultralcd_implementation_hitachi_HD44780.h

@ -136,7 +136,7 @@ extern volatile uint8_t buttons; //an extended version of the last checked butt
#define LCD_I2C_PIN_D5 5
#define LCD_I2C_PIN_D6 6
#define LCD_I2C_PIN_D7 7
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
@ -637,7 +637,7 @@ static void lcd_implementation_status_screen() {
else {
if (!axis_homed[X_AXIS])
lcd_printPGM(PSTR("?"));
else
else
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[X_AXIS])
lcd_printPGM(PSTR(" "));
@ -654,7 +654,7 @@ static void lcd_implementation_status_screen() {
else {
if (!axis_homed[Y_AXIS])
lcd_printPGM(PSTR("?"));
else
else
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[Y_AXIS])
lcd_printPGM(PSTR(" "));
@ -674,7 +674,7 @@ static void lcd_implementation_status_screen() {
else {
if (!axis_homed[Z_AXIS])
lcd_printPGM(PSTR("?"));
else
else
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[Z_AXIS])
lcd_printPGM(PSTR(" "));
@ -712,7 +712,8 @@ static void lcd_implementation_status_screen() {
lcd.setCursor(LCD_WIDTH - 6, 2);
lcd.print(LCD_STR_CLOCK[0]);
if (print_job_start_ms != 0) {
uint16_t time = millis() / 60000 - print_job_start_ms / 60000;
uint16_t time = (((print_job_stop_ms > print_job_start_ms)
? print_job_stop_ms : millis()) - print_job_start_ms) / 60000;
lcd.print(itostr2(time / 60));
lcd.print(':');
lcd.print(itostr2(time % 60));

Loading…
Cancel
Save