瀏覽代碼

Inline manage_inactivity, tweak autoreport_paused

Scott Lahteine 5 年之前
父節點
當前提交
a1f026f57a

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

204
   bool wait_for_user; // = false;
204
   bool wait_for_user; // = false;
205
 #endif
205
 #endif
206
 
206
 
207
-#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
208
-  bool suspend_auto_report; // = false
209
-#endif
210
-
211
 // Inactivity shutdown
207
 // Inactivity shutdown
212
 millis_t max_inactive_time, // = 0
208
 millis_t max_inactive_time, // = 0
213
          stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL;
209
          stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL;
432
  *  - Pulse FET_SAFETY_PIN if it exists
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
   #if HAS_FILAMENT_SENSOR
433
   #if HAS_FILAMENT_SENSOR
438
     runout.run();
434
     runout.run();
697
   #endif
693
   #endif
698
 
694
 
699
   #if HAS_AUTO_REPORTING
695
   #if HAS_AUTO_REPORTING
700
-    if (!suspend_auto_report) {
696
+    if (!gcode.autoreport_paused) {
701
       #if ENABLED(AUTO_REPORT_TEMPERATURES)
697
       #if ENABLED(AUTO_REPORT_TEMPERATURES)
702
         thermalManager.auto_report_temperatures();
698
         thermalManager.auto_report_temperatures();
703
       #endif
699
       #endif

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

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

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

35
   thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made
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
 #if ENABLED(DEBUG_LEVELING_FEATURE)
50
 #if ENABLED(DEBUG_LEVELING_FEATURE)
39
 
51
 
40
   #include "../module/probe.h"
52
   #include "../module/probe.h"

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

27
 // Delay that ensures heaters and watchdog are kept alive
27
 // Delay that ensures heaters and watchdog are kept alive
28
 void safe_delay(millis_t ms);
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
 #if GRID_MAX_POINTS_X && GRID_MAX_POINTS_Y
36
 #if GRID_MAX_POINTS_X && GRID_MAX_POINTS_Y
40
 
37
 

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

28
 
28
 
29
   unified_bed_leveling ubl;
29
   unified_bed_leveling ubl;
30
 
30
 
31
+  #include "../../../MarlinCore.h"
32
+
31
   #include "../../../module/configuration_store.h"
33
   #include "../../../module/configuration_store.h"
32
   #include "../../../module/planner.h"
34
   #include "../../../module/planner.h"
33
   #include "../../../module/motion.h"
35
   #include "../../../module/motion.h"
151
    *   4: Compact Human-Readable
153
    *   4: Compact Human-Readable
152
    */
154
    */
153
   void unified_bed_leveling::display_map(const int map_type) {
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
     constexpr uint8_t eachsp = 1 + 6 + 1,                           // [-3.567]
158
     constexpr uint8_t eachsp = 1 + 6 + 1,                           // [-3.567]
159
                       twixt = eachsp * (GRID_MAX_POINTS_X) - 9 * 2; // Leading 4sp, Coordinates 9sp each
159
                       twixt = eachsp * (GRID_MAX_POINTS_X) - 9 * 2; // Leading 4sp, Coordinates 9sp each
229
       SERIAL_EOL();
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
   bool unified_bed_leveling::sanity_check() {
235
   bool unified_bed_leveling::sanity_check() {

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

53
   #include "../feature/cancel_object.h"
53
   #include "../feature/cancel_object.h"
54
 #endif
54
 #endif
55
 
55
 
56
-#include "../MarlinCore.h" // for idle() and suspend_auto_report
56
+#include "../MarlinCore.h" // for idle()
57
 
57
 
58
 millis_t GcodeSuite::previous_move_ms;
58
 millis_t GcodeSuite::previous_move_ms;
59
 
59
 
66
   | (ar_init.e ? _BV(REL_E) : 0)
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
 #if ENABLED(HOST_KEEPALIVE_FEATURE)
73
 #if ENABLED(HOST_KEEPALIVE_FEATURE)
70
   GcodeSuite::MarlinBusyState GcodeSuite::busy_state = NOT_BUSY;
74
   GcodeSuite::MarlinBusyState GcodeSuite::busy_state = NOT_BUSY;
71
   uint8_t GcodeSuite::host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL;
75
   uint8_t GcodeSuite::host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL;
942
   void GcodeSuite::host_keepalive() {
946
   void GcodeSuite::host_keepalive() {
943
     const millis_t ms = millis();
947
     const millis_t ms = millis();
944
     static millis_t next_busy_signal_ms = 0;
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
       if (PENDING(ms, next_busy_signal_ms)) return;
950
       if (PENDING(ms, next_busy_signal_ms)) return;
947
       switch (busy_state) {
951
       switch (busy_state) {
948
         case IN_HANDLER:
952
         case IN_HANDLER:

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

351
     process_subcommands_now_P(G28_STR);
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
   #if ENABLED(HOST_KEEPALIVE_FEATURE)
366
   #if ENABLED(HOST_KEEPALIVE_FEATURE)
355
     /**
367
     /**
356
      * States for managing Marlin and host communication
368
      * States for managing Marlin and host communication

Loading…
取消
儲存