Pārlūkot izejas kodu

Move host keepalive to GcodeSuite

Scott Lahteine 8 gadus atpakaļ
vecāks
revīzija
8dc2838d98

+ 3
- 49
Marlin/src/Marlin.cpp Parādīt failu

353
   int lpq_len = 20;
353
   int lpq_len = 20;
354
 #endif
354
 #endif
355
 
355
 
356
-#if ENABLED(HOST_KEEPALIVE_FEATURE)
357
-  MarlinBusyState busy_state = NOT_BUSY;
358
-  static millis_t next_busy_signal_ms = 0;
359
-  uint8_t host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL;
360
-#else
361
-  #define host_keepalive() NOOP
362
-#endif
363
-
364
 #if ENABLED(I2C_POSITION_ENCODERS)
356
 #if ENABLED(I2C_POSITION_ENCODERS)
365
   I2CPositionEncodersMgr I2CPEM;
357
   I2CPositionEncodersMgr I2CPEM;
366
   uint8_t blockBufferIndexRef = 0;
358
   uint8_t blockBufferIndexRef = 0;
2245
 
2237
 
2246
 #endif
2238
 #endif
2247
 
2239
 
2248
-/**
2249
- * ***************************************************************************
2250
- * ***************************** G-CODE HANDLING *****************************
2251
- * ***************************************************************************
2252
- */
2253
-
2254
-#if ENABLED(HOST_KEEPALIVE_FEATURE)
2255
-
2256
-  /**
2257
-   * Output a "busy" message at regular intervals
2258
-   * while the machine is not accepting commands.
2259
-   */
2260
-  void host_keepalive() {
2261
-    const millis_t ms = millis();
2262
-    if (host_keepalive_interval && busy_state != NOT_BUSY) {
2263
-      if (PENDING(ms, next_busy_signal_ms)) return;
2264
-      switch (busy_state) {
2265
-        case IN_HANDLER:
2266
-        case IN_PROCESS:
2267
-          SERIAL_ECHO_START();
2268
-          SERIAL_ECHOLNPGM(MSG_BUSY_PROCESSING);
2269
-          break;
2270
-        case PAUSED_FOR_USER:
2271
-          SERIAL_ECHO_START();
2272
-          SERIAL_ECHOLNPGM(MSG_BUSY_PAUSED_FOR_USER);
2273
-          break;
2274
-        case PAUSED_FOR_INPUT:
2275
-          SERIAL_ECHO_START();
2276
-          SERIAL_ECHOLNPGM(MSG_BUSY_PAUSED_FOR_INPUT);
2277
-          break;
2278
-        default:
2279
-          break;
2280
-      }
2281
-    }
2282
-    next_busy_signal_ms = ms + host_keepalive_interval * 1000UL;
2283
-  }
2284
-
2285
-#endif // HOST_KEEPALIVE_FEATURE
2286
-
2287
-
2288
 /**************************************************
2240
 /**************************************************
2289
  ***************** GCode Handlers *****************
2241
  ***************** GCode Handlers *****************
2290
  **************************************************/
2242
  **************************************************/
3574
 
3526
 
3575
   lcd_update();
3527
   lcd_update();
3576
 
3528
 
3577
-  host_keepalive();
3529
+  #if ENABLED(HOST_KEEPALIVE_FEATURE)
3530
+    gcode.host_keepalive();
3531
+  #endif
3578
 
3532
 
3579
   #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
3533
   #if ENABLED(AUTO_REPORT_TEMPERATURES) && (HAS_TEMP_HOTEND || HAS_TEMP_BED)
3580
     auto_report_temperatures();
3534
     auto_report_temperatures();

+ 0
- 7
Marlin/src/Marlin.h Parādīt failu

266
   #define STOW_PROBE()
266
   #define STOW_PROBE()
267
 #endif
267
 #endif
268
 
268
 
269
-#if ENABLED(HOST_KEEPALIVE_FEATURE)
270
-  extern MarlinBusyState busy_state;
271
-  #define KEEPALIVE_STATE(n) do{ busy_state = n; }while(0)
272
-#else
273
-  #define KEEPALIVE_STATE(n) NOOP
274
-#endif
275
-
276
 #if FAN_COUNT > 0
269
 #if FAN_COUNT > 0
277
   extern int16_t fanSpeeds[FAN_COUNT];
270
   extern int16_t fanSpeeds[FAN_COUNT];
278
   #if ENABLED(PROBING_FANS_OFF)
271
   #if ENABLED(PROBING_FANS_OFF)

+ 0
- 14
Marlin/src/core/enum.h Parādīt failu

122
 #endif
122
 #endif
123
 
123
 
124
 /**
124
 /**
125
- * States for managing Marlin and host communication
126
- * Marlin sends messages if blocked or busy
127
- */
128
-#if ENABLED(HOST_KEEPALIVE_FEATURE)
129
-  enum MarlinBusyState {
130
-    NOT_BUSY,           // Not in a handler
131
-    IN_HANDLER,         // Processing a GCode
132
-    IN_PROCESS,         // Known to be blocking command input (as in G29)
133
-    PAUSED_FOR_USER,    // Blocking pending any input
134
-    PAUSED_FOR_INPUT    // Blocking pending text input (concept)
135
-  };
136
-#endif
137
-
138
-/**
139
  * SD Card
125
  * SD Card
140
  */
126
  */
