소스 검색

Add pre-calculated planner.e_factor

Scott Lahteine 6 년 전
부모
커밋
3293823642
11개의 변경된 파일110개의 추가작업 그리고 85개의 파일을 삭제
  1. 0
    6
      Marlin/Marlin.h
  2. 16
    28
      Marlin/Marlin_main.cpp
  3. 19
    22
      Marlin/configuration_store.cpp
  4. 2
    0
      Marlin/gcode.cpp
  5. 2
    4
      Marlin/gcode.h
  6. 21
    6
      Marlin/planner.cpp
  7. 13
    0
      Marlin/planner.h
  8. 2
    1
      Marlin/temperature.cpp
  9. 32
    15
      Marlin/ultralcd.cpp
  10. 2
    2
      Marlin/ultralcd_impl_DOGM.h
  11. 1
    1
      Marlin/ultralcd_impl_HD44780.h

+ 0
- 6
Marlin/Marlin.h 파일 보기

@@ -215,10 +215,6 @@ extern int16_t feedrate_percentage;
215 215
 #define MMS_SCALED(MM_S) ((MM_S)*feedrate_percentage*0.01)
216 216
 
217 217
 extern bool axis_relative_modes[];
218
-extern bool volumetric_enabled;
219
-extern int16_t flow_percentage[EXTRUDERS]; // Extrusion factor for each extruder
220
-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.
221
-extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
222 218
 extern bool axis_known_position[XYZ];
223 219
 extern bool axis_homed[XYZ];
224 220
 extern volatile bool wait_for_heatup;
@@ -427,8 +423,6 @@ extern uint8_t active_extruder;
427 423
   extern float mixing_factor[MIXING_STEPPERS];
428 424
 #endif
429 425
 
430
-void calculate_volumetric_multipliers();
431
-
432 426
 /**
433 427
  * Blocking movement and shorthand functions
434 428
  */

+ 16
- 28
Marlin/Marlin_main.cpp 파일 보기

