Browse Source

Handle runout in runout.cpp

Scott Lahteine 4 years ago
parent
commit
0322348924

+ 1
- 1
Marlin/src/HAL/HAL_LPC1768/main.cpp View File

@@ -155,7 +155,7 @@ void HAL_idletask() {
155 155
     // a PC via USB.
156 156
     // Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
157 157
     // this will not reliably detect delete operations. To be safe we will lock
158
-    // the disk if Marlin has it mounted. Unfortuately there is currently no way
158
+    // the disk if Marlin has it mounted. Unfortunately there is currently no way
159 159
     // to unmount the disk from the LCD menu.
160 160
     // if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
161 161
     if (card.isMounted())

+ 1
- 1
Marlin/src/HAL/HAL_STM32F1/HAL.cpp View File

@@ -233,7 +233,7 @@ void HAL_idletask() {
233 233
       // a PC via USB.
234 234
       // Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
235 235
       // this will not reliably detect delete operations. To be safe we will lock
236
-      // the disk if Marlin has it mounted. Unfortuately there is currently no way
236
+      // the disk if Marlin has it mounted. Unfortunately there is currently no way
237 237
       // to unmount the disk from the LCD menu.
238 238
       // if (IS_SD_PRINTING() || IS_SD_FILE_OPEN())
239 239
       /* copy from lpc1768 framework, should be fixed later for process SHARED_SD_CARD*/

+ 0
- 69
Marlin/src/Marlin.cpp View File

@@ -173,10 +173,6 @@
173 173
   #include "feature/prusa_MMU2/mmu2.h"
174 174
 #endif
175 175
 
176
-#if ENABLED(EXTENSIBLE_UI)
177
-  #include "lcd/extensible_ui/ui_api.h"
178
-#endif
179
-
180 176
 #if HAS_DRIVER(L6470)
181 177
   #include "libs/L6470/L6470_Marlin.h"
182 178
 #endif
@@ -330,71 +326,6 @@ void disable_all_steppers() {
330 326
   disable_e_steppers();
331 327
 }
332 328
 
333
-#if HAS_FILAMENT_SENSOR
334
-
335
-  void event_filament_runout() {
336
-
337
-    #if ENABLED(ADVANCED_PAUSE_FEATURE)
338
-      if (did_pause_print) return;  // Action already in progress. Purge triggered repeated runout.
339
-    #endif
340
-
341
-    #if ENABLED(EXTENSIBLE_UI)
342
-      ExtUI::onFilamentRunout(ExtUI::getActiveTool());
343
-    #endif
344
-
345
-    #if EITHER(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS)
346
-      const char tool = '0'
347
-        #if NUM_RUNOUT_SENSORS > 1
348
-          + active_extruder
349
-        #endif
350
-      ;
351
-    #endif
352
-
353
-    //action:out_of_filament
354
-    #if ENABLED(HOST_PROMPT_SUPPORT)
355
-      host_prompt_reason = PROMPT_FILAMENT_RUNOUT;
356
-      host_action_prompt_end();
357
-      host_action_prompt_begin(PSTR("FilamentRunout T"), false);
358
-      SERIAL_CHAR(tool);
359
-      SERIAL_EOL();
360
-      host_action_prompt_show();
361
-    #endif
362
-
363
-    const bool run_runout_script = !runout.host_handling;
364
-
365
-    #if ENABLED(HOST_ACTION_COMMANDS)
366
-      if (run_runout_script
367
-        && ( strstr(FILAMENT_RUNOUT_SCRIPT, "M600")
368
-          || strstr(FILAMENT_RUNOUT_SCRIPT, "M125")
369
-          #if ENABLED(ADVANCED_PAUSE_FEATURE)
370
-            || strstr(FILAMENT_RUNOUT_SCRIPT, "M25")
371
-          #endif
372
-        )
373
-      ) {
374
-        host_action_paused(false);
375
-      }
376
-      else {
377
-        // Legacy Repetier command for use until newer version supports standard dialog
378
-        // To be removed later when pause command also triggers dialog
379
-        #ifdef ACTION_ON_FILAMENT_RUNOUT
380
-          host_action(PSTR(ACTION_ON_FILAMENT_RUNOUT " T"), false);
381
-          SERIAL_CHAR(tool);
382
-          SERIAL_EOL();
383
-        #endif
384
-
385
-        host_action_pause(false);
386
-      }
387
-      SERIAL_ECHOPGM(" " ACTION_REASON_ON_FILAMENT_RUNOUT " ");
388
-      SERIAL_CHAR(tool);
389
-      SERIAL_EOL();
390
-    #endif // HOST_ACTION_COMMANDS
391
-
392
-    if (run_runout_script)
393
-      queue.inject_P(PSTR(FILAMENT_RUNOUT_SCRIPT));
394
-  }
395
-
396
-#endif // HAS_FILAMENT_SENSOR
397
-
398 329
 #if ENABLED(G29_RETRY_AND_RECOVER)
399 330
 
400 331
   void event_probe_failure() {

+ 0
- 4
Marlin/src/Marlin.h View File

@@ -371,10 +371,6 @@ void protected_pin_err();
371 371
   inline void suicide() { OUT_WRITE(SUICIDE_PIN, LOW); }
372 372
 #endif
373 373
 
374
-#if HAS_FILAMENT_SENSOR
375
-  void event_filament_runout();
376
-#endif
377
-
378 374
 #if ENABLED(G29_RETRY_AND_RECOVER)
379 375
   void event_probe_recover();
380 376
   void event_probe_failure();

+ 75
- 0
Marlin/src/feature/runout.cpp View File

@@ -58,4 +58,79 @@ void FilamentSensorBase::filament_present(const uint8_t extruder) {
58 58
   int8_t RunoutResponseDebounced::runout_count; // = 0
59 59
 #endif
60 60
 
61
+//
62
+// Filament Runout event handler
63
+//
64
+#include "../Marlin.h"
65
+#include "../gcode/queue.h"
66
+
67
+#if ENABLED(HOST_ACTION_COMMANDS)
68
+  #include "host_actions.h"
69
+#endif
70
+
71
+#if ENABLED(EXTENSIBLE_UI)
72
+  #include "../lcd/extensible_ui/ui_api.h"
73
+#endif
74
+
75
+void event_filament_runout() {
76
+
77
+  #if ENABLED(ADVANCED_PAUSE_FEATURE)
78
+    if (did_pause_print) return;  // Action already in progress. Purge triggered repeated runout.
79
+  #endif
80
+
81
+  #if ENABLED(EXTENSIBLE_UI)
82
+    ExtUI::onFilamentRunout(ExtUI::getActiveTool());
83
+  #endif
84
+
85
+  #if EITHER(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS)
86
+    const char tool = '0'
87
+      #if NUM_RUNOUT_SENSORS > 1
88
+        + active_extruder
89
+      #endif
90
+    ;
91
+  #endif
92
+
93
+  //action:out_of_filament
94
+  #if ENABLED(HOST_PROMPT_SUPPORT)
95
+    host_prompt_reason = PROMPT_FILAMENT_RUNOUT;
96
+    host_action_prompt_end();
97
+    host_action_prompt_begin(PSTR("FilamentRunout T"), false);
98
+    SERIAL_CHAR(tool);
99
+    SERIAL_EOL();
100
+    host_action_prompt_show();
101
+  #endif
102
+
103
+  const bool run_runout_script = !runout.host_handling;
104
+
105
+  #if ENABLED(HOST_ACTION_COMMANDS)
106
+    if (run_runout_script
107
+      && ( strstr(FILAMENT_RUNOUT_SCRIPT, "M600")
108
+        || strstr(FILAMENT_RUNOUT_SCRIPT, "M125")
109
+        #if ENABLED(ADVANCED_PAUSE_FEATURE)
110
+          || strstr(FILAMENT_RUNOUT_SCRIPT, "M25")
111
+        #endif
112
+      )
113
+    ) {
114
+      host_action_paused(false);
115
+    }
116
+    else {
117
+      // Legacy Repetier command for use until newer version supports standard dialog
118
+      // To be removed later when pause command also triggers dialog
119
+      #ifdef ACTION_ON_FILAMENT_RUNOUT
120
+        host_action(PSTR(ACTION_ON_FILAMENT_RUNOUT " T"), false);
121
+        SERIAL_CHAR(tool);
122
+        SERIAL_EOL();
123
+      #endif
124
+
125
+      host_action_pause(false);
126
+    }
127
+    SERIAL_ECHOPGM(" " ACTION_REASON_ON_FILAMENT_RUNOUT " ");
128
+    SERIAL_CHAR(tool);
129
+    SERIAL_EOL();
130
+  #endif // HOST_ACTION_COMMANDS
131
+
132
+  if (run_runout_script)
133
+    queue.inject_P(PSTR(FILAMENT_RUNOUT_SCRIPT));
134
+}
135
+
61 136
 #endif // HAS_FILAMENT_SENSOR

+ 2
- 0
Marlin/src/feature/runout.h View File

@@ -46,6 +46,8 @@
46 46
   #define FILAMENT_RUNOUT_THRESHOLD 5
47 47
 #endif
48 48
 
49
+void event_filament_runout();
50
+
49 51
 class FilamentMonitorBase {
50 52
   public:
51 53
     static bool enabled, filament_ran_out;

+ 14
- 9
Marlin/src/gcode/feature/pause/M701_M702.cpp View File

@@ -102,15 +102,20 @@ void GcodeSuite::M701() {
102 102
   #if ENABLED(PRUSA_MMU2)
103 103
     mmu2.load_filament_to_nozzle(target_extruder);
104 104
   #else
105
-    constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
106
-    const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
107
-                                                        : fc_settings[active_extruder].load_length);
108
-    load_filament(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, FILAMENT_CHANGE_ALERT_BEEPS,
109
-                  true, thermalManager.still_heating(target_extruder), PAUSE_MODE_LOAD_FILAMENT
110
-                  #if ENABLED(DUAL_X_CARRIAGE)
111
-                    , target_extruder
112
-                  #endif
113
-                );
105
+    constexpr float     purge_length = ADVANCED_PAUSE_PURGE_LENGTH,
106
+                    slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
107
+        const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
108
+                                                            : fc_settings[active_extruder].load_length);
109
+    load_filament(
110
+      slow_load_length, fast_load_length, purge_length,
111
+      FILAMENT_CHANGE_ALERT_BEEPS,
112
+      true,                                           // show_lcd
113
+      thermalManager.still_heating(target_extruder),  // pause_for_user
114
+      PAUSE_MODE_LOAD_FILAMENT                        // pause_mode
115
+      #if ENABLED(DUAL_X_CARRIAGE)
116
+        , target_extruder                             // Dual X target
117
+      #endif
118
+    );
114 119
   #endif
115 120
 
116 121
   // Restore Z axis

Loading…
Cancel
Save