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
   return false;
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
 #if DISABLED(EMERGENCY_PARSER)
377
 #if DISABLED(EMERGENCY_PARSER)
395
   #include "gcode/control/M108.h"
378
   #include "gcode/control/M108.h"
396
   #include "gcode/control/M112.h"
379
   #include "gcode/control/M112.h"
902
   #endif
885
   #endif
903
 
886
 
904
   #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
887
   #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
905
-    auto_report_temperatures();
888
+    thermalManager.auto_report_temperatures();
906
   #endif
889
   #endif
907
 
890
 
908
   manage_inactivity(
891
   manage_inactivity(

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

144
 extern void gcode_M145();
144
 extern void gcode_M145();
145
 extern void gcode_M149();
145
 extern void gcode_M149();
146
 extern void gcode_M150();
146
 extern void gcode_M150();
147
-extern void gcode_M155();
148
 extern void gcode_M163();
147
 extern void gcode_M163();
149
 extern void gcode_M164();
148
 extern void gcode_M164();
150
 extern void gcode_M165();
149
 extern void gcode_M165();
495
         return; // "ok" already printed
494
         return; // "ok" already printed
496
 
495
 
497
       #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
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
       #endif
498
       #endif
502
 
499
 
503
       #if HAS_TEMP_BED
500
       #if HAS_TEMP_BED

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

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
  * M155: Set temperature auto-report interval. M155 S<seconds>
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
     #endif
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
 #endif // HAS_TEMP_HOTEND || HAS_TEMP_BED
2277
 #endif // HAS_TEMP_HOTEND || HAS_TEMP_BED

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

527
 
527
 
528
     #if HAS_TEMP_HOTEND || HAS_TEMP_BED
528
     #if HAS_TEMP_HOTEND || HAS_TEMP_BED
529
       static void print_heaterstates();
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
     #endif
540
     #endif
531
 
541
 
532
   private:
542
   private:

Loading…
Cancel
Save