Browse Source

Filament Runout Inverting => State (#18537)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Robby Candra 4 years ago
parent
commit
c02451b602
No account linked to committer's email address

+ 1
- 1
Marlin/Configuration.h View File

@@ -1167,7 +1167,7 @@
1167 1167
 //#define FILAMENT_RUNOUT_SENSOR
1168 1168
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
1169 1169
   #define NUM_RUNOUT_SENSORS   1     // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
1170
-  #define FIL_RUNOUT_INVERTING false // Set to true to invert the logic of the sensor.
1170
+  #define FIL_RUNOUT_STATE     LOW   // Pin state indicating that filament is NOT present.
1171 1171
   #define FIL_RUNOUT_PULLUP          // Use internal pullup for filament runout pins.
1172 1172
   //#define FIL_RUNOUT_PULLDOWN      // Use internal pulldown for filament runout pins.
1173 1173
 

+ 1
- 1
Marlin/src/feature/mmu2/mmu2.cpp View File

@@ -161,7 +161,7 @@ uint8_t MMU2::get_current_tool() {
161 161
 }
162 162
 
163 163
 #if EITHER(PRUSA_MMU2_S_MODE, MMU_EXTRUDER_SENSOR)
164
-  #define FILAMENT_PRESENT() (READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_INVERTING)
164
+  #define FILAMENT_PRESENT() (READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_STATE)
165 165
 #endif
166 166
 
167 167
 void MMU2::mmu_loop() {

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

@@ -148,7 +148,7 @@ class FilamentSensorBase {
148 148
 
149 149
     // Return a bitmask of runout flag states (1 bits always indicates runout)
150 150
     static inline uint8_t poll_runout_states() {
151
-      return poll_runout_pins() ^ uint8_t(TERN(FIL_RUNOUT_INVERTING, 0, _BV(NUM_RUNOUT_SENSORS) - 1));
151
+      return poll_runout_pins() ^ uint8_t(TERN(FIL_RUNOUT_STATE, 0, _BV(NUM_RUNOUT_SENSORS) - 1));
152 152
     }
153 153
 };
154 154
 

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

@@ -84,7 +84,7 @@ void GcodeSuite::M600() {
84 84
                               // In this case, for duplicating modes set DXC_ext to the extruder that ran out.
85 85
       #if HAS_FILAMENT_SENSOR && NUM_RUNOUT_SENSORS > 1
86 86
         if (dxc_is_duplicating())
87
-          DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT_INVERTING) ? 1 : 0;
87
+          DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT_STATE) ? 1 : 0;
88 88
       #else
89 89
         DXC_ext = active_extruder;
90 90
       #endif

+ 11
- 0
Marlin/src/inc/SanityCheck.h View File

@@ -513,6 +513,17 @@
513 513
   #error "DIGIPOT_I2C is now DIGIPOT_MCP4451 (or DIGIPOT_MCP4018). Please update Configuration_adv.h."
514 514
 #endif
515 515
 
516
+#ifdef FIL_RUNOUT_INVERTING
517
+  #if FIL_RUNOUT_INVERTING
518
+    #warning "FIL_RUNOUT_INVERTING true is now FIL_RUNOUT_STATE HIGH. Please update Configuration.h."
519
+  #else
520
+    #warning "FIL_RUNOUT_INVERTING false is now FIL_RUNOUT_STATE LOW. Please update Configuration.h."
521
+  #endif
522
+  #ifndef FIL_RUNOUT_STATE
523
+    #define FIL_RUNOUT_STATE ((FIL_RUNOUT_INVERTING) ? HIGH : LOW)
524
+  #endif
525
+#endif
526
+
516 527
 /**
517 528
  * Probe temp compensation requirements
518 529
  */

+ 2
- 2
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/endstop_state_screen.cpp View File

@@ -92,12 +92,12 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) {
92 92
     PIN_DISABLED(5, 3, PSTR(STR_Z_MIN), Z_MIN)
93 93
   #endif
94 94
   #if ENABLED(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT)
95
-    PIN_ENABLED (1, 4, GET_TEXT_F(MSG_RUNOUT_1), FIL_RUNOUT, FIL_RUNOUT_INVERTING)
95
+    PIN_ENABLED (1, 4, GET_TEXT_F(MSG_RUNOUT_1), FIL_RUNOUT, FIL_RUNOUT_STATE)
96 96
   #else
97 97
     PIN_DISABLED(1, 4, GET_TEXT_F(MSG_RUNOUT_1), FIL_RUNOUT)
98 98
   #endif
99 99
   #if ENABLED(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT2) && EXTRUDERS > 1
100
-    PIN_ENABLED (3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2, FIL_RUNOUT_INVERTING)
100
+    PIN_ENABLED (3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2, FIL_RUNOUT_STATE)
101 101
   #else
102 102
     PIN_DISABLED(3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2)
103 103
   #endif

+ 2
- 2
Marlin/src/module/endstops.cpp View File

@@ -459,7 +459,7 @@ void _O2 Endstops::report_states() {
459 459
   #endif
460 460
   #if HAS_FILAMENT_SENSOR
461 461
     #if NUM_RUNOUT_SENSORS == 1
462
-      print_es_state(READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_INVERTING, PSTR(STR_FILAMENT_RUNOUT_SENSOR));
462
+      print_es_state(READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_STATE, PSTR(STR_FILAMENT_RUNOUT_SENSOR));
463 463
     #else
464 464
       #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break;
465 465
       LOOP_S_LE_N(i, 1, NUM_RUNOUT_SENSORS) {
@@ -470,7 +470,7 @@ void _O2 Endstops::report_states() {
470 470
         }
471 471
         SERIAL_ECHOPGM(STR_FILAMENT_RUNOUT_SENSOR);
472 472
         if (i > 1) SERIAL_CHAR(' ', '0' + i);
473
-        print_es_state(extDigitalRead(pin) != FIL_RUNOUT_INVERTING);
473
+        print_es_state(extDigitalRead(pin) != FIL_RUNOUT_STATE);
474 474
       }
475 475
       #undef _CASE_RUNOUT
476 476
     #endif

Loading…
Cancel
Save