141
 enum LsAction { LS_SerialPrint, LS_Count, LS_GetFilename };
127
 enum LsAction { LS_SerialPrint, LS_Count, LS_GetFilename };

+ 39
- 0
Marlin/src/gcode/gcode.cpp Parādīt failu

41
 
41
 
42
 bool GcodeSuite::axis_relative_modes[] = AXIS_RELATIVE_MODES;
42
 bool GcodeSuite::axis_relative_modes[] = AXIS_RELATIVE_MODES;
43
 
43
 
44
+#if ENABLED(HOST_KEEPALIVE_FEATURE)
45
+  GcodeSuite::MarlinBusyState GcodeSuite::busy_state = NOT_BUSY;
46
+  uint8_t GcodeSuite::host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL;
47
+#endif
48
+
44
 /**
49
 /**
45
  * Set target_extruder from the T parameter or the active_extruder
50
  * Set target_extruder from the T parameter or the active_extruder
46
  *
51
  *
1068
 
1073
 
1069
   ok_to_send();
1074
   ok_to_send();
1070
 }
1075
 }
1076
+
1077
+#if ENABLED(HOST_KEEPALIVE_FEATURE)
1078
+
1079
+  /**
1080
+   * Output a "busy" message at regular intervals
1081
+   * while the machine is not accepting commands.
1082
+   */
1083
+  void GcodeSuite::host_keepalive() {
1084
+    const millis_t ms = millis();
1085
+    static millis_t next_busy_signal_ms = 0;
1086
+    if (host_keepalive_interval && busy_state != NOT_BUSY) {
1087
+      if (PENDING(ms, next_busy_signal_ms)) return;
1088
+      switch (busy_state) {
1089
+        case IN_HANDLER:
1090
+        case IN_PROCESS:
1091
+          SERIAL_ECHO_START();
1092
+          SERIAL_ECHOLNPGM(MSG_BUSY_PROCESSING);
1093
+          break;
1094
+        case PAUSED_FOR_USER:
1095
+          SERIAL_ECHO_START();
1096
+          SERIAL_ECHOLNPGM(MSG_BUSY_PAUSED_FOR_USER);
1097
+          break;
1098
+        case PAUSED_FOR_INPUT:
1099
+          SERIAL_ECHO_START();
1100
+          SERIAL_ECHOLNPGM(MSG_BUSY_PAUSED_FOR_INPUT);
1101
+          break;
1102
+        default:
1103
+          break;
1104
+      }
1105
+    }
1106
+    next_busy_signal_ms = ms + host_keepalive_interval * 1000UL;
1107
+  }
1108
+
1109
+#endif // HOST_KEEPALIVE_FEATURE

+ 24
- 1
Marlin/src/gcode/gcode.h Parādīt failu

263
   static void get_destination_from_command();
263
   static void get_destination_from_command();
264
   static void process_next_command();
264
   static void process_next_command();
265
 
265
 
266
+  static FORCE_INLINE void home_all_axes() { G28(true); }
267
+
266
   /**
268
   /**
267
    * Multi-stepper support for M92, M201, M203
269
    * Multi-stepper support for M92, M201, M203
268
    */
270
    */
274
     #define TARGET_EXTRUDER 0
276
     #define TARGET_EXTRUDER 0
275
   #endif
277
   #endif
276
 
278
 
277
-  static FORCE_INLINE void home_all_axes() { G28(true); }
279
+  #if ENABLED(HOST_KEEPALIVE_FEATURE)
280
+    /**
281
+     * States for managing Marlin and host communication
282
+     * Marlin sends messages if blocked or busy
283
+     */
284
+    enum MarlinBusyState {
285
+      NOT_BUSY,           // Not in a handler
286
+      IN_HANDLER,         // Processing a GCode
287
+      IN_PROCESS,         // Known to be blocking command input (as in G29)
288
+      PAUSED_FOR_USER,    // Blocking pending any input
289
+      PAUSED_FOR_INPUT    // Blocking pending text input (concept)
290
+    };
291
+
292
+    static MarlinBusyState busy_state;
293
+    static uint8_t host_keepalive_interval;
294
+
295
+    static void host_keepalive();
296
+
297
+    #define KEEPALIVE_STATE(n) gcode.busy_state = gcode.n
298
+  #else
299
+    #define KEEPALIVE_STATE(n) NOOP
300
+  #endif
278
 
301
 
279
 private:
302
 private:
280
 
303
 

+ 3
- 3
Marlin/src/gcode/host/M113.h Parādīt failu

27
  */
27
  */
28
 void gcode_M113() {
28
 void gcode_M113() {
29
   if (parser.seenval('S')) {
29
   if (parser.seenval('S')) {
30
-    host_keepalive_interval = parser.value_byte();
31
-    NOMORE(host_keepalive_interval, 60);
30
+    gcode.host_keepalive_interval = parser.value_byte();
31
+    NOMORE(gcode.host_keepalive_interval, 60);
32
   }
32
   }
33
   else {
33
   else {
34
     SERIAL_ECHO_START();
34
     SERIAL_ECHO_START();
35
-    SERIAL_ECHOLNPAIR("M113 S", (unsigned long)host_keepalive_interval);
35
+    SERIAL_ECHOLNPAIR("M113 S", (unsigned long)gcode.host_keepalive_interval);
36
   }
36
   }
37
 }
37
 }

Notiek ielāde…
Atcelt
Saglabāt