Browse Source

Merge pull request #4287 from thinkyhead/rc_long_print_times

Allow stopwatch and printcounter to go over 18:12:15
Scott Lahteine 8 years ago
parent
commit
75901b616c

+ 14
- 12
Marlin/Marlin_main.cpp View File

@@ -1169,14 +1169,6 @@ inline void get_serial_commands() {
1169 1169
       ) {
1170 1170
         if (card_eof) {
1171 1171
           SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED);
1172
-          print_job_timer.stop();
1173
-          char time[30];
1174
-          millis_t t = print_job_timer.duration();
1175
-          int hours = t / 60 / 60, minutes = (t / 60) % 60;
1176
-          sprintf_P(time, PSTR("%i " MSG_END_HOUR " %i " MSG_END_MINUTE), hours, minutes);
1177
-          SERIAL_ECHO_START;
1178
-          SERIAL_ECHOLN(time);
1179
-          lcd_setstatus(time, true);
1180 1172
           card.printingHasFinished();
1181 1173
           card.checkautostart(true);
1182 1174
         }
@@ -3949,12 +3941,22 @@ inline void gcode_M17() {
3949 3941
  */
3950 3942
 inline void gcode_M31() {
3951 3943
   millis_t t = print_job_timer.duration();
3952
-  int min = t / 60, sec = t % 60;
3953
-  char time[30];
3954
-  sprintf_P(time, PSTR("%i min, %i sec"), min, sec);
3944
+  int d = int(t / 60 / 60 / 24),
3945
+      h = int(t / 60 / 60) % 60,
3946
+      m = int(t / 60) % 60,
3947
+      s = int(t % 60);
3948
+  char time[18];                                          // 123456789012345678
3949
+  if (d)
3950
+    sprintf_P(time, PSTR("%id %ih %im %is"), d, h, m, s); // 99d 23h 59m 59s
3951
+  else
3952
+    sprintf_P(time, PSTR("%ih %im %is"), h, m, s);        // 23h 59m 59s
3953
+
3954
+  lcd_setstatus(time);
3955
+
3955 3956
   SERIAL_ECHO_START;
3957
+  SERIAL_ECHOPGM(MSG_PRINT_TIME " ");
3956 3958
   SERIAL_ECHOLN(time);
3957
-  lcd_setstatus(time);
3959
+
3958 3960
   thermalManager.autotempShutdown();
3959 3961
 }
3960 3962
 

+ 3
- 3
Marlin/cardreader.cpp View File

@@ -602,19 +602,19 @@ void CardReader::updir() {
602 602
 
603 603
 void CardReader::printingHasFinished() {
604 604
   stepper.synchronize();
605
+  file.close();
605 606
   if (file_subcall_ctr > 0) { // Heading up to a parent file that called current as a procedure.
606
-    file.close();
607 607
     file_subcall_ctr--;
608 608
     openFile(proc_filenames[file_subcall_ctr], true, true);
609 609
     setIndex(filespos[file_subcall_ctr]);
610 610
     startFileprint();
611 611
   }
612 612
   else {
613
-    file.close();
614 613
     sdprinting = false;
615 614
     if (SD_FINISHED_STEPPERRELEASE)
616 615
       enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
617
-    thermalManager.autotempShutdown();
616
+    print_job_timer.stop();
617
+    enqueue_and_echo_commands_P(PSTR("M31"));
618 618
   }
619 619
 }
620 620
 

+ 1
- 1
Marlin/dogm_lcd_implementation.h View File

@@ -386,7 +386,7 @@ static void lcd_implementation_status_screen() {
386 386
     }
387 387
 
388 388
     u8g.setPrintPos(80,48);
389
-    uint16_t time = print_job_timer.duration() / 60;
389
+    millis_t time = print_job_timer.duration() / 60;
390 390
     if (time != 0) {
391 391
       lcd_print(itostr2(time/60));
392 392
       lcd_print(':');

+ 6
- 6
Marlin/language_cz.h View File

@@ -209,13 +209,13 @@
209 209
 #define MSG_INFO_BAUDRATE                   "Rychlost"
210 210
 #define MSG_INFO_PROTOCOL                   "Protokol"
211 211
 #if LCD_WIDTH > 19
212
-  #define MSG_INFO_PRINT_COUNT              "Pocet tisku "
213
-  #define MSG_INFO_FINISHED_PRINTS          "Dokonceno   "
214
-  #define MSG_INFO_PRINT_TIME               "Celkovy cas "
212
+  #define MSG_INFO_PRINT_COUNT              "Pocet tisku"
213
+  #define MSG_INFO_COMPLETED_PRINTS         "Dokonceno  "
214
+  #define MSG_INFO_PRINT_TIME               "Celkovy cas"
215 215
 #else
216
-  #define MSG_INFO_PRINT_COUNT              "Tisky    "
217
-  #define MSG_INFO_FINISHED_PRINTS          "Hotovo   "
218
-  #define MSG_INFO_PRINT_TIME               "Cas      "
216
+  #define MSG_INFO_PRINT_COUNT              "Tisky "
217
+  #define MSG_INFO_COMPLETED_PRINTS         "Hotovo"
218
+  #define MSG_INFO_PRINT_TIME               "Cas   "
219 219
 #endif
220 220
 #define MSG_INFO_MIN_TEMP                   "Teplota min"
221 221
 #define MSG_INFO_MAX_TEMP                   "Teplota max"

+ 10
- 3
Marlin/language_de.h View File

@@ -179,9 +179,16 @@
179 179
 #define MSG_INFO_EXTRUDERS                  "Extruders"
180 180
 #define MSG_INFO_BAUDRATE                   "Baud"
181 181
 #define MSG_INFO_PROTOCOL                   "Protokol"
182
-#define MSG_INFO_TOTAL_PRINTS               "Gesamte Drucke"
183
-#define MSG_INFO_FINISHED_PRINTS            "Beendete Drucke"
184
-#define MSG_INFO_PRINT_TIME                 "Gesamte Druckzeit"
182
+
183
+#if LCD_WIDTH > 19
184
+  #define MSG_INFO_TOTAL_PRINTS             "Gesamte Drucke   "
185
+  #define MSG_INFO_COMPLETED_PRINTS         "Beendete Drucke  "
186
+  #define MSG_INFO_PRINT_TIME               "Gesamte Druckzeit"
187
+#else
188
+  #define MSG_INFO_PRINT_COUNT              "Prints   "
189
+  #define MSG_INFO_COMPLETED_PRINTS         "Completed"
190
+  #define MSG_INFO_PRINT_TIME               "Duration "
191
+#endif
185 192
 #define MSG_INFO_MIN_TEMP                   "Min Temp"
186 193
 #define MSG_INFO_MAX_TEMP                   "Max Temp"
187 194
 #define MSG_INFO_PSU                        "Stromversorgung"

+ 36
- 27
Marlin/language_el.h View File

@@ -198,6 +198,7 @@
198 198
 #define MSG_DELTA_CALIBRATE_Y               "Βαθμονόμηση Y"
199 199
 #define MSG_DELTA_CALIBRATE_Z               "Βαθμονόμηση Z"
200 200
 #define MSG_DELTA_CALIBRATE_CENTER          "Βαθμονόμηση κέντρου"
201
+
201 202
 #define MSG_INFO_MENU                       "About Printer"
202 203
 #define MSG_INFO_PRINTER_MENU               "Printer Info"
203 204
 #define MSG_INFO_STATS_MENU                 "Printer Stats"
@@ -206,42 +207,50 @@
206 207
 #define MSG_INFO_EXTRUDERS                  "Extruders"
207 208
 #define MSG_INFO_BAUDRATE                   "Baud"
208 209
 #define MSG_INFO_PROTOCOL                   "Protocol"
209
-#define MSG_INFO_TOTAL_PRINTS               "Total Prints"
210
-#define MSG_INFO_FINISHED_PRINTS            "Finished Prints"
211
-#define MSG_INFO_PRINT_TIME                 "Total Print Time"
210
+
211
+#if LCD_WIDTH > 19
212
+  #define MSG_INFO_PRINT_COUNT              "Print Count"
213
+  #define MSG_INFO_COMPLETED_PRINTS         "Completed  "
214
+  #define MSG_INFO_PRINT_TIME               "Total Time "
215
+#else
216
+  #define MSG_INFO_PRINT_COUNT              "Prints   "
217
+  #define MSG_INFO_COMPLETED_PRINTS         "Completed"
218
+  #define MSG_INFO_PRINT_TIME               "Duration "
219
+#endif
212 220
 #define MSG_INFO_MIN_TEMP                   "Min Temp"
213 221
 #define MSG_INFO_MAX_TEMP                   "Max Temp"
214 222
 #define MSG_INFO_PSU                        "Power Supply"
223
+
215 224
 #define MSG_FILAMENT_CHANGE_HEADER          "CHANGE FILAMENT"
216 225
 #define MSG_FILAMENT_CHANGE_OPTION_EXTRUDE  "Extrude more"
217 226
 #define MSG_FILAMENT_CHANGE_OPTION_RESUME   "Resume print"
218 227
 
219 228
 #if LCD_HEIGHT >= 4
220
-  #define MSG_FILAMENT_CHANGE_INIT_1          "Wait for start"
221
-  #define MSG_FILAMENT_CHANGE_INIT_2          "of the filament"
222
-  #define MSG_FILAMENT_CHANGE_INIT_3          "change"
223
-  #define MSG_FILAMENT_CHANGE_UNLOAD_1        "Wait for"
224
-  #define MSG_FILAMENT_CHANGE_UNLOAD_2        "filament unload"
225
-  #define MSG_FILAMENT_CHANGE_UNLOAD_3        ""
226
-  #define MSG_FILAMENT_CHANGE_INSERT_1        "Insert filament"
227
-  #define MSG_FILAMENT_CHANGE_INSERT_2        "and press button"
228
-  #define MSG_FILAMENT_CHANGE_INSERT_3        "to continue..."
229
-  #define MSG_FILAMENT_CHANGE_LOAD_1          "Wait for"
230
-  #define MSG_FILAMENT_CHANGE_LOAD_2          "filament load"
231
-  #define MSG_FILAMENT_CHANGE_LOAD_3          ""
232
-  #define MSG_FILAMENT_CHANGE_EXTRUDE_1       "Wait for"
233
-  #define MSG_FILAMENT_CHANGE_EXTRUDE_2       "filament extrude"
234
-  #define MSG_FILAMENT_CHANGE_EXTRUDE_3       ""
235
-  #define MSG_FILAMENT_CHANGE_RESUME_1        "Wait for print"
236
-  #define MSG_FILAMENT_CHANGE_RESUME_2        "to resume"
237
-  #define MSG_FILAMENT_CHANGE_RESUME_3        ""
229
+  #define MSG_FILAMENT_CHANGE_INIT_1        "Wait for start"
230
+  #define MSG_FILAMENT_CHANGE_INIT_2        "of the filament"
231
+  #define MSG_FILAMENT_CHANGE_INIT_3        "change"
232
+  #define MSG_FILAMENT_CHANGE_UNLOAD_1      "Wait for"
233
+  #define MSG_FILAMENT_CHANGE_UNLOAD_2      "filament unload"
234
+  #define MSG_FILAMENT_CHANGE_UNLOAD_3      ""
235
+  #define MSG_FILAMENT_CHANGE_INSERT_1      "Insert filament"
236
+  #define MSG_FILAMENT_CHANGE_INSERT_2      "and press button"
237
+  #define MSG_FILAMENT_CHANGE_INSERT_3      "to continue..."
238
+  #define MSG_FILAMENT_CHANGE_LOAD_1        "Wait for"
239
+  #define MSG_FILAMENT_CHANGE_LOAD_2        "filament load"
240
+  #define MSG_FILAMENT_CHANGE_LOAD_3        ""
241
+  #define MSG_FILAMENT_CHANGE_EXTRUDE_1     "Wait for"
242
+  #define MSG_FILAMENT_CHANGE_EXTRUDE_2     "filament extrude"
243
+  #define MSG_FILAMENT_CHANGE_EXTRUDE_3     ""
244
+  #define MSG_FILAMENT_CHANGE_RESUME_1      "Wait for print"
245
+  #define MSG_FILAMENT_CHANGE_RESUME_2      "to resume"
246
+  #define MSG_FILAMENT_CHANGE_RESUME_3      ""
238 247
 #else // LCD_HEIGHT < 4
239
-  #define MSG_FILAMENT_CHANGE_INIT_1          "Please wait..."
240
-  #define MSG_FILAMENT_CHANGE_UNLOAD_1        "Ejecting..."
241
-  #define MSG_FILAMENT_CHANGE_INSERT_1        "Insert and Click"
242
-  #define MSG_FILAMENT_CHANGE_LOAD_1          "Loading..."
243
-  #define MSG_FILAMENT_CHANGE_EXTRUDE_1       "Extruding..."
244
-  #define MSG_FILAMENT_CHANGE_RESUME_1        "Resuming..."
248
+  #define MSG_FILAMENT_CHANGE_INIT_1        "Please wait..."
249
+  #define MSG_FILAMENT_CHANGE_UNLOAD_1      "Ejecting..."
250
+  #define MSG_FILAMENT_CHANGE_INSERT_1      "Insert and Click"
251
+  #define MSG_FILAMENT_CHANGE_LOAD_1        "Loading..."
252
+  #define MSG_FILAMENT_CHANGE_EXTRUDE_1     "Extruding..."
253
+  #define MSG_FILAMENT_CHANGE_RESUME_1      "Resuming..."
245 254
 #endif
246 255
 
247 256
 #endif // LANGUAGE_EL_H

+ 13
- 6
Marlin/language_en.h View File

@@ -488,12 +488,18 @@
488 488
 #ifndef MSG_PLEASE_RESET
489 489
   #define MSG_PLEASE_RESET                    "Please reset"
490 490
 #endif
491
+#ifndef MSG_END_DAY
492
+  #define MSG_END_DAY                         "days"
493
+#endif
491 494
 #ifndef MSG_END_HOUR
492 495
   #define MSG_END_HOUR                        "hours"
493 496
 #endif
494 497
 #ifndef MSG_END_MINUTE
495 498
   #define MSG_END_MINUTE                      "minutes"
496 499
 #endif
500
+#ifndef MSG_PRINT_TIME
501
+  #define MSG_PRINT_TIME                      "Print time"
502
+#endif
497 503
 #ifndef MSG_HEATING
498 504
   #define MSG_HEATING                         "Heating..."
499 505
 #endif
@@ -521,6 +527,7 @@
521 527
 #ifndef MSG_DELTA_CALIBRATE_CENTER
522 528
   #define MSG_DELTA_CALIBRATE_CENTER          "Calibrate Center"
523 529
 #endif
530
+
524 531
 #ifndef MSG_INFO_MENU
525 532
   #define MSG_INFO_MENU                       "About Printer"
526 533
 #endif
@@ -548,20 +555,20 @@
548 555
 
549 556
 #if LCD_WIDTH > 19
550 557
   #ifndef MSG_INFO_PRINT_COUNT
551
-    #define MSG_INFO_PRINT_COUNT              "Print Count "
558
+    #define MSG_INFO_PRINT_COUNT              "Print Count"
552 559
   #endif
553
-  #ifndef MSG_INFO_FINISHED_PRINTS
554
-    #define MSG_INFO_FINISHED_PRINTS          "Finished    "
560
+  #ifndef MSG_INFO_COMPLETED_PRINTS
561
+    #define MSG_INFO_COMPLETED_PRINTS         "Completed  "
555 562
   #endif
556 563
   #ifndef MSG_INFO_PRINT_TIME
557
-    #define MSG_INFO_PRINT_TIME               "Total Time  "
564
+    #define MSG_INFO_PRINT_TIME               "Total Time "
558 565
   #endif
559 566
 #else
560 567
   #ifndef MSG_INFO_PRINT_COUNT
561 568
     #define MSG_INFO_PRINT_COUNT              "Prints   "
562 569
   #endif
563
-  #ifndef MSG_INFO_FINISHED_PRINTS
564
-    #define MSG_INFO_FINISHED_PRINTS          "Finished "
570
+  #ifndef MSG_INFO_COMPLETED_PRINTS
571
+    #define MSG_INFO_COMPLETED_PRINTS         "Completed"
565 572
   #endif
566 573
   #ifndef MSG_INFO_PRINT_TIME
567 574
     #define MSG_INFO_PRINT_TIME               "Duration "

+ 8
- 9
Marlin/printcounter.cpp View File

@@ -27,12 +27,12 @@ PrintCounter::PrintCounter(): super() {
27 27
   this->loadStats();
28 28
 }
29 29
 
30
-uint16_t PrintCounter::deltaDuration() {
30
+millis_t PrintCounter::deltaDuration() {
31 31
   #if ENABLED(DEBUG_PRINTCOUNTER)
32 32
     PrintCounter::debug(PSTR("deltaDuration"));
33 33
   #endif
34 34
 
35
-  uint16_t tmp = this->lastDuration;
35
+  millis_t tmp = this->lastDuration;
36 36
   this->lastDuration = this->duration();
37 37
   return this->lastDuration - tmp;
38 38
 }
@@ -88,12 +88,12 @@ void PrintCounter::showStats() {
88 88
   SERIAL_ECHO(this->data.totalPrints - this->data.finishedPrints
89 89
     - ((this->isRunning() || this->isPaused()) ? 1 : 0)); // Removes 1 from failures with an active counter
90 90
 
91
-  uint32_t t = this->data.printTime / 60;
91
+  millis_t t = this->data.printTime / 60; // minutes from seconds
92 92
   SERIAL_ECHOPGM(", Total print time: ");
93
-  SERIAL_ECHO(t / 60);
93
+  SERIAL_ECHO(t / 60); // hours
94 94
 
95 95
   SERIAL_ECHOPGM("h ");
96
-  SERIAL_ECHO(t % 60);
96
+  SERIAL_ECHO(t % 60); // minutes
97 97
 
98 98
   SERIAL_ECHOPGM("min");
99 99
 
@@ -110,10 +110,10 @@ void PrintCounter::showStats() {
110 110
 void PrintCounter::tick() {
111 111
   if (!this->isRunning()) return;
112 112
 
113
-  static uint32_t update_before = millis(),
113
+  static millis_t update_before = millis(),
114 114
                   eeprom_before = millis();
115 115
 
116
-  uint32_t now = millis();
116
+  millis_t now = millis();
117 117
 
118 118
   // Trying to get the amount of calculations down to the bare min
119 119
   const static uint16_t i = this->updateInterval * 1000;
@@ -128,8 +128,7 @@ void PrintCounter::tick() {
128 128
   }
129 129
 
130 130
   // Trying to get the amount of calculations down to the bare min
131
-  const static uint32_t j = this->saveInterval * 1000;
132
-
131
+  const static millis_t j = this->saveInterval * 1000;
133 132
   if (now - eeprom_before >= j) {
134 133
     eeprom_before = now;
135 134
     this->saveStats();

+ 4
- 4
Marlin/printcounter.h View File

@@ -35,8 +35,8 @@ struct printStatistics {    // 13 bytes
35 35
   //const uint8_t magic;    // Magic header, it will always be 0x16
36 36
   uint16_t totalPrints;     // Number of prints
37 37
   uint16_t finishedPrints;  // Number of complete prints
38
-  uint32_t printTime;       // Total printing time
39
-  uint32_t longestPrint;    // Longest print job - not in use
38
+  millis_t printTime;       // Total printing time
39
+  millis_t longestPrint;    // Longest print job - not in use
40 40
 };
41 41
 
42 42
 class PrintCounter: public Stopwatch {
@@ -74,7 +74,7 @@ class PrintCounter: public Stopwatch {
74 74
      * @details Stores the timestamp of the last deltaDuration(), this is
75 75
      * required due to the updateInterval cycle.
76 76
      */
77
-    uint16_t lastDuration;
77
+    millis_t lastDuration;
78 78
 
79 79
     /**
80 80
      * @brief Stats were loaded from EERPROM
@@ -90,7 +90,7 @@ class PrintCounter: public Stopwatch {
90 90
      * used internally for print statistics accounting is not intended to be a
91 91
      * user callable function.
92 92
      */
93
-    uint16_t deltaDuration();
93
+    millis_t deltaDuration();
94 94
 
95 95
   public:
96 96
     /**

+ 2
- 2
Marlin/stopwatch.cpp View File

@@ -88,9 +88,9 @@ bool Stopwatch::isPaused() {
88 88
   return (this->state == STOPWATCH_PAUSED) ? true : false;
89 89
 }
90 90
 
91
-uint16_t Stopwatch::duration() {
91
+millis_t Stopwatch::duration() {
92 92
   return (((this->isRunning()) ? millis() : this->stopTimestamp)
93
-          - this->startTimestamp) / 1000 + this->accumulator;
93
+          - this->startTimestamp) / 1000UL + this->accumulator;
94 94
 }
95 95
 
96 96
 #if ENABLED(DEBUG_STOPWATCH)

+ 4
- 4
Marlin/stopwatch.h View File

@@ -42,9 +42,9 @@ enum StopwatchState {
42 42
 class Stopwatch {
43 43
   private:
44 44
     StopwatchState state;
45
-    uint16_t accumulator;
46
-    uint32_t startTimestamp;
47
-    uint32_t stopTimestamp;
45
+    millis_t accumulator;
46
+    millis_t startTimestamp;
47
+    millis_t stopTimestamp;
48 48
 
49 49
   public:
50 50
     /**
@@ -101,7 +101,7 @@ class Stopwatch {
101 101
      * @details Returns the total number of seconds the timer has been running.
102 102
      * @return the delta since starting the stopwatch
103 103
      */
104
-    uint16_t duration();
104
+    millis_t duration();
105 105
 
106 106
     #if ENABLED(DEBUG_STOPWATCH)
107 107
 

+ 6
- 6
Marlin/ultralcd.cpp View File

@@ -1967,13 +1967,13 @@ void kill_screen(const char* lcd_msg) {
1967 1967
         print_job_counter.loadStats();
1968 1968
         printStatistics stats = print_job_counter.getStats();
1969 1969
 
1970
-        char printTime[6];
1971
-        sprintf(printTime, "%02d:%02d", int(stats.printTime / 3600), int(stats.printTime / 60) % 60);
1970
+        char timeString[8];
1971
+        sprintf_P(timeString, PSTR("%i:%02i"), int(stats.printTime / 60 / 60), int(stats.printTime / 60) % 60);
1972 1972
 
1973
-        START_SCREEN();
1974
-        STATIC_ITEM(MSG_INFO_PRINT_COUNT ": ", false, false, itostr3left(stats.totalPrints));        // Print Count : 999
1975
-        STATIC_ITEM(MSG_INFO_FINISHED_PRINTS ": ", false, false, itostr3left(stats.finishedPrints)); // Finished    : 666
1976
-        STATIC_ITEM(MSG_INFO_PRINT_TIME ": ", false, false, printTime);                              // Total Time  : 12:34
1973
+        START_SCREEN();                                                                              // 12345678901234567890
1974
+        STATIC_ITEM(MSG_INFO_PRINT_COUNT ": ", false, false, itostr3left(stats.totalPrints));        // Print Count: 999
1975
+        STATIC_ITEM(MSG_INFO_COMPLETED_PRINTS": ", false, false, itostr3left(stats.finishedPrints)); // Completed  : 666
1976
+        STATIC_ITEM(MSG_INFO_PRINT_TIME ": ", false, false, timeString);                             // Total Time : 123:45
1977 1977
         END_SCREEN();
1978 1978
       }
1979 1979
     #endif // PRINTCOUNTER

Loading…
Cancel
Save