Browse Source

Filament sensor cleanup

Scott Lahteine 3 years ago
parent
commit
1aa421efe5

+ 1
- 5
Marlin/src/feature/pause.cpp View File

@@ -192,11 +192,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
192 192
     KEEPALIVE_STATE(PAUSED_FOR_USER);
193 193
     wait_for_user = true;    // LCD click or M108 will clear this
194 194
     #if ENABLED(HOST_PROMPT_SUPPORT)
195
-      const char tool = '0'
196
-        #if NUM_RUNOUT_SENSORS > 1
197
-          + active_extruder
198
-        #endif
199
-      ;
195
+      const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, active_extruder);
200 196
       host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Load Filament T"), tool, CONTINUE_STR);
201 197
     #endif
202 198
 

+ 1
- 5
Marlin/src/feature/runout.cpp View File

@@ -88,11 +88,7 @@ void event_filament_runout() {
88 88
   TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getActiveTool()));
89 89
 
90 90
   #if EITHER(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS)
91
-    const char tool = '0'
92
-      #if NUM_RUNOUT_SENSORS > 1
93
-        + active_extruder
94
-      #endif
95
-    ;
91
+    const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, active_extruder);
96 92
   #endif
97 93
 
98 94
   //action:out_of_filament

+ 6
- 6
Marlin/src/feature/runout.h View File

@@ -230,7 +230,7 @@ class FilamentSensorBase {
230 230
                       change    = old_state ^ new_state;
231 231
         old_state = new_state;
232 232
 
233
-        #ifdef FILAMENT_RUNOUT_SENSOR_DEBUG
233
+        #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)
234 234
           if (change) {
235 235
             SERIAL_ECHOPGM("Motion detected:");
236 236
             LOOP_L_N(e, NUM_RUNOUT_SENSORS)
@@ -266,12 +266,12 @@ class FilamentSensorBase {
266 266
     private:
267 267
       static inline bool poll_runout_state(const uint8_t extruder) {
268 268
         const uint8_t runout_states = poll_runout_states();
269
-        #if NUM_RUNOUT_SENSORS == 1
270
-          UNUSED(extruder);
271
-        #else
269
+        #if MULTI_FILAMENT_SENSOR
272 270
           if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())
273 271
             && !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled)
274 272
           ) return TEST(runout_states, extruder); // A specific extruder ran out
273
+        #else
274
+          UNUSED(extruder);
275 275
         #endif
276 276
         return !!runout_states;                   // Any extruder ran out
277 277
       }
@@ -282,7 +282,7 @@ class FilamentSensorBase {
282 282
       static inline void run() {
283 283
         const bool out = poll_runout_state(active_extruder);
284 284
         if (!out) filament_present(active_extruder);
285
-        #ifdef FILAMENT_RUNOUT_SENSOR_DEBUG
285
+        #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)
286 286
           static bool was_out = false;
287 287
           if (out != was_out) {
288 288
             was_out = out;
@@ -315,7 +315,7 @@ class FilamentSensorBase {
315 315
       }
316 316
 
317 317
       static inline void run() {
318
-        #ifdef FILAMENT_RUNOUT_SENSOR_DEBUG
318
+        #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)
319 319
           static millis_t t = 0;
320 320
           const millis_t ms = millis();
321 321
           if (ELAPSED(ms, t)) {

+ 1
- 1
Marlin/src/gcode/feature/pause/M600.cpp View File

@@ -83,7 +83,7 @@ void GcodeSuite::M600() {
83 83
     int8_t DXC_ext = target_extruder;
84 84
     if (!parser.seen('T')) {  // If no tool index is specified, M600 was (probably) sent in response to filament runout.
85 85
                               // In this case, for duplicating modes set DXC_ext to the extruder that ran out.
86
-      #if HAS_FILAMENT_SENSOR && NUM_RUNOUT_SENSORS > 1
86
+      #if MULTI_FILAMENT_SENSOR
87 87
         if (idex_is_duplicating())
88 88
           DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT2_STATE) ? 1 : 0;
89 89
       #else

+ 3
- 0
Marlin/src/inc/Conditionals_adv.h View File

@@ -128,6 +128,9 @@
128 128
 
129 129
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
130 130
   #define HAS_FILAMENT_SENSOR 1
131
+  #if NUM_RUNOUT_SENSORS > 1
132
+    #define MULTI_FILAMENT_SENSOR 1
133
+  #endif
131 134
   #ifdef FILAMENT_RUNOUT_DISTANCE_MM
132 135
     #define HAS_FILAMENT_RUNOUT_DISTANCE 1
133 136
   #endif

+ 6
- 2
Marlin/src/lcd/extui/ui_api.cpp View File

@@ -340,8 +340,10 @@ namespace ExtUI {
340 340
     #endif
341 341
   }
342 342
 
343
-  extruder_t getActiveTool() {
344
-    switch (active_extruder) {
343
+  extruder_t getTool(const uint8_t extruder) {
344
+    switch (extruder) {
345
+      case 7:  return E7;
346
+      case 6:  return E6;
345 347
       case 5:  return E5;
346 348
       case 4:  return E4;
347 349
       case 3:  return E3;
@@ -351,6 +353,8 @@ namespace ExtUI {
351 353
     }
352 354
   }
353 355
 
356
+  extruder_t getActiveTool() { return getTool(active_extruder); }
357
+
354 358
   bool isMoving() { return planner.has_blocks_queued(); }
355 359
 
356 360
   bool canMove(const axis_t axis) {

+ 1
- 0
Marlin/src/lcd/extui/ui_api.h View File

@@ -215,6 +215,7 @@ namespace ExtUI {
215 215
     void setAxisMaxJerk_mm_s(const float, const extruder_t);
216 216
   #endif
217 217
 
218
+  extruder_t getTool(const uint8_t extruder);
218 219
   extruder_t getActiveTool();
219 220
   void setActiveTool(const extruder_t, bool no_move);
220 221
 

+ 1
- 1
Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h View File

@@ -35,7 +35,7 @@
35 35
 #define MOSFET_D_PIN                           7
36 36
 
37 37
 #define FIL_RUNOUT_PIN                         2
38
-#if NUM_RUNOUT_SENSORS > 1
38
+#if NUM_RUNOUT_SENSORS >= 2
39 39
   #define FIL_RUNOUT2_PIN                     15  // Creality CR-X can use dual runout sensors
40 40
 #endif
41 41
 

Loading…
Cancel
Save