Browse Source

Move volumetric flag to GCodeParser

Scott Lahteine 8 years ago
parent
commit
63228fc453

+ 1
- 2
Marlin/src/Marlin.cpp View File

@@ -169,7 +169,6 @@ static float saved_feedrate_mm_s;
169 169
 int16_t feedrate_percentage = 100, saved_feedrate_percentage;
170 170
 
171 171
 // Initialized by settings.load()
172
-bool volumetric_enabled;
173 172
 float filament_size[EXTRUDERS], volumetric_multiplier[EXTRUDERS];
174 173
 
175 174
 #if HAS_WORKSPACE_OFFSET
@@ -3295,7 +3294,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
3295 3294
 #endif // FILAMENT_RUNOUT_SENSOR
3296 3295
 
3297 3296
 float calculate_volumetric_multiplier(const float diameter) {
3298
-  if (!volumetric_enabled || diameter == 0) return 1.0;
3297
+  if (!parser.volumetric_enabled || diameter == 0) return 1.0;
3299 3298
   return 1.0 / (M_PI * sq(diameter * 0.5));
3300 3299
 }
3301 3300
 

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

@@ -186,7 +186,6 @@ extern int16_t feedrate_percentage;
186 186
 
187 187
 #define MMS_SCALED(MM_S) ((MM_S)*feedrate_percentage*0.01)
188 188
 
189
-extern bool volumetric_enabled;
190 189
 extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder.
191 190
 extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
192 191
 

+ 2
- 2
Marlin/src/gcode/config/M200.cpp View File

