Browse Source

Add M412 to enable/disable filament runout detection (#12406)

Scott Lahteine 6 years ago
parent
commit
143b2896e0
No account linked to committer's email address

+ 45
- 0
Marlin/src/gcode/feature/runout/M412.cpp View File

@@ -0,0 +1,45 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(FILAMENT_RUNOUT_SENSOR)
26
+
27
+#include "../../gcode.h"
28
+#include "../../../feature/runout.h"
29
+
30
+/**
31
+ * M412: Enable / Disable filament runout detection
32
+ */
33
+void GcodeSuite::M412() {
34
+  if (parser.seen('S')) {
35
+    runout.reset();
36
+    runout.enabled = parser.value_bool();
37
+  }
38
+  else {
39
+    SERIAL_ECHO_START();
40
+    SERIAL_ECHOPGM("Filament runout ");
41
+    serialprintln_onoff(runout.enabled);
42
+  }
43
+}
44
+
45
+#endif // FILAMENT_RUNOUT_SENSOR

+ 4
- 0
Marlin/src/gcode/gcode.cpp View File

@@ -568,6 +568,10 @@ void GcodeSuite::process_parsed_command(
568 568
         case 407: M407(); break;                                  // M407: Display measured filament diameter
569 569
       #endif
570 570
 
571
+      #if ENABLED(FILAMENT_RUNOUT_SENSOR)
572
+        case 412: M412(); break;                                  // M412: Enable/Disable filament runout detection
573
+      #endif
574
+
571 575
       #if HAS_LEVELING
572 576
         case 420: M420(); break;                                  // M420: Enable/Disable Bed Leveling
573 577
       #endif

+ 6
- 1
Marlin/src/gcode/gcode.h View File

@@ -78,7 +78,7 @@
78 78
  * M3   - Turn laser/spindle on, set spindle/laser speed/power, set rotation to clockwise
79 79
  * M4   - Turn laser/spindle on, set spindle/laser speed/power, set rotation to counter-clockwise
80 80
  * M5   - Turn laser/spindle off
81
- * M12  - Set up closed loop control system. More features coming soon. (Requires EXTERNAL_CLOSED_LOOP_CONTROLLER)
81
+ * M12  - Set up closed loop control system. (Requires EXTERNAL_CLOSED_LOOP_CONTROLLER)
82 82
  * M17  - Enable/Power all stepper motors
83 83
  * M18  - Disable all stepper motors; same as M84
84 84
  * M20  - List SD card. (Requires SDSUPPORT)
@@ -196,6 +196,7 @@
196 196
  * M406 - Disable Filament Sensor flow control. (Requires FILAMENT_WIDTH_SENSOR)
197 197
  * M407 - Display measured filament diameter in millimeters. (Requires FILAMENT_WIDTH_SENSOR)
198 198
  * M410 - Quickstop. Abort all planned moves.
199
+ * M412 - Enable / Disable filament runout detection. (Requires FILAMENT_RUNOUT_SENSOR)
199 200
  * M420 - Enable/Disable Leveling (with current values) S1=enable S0=disable (Requires MESH_BED_LEVELING or ABL)
200 201
  * M421 - Set a single Z coordinate in the Mesh Leveling grid. X<units> Y<units> Z<units> (Requires MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, or AUTO_BED_LEVELING_UBL)
201 202
  * M422 - Set Z Stepper automatic alignment position using probe. X<units> Y<units> A<axis> (Requires Z_STEPPER_AUTO_ALIGN)
@@ -708,6 +709,10 @@ private:
708 709
     static void M407();
709 710
   #endif
710 711
 
712
+  #if ENABLED(FILAMENT_RUNOUT_SENSOR)
713
+    static void M412();
714
+  #endif
715
+
711 716
   #if HAS_LEVELING
712 717
     static void M420();
713 718
     static void M421();

+ 1
- 1
Marlin/src/lcd/menu/menu_configuration.cpp View File

@@ -347,7 +347,7 @@ void menu_configuration() {
347 347
   #endif
348 348
 
349 349
   #if ENABLED(FILAMENT_RUNOUT_SENSOR)
350
-    MENU_ITEM_EDIT(bool, MSG_RUNOUT_SENSOR_ENABLE, &runout.enabled);
350
+    MENU_ITEM_EDIT_CALLBACK(bool, MSG_RUNOUT_SENSOR_ENABLE, &runout.enabled, runout.reset);
351 351
   #endif
352 352
 
353 353
   #if DISABLED(SLIM_LCD_MENUS)

Loading…
Cancel
Save