Переглянути джерело

settings: store runout sensor on/off (#13876)

Tanguy Pruvot 6 роки тому
джерело
коміт
e5438a9a03
1 змінених файлів з 60 додано та 1 видалено
  1. 60
    1
      Marlin/src/module/configuration_store.cpp

+ 60
- 1
Marlin/src/module/configuration_store.cpp Переглянути файл

@@ -37,7 +37,7 @@
37 37
  */
38 38
 
39 39
 // Change EEPROM version if the structure changes
40
-#define EEPROM_VERSION "V64"
40
+#define EEPROM_VERSION "V65"
41 41
 #define EEPROM_OFFSET 100
42 42
 
43 43
 // Check the integrity of data offsets.
@@ -90,6 +90,10 @@
90 90
 
91 91
 #include "../feature/pause.h"
92 92
 
93
+#if HAS_FILAMENT_SENSOR
94
+  #include "../feature/runout.h"
95
+#endif
96
+
93 97
 #if ENABLED(EXTRA_LIN_ADVANCE_K)
94 98
 extern float saved_extruder_advance_K[EXTRUDERS];
95 99
 #endif
@@ -142,6 +146,11 @@ typedef struct SettingsDataStruct {
142 146
   #endif
143 147
 
144 148
   //
149
+  // FILAMENT_RUNOUT_SENSOR
150
+  //
151
+  bool runout_sensor_enabled;                           // M412 S
152
+
153
+  //
145 154
   // ENABLE_LEVELING_FADE_HEIGHT
146 155
   //
147 156
   float planner_z_fade_height;                          // M420 Zn  planner.z_fade_height
@@ -291,6 +300,8 @@ typedef struct SettingsDataStruct {
291 300
 
292 301
 } SettingsData;
293 302
 
303
+//static_assert(sizeof(SettingsData) <= E2END + 1, "EEPROM too small to contain SettingsData!");
304
+
294 305
 MarlinSettings settings;
295 306
 
296 307
 uint16_t MarlinSettings::datasize() { return sizeof(SettingsData); }
@@ -513,6 +524,18 @@ void MarlinSettings::postprocess() {
513 524
     }
514 525
 
515 526
     //
527
+    // Filament Runout Sensor
528
+    //
529
+    {
530
+      #if HAS_FILAMENT_SENSOR
531
+        EEPROM_WRITE(runout.enabled);
532
+      #else
533
+        const bool runout_sensor_enabled = true;
534
+        EEPROM_WRITE(runout_sensor_enabled);
535
+      #endif
536
+    }
537
+
538
+    //
516 539
     // Global Leveling
517 540
     //
518 541
     {
@@ -1238,6 +1261,19 @@ void MarlinSettings::postprocess() {
1238 1261
       }
1239 1262
 
1240 1263
       //
1264
+      // Filament Runout Sensor
1265
+      //
1266
+      {
1267
+        _FIELD_TEST(runout_sensor_enabled);
1268
+        #if HAS_FILAMENT_SENSOR
1269
+          EEPROM_READ(runout.enabled);
1270
+        #else
1271
+          bool runout_sensor_enabled;
1272
+          EEPROM_READ(runout_sensor_enabled);
1273
+        #endif
1274
+      }
1275
+
1276
+      //
1241 1277
       // Global Leveling
1242 1278
       //
1243 1279
       {
@@ -2047,6 +2083,19 @@ void MarlinSettings::reset() {
2047 2083
     reset_hotend_offsets();
2048 2084
   #endif
2049 2085
 
2086
+  //
2087
+  // Filament Runout Sensor
2088
+  //
2089
+
2090
+  #if HAS_FILAMENT_SENSOR
2091
+    runout.enabled = true;
2092
+    runout.reset();
2093
+  #endif
2094
+
2095
+  //
2096
+  // Tool-change Settings
2097
+  //
2098
+
2050 2099
   #if EXTRUDERS > 1
2051 2100
     #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
2052 2101
       toolchange_settings.swap_length = TOOLCHANGE_FIL_SWAP_LENGTH;
@@ -2059,6 +2108,10 @@ void MarlinSettings::reset() {
2059 2108
     toolchange_settings.z_raise = TOOLCHANGE_ZRAISE;
2060 2109
   #endif
2061 2110
 
2111
+  //
2112
+  // Magnetic Parking Extruder
2113
+  //
2114
+
2062 2115
   #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
2063 2116
     mpe_settings_init();
2064 2117
   #endif
@@ -2540,6 +2593,12 @@ void MarlinSettings::reset() {
2540 2593
       }
2541 2594
     #endif
2542 2595
 
2596
+    #if HAS_FILAMENT_SENSOR
2597
+      CONFIG_ECHO_HEADING("Filament Runout Sensor:");
2598
+      CONFIG_ECHO_START();
2599
+      SERIAL_ECHOLNPAIR("  M412 S", int(runout.enabled));
2600
+    #endif
2601
+
2543 2602
     /**
2544 2603
      * Bed Leveling
2545 2604
      */

Завантаження…
Відмінити
Зберегти