Browse Source

Added new G-Code: M78

João Brázio 8 years ago
parent
commit
d6cfcc9c8b
No account linked to committer's email address
2 changed files with 33 additions and 3 deletions
  1. 10
    2
      Marlin/Marlin.h
  2. 23
    1
      Marlin/Marlin_main.cpp

+ 10
- 2
Marlin/Marlin.h View File

@@ -65,7 +65,11 @@ typedef unsigned long millis_t;
65 65
 
66 66
 #include "WString.h"
67 67
 
68
-#include "stopwatch.h"
68
+#if ENABLED(PRINTCOUNTER)
69
+  #include "printcounter.h"
70
+#else
71
+  #include "stopwatch.h"
72
+#endif
69 73
 
70 74
 #ifdef USBCON
71 75
   #if ENABLED(BLUETOOTH)
@@ -364,7 +368,11 @@ extern bool axis_homed[3]; // axis[n].is_homed
364 368
 #endif
365 369
 
366 370
 // Print job timer
367
-extern Stopwatch print_job_timer;
371
+#if ENABLED(PRINTCOUNTER)
372
+  extern PrintCounter print_job_timer;
373
+#else
374
+  extern Stopwatch print_job_timer;
375
+#endif
368 376
 
369 377
 // Handling multiple extruders pins
370 378
 extern uint8_t active_extruder;

+ 23
- 1
Marlin/Marlin_main.cpp View File

@@ -327,7 +327,11 @@ static millis_t max_inactive_time = 0;
327 327
 static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL;
328 328
 
329 329
 // Print Job Timer
330
-Stopwatch print_job_timer = Stopwatch();
330
+#if ENABLED(PRINTCOUNTER)
331
+  PrintCounter print_job_timer = PrintCounter();
332
+#else
333
+  Stopwatch print_job_timer = Stopwatch();
334
+#endif
331 335
 
332 336
 static uint8_t target_extruder;
333 337
 
@@ -4252,6 +4256,15 @@ inline void gcode_M77() {
4252 4256
   print_job_timer.stop();
4253 4257
 }
4254 4258
 
4259
+#if ENABLED(PRINTCOUNTER)
4260
+  /*+
4261
+   * M78: Show print statistics
4262
+   */
4263
+  inline void gcode_M78() {
4264
+    print_job_timer.showStats();
4265
+  }
4266
+#endif
4267
+
4255 4268
 /**
4256 4269
  * M104: Set hot end temperature
4257 4270
  */
@@ -6636,6 +6649,12 @@ void process_next_command() {
6636 6649
         gcode_M77();
6637 6650
         break;
6638 6651
 
6652
+      #if ENABLED(PRINTCOUNTER)
6653
+        case 78: // Show print statistics
6654
+          gcode_M78();
6655
+          break;
6656
+      #endif
6657
+
6639 6658
       #if ENABLED(M100_FREE_MEMORY_WATCHER)
6640 6659
         case 100:
6641 6660
           gcode_M100();
@@ -7750,6 +7769,9 @@ void idle(
7750 7769
   );
7751 7770
   host_keepalive();
7752 7771
   lcd_update();
7772
+  #if ENABLED(PRINTCOUNTER)
7773
+      print_job_timer.tick();
7774
+  #endif
7753 7775
 }
7754 7776
 
7755 7777
 /**

Loading…
Cancel
Save