Browse Source

FILAMENT_WIDTH_SENSOR feature

Scott Lahteine 7 years ago
parent
commit
4f1eadf41f

+ 0
- 16
Marlin/src/Marlin.cpp View File

@@ -186,15 +186,6 @@ static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL
186 186
   ;
187 187
 #endif
188 188
 
189
-#if ENABLED(FILAMENT_WIDTH_SENSOR)
190
-  bool filament_sensor = false;                                 // M405 turns on filament sensor control. M406 turns it off.
191
-  float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA,  // Nominal filament width. Change with M404.
192
-        filament_width_meas = DEFAULT_MEASURED_FILAMENT_DIA;    // Measured filament diameter
193
-  uint8_t meas_delay_cm = MEASUREMENT_DELAY_CM,                 // Distance delay setting
194
-          measurement_delay[MAX_MEASUREMENT_DELAY + 1];         // Ring buffer to delayed measurement. Store extruder factor after subtracting 100
195
-  int8_t filwidth_delay_index[2] = { 0, -1 };                   // Indexes into ring buffer
196
-#endif
197
-
198 189
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
199 190
   static bool filament_ran_out = false;
200 191
 #endif
@@ -667,13 +658,6 @@ static bool pin_is_protected(const int8_t pin) {
667 658
   #include "gcode/probe/M401_M402.h"
668 659
 #endif
669 660
 
670
-#if ENABLED(FILAMENT_WIDTH_SENSOR)
671
-  #include "gcode/sensor/M404.h"
672
-  #include "gcode/sensor/M405.h"
673
-  #include "gcode/sensor/M406.h"
674
-  #include "gcode/sensor/M407.h"
675
-#endif
676
-
677 661
 void quickstop_stepper() {
678 662
   stepper.quick_stop();
679 663
   stepper.synchronize();

+ 0
- 9
Marlin/src/Marlin.h View File

@@ -211,15 +211,6 @@ extern volatile bool wait_for_heatup;
211 211
   extern uint8_t baricuda_valve_pressure, baricuda_e_to_p_pressure;
212 212
 #endif
213 213
 
214
-#if ENABLED(FILAMENT_WIDTH_SENSOR)
215
-  extern bool filament_sensor;         // Flag that filament sensor readings should control extrusion
216
-  extern float filament_width_nominal, // Theoretical filament diameter i.e., 3.00 or 1.75
217
-               filament_width_meas;    // Measured filament diameter
218
-  extern uint8_t meas_delay_cm,        // Delay distance
219
-                 measurement_delay[];  // Ring buffer to delay measurement
220
-  extern int8_t filwidth_delay_index[2]; // Ring buffer indexes. Used by planner, temperature, and main code
221
-#endif
222
-
223 214
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
224 215
   extern AdvancedPauseMenuResponse advanced_pause_menu_response;
225 216
 #endif

Marlin/src/gcode/sensor/M406.h → Marlin/src/feature/filwidth.cpp View File

@@ -20,10 +20,17 @@
20 20
  *
21 21
  */
22 22
 
23
-/**
24
- * M406: Turn off filament sensor for control
25
- */
26
-void gcode_M406() {
27
-  filament_sensor = false;
28
-  calculate_volumetric_multipliers();   // Restore correct 'volumetric_multiplier' value
29
-}
23
+#include "../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
26
+
27
+#include "filwidth.h"
28
+
29
+bool filament_sensor = false;                                 // M405/M406 turns filament sensor control ON/OFF.
30
+float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA,  // Nominal filament width. Change with M404.
31
+      filament_width_meas = DEFAULT_MEASURED_FILAMENT_DIA;    // Measured filament diameter
32
+uint8_t meas_delay_cm = MEASUREMENT_DELAY_CM,                 // Distance delay setting
33
+        measurement_delay[MAX_MEASUREMENT_DELAY + 1];         // Ring buffer to delayed measurement. Store extruder factor after subtracting 100
34
+int8_t filwidth_delay_index[2] = { 0, -1 };                   // Indexes into ring buffer
35
+
36
+#endif // FILAMENT_WIDTH_SENSOR

Marlin/src/gcode/sensor/M404.h → Marlin/src/feature/filwidth.h View File

@@ -20,15 +20,16 @@
20 20
  *
21 21
  */
22 22
 
23
-/**
24
- * M404: Display or set (in current units) the nominal filament width (3mm, 1.75mm ) W<3.0>
25
- */
26
-void gcode_M404() {
27
-  if (parser.seen('W')) {
28
-    filament_width_nominal = parser.value_linear_units();
29
-  }
30
-  else {
31
-    SERIAL_PROTOCOLPGM("Filament dia (nominal mm):");
32
-    SERIAL_PROTOCOLLN(filament_width_nominal);
33
-  }
34
-}
23
+#ifndef __FILWIDTH_H__
24
+#define __FILWIDTH_H__
25
+
26
+#include "../inc/MarlinConfig.h"
27
+
28
+extern bool filament_sensor;                                  // M405/M406 turns filament sensor control ON/OFF.
29
+extern float filament_width_nominal,                          // Nominal filament width. Change with M404.
30
+             filament_width_meas;                             // Measured filament diameter
31
+extern uint8_t meas_delay_cm,                                 // Distance delay setting
32
+               measurement_delay[MAX_MEASUREMENT_DELAY + 1];  // Ring buffer to delayed measurement. Store extruder factor after subtracting 100
33
+extern int8_t filwidth_delay_index[2];                        // Indexes into ring buffer
34
+
35
+#endif // __FILWIDTH_H__

Marlin/src/gcode/sensor/M405.h → Marlin/src/gcode/feature/filwidth/M404-M407.cpp View File

@@ -20,10 +20,33 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
26
+
27
+#include "../../../feature/filwidth.h"
28
+#include "../../../module/planner.h"
29
+#include "../../../module/temperature.h"
30
+#include "../../../Marlin.h"
31
+#include "../../gcode.h"
32
+
33
+/**
34
+ * M404: Display or set (in current units) the nominal filament width (3mm, 1.75mm ) W<3.0>
35
+ */
36
+void GcodeSuite::M404() {
37
+  if (parser.seen('W')) {
38
+    filament_width_nominal = parser.value_linear_units();
39
+  }
40
+  else {
41
+    SERIAL_PROTOCOLPGM("Filament dia (nominal mm):");
42
+    SERIAL_PROTOCOLLN(filament_width_nominal);
43
+  }
44
+}
45
+
23 46
 /**
24 47
  * M405: Turn on filament sensor for control
25 48
  */
26
-void gcode_M405() {
49
+void GcodeSuite::M405() {
27 50
   // This is technically a linear measurement, but since it's quantized to centimeters and is a different
28 51
   // unit than everything else, it uses parser.value_byte() instead of parser.value_linear_units().
29 52
   if (parser.seen('D')) {
@@ -47,3 +70,21 @@ void gcode_M405() {
47 70
   //SERIAL_PROTOCOLPGM("Extrusion ratio(%):");
48 71
   //SERIAL_PROTOCOL(planner.flow_percentage[active_extruder]);
49 72
 }
73
+
74
+/**
75
+ * M406: Turn off filament sensor for control
76
+ */
77
+void GcodeSuite::M406() {
78
+  filament_sensor = false;
79
+  calculate_volumetric_multipliers();   // Restore correct 'volumetric_multiplier' value
80
+}
81
+
82
+/**
83
+ * M407: Get measured filament diameter on serial output
84
+ */
85
+void GcodeSuite::M407() {
86
+  SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
87
+  SERIAL_PROTOCOLLN(filament_width_meas);
88
+}
89
+
90
+#endif // FILAMENT_WIDTH_SENSOR

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

@@ -102,11 +102,6 @@ void GcodeSuite::get_destination_from_command() {
102 102
 //
103 103
 // Placeholders for non-migrated codes
104 104
 //
105
-extern void gcode_G0_G1(
106
-  #if IS_SCARA
107
-    bool fast_move=false
108
-  #endif
109
-);
110 105
 extern void gcode_G2_G3(bool clockwise);
111 106
 extern void gcode_G4();
112 107
 extern void gcode_G5();
@@ -216,10 +211,6 @@ extern void gcode_M381();
216 211
 extern void gcode_M400();
217 212
 extern void gcode_M401();
218 213
 extern void gcode_M402();
219
-extern void gcode_M404();
220
-extern void gcode_M405();
221
-extern void gcode_M406();
222
-extern void gcode_M407();
223 214
 extern void gcode_M410();
224 215
 extern void gcode_M428();
225 216
 extern void gcode_M500();
@@ -871,16 +862,16 @@ void GcodeSuite::process_next_command() {
871 862
 
872 863
       #if ENABLED(FILAMENT_WIDTH_SENSOR)
873 864
         case 404:  // M404: Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width
874
-          gcode_M404();
865
+          M404();
875 866
           break;
876 867
         case 405:  // M405: Turn on filament sensor for control
877
-          gcode_M405();
868
+          M405();
878 869
           break;
879 870
         case 406:  // M406: Turn off filament sensor for control
880
-          gcode_M406();
871
+          M406();
881 872
           break;
882 873
         case 407:   // M407: Display measured filament diameter
883
-          gcode_M407();
874
+          M407();
884 875
           break;
885 876
       #endif // FILAMENT_WIDTH_SENSOR
886 877
 

+ 0
- 29
Marlin/src/gcode/sensor/M407.h View File

@@ -1,29 +0,0 @@
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
-/**
24
- * M407: Get measured filament diameter on serial output
25
- */
26
-void gcode_M407() {
27
-  SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
28
-  SERIAL_PROTOCOLLN(filament_width_meas);
29
-}

+ 0
- 4
Marlin/src/lcd/ultralcd.cpp View File

@@ -47,10 +47,6 @@
47 47
   #include "../feature/filwidth.h"
48 48
 #endif
49 49
 
50
-#if HAS_BED_PROBE
51
-  #include "../module/probe.h"
52
-#endif
53
-
54 50
 #if ENABLED(BLTOUCH)
55 51
   #include "../module/endstops.h"
56 52
 #endif

+ 4
- 0
Marlin/src/module/planner.cpp View File

@@ -72,6 +72,10 @@
72 72
   #include "../feature/bedlevel/bedlevel.h"
73 73
 #endif
74 74
 
75
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
76
+  #include "../feature/filwidth.h"
77
+#endif
78
+
75 79
 Planner planner;
76 80
 
77 81
   // public:

+ 4
- 0
Marlin/src/module/temperature.cpp View File

@@ -45,6 +45,10 @@
45 45
 
46 46
 #include "printcounter.h"
47 47
 
48
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
49
+  #include "../feature/filwidth.h"
50
+#endif
51
+
48 52
 #ifdef K1 // Defined in Configuration.h in the PID settings
49 53
   #define K2 (1.0-K1)
50 54
 #endif

Loading…
Cancel
Save