Przeglądaj źródła

Default Filament Runout Sensor enabled state (#19013)

Steven Haigh 3 lat temu
rodzic
commit
a62ae2aa2d
No account linked to committer's email address

+ 5
- 4
Marlin/Configuration.h Wyświetl plik

@@ -1178,10 +1178,11 @@
1178 1178
  */
1179 1179
 //#define FILAMENT_RUNOUT_SENSOR
1180 1180
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
1181
-  #define NUM_RUNOUT_SENSORS   1     // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
1182
-  #define FIL_RUNOUT_STATE     LOW   // Pin state indicating that filament is NOT present.
1183
-  #define FIL_RUNOUT_PULLUP          // Use internal pullup for filament runout pins.
1184
-  //#define FIL_RUNOUT_PULLDOWN      // Use internal pulldown for filament runout pins.
1181
+  #define FIL_RUNOUT_ENABLED_DEFAULT true // Enable the sensor on startup. Override with M412 followed by M500.
1182
+  #define NUM_RUNOUT_SENSORS   1          // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
1183
+  #define FIL_RUNOUT_STATE     LOW        // Pin state indicating that filament is NOT present.
1184
+  #define FIL_RUNOUT_PULLUP               // Use internal pullup for filament runout pins.
1185
+  //#define FIL_RUNOUT_PULLDOWN           // Use internal pulldown for filament runout pins.
1185 1186
 
1186 1187
   // Set one or more commands to execute on filament runout.
1187 1188
   // (After 'M412 H' Marlin will ask the host to handle the process.)

+ 0
- 8
Marlin/src/feature/runout.cpp Wyświetl plik

@@ -44,14 +44,6 @@ bool FilamentMonitorBase::enabled = true,
44 44
   #include "../module/tool_change.h"
45 45
 #endif
46 46
 
47
-/**
48
- * Called by FilamentSensorSwitch::run when filament is detected.
49
- * Called by FilamentSensorEncoder::block_completed when motion is detected.
50
- */
51
-void FilamentSensorBase::filament_present(const uint8_t extruder) {
52
-  runout.filament_present(extruder); // calls response.filament_present(extruder)
53
-}
54
-
55 47
 #if HAS_FILAMENT_RUNOUT_DISTANCE
56 48
   float RunoutResponseDelayed::runout_distance_mm = FILAMENT_RUNOUT_DISTANCE_MM;
57 49
   volatile float RunoutResponseDelayed::runout_mm_countdown[EXTRUDERS];

+ 25
- 10
Marlin/src/feature/runout.h Wyświetl plik

@@ -48,6 +48,24 @@
48 48
 
49 49
 void event_filament_runout();
50 50
 
51
+template<class RESPONSE_T, class SENSOR_T>
52
+class TFilamentMonitor;
53
+class FilamentSensorEncoder;
54
+class FilamentSensorSwitch;
55
+class RunoutResponseDelayed;
56
+class RunoutResponseDebounced;
57
+
58
+/********************************* TEMPLATE SPECIALIZATION *********************************/
59
+
60
+typedef TFilamentMonitor<
61
+          TERN(HAS_FILAMENT_RUNOUT_DISTANCE, RunoutResponseDelayed, RunoutResponseDebounced),
62
+          TERN(FILAMENT_MOTION_SENSOR, FilamentSensorEncoder, FilamentSensorSwitch)
63
+        > FilamentMonitor;
64
+
65
+extern FilamentMonitor runout;
66
+
67
+/*******************************************************************************************/
68
+
51 69
 class FilamentMonitorBase {
52 70
   public:
53 71
     static bool enabled, filament_ran_out;
@@ -121,7 +139,13 @@ class TFilamentMonitor : public FilamentMonitorBase {
121 139
 
122 140
 class FilamentSensorBase {
123 141
   protected:
124
-    static void filament_present(const uint8_t extruder);
142
+    /**
143
+     * Called by FilamentSensorSwitch::run when filament is detected.
144
+     * Called by FilamentSensorEncoder::block_completed when motion is detected.
145
+     */
146
+    static inline void filament_present(const uint8_t extruder) {
147
+      runout.filament_present(extruder); // ...which calls response.filament_present(extruder)
148
+    }
125 149
 
126 150
   public:
127 151
     static inline void setup() {
@@ -311,12 +335,3 @@ class FilamentSensorBase {
311 335
   };
312 336
 
313 337
 #endif // !HAS_FILAMENT_RUNOUT_DISTANCE
314
-
315
-/********************************* TEMPLATE SPECIALIZATION *********************************/
316
-
317
-typedef TFilamentMonitor<
318
-          TERN(HAS_FILAMENT_RUNOUT_DISTANCE, RunoutResponseDelayed, RunoutResponseDebounced),
319
-          TERN(FILAMENT_MOTION_SENSOR, FilamentSensorEncoder, FilamentSensorSwitch)
320
-        > FilamentMonitor;
321
-
322
-extern FilamentMonitor runout;

+ 12
- 9
Marlin/src/module/settings.cpp Wyświetl plik

@@ -106,6 +106,9 @@
106 106
 
107 107
 #if HAS_FILAMENT_SENSOR
108 108
   #include "../feature/runout.h"
109
+  #ifndef FIL_RUNOUT_ENABLED_DEFAULT
110
+    #define FIL_RUNOUT_ENABLED_DEFAULT true
111
+  #endif
109 112
 #endif
110 113
 
111 114
 #if ENABLED(EXTRA_LIN_ADVANCE_K)
@@ -646,15 +649,16 @@ void MarlinSettings::postprocess() {
646 649
       #if HAS_FILAMENT_SENSOR
647 650
         const bool &runout_sensor_enabled = runout.enabled;
648 651
       #else
649
-        constexpr bool runout_sensor_enabled = true;
652
+        constexpr int8_t runout_sensor_enabled = -1;
650 653
       #endif
654
+      _FIELD_TEST(runout_sensor_enabled);
655
+      EEPROM_WRITE(runout_sensor_enabled);
656
+
651 657
       #if HAS_FILAMENT_RUNOUT_DISTANCE
652 658
         const float &runout_distance_mm = runout.runout_distance();
653 659
       #else
654 660
         constexpr float runout_distance_mm = 0;
655 661
       #endif
656
-      _FIELD_TEST(runout_sensor_enabled);
657
-      EEPROM_WRITE(runout_sensor_enabled);
658 662
       EEPROM_WRITE(runout_distance_mm);
659 663
     }
660 664
 
@@ -1518,13 +1522,12 @@ void MarlinSettings::postprocess() {
1518 1522
       // Filament Runout Sensor
1519 1523
       //
1520 1524
       {
1521
-        #if HAS_FILAMENT_SENSOR
1522
-          const bool &runout_sensor_enabled = runout.enabled;
1523
-        #else
1524
-          bool runout_sensor_enabled;
1525
-        #endif
1525
+        int8_t runout_sensor_enabled;
1526 1526
         _FIELD_TEST(runout_sensor_enabled);
1527 1527
         EEPROM_READ(runout_sensor_enabled);
1528
+        #if HAS_FILAMENT_SENSOR
1529
+          runout.enabled = runout_sensor_enabled < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled;
1530
+        #endif
1528 1531
 
1529 1532
         TERN_(HAS_FILAMENT_SENSOR, if (runout.enabled) runout.reset());
1530 1533
 
@@ -2476,7 +2479,7 @@ void MarlinSettings::reset() {
2476 2479
   //
2477 2480
 
2478 2481
   #if HAS_FILAMENT_SENSOR
2479
-    runout.enabled = true;
2482
+    runout.enabled = FIL_RUNOUT_ENABLED_DEFAULT;
2480 2483
     runout.reset();
2481 2484
     TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM));
2482 2485
   #endif

Ładowanie…
Anuluj
Zapisz