Browse Source

Move M155 to cpp, auto-report to Temperature

Scott Lahteine 7 years ago
parent
commit
df0432c7c8

+ 1
- 18
Marlin/src/Marlin.cpp View File

@@ -374,23 +374,6 @@ bool pin_is_protected(const int8_t pin) {
374 374
   return false;
375 375
 }
376 376
 
377
-#if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
378
-
379
-  static uint8_t auto_report_temp_interval;
380
-  static millis_t next_temp_report_ms;
381
-
382
-  inline void auto_report_temperatures() {
383
-    if (auto_report_temp_interval && ELAPSED(millis(), next_temp_report_ms)) {
384
-      next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval;
385
-      thermalManager.print_heaterstates();
386
-      SERIAL_EOL();
387
-    }
388
-  }
389
-
390
-  #include "gcode/temperature/M155.h"
391
-
392
-#endif // AUTO_REPORT_TEMPERATURES && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
393
-
394 377
 #if DISABLED(EMERGENCY_PARSER)
395 378
   #include "gcode/control/M108.h"
396 379
   #include "gcode/control/M112.h"
@@ -902,7 +885,7 @@ void idle(
902 885
   #endif
903 886
 
904 887
   #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
905
-    auto_report_temperatures();
888
+    thermalManager.auto_report_temperatures();
906 889
   #endif
907 890
 
908 891
   manage_inactivity(

+ 1
- 4
Marlin/src/gcode/gcode.cpp View File

@@ -144,7 +144,6 @@ extern void gcode_M140();
144 144
 extern void gcode_M145();
145 145
 extern void gcode_M149();
146 146
 extern void gcode_M150();
147
-extern void gcode_M155();
148 147
 extern void gcode_M163();
149 148
 extern void gcode_M164();
150 149
 extern void gcode_M165();
@@ -495,9 +494,7 @@ void GcodeSuite::process_next_command() {
495 494
         return; // "ok" already printed
496 495
 
497 496
       #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
498
-        case 155: // M155: Set temperature auto-report interval
499
-          gcode_M155();
500
-          break;
497
+        case 155: M155(); break;  // M155: Set temperature auto-report interval
501 498
       #endif
502 499
 
503 500
       #if HAS_TEMP_BED

Marlin/src/gcode/temperature/M155.h → Marlin/src/gcode/temperature/M155.cpp View File

@@ -20,13 +20,21 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
26
+
27
+#include "../gcode.h"
28
+#include "../../module/temperature.h"
29
+
23 30
 /**
24 31
  * M155: Set temperature auto-report interval. M155 S<seconds>
25 32
  */
26
-void gcode_M155() {
27
-  if (parser.seenval('S')) {
28
-    auto_report_temp_interval = parser.value_byte();
29
-    NOMORE(auto_report_temp_interval, 60);
30
-    next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval;
31
-  }
33
+void GcodeSuite::M155() {
34
+
35
+  if (parser.seenval('S'))
36
+    thermalManager.set_auto_report_interval(parser.value_byte());
37
+
32 38
 }
39
+
40
+#endif // AUTO_REPORT_TEMPERATURES && (HAS_TEMP_HOTEND || HAS_TEMP_BED)

+ 15
- 0
Marlin/src/module/temperature.cpp View File

@@ -2259,4 +2259,19 @@ void Temperature::isr() {
2259 2259
     #endif
2260 2260
   }
2261 2261
 
2262
+  #if ENABLED(AUTO_REPORT_TEMPERATURES)
2263
+
2264
+    uint8_t Temperature::auto_report_temp_interval;
2265
+    millis_t Temperature::next_temp_report_ms;
2266
+
2267
+    void Temperature::auto_report_temperatures() {
2268
+      if (auto_report_temp_interval && ELAPSED(millis(), next_temp_report_ms)) {
2269
+        next_temp_report_ms = millis() + 1000UL * auto_report_temp_interval;
2270
+        print_heaterstates();
2271
+        SERIAL_EOL();
2272
+      }
2273
+    }
2274
+
2275
+  #endif // AUTO_REPORT_TEMPERATURES
2276
+
2262 2277
 #endif // HAS_TEMP_HOTEND || HAS_TEMP_BED

+ 10
- 0
Marlin/src/module/temperature.h View File

@@ -527,6 +527,16 @@ class Temperature {
527 527
 
528 528
     #if HAS_TEMP_HOTEND || HAS_TEMP_BED
529 529
       static void print_heaterstates();
530
+      #if ENABLED(AUTO_REPORT_TEMPERATURES)
531
+        static uint8_t auto_report_temp_interval;
532
+        static millis_t next_temp_report_ms;
533
+        static void auto_report_temperatures(void);
534
+        FORCE_INLINE void set_auto_report_interval(uint8_t v) {
535
+          NOMORE(v, 60);
536
+          auto_report_temp_interval = v;
537
+          next_temp_report_ms = millis() + 1000UL * v;
538
+        }
539
+      #endif
530 540
     #endif
531 541
 
532 542
   private:

Loading…
Cancel
Save