浏览代码

Inline manage_inactivity, tweak autoreport_paused

Scott Lahteine 4 年前
父节点
当前提交
a1f026f57a

+ 2
- 6
Marlin/src/MarlinCore.cpp 查看文件

@@ -204,10 +204,6 @@ bool wait_for_heatup = true;
204 204
   bool wait_for_user; // = false;
205 205
 #endif
206 206
 
207
-#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
208
-  bool suspend_auto_report; // = false
209
-#endif
210
-
211 207
 // Inactivity shutdown
212 208
 millis_t max_inactive_time, // = 0
213 209
          stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL;
@@ -432,7 +428,7 @@ void startOrResumeJob() {
432 428
  *  - Pulse FET_SAFETY_PIN if it exists
433 429
  */
434 430
 
435
-void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
431
+inline void manage_inactivity(const bool ignore_stepper_queue=false) {
436 432
 
437 433
   #if HAS_FILAMENT_SENSOR
438 434
     runout.run();
@@ -697,7 +693,7 @@ void idle(
697 693
   #endif
698 694
 
699 695
   #if HAS_AUTO_REPORTING
700
-    if (!suspend_auto_report) {
696
+    if (!gcode.autoreport_paused) {
701 697
       #if ENABLED(AUTO_REPORT_TEMPERATURES)
702 698
         thermalManager.auto_report_temperatures();
703 699
       #endif

+ 0
- 6
Marlin/src/MarlinCore.h 查看文件

@@ -44,8 +44,6 @@ void idle(
44 44
   #endif
45 45
 );
46 46
 
47
-void manage_inactivity(const bool ignore_stepper_queue=false);
48
-
49 47
 #if ENABLED(EXPERIMENTAL_I2CBUS)
50 48
   #include "feature/twibus.h"
51 49
   extern TWIBus i2c;
@@ -84,10 +82,6 @@ extern bool wait_for_heatup;
84 82
   extern bool wait_for_user;
85 83
 #endif
86 84
 
87
-#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
88
-  extern bool suspend_auto_report;
89
-#endif
90
-
91 85
 // Inactivity shutdown timer
92 86
 extern millis_t max_inactive_time, stepper_inactive_time;
93 87
 

+ 12
- 0
Marlin/src/core/utility.cpp 查看文件

@@ -35,6 +35,18 @@ void safe_delay(millis_t ms) {
35 35
   thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made
36 36
 }
37 37
 
38
+// A delay to provide brittle hosts time to receive bytes
39
+#if ENABLED(SERIAL_OVERRUN_PROTECTION)
40
+
41
+  #include "../gcode/gcode.h" // for set_autoreport_paused
42
+
43
+  void serial_delay(const millis_t ms) {
44
+    const bool was = gcode.set_autoreport_paused(true);
45
+    safe_delay(ms);
46
+    gcode.set_autoreport_paused(was);
47
+  }
48
+#endif
49
+
38 50
 #if ENABLED(DEBUG_LEVELING_FEATURE)
39 51
 
40 52
   #include "../module/probe.h"

+ 5
- 8
Marlin/src/core/utility.h 查看文件

@@ -27,14 +27,11 @@
27 27
 // Delay that ensures heaters and watchdog are kept alive
28 28
 void safe_delay(millis_t ms);
29 29
 
30
-// A delay to provide brittle hosts time to receive bytes
31
-inline void serial_delay(const millis_t ms) {
32
-  #if ENABLED(SERIAL_OVERRUN_PROTECTION)
33
-    safe_delay(ms);
34
-  #else
35
-    UNUSED(ms);
36
-  #endif
37
-}
30
+#if ENABLED(SERIAL_OVERRUN_PROTECTION)
31
+  void serial_delay(const millis_t ms);
32
+#else
33
+  inline void serial_delay(const millis_t) {}
34
+#endif
38 35
 
39 36
 #if GRID_MAX_POINTS_X && GRID_MAX_POINTS_Y
40 37
 

+ 4
- 6
Marlin/src/feature/bedlevel/ubl/ubl.cpp 查看文件

@@ -28,6 +28,8 @@
28 28
 
29 29
   unified_bed_leveling ubl;
30 30
 
31
+  #include "../../../MarlinCore.h"
32
+
31 33
   #include "../../../module/configuration_store.h"
32 34
   #include "../../../module/planner.h"
33 35
   #include "../../../module/motion.h"
@@ -151,9 +153,7 @@
151 153
    *   4: Compact Human-Readable
152 154
    */
153 155
   void unified_bed_leveling::display_map(const int map_type) {
154
-    #if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
155
-      suspend_auto_report = true;
156
-    #endif
156
+    const bool was = gcode.set_autoreport_paused(true);
157 157
 
158 158
     constexpr uint8_t eachsp = 1 + 6 + 1,                           // [-3.567]
159 159
                       twixt = eachsp * (GRID_MAX_POINTS_X) - 9 * 2; // Leading 4sp, Coordinates 9sp each
@@ -229,9 +229,7 @@
229 229
       SERIAL_EOL();
230 230
     }
231 231
 
232
-    #if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
233
-      suspend_auto_report = false;
234
-    #endif
232
+    set_gcode.set_autoreport_paused(was);
235 233
   }
236 234
 
237 235
   bool unified_bed_leveling::sanity_check() {

+ 6
- 2
Marlin/src/gcode/gcode.cpp 查看文件

@@ -53,7 +53,7 @@ GcodeSuite gcode;
53 53
   #include "../feature/cancel_object.h"
54 54
 #endif
55 55
 
56
-#include "../MarlinCore.h" // for idle() and suspend_auto_report
56
+#include "../MarlinCore.h" // for idle()
57 57
 
58 58
 millis_t GcodeSuite::previous_move_ms;
59 59
 
@@ -66,6 +66,10 @@ uint8_t GcodeSuite::axis_relative = (
66 66
   | (ar_init.e ? _BV(REL_E) : 0)
67 67
 );
68 68
 
69
+#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
70
+  bool GcodeSuite::autoreport_paused; // = false
71
+#endif
72
+
69 73
 #if ENABLED(HOST_KEEPALIVE_FEATURE)
70 74
   GcodeSuite::MarlinBusyState GcodeSuite::busy_state = NOT_BUSY;
71 75
   uint8_t GcodeSuite::host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL;
@@ -942,7 +946,7 @@ void GcodeSuite::process_subcommands_now(char * gcode) {
942 946
   void GcodeSuite::host_keepalive() {
943 947
     const millis_t ms = millis();
944 948
     static millis_t next_busy_signal_ms = 0;
945
-    if (!suspend_auto_report && host_keepalive_interval && busy_state != NOT_BUSY) {
949
+    if (!autoreport_paused && host_keepalive_interval && busy_state != NOT_BUSY) {
946 950
       if (PENDING(ms, next_busy_signal_ms)) return;
947 951
       switch (busy_state) {
948 952
         case IN_HANDLER:

+ 12
- 0
Marlin/src/gcode/gcode.h 查看文件

@@ -351,6 +351,18 @@ public:
351 351
     process_subcommands_now_P(G28_STR);
352 352
   }
353 353
 
354
+  #if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
355
+    static bool autoreport_paused;
356
+    static inline bool set_autoreport_paused(const bool p) {
357
+      const bool was = autoreport_paused;
358
+      autoreport_paused = p;
359
+      return was;
360
+    }
361
+  #else
362
+    static constexpr bool autoreport_paused = false;
363
+    static inline bool set_autoreport_paused(const bool) { return false; }
364
+  #endif
365
+
354 366
   #if ENABLED(HOST_KEEPALIVE_FEATURE)
355 367
     /**
356 368
      * States for managing Marlin and host communication

正在加载...
取消
保存