@@ -37,8 +37,8 @@ void GcodeSuite::M200() {
37 37
     // setting any extruder filament size disables volumetric on the assumption that
38 38
     // slicers either generate in extruder values as cubic mm or as as filament feeds
39 39
     // for all extruders
40
-    volumetric_enabled = (parser.value_linear_units() != 0.0);
41
-    if (volumetric_enabled) {
40
+    parser.volumetric_enabled = (parser.value_linear_units() != 0.0);
41
+    if (parser.volumetric_enabled) {
42 42
       filament_size[target_extruder] = parser.value_linear_units();
43 43
       // make sure all extruders have some sane value for the filament size
44 44
       for (uint8_t i = 0; i < COUNT(filament_size); i++)

+ 2
- 0
Marlin/src/gcode/parser.cpp View File

@@ -35,6 +35,8 @@
35 35
 // Must be declared for allocation and to satisfy the linker
36 36
 // Zero values need no initialization.
37 37
 
38
+bool GCodeParser::volumetric_enabled;
39
+
38 40
 #if ENABLED(INCH_MODE_SUPPORT)
39 41
   float GCodeParser::linear_unit_factor, GCodeParser::volumetric_unit_factor;
40 42
 #endif

+ 2
- 4
Marlin/src/gcode/parser.h View File

@@ -33,10 +33,6 @@
33 33
 
34 34
 //#define DEBUG_GCODE_PARSER
35 35
 
36
-#if ENABLED(INCH_MODE_SUPPORT)
37
-  extern bool volumetric_enabled;
38
-#endif
39
-
40 36
 /**
41 37
  * GCode parser
42 38
  *
@@ -65,6 +61,8 @@ public:
65 61
 
66 62
   // Global states for GCode-level units features
67 63
 
64
+  static bool volumetric_enabled;
65
+
68 66
   #if ENABLED(INCH_MODE_SUPPORT)
69 67
     static float linear_unit_factor, volumetric_unit_factor;
70 68
   #endif

+ 2
- 2
Marlin/src/lcd/ultralcd.cpp View File

@@ -3445,9 +3445,9 @@ void kill_screen(const char* lcd_msg) {
3445 3445
       MENU_ITEM_EDIT(float3, MSG_ADVANCE_K, &planner.extruder_advance_k, 0, 999);
3446 3446
     #endif
3447 3447
 
3448
-    MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers);
3448
+    MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &parser.volumetric_enabled, calculate_volumetric_multipliers);
3449 3449
 
3450
-    if (volumetric_enabled) {
3450
+    if (parser.volumetric_enabled) {
3451 3451
       #if EXTRUDERS == 1
3452 3452
         MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &filament_size[0], 1.5, 3.25, calculate_volumetric_multipliers);
3453 3453
       #else // EXTRUDERS > 1

+ 8
- 10
Marlin/src/module/configuration_store.cpp View File

@@ -137,7 +137,7 @@
137 137
  *  533  M208 R    swap_retract_recover_feedrate_mm_s (float)
138 138
  *
139 139
  * Volumetric Extrusion:                            21 bytes
140
- *  537  M200 D    volumetric_enabled               (bool)
140
+ *  537  M200 D    parser.volumetric_enabled        (bool)
141 141
  *  538  M200 T D  filament_size                    (float x5) (T0..3)
142 142
  *
143 143
  * HAVE_TMC2130:                                    20 bytes
@@ -185,9 +185,7 @@ MarlinSettings settings;
185 185
 #include "../core/language.h"
186 186
 #include "../Marlin.h"
187 187
 
188
-#if ENABLED(INCH_MODE_SUPPORT) || (ENABLED(ULTIPANEL) && ENABLED(TEMPERATURE_UNITS_SUPPORT))
189
-  #include "../gcode/parser.h"
190
-#endif
188
+#include "../gcode/parser.h"
191 189
 
192 190
 #if HAS_BED_PROBE
193 191
   #include "../module/probe.h"
@@ -511,7 +509,7 @@ void MarlinSettings::postprocess() {
511 509
       EEPROM_WRITE(fwretract.swap_retract_recover_feedrate_mm_s);
512 510
     #endif
513 511
 
514
-    EEPROM_WRITE(volumetric_enabled);
512
+    EEPROM_WRITE(parser.volumetric_enabled);
515 513
 
516 514
     // Save filament sizes
517 515
     for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
@@ -897,7 +895,7 @@ void MarlinSettings::postprocess() {
897 895
         for (uint8_t q=8; q--;) EEPROM_READ(dummy);
898 896
       #endif
899 897
 
900
-      EEPROM_READ(volumetric_enabled);
898
+      EEPROM_READ(parser.volumetric_enabled);
901 899
 
902 900
       for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
903 901
         EEPROM_READ(dummy);
@@ -1259,7 +1257,7 @@ void MarlinSettings::reset() {
1259 1257
     fwretract.reset();
1260 1258
   #endif
1261 1259
 
1262
-  volumetric_enabled =
1260
+  parser.volumetric_enabled =
1263 1261
     #if ENABLED(VOLUMETRIC_DEFAULT_ON)
1264 1262
       true
1265 1263
     #else
@@ -1350,7 +1348,7 @@ void MarlinSettings::reset() {
1350 1348
     CONFIG_ECHO_START;
1351 1349
     #if ENABLED(INCH_MODE_SUPPORT)
1352 1350
       #define LINEAR_UNIT(N) ((N) / parser.linear_unit_factor)
1353
-      #define VOLUMETRIC_UNIT(N) ((N) / (volumetric_enabled ? parser.volumetric_unit_factor : parser.linear_unit_factor))
1351
+      #define VOLUMETRIC_UNIT(N) ((N) / (parser.volumetric_enabled ? parser.volumetric_unit_factor : parser.linear_unit_factor))
1354 1352
       SERIAL_ECHOPGM("  G2");
1355 1353
       SERIAL_CHAR(parser.linear_unit_factor == 1.0 ? '1' : '0');
1356 1354
       SERIAL_ECHOPGM(" ; Units in ");
@@ -1387,7 +1385,7 @@ void MarlinSettings::reset() {
1387 1385
     if (!forReplay) {
1388 1386
       CONFIG_ECHO_START;
1389 1387
       SERIAL_ECHOPGM("Filament settings:");
1390
-      if (volumetric_enabled)
1388
+      if (parser.volumetric_enabled)
1391 1389
         SERIAL_EOL();
1392 1390
       else
1393 1391
         SERIAL_ECHOLNPGM(" Disabled");
@@ -1417,7 +1415,7 @@ void MarlinSettings::reset() {
1417 1415
       #endif // EXTRUDERS > 2
1418 1416
     #endif // EXTRUDERS > 1
1419 1417
 
1420
-    if (!volumetric_enabled) {
1418
+    if (!parser.volumetric_enabled) {
1421 1419
       CONFIG_ECHO_START;
1422 1420
       SERIAL_ECHOLNPGM("  M200 D0");
1423 1421
     }

Loading…
Cancel
Save