@@ -452,13 +452,10 @@ FORCE_INLINE float homing_feedrate(const AxisEnum a) { return pgm_read_float(&ho
452 452
 
453 453
 float feedrate_mm_s = MMM_TO_MMS(1500.0);
454 454
 static float saved_feedrate_mm_s;
455
-int16_t feedrate_percentage = 100, saved_feedrate_percentage,
456
-    flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100);
455
+int16_t feedrate_percentage = 100, saved_feedrate_percentage;
457 456
 
458 457
 // Initialized by settings.load()
459
-bool axis_relative_modes[] = AXIS_RELATIVE_MODES,
460
-     volumetric_enabled;
461
-float filament_size[EXTRUDERS], volumetric_multiplier[EXTRUDERS];
458
+bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
462 459
 
463 460
 #if HAS_WORKSPACE_OFFSET
464 461
   #if HAS_POSITION_SHIFT
@@ -3226,7 +3223,7 @@ static void homeaxis(const AxisEnum axis) {
3226 3223
     set_destination_from_current();
3227 3224
     stepper.synchronize();  // Wait for buffered moves to complete
3228 3225
 
3229
-    const float renormalize = 100.0 / flow_percentage[active_extruder] / volumetric_multiplier[active_extruder];
3226
+    const float renormalize = 1.0 / planner.e_factor[active_extruder];
3230 3227
 
3231 3228
     if (retracting) {
3232 3229
       // Retract by moving from a faux E position back to the current E position
@@ -6553,7 +6550,7 @@ inline void gcode_M17() {
6553 6550
   #endif
6554 6551
 
6555 6552
   void do_pause_e_move(const float &length, const float fr) {
6556
-    current_position[E_AXIS] += length * 100.0 / flow_percentage[active_extruder] / volumetric_multiplier[active_extruder];
6553
+    current_position[E_AXIS] += length / planner.e_factor[active_extruder];
6557 6554
     set_destination_from_current();
6558 6555
     RUNPLAN(fr);
6559 6556
     stepper.synchronize();
@@ -8832,15 +8829,14 @@ inline void gcode_M200() {
8832 8829
     // setting any extruder filament size disables volumetric on the assumption that
8833 8830
     // slicers either generate in extruder values as cubic mm or as as filament feeds
8834 8831
     // for all extruders
8835
-    volumetric_enabled = (parser.value_linear_units() != 0.0);
8836
-    if (volumetric_enabled) {
8837
-      filament_size[target_extruder] = parser.value_linear_units();
8832
+    if ( (parser.volumetric_enabled = (parser.value_linear_units() != 0.0)) ) {
8833
+      planner.filament_size[target_extruder] = parser.value_linear_units();
8838 8834
       // make sure all extruders have some sane value for the filament size
8839
-      for (uint8_t i = 0; i < COUNT(filament_size); i++)
8840
-        if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
8835
+      for (uint8_t i = 0; i < COUNT(planner.filament_size); i++)
8836
+        if (!planner.filament_size[i]) planner.filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
8841 8837
     }
8842 8838
   }
8843
-  calculate_volumetric_multipliers();
8839
+  planner.calculate_volumetric_multipliers();
8844 8840
 }
8845 8841
 
8846 8842
 /**
@@ -9201,8 +9197,10 @@ inline void gcode_M220() {
9201 9197
  */
9202 9198
 inline void gcode_M221() {
9203 9199
   if (get_target_extruder_from_command(221)) return;
9204
-  if (parser.seenval('S'))
9205
-    flow_percentage[target_extruder] = parser.value_int();
9200
+  if (parser.seenval('S')) {
9201
+    planner.flow_percentage[target_extruder] = parser.value_int();
9202
+    planner.refresh_e_factor(target_extruder);
9203
+  }
9206 9204
 }
9207 9205
 
9208 9206
 /**
@@ -9735,7 +9733,7 @@ inline void gcode_M400() { stepper.synchronize(); }
9735 9733
     //SERIAL_PROTOCOLPGM("Filament dia (measured mm):");
9736 9734
     //SERIAL_PROTOCOL(filament_width_meas);
9737 9735
     //SERIAL_PROTOCOLPGM("Extrusion ratio(%):");
9738
-    //SERIAL_PROTOCOL(flow_percentage[active_extruder]);
9736
+    //SERIAL_PROTOCOL(planner.flow_percentage[active_extruder]);
9739 9737
   }
9740 9738
 
9741 9739
   /**
@@ -9743,7 +9741,7 @@ inline void gcode_M400() { stepper.synchronize(); }
9743 9741
    */
9744 9742
   inline void gcode_M406() {
9745 9743
     filament_sensor = false;
9746
-    calculate_volumetric_multipliers();   // Restore correct 'volumetric_multiplier' value
9744
+    planner.calculate_volumetric_multipliers();   // Restore correct 'volumetric_multiplier' value
9747 9745
   }
9748 9746
 
9749 9747
   /**
@@ -12967,7 +12965,7 @@ void prepare_move_to_destination() {
12967 12965
           }
12968 12966
         #endif // PREVENT_COLD_EXTRUSION
12969 12967
         #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
12970
-          if (FABS(destination[E_AXIS] - current_position[E_AXIS]) > (EXTRUDE_MAXLENGTH) / volumetric_multiplier[active_extruder]) {
12968
+          if (FABS(destination[E_AXIS] - current_position[E_AXIS]) * planner.e_factor[active_extruder] > (EXTRUDE_MAXLENGTH)) {
12971 12969
             current_position[E_AXIS] = destination[E_AXIS]; // Behave as if the move really took place, but ignore E part
12972 12970
             SERIAL_ECHO_START();
12973 12971
             SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
@@ -13387,16 +13385,6 @@ void prepare_move_to_destination() {
13387 13385
 
13388 13386
 #endif // FAST_PWM_FAN
13389 13387
 
13390
-float calculate_volumetric_multiplier(const float diameter) {
13391
-  if (!volumetric_enabled || diameter == 0) return 1.0;
13392
-  return 1.0 / (M_PI * sq(diameter * 0.5));
13393
-}
13394
-
13395
-void calculate_volumetric_multipliers() {
13396
-  for (uint8_t i = 0; i < COUNT(filament_size); i++)
13397
-    volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
13398
-}
13399
-
13400 13388
 void enable_all_steppers() {
13401 13389
   enable_X();
13402 13390
   enable_Y();

+ 19
- 22
Marlin/configuration_store.cpp 파일 보기

@@ -138,8 +138,8 @@
138 138
  *  533  M208 R    swap_retract_recover_feedrate_mm_s (float)
139 139
  *
140 140
  * Volumetric Extrusion:                            21 bytes
141
- *  537  M200 D    volumetric_enabled               (bool)
142
- *  538  M200 T D  filament_size                    (float x5) (T0..3)
141
+ *  537  M200 D    parser.volumetric_enabled        (bool)
142
+ *  538  M200 T D  planner.filament_size            (float x5) (T0..3)
143 143
  *
144 144
  * HAVE_TMC2130:                                    22 bytes
145 145
  *  558  M906 X    Stepper X current                (uint16_t)
@@ -188,10 +188,7 @@ MarlinSettings settings;
188 188
 #include "temperature.h"
189 189
 #include "ultralcd.h"
190 190
 #include "stepper.h"
191
-
192
-#if ENABLED(INCH_MODE_SUPPORT) || (ENABLED(ULTIPANEL) && ENABLED(TEMPERATURE_UNITS_SUPPORT))
193
-  #include "gcode.h"
194
-#endif
191
+#include "gcode.h"
195 192
 
196 193
 #if ENABLED(MESH_BED_LEVELING)
197 194
   #include "mesh_bed_leveling.h"
@@ -238,7 +235,7 @@ void MarlinSettings::postprocess() {
238 235
     thermalManager.updatePID();
239 236
   #endif
240 237
 
241
-  calculate_volumetric_multipliers();
238
+  planner.calculate_volumetric_multipliers();
242 239
 
243 240
   #if HAS_HOME_OFFSET || ENABLED(DUAL_X_CARRIAGE)
244 241
     // Software endstops depend on home_offset
@@ -569,11 +566,11 @@ void MarlinSettings::postprocess() {
569 566
     EEPROM_WRITE(swap_retract_recover_length);
570 567
     EEPROM_WRITE(swap_retract_recover_feedrate_mm_s);
571 568
 
572
-    EEPROM_WRITE(volumetric_enabled);
569
+    EEPROM_WRITE(parser.volumetric_enabled);
573 570
 
574 571
     // Save filament sizes
575 572
     for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
576
-      if (q < COUNT(filament_size)) dummy = filament_size[q];
573
+      if (q < COUNT(planner.filament_size)) dummy = planner.filament_size[q];
577 574
       EEPROM_WRITE(dummy);
578 575
     }
579 576
 
@@ -1018,10 +1015,10 @@ void MarlinSettings::postprocess() {
1018 1015
       // Volumetric & Filament Size
1019 1016
       //
1020 1017
 
1021
-      EEPROM_READ(volumetric_enabled);
1018
+      EEPROM_READ(parser.volumetric_enabled);
1022 1019
       for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
1023 1020
         EEPROM_READ(dummy);
1024
-        if (q < COUNT(filament_size)) filament_size[q] = dummy;
1021
+        if (q < COUNT(planner.filament_size)) planner.filament_size[q] = dummy;
1025 1022
       }
1026 1023
 
1027 1024
       //
@@ -1424,15 +1421,15 @@ void MarlinSettings::reset() {
1424 1421
     swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
1425 1422
   #endif // FWRETRACT
1426 1423
 
1427
-  volumetric_enabled =
1424
+  parser.volumetric_enabled =
1428 1425
     #if ENABLED(VOLUMETRIC_DEFAULT_ON)
1429 1426
       true
1430 1427
     #else
1431 1428
       false
1432 1429
     #endif
1433 1430
   ;
1434
-  for (uint8_t q = 0; q < COUNT(filament_size); q++)
1435
-    filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
1431
+  for (uint8_t q = 0; q < COUNT(planner.filament_size); q++)
1432
+    planner.filament_size[q] = DEFAULT_NOMINAL_FILAMENT_DIA;
1436 1433
 
1437 1434
   endstops.enable_globally(
1438 1435
     #if ENABLED(ENDSTOPS_ALWAYS_ON_DEFAULT)
@@ -1515,7 +1512,7 @@ void MarlinSettings::reset() {
1515 1512
     CONFIG_ECHO_START;
1516 1513
     #if ENABLED(INCH_MODE_SUPPORT)
1517 1514
       #define LINEAR_UNIT(N) ((N) / parser.linear_unit_factor)
1518
-      #define VOLUMETRIC_UNIT(N) ((N) / (volumetric_enabled ? parser.volumetric_unit_factor : parser.linear_unit_factor))
1515
+      #define VOLUMETRIC_UNIT(N) ((N) / (parser.volumetric_enabled ? parser.volumetric_unit_factor : parser.linear_unit_factor))
1519 1516
       SERIAL_ECHOPGM("  G2");
1520 1517
       SERIAL_CHAR(parser.linear_unit_factor == 1.0 ? '1' : '0');
1521 1518
       SERIAL_ECHOPGM(" ; Units in ");
@@ -1552,37 +1549,37 @@ void MarlinSettings::reset() {
1552 1549
     if (!forReplay) {
1553 1550
       CONFIG_ECHO_START;
1554 1551
       SERIAL_ECHOPGM("Filament settings:");
1555
-      if (volumetric_enabled)
1552
+      if (parser.volumetric_enabled)
1556 1553
         SERIAL_EOL();
1557 1554
       else
1558 1555
         SERIAL_ECHOLNPGM(" Disabled");
1559 1556
     }
1560 1557
 
1561 1558
     CONFIG_ECHO_START;
1562
-    SERIAL_ECHOPAIR("  M200 D", filament_size[0]);
1559
+    SERIAL_ECHOPAIR("  M200 D", planner.filament_size[0]);
1563 1560
     SERIAL_EOL();
1564 1561
     #if EXTRUDERS > 1
1565 1562
       CONFIG_ECHO_START;
1566
-      SERIAL_ECHOPAIR("  M200 T1 D", filament_size[1]);
1563
+      SERIAL_ECHOPAIR("  M200 T1 D", planner.filament_size[1]);
1567 1564
       SERIAL_EOL();
1568 1565
       #if EXTRUDERS > 2
1569 1566
         CONFIG_ECHO_START;
1570
-        SERIAL_ECHOPAIR("  M200 T2 D", filament_size[2]);
1567
+        SERIAL_ECHOPAIR("  M200 T2 D", planner.filament_size[2]);
1571 1568
         SERIAL_EOL();
1572 1569
         #if EXTRUDERS > 3
1573 1570
           CONFIG_ECHO_START;
1574
-          SERIAL_ECHOPAIR("  M200 T3 D", filament_size[3]);
1571
+          SERIAL_ECHOPAIR("  M200 T3 D", planner.filament_size[3]);
1575 1572
           SERIAL_EOL();
1576 1573
           #if EXTRUDERS > 4
1577 1574
             CONFIG_ECHO_START;
1578
-            SERIAL_ECHOPAIR("  M200 T4 D", filament_size[4]);
1575
+            SERIAL_ECHOPAIR("  M200 T4 D", planner.filament_size[4]);
1579 1576
             SERIAL_EOL();
1580 1577
           #endif // EXTRUDERS > 4
1581 1578
         #endif // EXTRUDERS > 3
1582 1579
       #endif // EXTRUDERS > 2
1583 1580
     #endif // EXTRUDERS > 1
1584 1581
 
1585
-    if (!volumetric_enabled) {
1582
+    if (!parser.volumetric_enabled) {
1586 1583
       CONFIG_ECHO_START;
1587 1584
       SERIAL_ECHOLNPGM("  M200 D0");
1588 1585
     }

+ 2
- 0
Marlin/gcode.cpp 파일 보기

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

+ 2
- 4
Marlin/gcode.h 파일 보기

@@ -44,10 +44,6 @@
44 44
   #include "serial.h"
45 45
 #endif
46 46
 
47
-#if ENABLED(INCH_MODE_SUPPORT)
48
-  extern bool volumetric_enabled;
49
-#endif
50
-
51 47
 /**
52 48
  * GCode parser
53 49
  *
@@ -76,6 +72,8 @@ public:
76 72
 
77 73
   // Global states for GCode-level units features
78 74
 
75
+  static bool volumetric_enabled;
76
+
79 77
   #if ENABLED(INCH_MODE_SUPPORT)
80 78
     static float linear_unit_factor, volumetric_unit_factor;
81 79
   #endif

+ 21
- 6
Marlin/planner.cpp 파일 보기

@@ -91,6 +91,12 @@ float Planner::max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second
91 91
   uint8_t Planner::last_extruder = 0;     // Respond to extruder change
92 92
 #endif
93 93
 
94
+int16_t Planner::flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100); // Extrusion factor for each extruder
95
+
96
+float Planner::e_factor[EXTRUDERS],               // The flow percentage and volumetric multiplier combine to scale E movement
97
+      Planner::filament_size[EXTRUDERS],          // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder
98
+      Planner::volumetric_multiplier[EXTRUDERS];  // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner
99
+
94 100
 uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N],
95 101
          Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
96 102
 
@@ -521,6 +527,18 @@ void Planner::check_axes_activity() {
521 527
   #endif
522 528
 }
523 529
 
530
+inline float calculate_volumetric_multiplier(const float &diameter) {
531
+  if (!parser.volumetric_enabled || diameter == 0) return 1.0;
532
+  return 1.0 / CIRCLE_AREA(diameter * 0.5);
533
+}
534
+
535
+void Planner::calculate_volumetric_multipliers() {
536
+  for (uint8_t i = 0; i < COUNT(filament_size); i++) {
537
+    volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
538
+    refresh_e_factor(i);
539
+  }
540
+}
541
+
524 542
 #if PLANNER_LEVELING
525 543
   /**
526 544
    * rx, ry, rz - cartesian position in mm
@@ -719,10 +737,8 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
719 737
 
720 738
   long de = target[E_AXIS] - position[E_AXIS];
721 739
 
722
-  const float e_factor = volumetric_multiplier[extruder] * flow_percentage[extruder] * 0.01;
723
-
724 740
   #if ENABLED(LIN_ADVANCE)
725
-    float de_float = e - position_float[E_AXIS];
741
+    float de_float = e - position_float[E_AXIS]; // Should this include e_factor?
726 742
   #endif
727 743
 
728 744
   #if ENABLED(PREVENT_COLD_EXTRUSION) || ENABLED(PREVENT_LENGTHY_EXTRUDE)
@@ -740,8 +756,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
740 756
         }
741 757
       #endif // PREVENT_COLD_EXTRUSION
742 758
       #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
743
-        const int32_t de_mm = labs(de * e_factor);
744
-        if (de_mm > (int32_t)axis_steps_per_mm[E_AXIS_N] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
759
+        if (labs(de * e_factor[extruder]) > (int32_t)axis_steps_per_mm[E_AXIS_N] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
745 760
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
746 761
           de = 0; // no difference
747 762
           #if ENABLED(LIN_ADVANCE)
@@ -782,7 +797,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
782 797
   #endif
783 798
   if (de < 0) SBI(dm, E_AXIS);
784 799
 
785
-  const float esteps_float = de * e_factor;
800
+  const float esteps_float = de * e_factor[extruder];
786 801
   const int32_t esteps = abs(esteps_float) + 0.5;
787 802
 
788 803
   // Calculate the buffer head after we push this byte

+ 13
- 0
Marlin/planner.h 파일 보기

@@ -140,6 +140,13 @@ class Planner {
140 140
       static uint8_t last_extruder;             // Respond to extruder change
141 141
     #endif
142 142
 
143
+    static int16_t flow_percentage[EXTRUDERS]; // Extrusion factor for each extruder
144
+
145
+    static float e_factor[EXTRUDERS],               // The flow percentage and volumetric multiplier combine to scale E movement
146
+                 filament_size[EXTRUDERS],          // diameter of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder
147
+                 volumetric_multiplier[EXTRUDERS];  // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner
148
+                                                    // May be auto-adjusted by a filament width sensor
149
+
143 150
     static float max_feedrate_mm_s[XYZE_N],     // Max speeds in mm per second
144 151
                  axis_steps_per_mm[XYZE_N],
145 152
                  steps_to_mm[XYZE_N];
@@ -236,9 +243,15 @@ class Planner {
236 243
     static void reset_acceleration_rates();
237 244
     static void refresh_positioning();
238 245
 
246
+    FORCE_INLINE static void refresh_e_factor(const uint8_t e) {
247
+      e_factor[e] = volumetric_multiplier[e] * flow_percentage[e] * 0.01;
248
+    }
249
+
239 250
     // Manage fans, paste pressure, etc.
240 251
     static void check_axes_activity();
241 252
 
253
+    static void calculate_volumetric_multipliers();
254
+
242 255
     /**
243 256
      * Number of moves currently in the planner
244 257
      */

+ 2
- 1
Marlin/temperature.cpp 파일 보기

@@ -815,7 +815,8 @@ void Temperature::manage_heater() {
815 815
       // Get the delayed info and add 100 to reconstitute to a percent of
816 816
       // the nominal filament diameter then square it to get an area
817 817
       const float vmroot = measurement_delay[meas_shift_index] * 0.01 + 1.0;
818
-      volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vmroot <= 0.1 ? 0.01 : sq(vmroot);
818
+      planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = vmroot <= 0.1 ? 0.01 : sq(vmroot);
819
+      planner.refresh_e_factor(FILAMENT_SENSOR_EXTRUDER_NUM);
819 820
     }
820 821
   #endif // FILAMENT_WIDTH_SENSOR
821 822
 

+ 32
- 15
Marlin/ultralcd.cpp 파일 보기

@@ -33,6 +33,7 @@
33 33
 #include "stepper.h"
34 34
 #include "configuration_store.h"
35 35
 #include "utility.h"
36
+#include "gcode.h"
36 37
 
37 38
 #if HAS_BUZZER && DISABLED(LCD_USE_I2C_BUZZER)
38 39
   #include "buzzer.h"
@@ -1248,6 +1249,22 @@ void kill_screen(const char* lcd_msg) {
1248 1249
     #endif
1249 1250
   #endif
1250 1251
 
1252
+  // Refresh the E factor after changing flow
1253
+  inline void _lcd_refresh_e_factor_0() { planner.refresh_e_factor(0); }
1254
+  #if EXTRUDERS > 1
1255
+    inline void _lcd_refresh_e_factor() { planner.refresh_e_factor(active_extruder); }
1256
+    inline void _lcd_refresh_e_factor_1() { planner.refresh_e_factor(1); }
1257
+    #if EXTRUDERS > 2
1258
+      inline void _lcd_refresh_e_factor_2() { planner.refresh_e_factor(2); }
1259
+      #if EXTRUDERS > 3
1260
+        inline void _lcd_refresh_e_factor_3() { planner.refresh_e_factor(3); }
1261
+        #if EXTRUDERS > 4
1262
+          inline void _lcd_refresh_e_factor_4() { planner.refresh_e_factor(4); }
1263
+        #endif // EXTRUDERS > 4
1264
+      #endif // EXTRUDERS > 3
1265
+    #endif // EXTRUDERS > 2
1266
+  #endif // EXTRUDERS > 1
1267
+
1251 1268
   /**
1252 1269
    *
1253 1270
    * "Tune" submenu
@@ -1327,17 +1344,17 @@ void kill_screen(const char* lcd_msg) {
1327 1344
     // Flow [1-5]:
1328 1345
     //
1329 1346
     #if EXTRUDERS == 1
1330
-      MENU_ITEM_EDIT(int3, MSG_FLOW, &flow_percentage[0], 10, 999);
1347
+      MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW, &planner.flow_percentage[0], 10, 999, _lcd_refresh_e_factor_0);
1331 1348
     #else // EXTRUDERS > 1
1332
-      MENU_ITEM_EDIT(int3, MSG_FLOW, &flow_percentage[active_extruder], 10, 999);
1333
-      MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N1, &flow_percentage[0], 10, 999);
1334
-      MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N2, &flow_percentage[1], 10, 999);
1349
+      MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, _lcd_refresh_e_factor);
1350
+      MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N1, &planner.flow_percentage[0], 10, 999, _lcd_refresh_e_factor_0);
1351
+      MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N2, &planner.flow_percentage[1], 10, 999, _lcd_refresh_e_factor_1);
1335 1352
       #if EXTRUDERS > 2
1336
-        MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N3, &flow_percentage[2], 10, 999);
1353
+        MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N3, &planner.flow_percentage[2], 10, 999, _lcd_refresh_e_factor_2);
1337 1354
         #if EXTRUDERS > 3
1338
-          MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N4, &flow_percentage[3], 10, 999);
1355
+          MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N4, &planner.flow_percentage[3], 10, 999, _lcd_refresh_e_factor_3);
1339 1356
           #if EXTRUDERS > 4
1340
-            MENU_ITEM_EDIT(int3, MSG_FLOW MSG_N5, &flow_percentage[4], 10, 999);
1357
+            MENU_ITEM_EDIT_CALLBACK(int3, MSG_FLOW MSG_N5, &planner.flow_percentage[4], 10, 999, _lcd_refresh_e_factor_4);
1341 1358
           #endif // EXTRUDERS > 4
1342 1359
         #endif // EXTRUDERS > 3
1343 1360
       #endif // EXTRUDERS > 2
@@ -3678,20 +3695,20 @@ void kill_screen(const char* lcd_msg) {
3678 3695
       MENU_ITEM_EDIT(float3, MSG_ADVANCE_K, &planner.extruder_advance_k, 0, 999);
3679 3696
     #endif
3680 3697
 
3681
-    MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers);
3698
+    MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &parser.volumetric_enabled, planner.calculate_volumetric_multipliers);
3682 3699
 
3683
-    if (volumetric_enabled) {
3700
+    if (parser.volumetric_enabled) {
3684 3701
       #if EXTRUDERS == 1
3685
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &filament_size[0], 1.5, 3.25, calculate_volumetric_multipliers);
3702
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM, &planner.filament_size[0], 1.5, 3.25, planner.calculate_volumetric_multipliers);
3686 3703
       #else // EXTRUDERS > 1
3687
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E1, &filament_size[0], 1.5, 3.25, calculate_volumetric_multipliers);
3688
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E2, &filament_size[1], 1.5, 3.25, calculate_volumetric_multipliers);
3704
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E1, &planner.filament_size[0], 1.5, 3.25, planner.calculate_volumetric_multipliers);
3705
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E2, &planner.filament_size[1], 1.5, 3.25, planner.calculate_volumetric_multipliers);
3689 3706
         #if EXTRUDERS > 2
3690
-          MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E3, &filament_size[2], 1.5, 3.25, calculate_volumetric_multipliers);
3707
+          MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E3, &planner.filament_size[2], 1.5, 3.25, planner.calculate_volumetric_multipliers);
3691 3708
           #if EXTRUDERS > 3
3692
-            MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E4, &filament_size[3], 1.5, 3.25, calculate_volumetric_multipliers);
3709
+            MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E4, &planner.filament_size[3], 1.5, 3.25, planner.calculate_volumetric_multipliers);
3693 3710
             #if EXTRUDERS > 4
3694
-              MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E5, &filament_size[4], 1.5, 3.25, calculate_volumetric_multipliers);
3711
+              MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_DIAM MSG_DIAM_E5, &planner.filament_size[4], 1.5, 3.25, planner.calculate_volumetric_multipliers);
3695 3712
             #endif // EXTRUDERS > 4
3696 3713
           #endif // EXTRUDERS > 3
3697 3714
         #endif // EXTRUDERS > 2

+ 2
- 2
Marlin/ultralcd_impl_DOGM.h 파일 보기

@@ -650,7 +650,7 @@ static void lcd_implementation_status_screen() {
650 650
     strcpy(zstring, ftostr52sp(FIXFLOAT(LOGICAL_Z_POSITION(current_position[Z_AXIS]))));
651 651
     #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
652 652
       strcpy(wstring, ftostr12ns(filament_width_meas));
653
-      strcpy(mstring, itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
653
+      strcpy(mstring, itostr3(100.0 * planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
654 654
     #endif
655 655
   }
656 656
 
@@ -739,7 +739,7 @@ static void lcd_implementation_status_screen() {
739 739
         lcd_print(ftostr12ns(filament_width_meas));
740 740
         lcd_printPGM(PSTR("  " LCD_STR_FILAM_MUL));
741 741
         u8g.print(':');
742
-        lcd_print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
742
+        lcd_print(itostr3(100.0 * planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
743 743
         u8g.print('%');
744 744
       }
745 745
     #else

+ 1
- 1
Marlin/ultralcd_impl_HD44780.h 파일 보기

@@ -857,7 +857,7 @@ static void lcd_implementation_status_screen() {
857 857
       lcd_printPGM(PSTR("Dia "));
858 858
       lcd.print(ftostr12ns(filament_width_meas));
859 859
       lcd_printPGM(PSTR(" V"));
860
-      lcd.print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
860
+      lcd.print(itostr3(100.0 * planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
861 861
       lcd.write('%');
862 862
       return;
863 863
     }

Loading…
취소
저장