Bläddra i källkod

Fix and improve EEPROM storage (#12054)

* Clean up Temperature PID
* Improve EEPROM read/write/validate
* Group `SINGLENOZZLE` saved settings
* Group planner saved settings
* Group filament change saved settings
* Group skew saved settings
* Group `FWRETRACT` saved settings
Scott Lahteine 6 år sedan
förälder
incheckning
d556dc1865
Inget konto är kopplat till bidragsgivarens mejladress
35 ändrade filer med 1139 tillägg och 1234 borttagningar
  1. 19
    0
      Marlin/src/core/types.h
  2. 7
    7
      Marlin/src/feature/I2CPositionEncoder.cpp
  3. 2
    2
      Marlin/src/feature/I2CPositionEncoder.h
  4. 1
    1
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  5. 26
    28
      Marlin/src/feature/fwretract.cpp
  6. 13
    18
      Marlin/src/feature/fwretract.h
  7. 10
    11
      Marlin/src/feature/pause.cpp
  8. 2
    7
      Marlin/src/feature/pause.h
  9. 13
    13
      Marlin/src/feature/tmc_util.cpp
  10. 4
    4
      Marlin/src/gcode/bedlevel/G26.cpp
  11. 9
    9
      Marlin/src/gcode/calibrate/M852.cpp
  12. 12
    12
      Marlin/src/gcode/config/M200-M205.cpp
  13. 6
    6
      Marlin/src/gcode/config/M217.cpp
  14. 1
    1
      Marlin/src/gcode/config/M218.cpp
  15. 6
    6
      Marlin/src/gcode/config/M304.cpp
  16. 4
    4
      Marlin/src/gcode/config/M92.cpp
  17. 8
    8
      Marlin/src/gcode/feature/fwretract/M207-M209.cpp
  18. 2
    2
      Marlin/src/gcode/feature/pause/M600.cpp
  19. 4
    4
      Marlin/src/gcode/feature/pause/M603.cpp
  20. 3
    3
      Marlin/src/gcode/feature/pause/M701_M702.cpp
  21. 4
    4
      Marlin/src/gcode/feature/trinamic/M911-M915.cpp
  22. 1
    1
      Marlin/src/gcode/gcode.h
  23. 2
    2
      Marlin/src/gcode/motion/M290.cpp
  24. 22
    22
      Marlin/src/lcd/extensible_ui/ui_api.cpp
  25. 66
    66
      Marlin/src/lcd/ultralcd.cpp
  26. 585
    654
      Marlin/src/module/configuration_store.cpp
  27. 3
    3
      Marlin/src/module/motion.cpp
  28. 31
    49
      Marlin/src/module/planner.cpp
  29. 50
    40
      Marlin/src/module/planner.h
  30. 2
    2
      Marlin/src/module/stepper.cpp
  31. 13
    13
      Marlin/src/module/stepper_indirection.cpp
  32. 138
    152
      Marlin/src/module/temperature.cpp
  33. 32
    38
      Marlin/src/module/temperature.h
  34. 31
    33
      Marlin/src/module/tool_change.cpp
  35. 7
    9
      Marlin/src/module/tool_change.h

+ 19
- 0
Marlin/src/core/types.h Visa fil

@@ -25,3 +25,22 @@
25 25
 #include <string.h>
26 26
 
27 27
 typedef uint32_t millis_t;
28
+
29
+#pragma pack(push, 1) // No padding between fields
30
+
31
+typedef struct {
32
+  float unload_length, load_length;
33
+} fil_change_settings_t;
34
+
35
+typedef struct {
36
+  float retract_length,                     // M207 S - G10 Retract length
37
+        retract_feedrate_mm_s,              // M207 F - G10 Retract feedrate
38
+        retract_zlift,                      // M207 Z - G10 Retract hop size
39
+        retract_recover_length,             // M208 S - G11 Recover length
40
+        retract_recover_feedrate_mm_s,      // M208 F - G11 Recover feedrate
41
+        swap_retract_length,                // M207 W - G10 Swap Retract length
42
+        swap_retract_recover_length,        // M208 W - G11 Swap Recover length
43
+        swap_retract_recover_feedrate_mm_s; // M208 R - G11 Swap Recover feedrate
44
+} fwretract_settings_t;
45
+
46
+#pragma pack(pop)

+ 7
- 7
Marlin/src/feature/I2CPositionEncoder.cpp Visa fil

@@ -163,7 +163,7 @@ void I2CPositionEncoder::update() {
163 163
     //SERIAL_ECHOLN(error);
164 164
 
165 165
     #ifdef I2CPE_ERR_THRESH_ABORT
166
-      if (ABS(error) > I2CPE_ERR_THRESH_ABORT * planner.axis_steps_per_mm[encoderAxis]) {
166
+      if (ABS(error) > I2CPE_ERR_THRESH_ABORT * planner.settings.axis_steps_per_mm[encoderAxis]) {
167 167
         //kill("Significant Error");
168 168
         SERIAL_ECHOPGM("Axis error greater than set threshold, aborting!");
169 169
         SERIAL_ECHOLN(error);
@@ -175,7 +175,7 @@ void I2CPositionEncoder::update() {
175 175
       if (errIdx == 0) {
176 176
         // In order to correct for "error" but avoid correcting for noise and non-skips
177 177
         // it must be > threshold and have a difference average of < 10 and be < 2000 steps
178
-        if (ABS(error) > threshold * planner.axis_steps_per_mm[encoderAxis] &&
178
+        if (ABS(error) > threshold * planner.settings.axis_steps_per_mm[encoderAxis] &&
179 179
             diffSum < 10 * (I2CPE_ERR_ARRAY_SIZE - 1) && ABS(error) < 2000) { // Check for persistent error (skip)
180 180
           errPrst[errPrstIdx++] = error; // Error must persist for I2CPE_ERR_PRST_ARRAY_SIZE error cycles. This also serves to improve the average accuracy
181 181
           if (errPrstIdx >= I2CPE_ERR_PRST_ARRAY_SIZE) {
@@ -193,14 +193,14 @@ void I2CPositionEncoder::update() {
193 193
           errPrstIdx = 0;
194 194
       }
195 195
     #else
196
-      if (ABS(error) > threshold * planner.axis_steps_per_mm[encoderAxis]) {
196
+      if (ABS(error) > threshold * planner.settings.axis_steps_per_mm[encoderAxis]) {
197 197
         //SERIAL_ECHOLN(error);
198 198
         //SERIAL_ECHOLN(position);
199 199
         thermalManager.babystepsTodo[encoderAxis] = -LROUND(error / 2);
200 200
       }
201 201
     #endif
202 202
 
203
-    if (ABS(error) > I2CPE_ERR_CNT_THRESH * planner.axis_steps_per_mm[encoderAxis]) {
203
+    if (ABS(error) > I2CPE_ERR_CNT_THRESH * planner.settings.axis_steps_per_mm[encoderAxis]) {
204 204
       const millis_t ms = millis();
205 205
       if (ELAPSED(ms, nextErrorCountTime)) {
206 206
         SERIAL_ECHOPAIR("Large error on ", axis_codes[encoderAxis]);
@@ -284,7 +284,7 @@ int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) {
284 284
   //int32_t stepperTicks = stepper.position(encoderAxis);
285 285
 
286 286
   // With a rotary encoder we're concerned with ticks/rev; whereas with a linear we're concerned with ticks/mm
287
-  stepperTicksPerUnit = (type == I2CPE_ENC_TYPE_ROTARY) ? stepperTicks : planner.axis_steps_per_mm[encoderAxis];
287
+  stepperTicksPerUnit = (type == I2CPE_ENC_TYPE_ROTARY) ? stepperTicks : planner.settings.axis_steps_per_mm[encoderAxis];
288 288
 
289 289
   //convert both 'ticks' into same units / base
290 290
   encoderCountInStepperTicksScaled = LROUND((stepperTicksPerUnit * encoderTicks) / encoderTicksPerUnit);
@@ -444,14 +444,14 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) {
444 444
     SERIAL_ECHOLNPGM("mm.");
445 445
 
446 446
     //Calculate new axis steps per unit
447
-    old_steps_mm = planner.axis_steps_per_mm[encoderAxis];
447
+    old_steps_mm = planner.settings.axis_steps_per_mm[encoderAxis];
448 448
     new_steps_mm = (old_steps_mm * travelDistance) / travelledDistance;
449 449
 
450 450
     SERIAL_ECHOLNPAIR("Old steps per mm: ", old_steps_mm);
451 451
     SERIAL_ECHOLNPAIR("New steps per mm: ", new_steps_mm);
452 452
 
453 453
     //Save new value
454
-    planner.axis_steps_per_mm[encoderAxis] = new_steps_mm;
454
+    planner.settings.axis_steps_per_mm[encoderAxis] = new_steps_mm;
455 455
 
456 456
     if (iter > 1) {
457 457
       total += new_steps_mm;

+ 2
- 2
Marlin/src/feature/I2CPositionEncoder.h Visa fil

@@ -155,7 +155,7 @@ class I2CPositionEncoder {
155 155
         case I2CPE_ENC_TYPE_LINEAR:
156 156
           return count / encoderTicksPerUnit;
157 157
         case I2CPE_ENC_TYPE_ROTARY:
158
-          return (count * stepperTicks) / (encoderTicksPerUnit * planner.axis_steps_per_mm[encoderAxis]);
158
+          return (count * stepperTicks) / (encoderTicksPerUnit * planner.settings.axis_steps_per_mm[encoderAxis]);
159 159
       }
160 160
     }
161 161
 
@@ -199,7 +199,7 @@ class I2CPositionEncoder {
199 199
         case I2CPE_ENC_TYPE_LINEAR:
200 200
           return encoderTicksPerUnit;
201 201
         case I2CPE_ENC_TYPE_ROTARY:
202
-          return (int)((encoderTicksPerUnit / stepperTicks) * planner.axis_steps_per_mm[encoderAxis]);
202
+          return (int)((encoderTicksPerUnit / stepperTicks) * planner.settings.axis_steps_per_mm[encoderAxis]);
203 203
       }
204 204
     }
205 205
 

+ 1
- 1
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Visa fil

@@ -803,7 +803,7 @@
803 803
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
804 804
 
805 805
       do_blocking_move_to(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
806
-        //, MIN(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) * 0.5f);
806
+        //, MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]) * 0.5f);
807 807
       planner.synchronize();
808 808
 
809 809
       SERIAL_PROTOCOLPGM("Place shim under nozzle");

+ 26
- 28
Marlin/src/feature/fwretract.cpp Visa fil

@@ -43,34 +43,32 @@ FWRetract fwretract; // Single instance - this calls the constructor
43 43
 // private:
44 44
 
45 45
 #if EXTRUDERS > 1
46
-  bool FWRetract::retracted_swap[EXTRUDERS];         // Which extruders are swap-retracted
46
+  bool FWRetract::retracted_swap[EXTRUDERS];          // Which extruders are swap-retracted
47 47
 #endif
48 48
 
49 49
 // public:
50 50
 
51
-bool FWRetract::autoretract_enabled,                 // M209 S - Autoretract switch
52
-     FWRetract::retracted[EXTRUDERS];                // Which extruders are currently retracted
53
-float FWRetract::retract_length,                     // M207 S - G10 Retract length
54
-      FWRetract::retract_feedrate_mm_s,              // M207 F - G10 Retract feedrate
55
-      FWRetract::retract_zlift,                      // M207 Z - G10 Retract hop size
56
-      FWRetract::retract_recover_length,             // M208 S - G11 Recover length
57
-      FWRetract::retract_recover_feedrate_mm_s,      // M208 F - G11 Recover feedrate
58
-      FWRetract::swap_retract_length,                // M207 W - G10 Swap Retract length
59
-      FWRetract::swap_retract_recover_length,        // M208 W - G11 Swap Recover length
60
-      FWRetract::swap_retract_recover_feedrate_mm_s, // M208 R - G11 Swap Recover feedrate
61
-      FWRetract::current_retract[EXTRUDERS],         // Retract value used by planner
51
+fwretract_settings_t FWRetract::settings;             // M207 S F Z W, M208 S F W R
52
+
53
+#if ENABLED(FWRETRACT_AUTORETRACT)
54
+  bool FWRetract::autoretract_enabled;                // M209 S - Autoretract switch
55
+#endif
56
+
57
+bool FWRetract::retracted[EXTRUDERS];                 // Which extruders are currently retracted
58
+
59
+float FWRetract::current_retract[EXTRUDERS],          // Retract value used by planner
62 60
       FWRetract::current_hop;
63 61
 
64 62
 void FWRetract::reset() {
65 63
   autoretract_enabled = false;
66
-  retract_length = RETRACT_LENGTH;
67
-  retract_feedrate_mm_s = RETRACT_FEEDRATE;
68
-  retract_zlift = RETRACT_ZLIFT;
69
-  retract_recover_length = RETRACT_RECOVER_LENGTH;
70
-  retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE;
71
-  swap_retract_length = RETRACT_LENGTH_SWAP;
72
-  swap_retract_recover_length = RETRACT_RECOVER_LENGTH_SWAP;
73
-  swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
64
+  settings.retract_length = RETRACT_LENGTH;
65
+  settings.retract_feedrate_mm_s = RETRACT_FEEDRATE;
66
+  settings.retract_zlift = RETRACT_ZLIFT;
67
+  settings.retract_recover_length = RETRACT_RECOVER_LENGTH;
68
+  settings.retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE;
69
+  settings.swap_retract_length = RETRACT_LENGTH_SWAP;
70
+  settings.swap_retract_recover_length = RETRACT_RECOVER_LENGTH_SWAP;
71
+  settings.swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
74 72
   current_hop = 0.0;
75 73
 
76 74
   for (uint8_t i = 0; i < EXTRUDERS; ++i) {
@@ -132,7 +130,7 @@ void FWRetract::retract(const bool retracting
132 130
               unscale_e = RECIPROCAL(planner.e_factor[active_extruder]),
133 131
               unscale_fr = 100.0 / feedrate_percentage, // Disable feedrate scaling for retract moves
134 132
               base_retract = (
135
-                (swapping ? swap_retract_length : retract_length)
133
+                (swapping ? settings.swap_retract_length : settings.retract_length)
136 134
                 #if ENABLED(RETRACT_SYNC_MIXING)
137 135
                   * (MIXING_STEPPERS)
138 136
                 #endif
@@ -152,7 +150,7 @@ void FWRetract::retract(const bool retracting
152 150
   if (retracting) {
153 151
     // Retract by moving from a faux E position back to the current E position
154 152
     feedrate_mm_s = (
155
-      retract_feedrate_mm_s * unscale_fr
153
+      settings.retract_feedrate_mm_s * unscale_fr
156 154
       #if ENABLED(RETRACT_SYNC_MIXING)
157 155
         * (MIXING_STEPPERS)
158 156
       #endif
@@ -162,9 +160,9 @@ void FWRetract::retract(const bool retracting
162 160
     planner.synchronize();                                // Wait for move to complete
163 161
 
164 162
     // Is a Z hop set, and has the hop not yet been done?
165
-    if (retract_zlift > 0.01 && !current_hop) {           // Apply hop only once
166
-      current_hop += retract_zlift;                       // Add to the hop total (again, only once)
167
-      feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS] * unscale_fr;  // Maximum Z feedrate
163
+    if (settings.retract_zlift > 0.01 && !current_hop) {           // Apply hop only once
164
+      current_hop += settings.retract_zlift;                       // Add to the hop total (again, only once)
165
+      feedrate_mm_s = planner.settings.max_feedrate_mm_s[Z_AXIS] * unscale_fr;  // Maximum Z feedrate
168 166
       prepare_move_to_destination();                      // Raise up, set_current_to_destination
169 167
       planner.synchronize();                              // Wait for move to complete
170 168
     }
@@ -173,12 +171,12 @@ void FWRetract::retract(const bool retracting
173 171
     // If a hop was done and Z hasn't changed, undo the Z hop
174 172
     if (current_hop) {
175 173
       current_hop = 0.0;
176
-      feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS] * unscale_fr;  // Z feedrate to max
174
+      feedrate_mm_s = planner.settings.max_feedrate_mm_s[Z_AXIS] * unscale_fr;  // Z feedrate to max
177 175
       prepare_move_to_destination();                      // Lower Z, set_current_to_destination
178 176
       planner.synchronize();                              // Wait for move to complete
179 177
     }
180 178
 
181
-    const float extra_recover = swapping ? swap_retract_recover_length : retract_recover_length;
179
+    const float extra_recover = swapping ? settings.swap_retract_recover_length : settings.retract_recover_length;
182 180
     if (extra_recover != 0.0) {
183 181
       current_position[E_AXIS] -= extra_recover;          // Adjust the current E position by the extra amount to recover
184 182
       sync_plan_position_e();                             // Sync the planner position so the extra amount is recovered
@@ -186,7 +184,7 @@ void FWRetract::retract(const bool retracting
186 184
 
187 185
     current_retract[active_extruder] = 0.0;
188 186
     feedrate_mm_s = (
189
-      (swapping ? swap_retract_recover_feedrate_mm_s : retract_recover_feedrate_mm_s) * unscale_fr
187
+      (swapping ? settings.swap_retract_recover_feedrate_mm_s : settings.retract_recover_feedrate_mm_s) * unscale_fr
190 188
       #if ENABLED(RETRACT_SYNC_MIXING)
191 189
         * (MIXING_STEPPERS)
192 190
       #endif

+ 13
- 18
Marlin/src/feature/fwretract.h Visa fil

@@ -19,15 +19,13 @@
19 19
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 20
  *
21 21
  */
22
+#pragma once
22 23
 
23 24
 /**
24 25
  * fwretract.h - Define firmware-based retraction interface
25 26
  */
26 27
 
27
-#ifndef FWRETRACT_H
28
-#define FWRETRACT_H
29
-
30
-#include "../inc/MarlinConfig.h"
28
+#include "../inc/MarlinConfigPre.h"
31 29
 
32 30
 class FWRetract {
33 31
 private:
@@ -36,17 +34,16 @@ private:
36 34
   #endif
37 35
 
38 36
 public:
39
-  static bool autoretract_enabled,                 // M209 S - Autoretract switch
40
-              retracted[EXTRUDERS];                // Which extruders are currently retracted
41
-  static float retract_length,                     // M207 S - G10 Retract length
42
-               retract_feedrate_mm_s,              // M207 F - G10 Retract feedrate
43
-               retract_zlift,                      // M207 Z - G10 Retract hop size
44
-               retract_recover_length,             // M208 S - G11 Recover length
45
-               retract_recover_feedrate_mm_s,      // M208 F - G11 Recover feedrate
46
-               swap_retract_length,                // M207 W - G10 Swap Retract length
47
-               swap_retract_recover_length,        // M208 W - G11 Swap Recover length
48
-               swap_retract_recover_feedrate_mm_s, // M208 R - G11 Swap Recover feedrate
49
-               current_retract[EXTRUDERS],         // Retract value used by planner
37
+  static fwretract_settings_t settings;
38
+
39
+  #if ENABLED(FWRETRACT_AUTORETRACT)
40
+    static bool autoretract_enabled;               // M209 S - Autoretract switch
41
+  #else
42
+    constexpr static bool autoretract_enabled = false;
43
+  #endif
44
+
45
+  static bool retracted[EXTRUDERS];                // Which extruders are currently retracted
46
+  static float current_retract[EXTRUDERS],         // Retract value used by planner
50 47
                current_hop;                        // Hop value used by planner
51 48
 
52 49
   FWRetract() { reset(); }
@@ -54,7 +51,7 @@ public:
54 51
   static void reset();
55 52
 
56 53
   static void refresh_autoretract() {
57
-    for (uint8_t i = 0; i < EXTRUDERS; i++) retracted[i] = false;
54
+    LOOP_L_N(i, EXTRUDERS) retracted[i] = false;
58 55
   }
59 56
 
60 57
   static void enable_autoretract(const bool enable) {
@@ -72,5 +69,3 @@ public:
72 69
 };
73 70
 
74 71
 extern FWRetract fwretract;
75
-
76
-#endif // FWRETRACT_H

+ 10
- 11
Marlin/src/feature/pause.cpp Visa fil

@@ -25,7 +25,7 @@
25 25
  * This may be combined with related G-codes if features are consolidated.
26 26
  */
27 27
 
28
-#include "../inc/MarlinConfig.h"
28
+#include "../inc/MarlinConfigPre.h"
29 29
 
30 30
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
31 31
 
@@ -59,8 +59,7 @@ static float resume_position[XYZE];
59 59
 
60 60
 AdvancedPauseMenuResponse advanced_pause_menu_response;
61 61
 
62
-float filament_change_unload_length[EXTRUDERS],
63
-      filament_change_load_length[EXTRUDERS];
62
+fil_change_settings_t fc_settings[EXTRUDERS];
64 63
 
65 64
 #if ENABLED(SDSUPPORT)
66 65
   #include "../sd/cardreader.h"
@@ -191,14 +190,14 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
191 190
   // Fast Load Filament
192 191
   if (fast_load_length) {
193 192
     #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
194
-      const float saved_acceleration = planner.retract_acceleration;
195
-      planner.retract_acceleration = FILAMENT_CHANGE_FAST_LOAD_ACCEL;
193
+      const float saved_acceleration = planner.settings.retract_acceleration;
194
+      planner.settings.retract_acceleration = FILAMENT_CHANGE_FAST_LOAD_ACCEL;
196 195
     #endif
197 196
 
198 197
     do_pause_e_move(fast_load_length, FILAMENT_CHANGE_FAST_LOAD_FEEDRATE);
199 198
 
200 199
     #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
201
-      planner.retract_acceleration = saved_acceleration;
200
+      planner.settings.retract_acceleration = saved_acceleration;
202 201
     #endif
203 202
   }
204 203
 
@@ -295,18 +294,18 @@ bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
295 294
   safe_delay(FILAMENT_UNLOAD_DELAY);
296 295
 
297 296
   // Quickly purge
298
-  do_pause_e_move(FILAMENT_UNLOAD_RETRACT_LENGTH + FILAMENT_UNLOAD_PURGE_LENGTH, planner.max_feedrate_mm_s[E_AXIS]);
297
+  do_pause_e_move(FILAMENT_UNLOAD_RETRACT_LENGTH + FILAMENT_UNLOAD_PURGE_LENGTH, planner.settings.max_feedrate_mm_s[E_AXIS]);
299 298
 
300 299
   // Unload filament
301 300
   #if FILAMENT_CHANGE_UNLOAD_ACCEL > 0
302
-    const float saved_acceleration = planner.retract_acceleration;
303
-    planner.retract_acceleration = FILAMENT_CHANGE_UNLOAD_ACCEL;
301
+    const float saved_acceleration = planner.settings.retract_acceleration;
302
+    planner.settings.retract_acceleration = FILAMENT_CHANGE_UNLOAD_ACCEL;
304 303
   #endif
305 304
 
306 305
   do_pause_e_move(unload_length, FILAMENT_CHANGE_UNLOAD_FEEDRATE);
307 306
 
308 307
   #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
309
-    planner.retract_acceleration = saved_acceleration;
308
+    planner.settings.retract_acceleration = saved_acceleration;
310 309
   #endif
311 310
 
312 311
   // Disable extruders steppers for manual filament changing (only on boards that have separate ENABLE_PINS)
@@ -559,7 +558,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
559 558
   #if ENABLED(FWRETRACT)
560 559
     // If retracted before goto pause
561 560
     if (fwretract.retracted[active_extruder])
562
-      do_pause_e_move(-fwretract.retract_length, fwretract.retract_feedrate_mm_s);
561
+      do_pause_e_move(-fwretract.settings.retract_length, fwretract.settings.retract_feedrate_mm_s);
563 562
   #endif
564 563
 
565 564
   // If resume_position is negative

+ 2
- 7
Marlin/src/feature/pause.h Visa fil

@@ -19,15 +19,13 @@
19 19
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 20
  *
21 21
  */
22
+#pragma once
22 23
 
23 24
 /**
24 25
  * feature/pause.h - Pause feature support functions
25 26
  * This may be combined with related G-codes if features are consolidated.
26 27
  */
27 28
 
28
-#ifndef _PAUSE_H_
29
-#define _PAUSE_H_
30
-
31 29
 #include "../libs/nozzle.h"
32 30
 
33 31
 #include "../inc/MarlinConfigPre.h"
@@ -62,8 +60,7 @@ enum AdvancedPauseMenuResponse : char {
62 60
 
63 61
 extern AdvancedPauseMenuResponse advanced_pause_menu_response;
64 62
 
65
-extern float filament_change_unload_length[EXTRUDERS],
66
-             filament_change_load_length[EXTRUDERS];
63
+extern fil_change_settings_t fc_settings[EXTRUDERS];
67 64
 
68 65
 extern uint8_t did_pause_print;
69 66
 
@@ -89,5 +86,3 @@ bool load_filament(const float &slow_load_length=0, const float &fast_load_lengt
89 86
                           const bool pause_for_user=false, const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT DXC_PARAMS);
90 87
 
91 88
 bool unload_filament(const float &unload_length, const bool show_lcd=false, const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT);
92
-
93
-#endif // _PAUSE_H_

+ 13
- 13
Marlin/src/feature/tmc_util.cpp Visa fil

@@ -456,62 +456,62 @@
456 456
 
457 457
   static void tmc_debug_loop(const TMC_debug_enum i) {
458 458
     #if AXIS_IS_TMC(X)
459
-      tmc_status(stepperX, i, planner.axis_steps_per_mm[X_AXIS]);
459
+      tmc_status(stepperX, i, planner.settings.axis_steps_per_mm[X_AXIS]);
460 460
     #endif
461 461
     #if AXIS_IS_TMC(X2)
462
-      tmc_status(stepperX2, i, planner.axis_steps_per_mm[X_AXIS]);
462
+      tmc_status(stepperX2, i, planner.settings.axis_steps_per_mm[X_AXIS]);
463 463
     #endif
464 464
 
465 465
     #if AXIS_IS_TMC(Y)
466
-      tmc_status(stepperY, i, planner.axis_steps_per_mm[Y_AXIS]);
466
+      tmc_status(stepperY, i, planner.settings.axis_steps_per_mm[Y_AXIS]);
467 467
     #endif
468 468
     #if AXIS_IS_TMC(Y2)
469
-      tmc_status(stepperY2, i, planner.axis_steps_per_mm[Y_AXIS]);
469
+      tmc_status(stepperY2, i, planner.settings.axis_steps_per_mm[Y_AXIS]);
470 470
     #endif
471 471
 
472 472
     #if AXIS_IS_TMC(Z)
473
-      tmc_status(stepperZ, i, planner.axis_steps_per_mm[Z_AXIS]);
473
+      tmc_status(stepperZ, i, planner.settings.axis_steps_per_mm[Z_AXIS]);
474 474
     #endif
475 475
     #if AXIS_IS_TMC(Z2)
476
-      tmc_status(stepperZ2, i, planner.axis_steps_per_mm[Z_AXIS]);
476
+      tmc_status(stepperZ2, i, planner.settings.axis_steps_per_mm[Z_AXIS]);
477 477
     #endif
478 478
     #if AXIS_IS_TMC(Z3)
479
-      tmc_status(stepperZ3, i, planner.axis_steps_per_mm[Z_AXIS]);
479
+      tmc_status(stepperZ3, i, planner.settings.axis_steps_per_mm[Z_AXIS]);
480 480
     #endif
481 481
 
482 482
     #if AXIS_IS_TMC(E0)
483
-      tmc_status(stepperE0, i, planner.axis_steps_per_mm[E_AXIS]);
483
+      tmc_status(stepperE0, i, planner.settings.axis_steps_per_mm[E_AXIS]);
484 484
     #endif
485 485
     #if AXIS_IS_TMC(E1)
486
-      tmc_status(stepperE1, i, planner.axis_steps_per_mm[E_AXIS
486
+      tmc_status(stepperE1, i, planner.settings.axis_steps_per_mm[E_AXIS
487 487
         #if ENABLED(DISTINCT_E_FACTORS)
488 488
           + 1
489 489
         #endif
490 490
       ]);
491 491
     #endif
492 492
     #if AXIS_IS_TMC(E2)
493
-      tmc_status(stepperE2, i, planner.axis_steps_per_mm[E_AXIS
493
+      tmc_status(stepperE2, i, planner.settings.axis_steps_per_mm[E_AXIS
494 494
         #if ENABLED(DISTINCT_E_FACTORS)
495 495
           + 2
496 496
         #endif
497 497
       ]);
498 498
     #endif
499 499
     #if AXIS_IS_TMC(E3)
500
-      tmc_status(stepperE3, i, planner.axis_steps_per_mm[E_AXIS
500
+      tmc_status(stepperE3, i, planner.settings.axis_steps_per_mm[E_AXIS
501 501
         #if ENABLED(DISTINCT_E_FACTORS)
502 502
           + 3
503 503
         #endif
504 504
       ]);
505 505
     #endif
506 506
     #if AXIS_IS_TMC(E4)
507
-      tmc_status(stepperE4, i, planner.axis_steps_per_mm[E_AXIS
507
+      tmc_status(stepperE4, i, planner.settings.axis_steps_per_mm[E_AXIS
508 508
         #if ENABLED(DISTINCT_E_FACTORS)
509 509
           + 4
510 510
         #endif
511 511
       ]);
512 512
     #endif
513 513
     #if AXIS_IS_TMC(E5)
514
-      tmc_status(stepperE5, i, planner.axis_steps_per_mm[E_AXIS
514
+      tmc_status(stepperE5, i, planner.settings.axis_steps_per_mm[E_AXIS
515 515
         #if ENABLED(DISTINCT_E_FACTORS)
516 516
           + 5
517 517
         #endif

+ 4
- 4
Marlin/src/gcode/bedlevel/G26.cpp Visa fil

@@ -232,7 +232,7 @@ void move_to(const float &rx, const float &ry, const float &z, const float &e_de
232 232
 
233 233
   if (z != last_z) {
234 234
     last_z = z;
235
-    feed_value = planner.max_feedrate_mm_s[Z_AXIS]/(3.0);  // Base the feed rate off of the configured Z_AXIS feed rate
235
+    feed_value = planner.settings.max_feedrate_mm_s[Z_AXIS]/(3.0);  // Base the feed rate off of the configured Z_AXIS feed rate
236 236
 
237 237
     destination[X_AXIS] = current_position[X_AXIS];
238 238
     destination[Y_AXIS] = current_position[Y_AXIS];
@@ -245,7 +245,7 @@ void move_to(const float &rx, const float &ry, const float &z, const float &e_de
245 245
 
246 246
   // Check if X or Y is involved in the movement.
247 247
   // Yes: a 'normal' movement. No: a retract() or recover()
248
-  feed_value = has_xy_component ? PLANNER_XY_FEEDRATE() / 10.0 : planner.max_feedrate_mm_s[E_AXIS] / 1.5;
248
+  feed_value = has_xy_component ? PLANNER_XY_FEEDRATE() / 10.0 : planner.settings.max_feedrate_mm_s[E_AXIS] / 1.5;
249 249
 
250 250
   if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
251 251
 
@@ -496,7 +496,7 @@ inline bool prime_nozzle() {
496 496
           Total_Prime += 0.25;
497 497
           if (Total_Prime >= EXTRUDE_MAXLENGTH) return G26_ERR;
498 498
         #endif
499
-        G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);
499
+        G26_line_to_destination(planner.settings.max_feedrate_mm_s[E_AXIS] / 15.0);
500 500
         set_destination_from_current();
501 501
         planner.synchronize();    // Without this synchronize, the purge is more consistent,
502 502
                                   // but because the planner has a buffer, we won't be able
@@ -519,7 +519,7 @@ inline bool prime_nozzle() {
519 519
     #endif
520 520
     set_destination_from_current();
521 521
     destination[E_AXIS] += g26_prime_length;
522
-    G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);
522
+    G26_line_to_destination(planner.settings.max_feedrate_mm_s[E_AXIS] / 15.0);
523 523
     set_destination_from_current();
524 524
     retract_filament(destination);
525 525
   }

+ 9
- 9
Marlin/src/gcode/calibrate/M852.cpp Visa fil

@@ -42,8 +42,8 @@ void GcodeSuite::M852() {
42 42
     ++ijk;
43 43
     const float value = parser.value_linear_units();
44 44
     if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
45
-      if (planner.xy_skew_factor != value) {
46
-        planner.xy_skew_factor = value;
45
+      if (planner.skew_factor.xy != value) {
46
+        planner.skew_factor.xy = value;
47 47
         ++setval;
48 48
       }
49 49
     }
@@ -57,8 +57,8 @@ void GcodeSuite::M852() {
57 57
       ++ijk;
58 58
       const float value = parser.value_linear_units();
59 59
       if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
60
-        if (planner.xz_skew_factor != value) {
61
-          planner.xz_skew_factor = value;
60
+        if (planner.skew_factor.xz != value) {
61
+          planner.skew_factor.xz = value;
62 62
           ++setval;
63 63
         }
64 64
       }
@@ -70,8 +70,8 @@ void GcodeSuite::M852() {
70 70
       ++ijk;
71 71
       const float value = parser.value_linear_units();
72 72
       if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
73
-        if (planner.yz_skew_factor != value) {
74
-          planner.yz_skew_factor = value;
73
+        if (planner.skew_factor.yz != value) {
74
+          planner.skew_factor.yz = value;
75 75
           ++setval;
76 76
         }
77 77
       }
@@ -94,11 +94,11 @@ void GcodeSuite::M852() {
94 94
   if (!ijk) {
95 95
     SERIAL_ECHO_START();
96 96
     SERIAL_ECHOPGM(MSG_SKEW_FACTOR " XY: ");
97
-    SERIAL_ECHO_F(planner.xy_skew_factor, 6);
97
+    SERIAL_ECHO_F(planner.skew_factor.xy, 6);
98 98
     SERIAL_EOL();
99 99
     #if ENABLED(SKEW_CORRECTION_FOR_Z)
100
-      SERIAL_ECHOPAIR(" XZ: ", planner.xz_skew_factor);
101
-      SERIAL_ECHOLNPAIR(" YZ: ", planner.yz_skew_factor);
100
+      SERIAL_ECHOPAIR(" XZ: ", planner.skew_factor.xz);
101
+      SERIAL_ECHOLNPAIR(" YZ: ", planner.skew_factor.yz);
102 102
     #else
103 103
       SERIAL_EOL();
104 104
     #endif

+ 12
- 12
Marlin/src/gcode/config/M200-M205.cpp Visa fil

@@ -60,7 +60,7 @@ void GcodeSuite::M201() {
60 60
   LOOP_XYZE(i) {
61 61
     if (parser.seen(axis_codes[i])) {
62 62
       const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
63
-      planner.max_acceleration_mm_per_s2[a] = parser.value_axis_units((AxisEnum)a);
63
+      planner.settings.max_acceleration_mm_per_s2[a] = parser.value_axis_units((AxisEnum)a);
64 64
     }
65 65
   }
66 66
   // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
@@ -79,7 +79,7 @@ void GcodeSuite::M203() {
79 79
   LOOP_XYZE(i)
80 80
     if (parser.seen(axis_codes[i])) {
81 81
       const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
82
-      planner.max_feedrate_mm_s[a] = parser.value_axis_units((AxisEnum)a);
82
+      planner.settings.max_feedrate_mm_s[a] = parser.value_axis_units((AxisEnum)a);
83 83
     }
84 84
 }
85 85
 
@@ -93,25 +93,25 @@ void GcodeSuite::M203() {
93 93
 void GcodeSuite::M204() {
94 94
   bool report = true;
95 95
   if (parser.seenval('S')) { // Kept for legacy compatibility. Should NOT BE USED for new developments.
96
-    planner.travel_acceleration = planner.acceleration = parser.value_linear_units();
96
+    planner.settings.travel_acceleration = planner.settings.acceleration = parser.value_linear_units();
97 97
     report = false;
98 98
   }
99 99
   if (parser.seenval('P')) {
100
-    planner.acceleration = parser.value_linear_units();
100
+    planner.settings.acceleration = parser.value_linear_units();
101 101
     report = false;
102 102
   }
103 103
   if (parser.seenval('R')) {
104
-    planner.retract_acceleration = parser.value_linear_units();
104
+    planner.settings.retract_acceleration = parser.value_linear_units();
105 105
     report = false;
106 106
   }
107 107
   if (parser.seenval('T')) {
108
-    planner.travel_acceleration = parser.value_linear_units();
108
+    planner.settings.travel_acceleration = parser.value_linear_units();
109 109
     report = false;
110 110
   }
111 111
   if (report) {
112
-    SERIAL_ECHOPAIR("Acceleration: P", planner.acceleration);
113
-    SERIAL_ECHOPAIR(" R", planner.retract_acceleration);
114
-    SERIAL_ECHOLNPAIR(" T", planner.travel_acceleration);
112
+    SERIAL_ECHOPAIR("Acceleration: P", planner.settings.acceleration);
113
+    SERIAL_ECHOPAIR(" R", planner.settings.retract_acceleration);
114
+    SERIAL_ECHOLNPAIR(" T", planner.settings.travel_acceleration);
115 115
   }
116 116
 }
117 117
 
@@ -128,9 +128,9 @@ void GcodeSuite::M204() {
128 128
  *    J = Junction Deviation (mm) (Requires JUNCTION_DEVIATION)
129 129
  */
130 130
 void GcodeSuite::M205() {
131
-  if (parser.seen('B')) planner.min_segment_time_us = parser.value_ulong();
132
-  if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units();
133
-  if (parser.seen('T')) planner.min_travel_feedrate_mm_s = parser.value_linear_units();
131
+  if (parser.seen('B')) planner.settings.min_segment_time_us = parser.value_ulong();
132
+  if (parser.seen('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units();
133
+  if (parser.seen('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units();
134 134
   #if ENABLED(JUNCTION_DEVIATION)
135 135
     if (parser.seen('J')) {
136 136
       const float junc_dev = parser.value_linear_units();

+ 6
- 6
Marlin/src/gcode/config/M217.cpp Visa fil

@@ -36,9 +36,9 @@ void M217_report(const bool eeprom=false) {
36 36
     const int16_t port = command_queue_port[cmd_queue_index_r];
37 37
   #endif
38 38
   serialprintPGM_P(port, eeprom ? PSTR("  M217") : PSTR("Singlenozzle:"));
39
-  SERIAL_ECHOPAIR_P(port, " S", singlenozzle_swap_length);
40
-  SERIAL_ECHOPAIR_P(port, " P", singlenozzle_prime_speed);
41
-  SERIAL_ECHOLNPAIR_P(port, " R", singlenozzle_retract_speed);
39
+  SERIAL_ECHOPAIR_P(port, " S", sn_settings.swap_length);
40
+  SERIAL_ECHOPAIR_P(port, " P", sn_settings.prime_speed);
41
+  SERIAL_ECHOLNPAIR_P(port, " R", sn_settings.retract_speed);
42 42
 }
43 43
 
44 44
 /**
@@ -52,9 +52,9 @@ void GcodeSuite::M217() {
52 52
 
53 53
   bool report = true;
54 54
 
55
-  if (parser.seenval('S')) { report = false; const float v = parser.value_float(); singlenozzle_swap_length = constrain(v, 0, 500); }
56
-  if (parser.seenval('P')) { report = false; const int16_t v = parser.value_int(); singlenozzle_prime_speed = constrain(v, 10, 5400); }
57
-  if (parser.seenval('R')) { report = false; const int16_t v = parser.value_int(); singlenozzle_retract_speed = constrain(v, 10, 5400); }
55
+  if (parser.seenval('S')) { report = false; const float v = parser.value_float(); sn_settings.swap_length = constrain(v, 0, 500); }
56
+  if (parser.seenval('P')) { report = false; const int16_t v = parser.value_int(); sn_settings.prime_speed = constrain(v, 10, 5400); }
57
+  if (parser.seenval('R')) { report = false; const int16_t v = parser.value_int(); sn_settings.retract_speed = constrain(v, 10, 5400); }
58 58
 
59 59
   if (report) M217_report();
60 60
 

+ 1
- 1
Marlin/src/gcode/config/M218.cpp Visa fil

@@ -72,7 +72,7 @@ void GcodeSuite::M218() {
72 72
 
73 73
   #if ENABLED(DELTA)
74 74
     if (target_extruder == active_extruder)
75
-      do_blocking_move_to_xy(current_position[X_AXIS], current_position[Y_AXIS], planner.max_feedrate_mm_s[X_AXIS]);
75
+      do_blocking_move_to_xy(current_position[X_AXIS], current_position[Y_AXIS], planner.settings.max_feedrate_mm_s[X_AXIS]);
76 76
   #endif
77 77
 }
78 78
 

+ 6
- 6
Marlin/src/gcode/config/M304.cpp Visa fil

@@ -28,14 +28,14 @@
28 28
 #include "../../module/temperature.h"
29 29
 
30 30
 void GcodeSuite::M304() {
31
-  if (parser.seen('P')) thermalManager.bedKp = parser.value_float();
32
-  if (parser.seen('I')) thermalManager.bedKi = scalePID_i(parser.value_float());
33
-  if (parser.seen('D')) thermalManager.bedKd = scalePID_d(parser.value_float());
31
+  if (parser.seen('P')) thermalManager.bed_pid.Kp = parser.value_float();
32
+  if (parser.seen('I')) thermalManager.bed_pid.Ki = scalePID_i(parser.value_float());
33
+  if (parser.seen('D')) thermalManager.bed_pid.Kd = scalePID_d(parser.value_float());
34 34
 
35 35
   SERIAL_ECHO_START();
36
-  SERIAL_ECHOPAIR(" p:", thermalManager.bedKp);
37
-  SERIAL_ECHOPAIR(" i:", unscalePID_i(thermalManager.bedKi));
38
-  SERIAL_ECHOLNPAIR(" d:", unscalePID_d(thermalManager.bedKd));
36
+  SERIAL_ECHOPAIR(" p:", thermalManager.bed_pid.Kp);
37
+  SERIAL_ECHOPAIR(" i:", unscalePID_i(thermalManager.bed_pid.Ki));
38
+  SERIAL_ECHOLNPAIR(" d:", unscalePID_d(thermalManager.bed_pid.Kd));
39 39
 }
40 40
 
41 41
 #endif // PIDTEMPBED

+ 4
- 4
Marlin/src/gcode/config/M92.cpp Visa fil

@@ -38,17 +38,17 @@ void GcodeSuite::M92() {
38 38
       if (i == E_AXIS) {
39 39
         const float value = parser.value_per_axis_unit((AxisEnum)(E_AXIS + TARGET_EXTRUDER));
40 40
         if (value < 20) {
41
-          float factor = planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
41
+          float factor = planner.settings.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
42 42
           #if HAS_CLASSIC_JERK && (DISABLED(JUNCTION_DEVIATION) || DISABLED(LIN_ADVANCE))
43 43
             planner.max_jerk[E_AXIS] *= factor;
44 44
           #endif
45
-          planner.max_feedrate_mm_s[E_AXIS + TARGET_EXTRUDER] *= factor;
45
+          planner.settings.max_feedrate_mm_s[E_AXIS + TARGET_EXTRUDER] *= factor;
46 46
           planner.max_acceleration_steps_per_s2[E_AXIS + TARGET_EXTRUDER] *= factor;
47 47
         }
48
-        planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] = value;
48
+        planner.settings.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] = value;
49 49
       }
50 50
       else {
51
-        planner.axis_steps_per_mm[i] = parser.value_per_axis_unit((AxisEnum)i);
51
+        planner.settings.axis_steps_per_mm[i] = parser.value_per_axis_unit((AxisEnum)i);
52 52
       }
53 53
     }
54 54
   }

+ 8
- 8
Marlin/src/gcode/feature/fwretract/M207-M209.cpp Visa fil

@@ -36,10 +36,10 @@
36 36
  *   Z[units]     retract_zlift
37 37
  */
38 38
 void GcodeSuite::M207() {
39
-  if (parser.seen('S')) fwretract.retract_length = parser.value_axis_units(E_AXIS);
40
-  if (parser.seen('F')) fwretract.retract_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
41
-  if (parser.seen('Z')) fwretract.retract_zlift = parser.value_linear_units();
42
-  if (parser.seen('W')) fwretract.swap_retract_length = parser.value_axis_units(E_AXIS);
39
+  if (parser.seen('S')) fwretract.settings.retract_length = parser.value_axis_units(E_AXIS);
40
+  if (parser.seen('F')) fwretract.settings.retract_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
41
+  if (parser.seen('Z')) fwretract.settings.retract_zlift = parser.value_linear_units();
42
+  if (parser.seen('W')) fwretract.settings.swap_retract_length = parser.value_axis_units(E_AXIS);
43 43
 }
44 44
 
45 45
 /**
@@ -51,10 +51,10 @@ void GcodeSuite::M207() {
51 51
  *   R[units/min] swap_retract_recover_feedrate_mm_s
52 52
  */
53 53
 void GcodeSuite::M208() {
54
-  if (parser.seen('S')) fwretract.retract_recover_length = parser.value_axis_units(E_AXIS);
55
-  if (parser.seen('F')) fwretract.retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
56
-  if (parser.seen('R')) fwretract.swap_retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
57
-  if (parser.seen('W')) fwretract.swap_retract_recover_length = parser.value_axis_units(E_AXIS);
54
+  if (parser.seen('S')) fwretract.settings.retract_recover_length = parser.value_axis_units(E_AXIS);
55
+  if (parser.seen('F')) fwretract.settings.retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
56
+  if (parser.seen('R')) fwretract.settings.swap_retract_recover_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
57
+  if (parser.seen('W')) fwretract.settings.swap_retract_recover_length = parser.value_axis_units(E_AXIS);
58 58
 }
59 59
 
60 60
 #if ENABLED(FWRETRACT_AUTORETRACT)

+ 2
- 2
Marlin/src/gcode/feature/pause/M600.cpp Visa fil

@@ -111,14 +111,14 @@ void GcodeSuite::M600() {
111 111
 
112 112
   // Unload filament
113 113
   const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
114
-                                                     : filament_change_unload_length[active_extruder]);
114
+                                                     : fc_settings[active_extruder].unload_length);
115 115
 
116 116
   // Slow load filament
117 117
   constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
118 118
 
119 119
   // Fast load filament
120 120
   const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
121
-                                                       : filament_change_load_length[active_extruder]);
121
+                                                       : fc_settings[active_extruder].load_length);
122 122
 
123 123
   const int beep_count = parser.intval('B',
124 124
     #ifdef FILAMENT_CHANGE_ALERT_BEEPS

+ 4
- 4
Marlin/src/gcode/feature/pause/M603.cpp Visa fil

@@ -47,17 +47,17 @@ void GcodeSuite::M603() {
47 47
 
48 48
   // Unload length
49 49
   if (parser.seen('U')) {
50
-    filament_change_unload_length[target_extruder] = ABS(parser.value_axis_units(E_AXIS));
50
+    fc_settings[target_extruder].unload_length = ABS(parser.value_axis_units(E_AXIS));
51 51
     #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
52
-      NOMORE(filament_change_unload_length[target_extruder], EXTRUDE_MAXLENGTH);
52
+      NOMORE(fc_settings[target_extruder].unload_length, EXTRUDE_MAXLENGTH);
53 53
     #endif
54 54
   }
55 55
 
56 56
   // Load length
57 57
   if (parser.seen('L')) {
58
-    filament_change_load_length[target_extruder] = ABS(parser.value_axis_units(E_AXIS));
58
+    fc_settings[target_extruder].load_length = ABS(parser.value_axis_units(E_AXIS));
59 59
     #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
60
-      NOMORE(filament_change_load_length[target_extruder], EXTRUDE_MAXLENGTH);
60
+      NOMORE(fc_settings[target_extruder].load_length, EXTRUDE_MAXLENGTH);
61 61
     #endif
62 62
   }
63 63
 }

+ 3
- 3
Marlin/src/gcode/feature/pause/M701_M702.cpp Visa fil

@@ -79,7 +79,7 @@ void GcodeSuite::M701() {
79 79
   // Load filament
80 80
   constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
81 81
   const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
82
-                                                       : filament_change_load_length[active_extruder]);
82
+                                                       : fc_settings[active_extruder].load_length);
83 83
   load_filament(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, FILAMENT_CHANGE_ALERT_BEEPS,
84 84
                 true, thermalManager.still_heating(target_extruder), ADVANCED_PAUSE_MODE_LOAD_FILAMENT
85 85
                 #if ENABLED(DUAL_X_CARRIAGE)
@@ -147,7 +147,7 @@ void GcodeSuite::M702() {
147 147
     if (!parser.seenval('T')) {
148 148
       HOTEND_LOOP() {
149 149
         if (e != active_extruder) tool_change(e, 0, true);
150
-        unload_filament(-filament_change_unload_length[e], true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
150
+        unload_filament(-fc_settings[e].unload_length, true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
151 151
       }
152 152
     }
153 153
     else
@@ -155,7 +155,7 @@ void GcodeSuite::M702() {
155 155
   {
156 156
     // Unload length
157 157
     const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS) :
158
-                                                        filament_change_unload_length[target_extruder]);
158
+                                                        fc_settings[target_extruder].unload_length);
159 159
 
160 160
     unload_filament(unload_length, true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
161 161
   }

+ 4
- 4
Marlin/src/gcode/feature/trinamic/M911-M915.cpp Visa fil

@@ -161,10 +161,10 @@
161 161
  */
162 162
 #if ENABLED(HYBRID_THRESHOLD)
163 163
   void GcodeSuite::M913() {
164
-    #define TMC_SAY_PWMTHRS(A,Q) tmc_get_pwmthrs(stepper##Q, planner.axis_steps_per_mm[_AXIS(A)])
165
-    #define TMC_SET_PWMTHRS(A,Q) tmc_set_pwmthrs(stepper##Q, value, planner.axis_steps_per_mm[_AXIS(A)])
166
-    #define TMC_SAY_PWMTHRS_E(E) tmc_get_pwmthrs(stepperE##E, planner.axis_steps_per_mm[E_AXIS_N(E)])
167
-    #define TMC_SET_PWMTHRS_E(E) tmc_set_pwmthrs(stepperE##E, value, planner.axis_steps_per_mm[E_AXIS_N(E)])
164
+    #define TMC_SAY_PWMTHRS(A,Q) tmc_get_pwmthrs(stepper##Q, planner.settings.axis_steps_per_mm[_AXIS(A)])
165
+    #define TMC_SET_PWMTHRS(A,Q) tmc_set_pwmthrs(stepper##Q, value, planner.settings.axis_steps_per_mm[_AXIS(A)])
166
+    #define TMC_SAY_PWMTHRS_E(E) tmc_get_pwmthrs(stepperE##E, planner.settings.axis_steps_per_mm[E_AXIS_N(E)])
167
+    #define TMC_SET_PWMTHRS_E(E) tmc_set_pwmthrs(stepperE##E, value, planner.settings.axis_steps_per_mm[E_AXIS_N(E)])
168 168
 
169 169
     bool report = true;
170 170
     const uint8_t index = parser.byteval('I');

+ 1
- 1
Marlin/src/gcode/gcode.h Visa fil

@@ -113,7 +113,7 @@
113 113
  * M84  - Disable steppers until next move, or use S<seconds> to specify an idle
114 114
  *        duration after which steppers should turn off. S0 disables the timeout.
115 115
  * M85  - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
116
- * M92  - Set planner.axis_steps_per_mm for one or more axes.
116
+ * M92  - Set planner.settings.axis_steps_per_mm for one or more axes.
117 117
  * M100 - Watch Free Memory (for debugging) (Requires M100_FREE_MEMORY_WATCHER)
118 118
  * M104 - Set extruder target temp.
119 119
  * M105 - Report current temperatures.

+ 2
- 2
Marlin/src/gcode/motion/M290.cpp Visa fil

@@ -64,7 +64,7 @@ void GcodeSuite::M290() {
64 64
     for (uint8_t a = X_AXIS; a <= Z_AXIS; a++)
65 65
       if (parser.seenval(axis_codes[a]) || (a == Z_AXIS && parser.seenval('S'))) {
66 66
         const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2);
67
-        thermalManager.babystep_axis((AxisEnum)a, offs * planner.axis_steps_per_mm[a]);
67
+        thermalManager.babystep_axis((AxisEnum)a, offs * planner.settings.axis_steps_per_mm[a]);
68 68
         #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
69 69
           if (a == Z_AXIS && (!parser.seen('P') || parser.value_bool())) mod_zprobe_zoffset(offs);
70 70
         #endif
@@ -72,7 +72,7 @@ void GcodeSuite::M290() {
72 72
   #else
73 73
     if (parser.seenval('Z') || parser.seenval('S')) {
74 74
       const float offs = constrain(parser.value_axis_units(Z_AXIS), -2, 2);
75
-      thermalManager.babystep_axis(Z_AXIS, offs * planner.axis_steps_per_mm[Z_AXIS]);
75
+      thermalManager.babystep_axis(Z_AXIS, offs * planner.settings.axis_steps_per_mm[Z_AXIS]);
76 76
       #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
77 77
         if (!parser.seen('P') || parser.value_bool()) mod_zprobe_zoffset(offs);
78 78
       #endif

+ 22
- 22
Marlin/src/lcd/extensible_ui/ui_api.cpp Visa fil

@@ -147,9 +147,9 @@ namespace UI {
147 147
   float getAxisSteps_per_mm(const axis_t axis) {
148 148
     switch (axis) {
149 149
       case X: case Y: case Z:
150
-        return planner.axis_steps_per_mm[axis];
150
+        return planner.settings.axis_steps_per_mm[axis];
151 151
       case E0: case E1: case E2: case E3: case E4: case E5:
152
-        return planner.axis_steps_per_mm[E_AXIS_N(axis - E0)];
152
+        return planner.settings.axis_steps_per_mm[E_AXIS_N(axis - E0)];
153 153
       default: return 0;
154 154
     }
155 155
   }
@@ -157,10 +157,10 @@ namespace UI {
157 157
   void setAxisSteps_per_mm(const axis_t axis, const float steps_per_mm) {
158 158
     switch (axis) {
159 159
       case X: case Y: case Z:
160
-        planner.axis_steps_per_mm[axis] = steps_per_mm;
160
+        planner.settings.axis_steps_per_mm[axis] = steps_per_mm;
161 161
         break;
162 162
       case E0: case E1: case E2: case E3: case E4: case E5:
163
-        planner.axis_steps_per_mm[E_AXIS_N(axis - E0)] = steps_per_mm;
163
+        planner.settings.axis_steps_per_mm[E_AXIS_N(axis - E0)] = steps_per_mm;
164 164
         break;
165 165
     }
166 166
   }
@@ -168,9 +168,9 @@ namespace UI {
168 168
   float getAxisMaxFeedrate_mm_s(const axis_t axis) {
169 169
     switch (axis) {
170 170
       case X: case Y: case Z:
171
-        return planner.max_feedrate_mm_s[axis];
171
+        return planner.settings.max_feedrate_mm_s[axis];
172 172
       case E0: case E1: case E2: case E3: case E4: case E5:
173
-        return planner.max_feedrate_mm_s[E_AXIS_N(axis - E0)];
173
+        return planner.settings.max_feedrate_mm_s[E_AXIS_N(axis - E0)];
174 174
       default: return 0;
175 175
     }
176 176
   }
@@ -178,10 +178,10 @@ namespace UI {
178 178
   void setAxisMaxFeedrate_mm_s(const axis_t axis, const float max_feedrate_mm_s) {
179 179
     switch (axis) {
180 180
       case X: case Y: case Z:
181
-        planner.max_feedrate_mm_s[axis] = max_feedrate_mm_s;
181
+        planner.settings.max_feedrate_mm_s[axis] = max_feedrate_mm_s;
182 182
         break;
183 183
       case E0: case E1: case E2: case E3: case E4: case E5:
184
-        planner.max_feedrate_mm_s[E_AXIS_N(axis - E0)] = max_feedrate_mm_s;
184
+        planner.settings.max_feedrate_mm_s[E_AXIS_N(axis - E0)] = max_feedrate_mm_s;
185 185
         break;
186 186
       default: return;
187 187
     }
@@ -190,9 +190,9 @@ namespace UI {
190 190
   float getAxisMaxAcceleration_mm_s2(const axis_t axis) {
191 191
     switch (axis) {
192 192
       case X: case Y: case Z:
193
-        return planner.max_acceleration_mm_per_s2[axis];
193
+        return planner.settings.max_acceleration_mm_per_s2[axis];
194 194
       case E0: case E1: case E2: case E3: case E4: case E5:
195
-        return planner.max_acceleration_mm_per_s2[E_AXIS_N(axis - E0)];
195
+        return planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(axis - E0)];
196 196
       default: return 0;
197 197
     }
198 198
   }
@@ -200,10 +200,10 @@ namespace UI {
200 200
   void setAxisMaxAcceleration_mm_s2(const axis_t axis, const float max_acceleration_mm_per_s2) {
201 201
     switch (axis) {
202 202
       case X: case Y: case Z:
203
-        planner.max_acceleration_mm_per_s2[axis] = max_acceleration_mm_per_s2;
203
+        planner.settings.max_acceleration_mm_per_s2[axis] = max_acceleration_mm_per_s2;
204 204
         break;
205 205
       case E0: case E1: case E2: case E3: case E4: case E5:
206
-        planner.max_acceleration_mm_per_s2[E_AXIS_N(axis - E0)] = max_acceleration_mm_per_s2;
206
+        planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(axis - E0)] = max_acceleration_mm_per_s2;
207 207
         break;
208 208
       default: return;
209 209
     }
@@ -253,16 +253,16 @@ namespace UI {
253 253
     }
254 254
   #endif
255 255
 
256
-  float getMinFeedrate_mm_s()                             { return planner.min_feedrate_mm_s; }
257
-  float getMinTravelFeedrate_mm_s()                       { return planner.min_travel_feedrate_mm_s; }
258
-  float getPrintingAcceleration_mm_s2()                   { return planner.acceleration; }
259
-  float getRetractAcceleration_mm_s2()                    { return planner.retract_acceleration; }
260
-  float getTravelAcceleration_mm_s2()                     { return planner.travel_acceleration; }
261
-  void setMinFeedrate_mm_s(const float fr)                { planner.min_feedrate_mm_s = fr; }
262
-  void setMinTravelFeedrate_mm_s(const float fr)          { planner.min_travel_feedrate_mm_s = fr; }
263
-  void setPrintingAcceleration_mm_per_s2(const float acc) { planner.acceleration = acc; }
264
-  void setRetractAcceleration_mm_s2(const float acc)      { planner.retract_acceleration = acc; }
265
-  void setTravelAcceleration_mm_s2(const float acc)       { planner.travel_acceleration = acc; }
256
+  float getMinFeedrate_mm_s()                             { return planner.settings.min_feedrate_mm_s; }
257
+  float getMinTravelFeedrate_mm_s()                       { return planner.settings.min_travel_feedrate_mm_s; }
258
+  float getPrintingAcceleration_mm_s2()                   { return planner.settings.acceleration; }
259
+  float getRetractAcceleration_mm_s2()                    { return planner.settings.retract_acceleration; }
260
+  float getTravelAcceleration_mm_s2()                     { return planner.settings.travel_acceleration; }
261
+  void setMinFeedrate_mm_s(const float fr)                { planner.settings.min_feedrate_mm_s = fr; }
262
+  void setMinTravelFeedrate_mm_s(const float fr)          { planner.settings.min_travel_feedrate_mm_s = fr; }
263
+  void setPrintingAcceleration_mm_per_s2(const float acc) { planner.settings.acceleration = acc; }
264
+  void setRetractAcceleration_mm_s2(const float acc)      { planner.settings.retract_acceleration = acc; }
265
+  void setTravelAcceleration_mm_s2(const float acc)       { planner.settings.travel_acceleration = acc; }
266 266
 
267 267
   #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
268 268
     float getZOffset_mm() {

+ 66
- 66
Marlin/src/lcd/ultralcd.cpp Visa fil

@@ -980,9 +980,9 @@ void lcd_quick_feedback(const bool clear_buttons) {
980 980
     void singlenozzle_swap_menu() {
981 981
       START_MENU();
982 982
       MENU_BACK(MSG_MAIN);
983
-      MENU_ITEM_EDIT(float3, MSG_FILAMENT_SWAP_LENGTH, &singlenozzle_swap_length, 0, 200);
984
-      MENU_MULTIPLIER_ITEM_EDIT(int4, MSG_SINGLENOZZLE_RETRACT_SPD, &singlenozzle_retract_speed, 10, 5400);
985
-      MENU_MULTIPLIER_ITEM_EDIT(int4, MSG_SINGLENOZZLE_PRIME_SPD, &singlenozzle_prime_speed, 10, 5400);
983
+      MENU_ITEM_EDIT(float3, MSG_FILAMENT_SWAP_LENGTH, &sn_settings.swap_length, 0, 200);
984
+      MENU_MULTIPLIER_ITEM_EDIT(int4, MSG_SINGLENOZZLE_RETRACT_SPD, &sn_settings.retract_speed, 10, 5400);
985
+      MENU_MULTIPLIER_ITEM_EDIT(int4, MSG_SINGLENOZZLE_PRIME_SPD, &sn_settings.prime_speed, 10, 5400);
986 986
       END_MENU();
987 987
     }
988 988
   #endif
@@ -3818,7 +3818,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
3818 3818
         if (e == active_extruder)
3819 3819
           _planner_refresh_positioning();
3820 3820
         else
3821
-          planner.steps_to_mm[E_AXIS + e] = 1.0f / planner.axis_steps_per_mm[E_AXIS + e];
3821
+          planner.steps_to_mm[E_AXIS + e] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS + e];
3822 3822
       }
3823 3823
       void _planner_refresh_e0_positioning() { _planner_refresh_e_positioning(0); }
3824 3824
       void _planner_refresh_e1_positioning() { _planner_refresh_e_positioning(1); }
@@ -3842,35 +3842,35 @@ void lcd_quick_feedback(const bool clear_buttons) {
3842 3842
       MENU_BACK(MSG_ADVANCED_SETTINGS);
3843 3843
 
3844 3844
       // M203 Max Feedrate
3845
-      MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_A, &planner.max_feedrate_mm_s[A_AXIS], 1, 999);
3846
-      MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_B, &planner.max_feedrate_mm_s[B_AXIS], 1, 999);
3847
-      MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_C, &planner.max_feedrate_mm_s[C_AXIS], 1, 999);
3845
+      MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_A, &planner.settings.max_feedrate_mm_s[A_AXIS], 1, 999);
3846
+      MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_B, &planner.settings.max_feedrate_mm_s[B_AXIS], 1, 999);
3847
+      MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_C, &planner.settings.max_feedrate_mm_s[C_AXIS], 1, 999);
3848 3848
 
3849 3849
       #if ENABLED(DISTINCT_E_FACTORS)
3850
-        MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E, &planner.max_feedrate_mm_s[E_AXIS + active_extruder], 1, 999);
3851
-        MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E1, &planner.max_feedrate_mm_s[E_AXIS], 1, 999);
3852
-        MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E2, &planner.max_feedrate_mm_s[E_AXIS + 1], 1, 999);
3850
+        MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E, &planner.settings.max_feedrate_mm_s[E_AXIS + active_extruder], 1, 999);
3851
+        MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E1, &planner.settings.max_feedrate_mm_s[E_AXIS], 1, 999);
3852
+        MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E2, &planner.settings.max_feedrate_mm_s[E_AXIS + 1], 1, 999);
3853 3853
         #if E_STEPPERS > 2
3854
-          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E3, &planner.max_feedrate_mm_s[E_AXIS + 2], 1, 999);
3854
+          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E3, &planner.settings.max_feedrate_mm_s[E_AXIS + 2], 1, 999);
3855 3855
           #if E_STEPPERS > 3
3856
-            MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E4, &planner.max_feedrate_mm_s[E_AXIS + 3], 1, 999);
3856
+            MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E4, &planner.settings.max_feedrate_mm_s[E_AXIS + 3], 1, 999);
3857 3857
             #if E_STEPPERS > 4
3858
-              MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E5, &planner.max_feedrate_mm_s[E_AXIS + 4], 1, 999);
3858
+              MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E5, &planner.settings.max_feedrate_mm_s[E_AXIS + 4], 1, 999);
3859 3859
               #if E_STEPPERS > 5
3860
-                MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E6, &planner.max_feedrate_mm_s[E_AXIS + 5], 1, 999);
3860
+                MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E6, &planner.settings.max_feedrate_mm_s[E_AXIS + 5], 1, 999);
3861 3861
               #endif // E_STEPPERS > 5
3862 3862
             #endif // E_STEPPERS > 4
3863 3863
           #endif // E_STEPPERS > 3
3864 3864
         #endif // E_STEPPERS > 2
3865 3865
       #else
3866
-        MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E, &planner.max_feedrate_mm_s[E_AXIS], 1, 999);
3866
+        MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMAX MSG_E, &planner.settings.max_feedrate_mm_s[E_AXIS], 1, 999);
3867 3867
       #endif
3868 3868
 
3869 3869
       // M205 S Min Feedrate
3870
-      MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMIN, &planner.min_feedrate_mm_s, 0, 999);
3870
+      MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VMIN, &planner.settings.min_feedrate_mm_s, 0, 999);
3871 3871
 
3872 3872
       // M205 T Min Travel Feedrate
3873
-      MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VTRAV_MIN, &planner.min_travel_feedrate_mm_s, 0, 999);
3873
+      MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VTRAV_MIN, &planner.settings.min_travel_feedrate_mm_s, 0, 999);
3874 3874
 
3875 3875
       END_MENU();
3876 3876
     }
@@ -3881,37 +3881,37 @@ void lcd_quick_feedback(const bool clear_buttons) {
3881 3881
       MENU_BACK(MSG_ADVANCED_SETTINGS);
3882 3882
 
3883 3883
       // M204 P Acceleration
3884
-      MENU_MULTIPLIER_ITEM_EDIT(float5, MSG_ACC, &planner.acceleration, 10, 99000);
3884
+      MENU_MULTIPLIER_ITEM_EDIT(float5, MSG_ACC, &planner.settings.acceleration, 10, 99000);
3885 3885
 
3886 3886
       // M204 R Retract Acceleration
3887
-      MENU_MULTIPLIER_ITEM_EDIT(float5, MSG_A_RETRACT, &planner.retract_acceleration, 100, 99000);
3887
+      MENU_MULTIPLIER_ITEM_EDIT(float5, MSG_A_RETRACT, &planner.settings.retract_acceleration, 100, 99000);
3888 3888
 
3889 3889
       // M204 T Travel Acceleration
3890
-      MENU_MULTIPLIER_ITEM_EDIT(float5, MSG_A_TRAVEL, &planner.travel_acceleration, 100, 99000);
3890
+      MENU_MULTIPLIER_ITEM_EDIT(float5, MSG_A_TRAVEL, &planner.settings.travel_acceleration, 100, 99000);
3891 3891
 
3892 3892
       // M201 settings
3893
-      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_A, &planner.max_acceleration_mm_per_s2[A_AXIS], 100, 99000, _reset_acceleration_rates);
3894
-      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_B, &planner.max_acceleration_mm_per_s2[B_AXIS], 100, 99000, _reset_acceleration_rates);
3895
-      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_C, &planner.max_acceleration_mm_per_s2[C_AXIS], 10, 99000, _reset_acceleration_rates);
3893
+      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_A, &planner.settings.max_acceleration_mm_per_s2[A_AXIS], 100, 99000, _reset_acceleration_rates);
3894
+      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_B, &planner.settings.max_acceleration_mm_per_s2[B_AXIS], 100, 99000, _reset_acceleration_rates);
3895
+      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_C, &planner.settings.max_acceleration_mm_per_s2[C_AXIS], 10, 99000, _reset_acceleration_rates);
3896 3896
 
3897 3897
       #if ENABLED(DISTINCT_E_FACTORS)
3898
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E, &planner.max_acceleration_mm_per_s2[E_AXIS + active_extruder], 100, 99000, _reset_acceleration_rates);
3899
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E1, &planner.max_acceleration_mm_per_s2[E_AXIS], 100, 99000, _reset_e0_acceleration_rate);
3900
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E2, &planner.max_acceleration_mm_per_s2[E_AXIS + 1], 100, 99000, _reset_e1_acceleration_rate);
3898
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS + active_extruder], 100, 99000, _reset_acceleration_rates);
3899
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E1, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, 99000, _reset_e0_acceleration_rate);
3900
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E2, &planner.settings.max_acceleration_mm_per_s2[E_AXIS + 1], 100, 99000, _reset_e1_acceleration_rate);
3901 3901
         #if E_STEPPERS > 2
3902
-          MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E3, &planner.max_acceleration_mm_per_s2[E_AXIS + 2], 100, 99000, _reset_e2_acceleration_rate);
3902
+          MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E3, &planner.settings.max_acceleration_mm_per_s2[E_AXIS + 2], 100, 99000, _reset_e2_acceleration_rate);
3903 3903
           #if E_STEPPERS > 3
3904
-            MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E4, &planner.max_acceleration_mm_per_s2[E_AXIS + 3], 100, 99000, _reset_e3_acceleration_rate);
3904
+            MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E4, &planner.settings.max_acceleration_mm_per_s2[E_AXIS + 3], 100, 99000, _reset_e3_acceleration_rate);
3905 3905
             #if E_STEPPERS > 4
3906
-              MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E5, &planner.max_acceleration_mm_per_s2[E_AXIS + 4], 100, 99000, _reset_e4_acceleration_rate);
3906
+              MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E5, &planner.settings.max_acceleration_mm_per_s2[E_AXIS + 4], 100, 99000, _reset_e4_acceleration_rate);
3907 3907
               #if E_STEPPERS > 5
3908
-                MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E6, &planner.max_acceleration_mm_per_s2[E_AXIS + 5], 100, 99000, _reset_e5_acceleration_rate);
3908
+                MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E6, &planner.settings.max_acceleration_mm_per_s2[E_AXIS + 5], 100, 99000, _reset_e5_acceleration_rate);
3909 3909
               #endif // E_STEPPERS > 5
3910 3910
             #endif // E_STEPPERS > 4
3911 3911
           #endif // E_STEPPERS > 3
3912 3912
         #endif // E_STEPPERS > 2
3913 3913
       #else
3914
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E, &planner.max_acceleration_mm_per_s2[E_AXIS], 100, 99000, _reset_acceleration_rates);
3914
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, 99000, _reset_acceleration_rates);
3915 3915
       #endif
3916 3916
 
3917 3917
       END_MENU();
@@ -3950,28 +3950,28 @@ void lcd_quick_feedback(const bool clear_buttons) {
3950 3950
       START_MENU();
3951 3951
       MENU_BACK(MSG_ADVANCED_SETTINGS);
3952 3952
 
3953
-      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_ASTEPS, &planner.axis_steps_per_mm[A_AXIS], 5, 9999, _planner_refresh_positioning);
3954
-      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_BSTEPS, &planner.axis_steps_per_mm[B_AXIS], 5, 9999, _planner_refresh_positioning);
3955
-      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_CSTEPS, &planner.axis_steps_per_mm[C_AXIS], 5, 9999, _planner_refresh_positioning);
3953
+      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_ASTEPS, &planner.settings.axis_steps_per_mm[A_AXIS], 5, 9999, _planner_refresh_positioning);
3954
+      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_BSTEPS, &planner.settings.axis_steps_per_mm[B_AXIS], 5, 9999, _planner_refresh_positioning);
3955
+      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_CSTEPS, &planner.settings.axis_steps_per_mm[C_AXIS], 5, 9999, _planner_refresh_positioning);
3956 3956
 
3957 3957
       #if ENABLED(DISTINCT_E_FACTORS)
3958
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_ESTEPS, &planner.axis_steps_per_mm[E_AXIS + active_extruder], 5, 9999, _planner_refresh_positioning);
3959
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E1STEPS, &planner.axis_steps_per_mm[E_AXIS], 5, 9999, _planner_refresh_e0_positioning);
3960
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E2STEPS, &planner.axis_steps_per_mm[E_AXIS + 1], 5, 9999, _planner_refresh_e1_positioning);
3958
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_ESTEPS, &planner.settings.axis_steps_per_mm[E_AXIS + active_extruder], 5, 9999, _planner_refresh_positioning);
3959
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E1STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, _planner_refresh_e0_positioning);
3960
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E2STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 1], 5, 9999, _planner_refresh_e1_positioning);
3961 3961
         #if E_STEPPERS > 2
3962
-          MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E3STEPS, &planner.axis_steps_per_mm[E_AXIS + 2], 5, 9999, _planner_refresh_e2_positioning);
3962
+          MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E3STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 2], 5, 9999, _planner_refresh_e2_positioning);
3963 3963
           #if E_STEPPERS > 3
3964
-            MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E4STEPS, &planner.axis_steps_per_mm[E_AXIS + 3], 5, 9999, _planner_refresh_e3_positioning);
3964
+            MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E4STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 3], 5, 9999, _planner_refresh_e3_positioning);
3965 3965
             #if E_STEPPERS > 4
3966
-              MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E5STEPS, &planner.axis_steps_per_mm[E_AXIS + 4], 5, 9999, _planner_refresh_e4_positioning);
3966
+              MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E5STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 4], 5, 9999, _planner_refresh_e4_positioning);
3967 3967
               #if E_STEPPERS > 5
3968
-                MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E6STEPS, &planner.axis_steps_per_mm[E_AXIS + 5], 5, 9999, _planner_refresh_e5_positioning);
3968
+                MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_E6STEPS, &planner.settings.axis_steps_per_mm[E_AXIS + 5], 5, 9999, _planner_refresh_e5_positioning);
3969 3969
               #endif // E_STEPPERS > 5
3970 3970
             #endif // E_STEPPERS > 4
3971 3971
           #endif // E_STEPPERS > 3
3972 3972
         #endif // E_STEPPERS > 2
3973 3973
       #else
3974
-        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_ESTEPS, &planner.axis_steps_per_mm[E_AXIS], 5, 9999, _planner_refresh_positioning);
3974
+        MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_ESTEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, _planner_refresh_positioning);
3975 3975
       #endif
3976 3976
 
3977 3977
       END_MENU();
@@ -4159,19 +4159,19 @@ void lcd_quick_feedback(const bool clear_buttons) {
4159 4159
         ;
4160 4160
 
4161 4161
         #if EXTRUDERS == 1
4162
-          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD, &filament_change_unload_length[0], 0, extrude_maxlength);
4162
+          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD, &fc_settings[0].unload_length, 0, extrude_maxlength);
4163 4163
         #else // EXTRUDERS > 1
4164
-          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD, &filament_change_unload_length[active_extruder], 0, extrude_maxlength);
4165
-          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E1, &filament_change_unload_length[0], 0, extrude_maxlength);
4166
-          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E2, &filament_change_unload_length[1], 0, extrude_maxlength);
4164
+          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength);
4165
+          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E1, &fc_settings[0].unload_length, 0, extrude_maxlength);
4166
+          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E2, &fc_settings[1].unload_length, 0, extrude_maxlength);
4167 4167
           #if EXTRUDERS > 2
4168
-            MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E3, &filament_change_unload_length[2], 0, extrude_maxlength);
4168
+            MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E3, &fc_settings[2].unload_length, 0, extrude_maxlength);
4169 4169
             #if EXTRUDERS > 3
4170
-              MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E4, &filament_change_unload_length[3], 0, extrude_maxlength);
4170
+              MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E4, &fc_settings[3].unload_length, 0, extrude_maxlength);
4171 4171
               #if EXTRUDERS > 4
4172
-                MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E5, &filament_change_unload_length[4], 0, extrude_maxlength);
4172
+                MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E5, &fc_settings[4].unload_length, 0, extrude_maxlength);
4173 4173
                 #if EXTRUDERS > 5
4174
-                  MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E6, &filament_change_unload_length[5], 0, extrude_maxlength);
4174
+                  MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_UNLOAD MSG_DIAM_E6, &fc_settings[5].unload_length, 0, extrude_maxlength);
4175 4175
                 #endif // EXTRUDERS > 5
4176 4176
               #endif // EXTRUDERS > 4
4177 4177
             #endif // EXTRUDERS > 3
@@ -4179,19 +4179,19 @@ void lcd_quick_feedback(const bool clear_buttons) {
4179 4179
         #endif // EXTRUDERS > 1
4180 4180
 
4181 4181
         #if EXTRUDERS == 1
4182
-          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD, &filament_change_load_length[0], 0, extrude_maxlength);
4182
+          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD, &fc_settings[0].load_length, 0, extrude_maxlength);
4183 4183
         #else // EXTRUDERS > 1
4184
-          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD, &filament_change_load_length[active_extruder], 0, extrude_maxlength);
4185
-          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E1, &filament_change_load_length[0], 0, extrude_maxlength);
4186
-          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E2, &filament_change_load_length[1], 0, extrude_maxlength);
4184
+          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength);
4185
+          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E1, &fc_settings[0].load_length, 0, extrude_maxlength);
4186
+          MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E2, &fc_settings[1].load_length, 0, extrude_maxlength);
4187 4187
           #if EXTRUDERS > 2
4188
-            MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E3, &filament_change_load_length[2], 0, extrude_maxlength);
4188
+            MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E3, &fc_settings[2].load_length, 0, extrude_maxlength);
4189 4189
             #if EXTRUDERS > 3
4190
-              MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E4, &filament_change_load_length[3], 0, extrude_maxlength);
4190
+              MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E4, &fc_settings[3].load_length, 0, extrude_maxlength);
4191 4191
               #if EXTRUDERS > 4
4192
-                MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E5, &filament_change_load_length[4], 0, extrude_maxlength);
4192
+                MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E5, &fc_settings[4].load_length, 0, extrude_maxlength);
4193 4193
                 #if EXTRUDERS > 5
4194
-                  MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E6, &filament_change_load_length[5], 0, extrude_maxlength);
4194
+                  MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_FILAMENT_LOAD MSG_DIAM_E6, &fc_settings[5].load_length, 0, extrude_maxlength);
4195 4195
                 #endif // EXTRUDERS > 5
4196 4196
               #endif // EXTRUDERS > 4
4197 4197
             #endif // EXTRUDERS > 3
@@ -4216,19 +4216,19 @@ void lcd_quick_feedback(const bool clear_buttons) {
4216 4216
       #if ENABLED(FWRETRACT_AUTORETRACT)
4217 4217
         MENU_ITEM_EDIT_CALLBACK(bool, MSG_AUTORETRACT, &fwretract.autoretract_enabled, fwretract.refresh_autoretract);
4218 4218
       #endif
4219
-      MENU_ITEM_EDIT(float52sign, MSG_CONTROL_RETRACT, &fwretract.retract_length, 0, 100);
4219
+      MENU_ITEM_EDIT(float52sign, MSG_CONTROL_RETRACT, &fwretract.settings.retract_length, 0, 100);
4220 4220
       #if EXTRUDERS > 1
4221
-        MENU_ITEM_EDIT(float52sign, MSG_CONTROL_RETRACT_SWAP, &fwretract.swap_retract_length, 0, 100);
4221
+        MENU_ITEM_EDIT(float52sign, MSG_CONTROL_RETRACT_SWAP, &fwretract.settings.swap_retract_length, 0, 100);
4222 4222
       #endif
4223
-      MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACTF, &fwretract.retract_feedrate_mm_s, 1, 999);
4224
-      MENU_ITEM_EDIT(float52sign, MSG_CONTROL_RETRACT_ZLIFT, &fwretract.retract_zlift, 0, 999);
4225
-      MENU_ITEM_EDIT(float52sign, MSG_CONTROL_RETRACT_RECOVER, &fwretract.retract_recover_length, -100, 100);
4223
+      MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACTF, &fwretract.settings.retract_feedrate_mm_s, 1, 999);
4224
+      MENU_ITEM_EDIT(float52sign, MSG_CONTROL_RETRACT_ZLIFT, &fwretract.settings.retract_zlift, 0, 999);
4225
+      MENU_ITEM_EDIT(float52sign, MSG_CONTROL_RETRACT_RECOVER, &fwretract.settings.retract_recover_length, -100, 100);
4226 4226
       #if EXTRUDERS > 1
4227
-        MENU_ITEM_EDIT(float52sign, MSG_CONTROL_RETRACT_RECOVER_SWAP, &fwretract.swap_retract_recover_length, -100, 100);
4227
+        MENU_ITEM_EDIT(float52sign, MSG_CONTROL_RETRACT_RECOVER_SWAP, &fwretract.settings.swap_retract_recover_length, -100, 100);
4228 4228
       #endif
4229
-      MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &fwretract.retract_recover_feedrate_mm_s, 1, 999);
4229
+      MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &fwretract.settings.retract_recover_feedrate_mm_s, 1, 999);
4230 4230
       #if EXTRUDERS > 1
4231
-        MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVER_SWAPF, &fwretract.swap_retract_recover_feedrate_mm_s, 1, 999);
4231
+        MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVER_SWAPF, &fwretract.settings.swap_retract_recover_feedrate_mm_s, 1, 999);
4232 4232
       #endif
4233 4233
       END_MENU();
4234 4234
     }

+ 585
- 654
Marlin/src/module/configuration_store.cpp
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 3
- 3
Marlin/src/module/motion.cpp Visa fil

@@ -817,9 +817,9 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
817 817
             #define RAISED_Y raised_parked_position[Y_AXIS]
818 818
             #define RAISED_Z raised_parked_position[Z_AXIS]
819 819
 
820
-            if (  planner.buffer_line(RAISED_X, RAISED_Y, RAISED_Z, CUR_E, planner.max_feedrate_mm_s[Z_AXIS], active_extruder))
820
+            if (  planner.buffer_line(RAISED_X, RAISED_Y, RAISED_Z, CUR_E, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder))
821 821
               if (planner.buffer_line(   CUR_X,    CUR_Y, RAISED_Z, CUR_E, PLANNER_XY_FEEDRATE(),             active_extruder))
822
-                  planner.buffer_line(   CUR_X,    CUR_Y,    CUR_Z, CUR_E, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
822
+                  planner.buffer_line(   CUR_X,    CUR_Y,    CUR_Z, CUR_E, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
823 823
           delayed_move_time = 0;
824 824
           active_extruder_parked = false;
825 825
           #if ENABLED(DEBUG_LEVELING_FEATURE)
@@ -841,7 +841,7 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
841 841
             if (!planner.buffer_line(
842 842
                 dual_x_carriage_mode == DXC_DUPLICATION_MODE ? duplicate_extruder_x_offset + current_position[X_AXIS] : inactive_extruder_x_pos,
843 843
                 current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS],
844
-                planner.max_feedrate_mm_s[X_AXIS], 1
844
+                planner.settings.max_feedrate_mm_s[X_AXIS], 1
845 845
               )
846 846
             ) break;
847 847
             planner.synchronize();

+ 31
- 49
Marlin/src/module/planner.cpp Visa fil

@@ -111,18 +111,11 @@ volatile uint8_t Planner::block_buffer_head,    // Index of the next block to be
111 111
 uint16_t Planner::cleaning_buffer_counter;      // A counter to disable queuing of blocks
112 112
 uint8_t Planner::delay_before_delivering;       // This counter delays delivery of blocks when queue becomes empty to allow the opportunity of merging blocks
113 113
 
114
-uint32_t Planner::max_acceleration_mm_per_s2[XYZE_N],    // (mm/s^2) M201 XYZE
115
-         Planner::max_acceleration_steps_per_s2[XYZE_N], // (steps/s^2) Derived from mm_per_s2
116
-         Planner::min_segment_time_us;                   // (µs) M205 B
117
-
118
-float Planner::max_feedrate_mm_s[XYZE_N],     // (mm/s) M203 XYZE - Max speeds
119
-      Planner::axis_steps_per_mm[XYZE_N],     // (steps) M92 XYZE - Steps per millimeter
120
-      Planner::steps_to_mm[XYZE_N],           // (mm) Millimeters per step
121
-      Planner::min_feedrate_mm_s,             // (mm/s) M205 S - Minimum linear feedrate
122
-      Planner::acceleration,                  // (mm/s^2) M204 S - Normal acceleration. DEFAULT ACCELERATION for all printing moves.
123
-      Planner::retract_acceleration,          // (mm/s^2) M204 R - Retract acceleration. Filament pull-back and push-forward while standing still in the other axes
124
-      Planner::travel_acceleration,           // (mm/s^2) M204 T - Travel acceleration. DEFAULT ACCELERATION for all NON printing moves.
125
-      Planner::min_travel_feedrate_mm_s;      // (mm/s) M205 T - Minimum travel feedrate
114
+planner_settings_t Planner::settings;           // Initialized by settings.load()
115
+
116
+uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N]; // (steps/s^2) Derived from mm_per_s2
117
+
118
+float Planner::steps_to_mm[XYZE_N];           // (mm) Millimeters per step
126 119
 
127 120
 #if ENABLED(JUNCTION_DEVIATION)
128 121
   float Planner::junction_deviation_mm;       // (mm) M205 J
@@ -177,18 +170,7 @@ float Planner::e_factor[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(1.0f); // The flow perc
177 170
   constexpr bool Planner::leveling_active;
178 171
 #endif
179 172
 
180
-#if ENABLED(SKEW_CORRECTION)
181
-  #if ENABLED(SKEW_CORRECTION_GCODE)
182
-    float Planner::xy_skew_factor;
183
-  #else
184
-    constexpr float Planner::xy_skew_factor;
185
-  #endif
186
-  #if ENABLED(SKEW_CORRECTION_FOR_Z) && ENABLED(SKEW_CORRECTION_GCODE)
187
-    float Planner::xz_skew_factor, Planner::yz_skew_factor;
188
-  #else
189
-    constexpr float Planner::xz_skew_factor, Planner::yz_skew_factor;
190
-  #endif
191
-#endif
173
+skew_factor_t Planner::skew_factor; // Initialized by settings.load()
192 174
 
193 175
 #if ENABLED(AUTOTEMP)
194 176
   float Planner::autotemp_max = 250,
@@ -1094,7 +1076,7 @@ void Planner::recalculate_trapezoids() {
1094 1076
             calculate_trapezoid_for_block(current, current_entry_speed * nomr, next_entry_speed * nomr);
1095 1077
             #if ENABLED(LIN_ADVANCE)
1096 1078
               if (current->use_advance_lead) {
1097
-                const float comp = current->e_D_ratio * extruder_advance_K[active_extruder] * axis_steps_per_mm[E_AXIS];
1079
+                const float comp = current->e_D_ratio * extruder_advance_K[active_extruder] * settings.axis_steps_per_mm[E_AXIS];
1098 1080
                 current->max_adv_steps = current_nominal_speed * comp;
1099 1081
                 current->final_adv_steps = next_entry_speed * comp;
1100 1082
               }
@@ -1133,7 +1115,7 @@ void Planner::recalculate_trapezoids() {
1133 1115
       calculate_trapezoid_for_block(next, next_entry_speed * nomr, float(MINIMUM_PLANNER_SPEED) * nomr);
1134 1116
       #if ENABLED(LIN_ADVANCE)
1135 1117
         if (next->use_advance_lead) {
1136
-          const float comp = next->e_D_ratio * extruder_advance_K[active_extruder] * axis_steps_per_mm[E_AXIS];
1118
+          const float comp = next->e_D_ratio * extruder_advance_K[active_extruder] * settings.axis_steps_per_mm[E_AXIS];
1137 1119
           next->max_adv_steps = next_nominal_speed * comp;
1138 1120
           next->final_adv_steps = (MINIMUM_PLANNER_SPEED) * comp;
1139 1121
         }
@@ -1687,7 +1669,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
1687 1669
         }
1688 1670
       #endif // PREVENT_COLD_EXTRUSION
1689 1671
       #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
1690
-        if (ABS(de * e_factor[extruder]) > (int32_t)axis_steps_per_mm[E_AXIS_N(extruder)] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
1672
+        if (ABS(de * e_factor[extruder]) > (int32_t)settings.axis_steps_per_mm[E_AXIS_N(extruder)] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
1691 1673
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
1692 1674
           #if HAS_POSITION_FLOAT
1693 1675
             position_float[E_AXIS] = target_float[E_AXIS];
@@ -1946,9 +1928,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
1946 1928
   }
1947 1929
 
1948 1930
   if (esteps)
1949
-    NOLESS(fr_mm_s, min_feedrate_mm_s);
1931
+    NOLESS(fr_mm_s, settings.min_feedrate_mm_s);
1950 1932
   else
1951
-    NOLESS(fr_mm_s, min_travel_feedrate_mm_s);
1933
+    NOLESS(fr_mm_s, settings.min_travel_feedrate_mm_s);
1952 1934
 
1953 1935
   /**
1954 1936
    * This part of the code calculates the total length of the movement.
@@ -2023,9 +2005,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2023 2005
 
2024 2006
   #if ENABLED(SLOWDOWN)
2025 2007
     if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) {
2026
-      if (segment_time_us < min_segment_time_us) {
2008
+      if (segment_time_us < settings.min_segment_time_us) {
2027 2009
         // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
2028
-        const uint32_t nst = segment_time_us + LROUND(2 * (min_segment_time_us - segment_time_us) / moves_queued);
2010
+        const uint32_t nst = segment_time_us + LROUND(2 * (settings.min_segment_time_us - segment_time_us) / moves_queued);
2029 2011
         inverse_secs = 1000000.0f / nst;
2030 2012
         #if defined(XY_FREQUENCY_LIMIT) || ENABLED(ULTRA_LCD)
2031 2013
           segment_time_us = nst;
@@ -2100,7 +2082,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2100 2082
     #if ENABLED(DISTINCT_E_FACTORS)
2101 2083
       if (i == E_AXIS) i += extruder;
2102 2084
     #endif
2103
-    if (cs > max_feedrate_mm_s[i]) NOMORE(speed_factor, max_feedrate_mm_s[i] / cs);
2085
+    if (cs > settings.max_feedrate_mm_s[i]) NOMORE(speed_factor, settings.max_feedrate_mm_s[i] / cs);
2104 2086
   }
2105 2087
 
2106 2088
   // Max segment time in µs.
@@ -2153,7 +2135,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2153 2135
   uint32_t accel;
2154 2136
   if (!block->steps[A_AXIS] && !block->steps[B_AXIS] && !block->steps[C_AXIS]) {
2155 2137
     // convert to: acceleration steps/sec^2
2156
-    accel = CEIL(retract_acceleration * steps_per_mm);
2138
+    accel = CEIL(settings.retract_acceleration * steps_per_mm);
2157 2139
     #if ENABLED(LIN_ADVANCE)
2158 2140
       block->use_advance_lead = false;
2159 2141
     #endif
@@ -2174,7 +2156,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2174 2156
     }while(0)
2175 2157
 
2176 2158
     // Start with print or travel acceleration
2177
-    accel = CEIL((esteps ? acceleration : travel_acceleration) * steps_per_mm);
2159
+    accel = CEIL((esteps ? settings.acceleration : settings.travel_acceleration) * steps_per_mm);
2178 2160
 
2179 2161
     #if ENABLED(LIN_ADVANCE)
2180 2162
 
@@ -2254,7 +2236,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2254 2236
   #endif
2255 2237
   #if ENABLED(LIN_ADVANCE)
2256 2238
     if (block->use_advance_lead) {
2257
-      block->advance_speed = (STEPPER_TIMER_RATE) / (extruder_advance_K[active_extruder] * block->e_D_ratio * block->acceleration * axis_steps_per_mm[E_AXIS_N(extruder)]);
2239
+      block->advance_speed = (STEPPER_TIMER_RATE) / (extruder_advance_K[active_extruder] * block->e_D_ratio * block->acceleration * settings.axis_steps_per_mm[E_AXIS_N(extruder)]);
2258 2240
       #if ENABLED(LA_DEBUG)
2259 2241
         if (extruder_advance_K[active_extruder] * block->e_D_ratio * block->acceleration * 2 < SQRT(block->nominal_speed_sqr) * block->e_D_ratio)
2260 2242
           SERIAL_ECHOLNPGM("More than 2 steps per eISR loop executed.");
@@ -2566,8 +2548,8 @@ bool Planner::buffer_segment(const float &a, const float &b, const float &c, con
2566 2548
 
2567 2549
   // When changing extruders recalculate steps corresponding to the E position
2568 2550
   #if ENABLED(DISTINCT_E_FACTORS)
2569
-    if (last_extruder != extruder && axis_steps_per_mm[E_AXIS_N(extruder)] != axis_steps_per_mm[E_AXIS + last_extruder]) {
2570
-      position[E_AXIS] = LROUND(position[E_AXIS] * axis_steps_per_mm[E_AXIS_N(extruder)] * steps_to_mm[E_AXIS + last_extruder]);
2551
+    if (last_extruder != extruder && settings.axis_steps_per_mm[E_AXIS_N(extruder)] != settings.axis_steps_per_mm[E_AXIS + last_extruder]) {
2552
+      position[E_AXIS] = LROUND(position[E_AXIS] * settings.axis_steps_per_mm[E_AXIS_N(extruder)] * steps_to_mm[E_AXIS + last_extruder]);
2571 2553
       last_extruder = extruder;
2572 2554
     }
2573 2555
   #endif
@@ -2575,10 +2557,10 @@ bool Planner::buffer_segment(const float &a, const float &b, const float &c, con
2575 2557
   // The target position of the tool in absolute steps
2576 2558
   // Calculate target position in absolute steps
2577 2559
   const int32_t target[ABCE] = {
2578
-    LROUND(a * axis_steps_per_mm[A_AXIS]),
2579
-    LROUND(b * axis_steps_per_mm[B_AXIS]),
2580
-    LROUND(c * axis_steps_per_mm[C_AXIS]),
2581
-    LROUND(e * axis_steps_per_mm[E_AXIS_N(extruder)])
2560
+    LROUND(a * settings.axis_steps_per_mm[A_AXIS]),
2561
+    LROUND(b * settings.axis_steps_per_mm[B_AXIS]),
2562
+    LROUND(c * settings.axis_steps_per_mm[C_AXIS]),
2563
+    LROUND(e * settings.axis_steps_per_mm[E_AXIS_N(extruder)])
2582 2564
   };
2583 2565
 
2584 2566
   #if HAS_POSITION_FLOAT
@@ -2714,10 +2696,10 @@ void Planner::set_machine_position_mm(const float &a, const float &b, const floa
2714 2696
   #if ENABLED(DISTINCT_E_FACTORS)
2715 2697
     last_extruder = active_extruder;
2716 2698
   #endif
2717
-  position[A_AXIS] = LROUND(a * axis_steps_per_mm[A_AXIS]);
2718
-  position[B_AXIS] = LROUND(b * axis_steps_per_mm[B_AXIS]);
2719
-  position[C_AXIS] = LROUND(c * axis_steps_per_mm[C_AXIS]);
2720
-  position[E_AXIS] = LROUND(e * axis_steps_per_mm[_EINDEX]);
2699
+  position[A_AXIS] = LROUND(a * settings.axis_steps_per_mm[A_AXIS]);
2700
+  position[B_AXIS] = LROUND(b * settings.axis_steps_per_mm[B_AXIS]);
2701
+  position[C_AXIS] = LROUND(c * settings.axis_steps_per_mm[C_AXIS]);
2702
+  position[E_AXIS] = LROUND(e * settings.axis_steps_per_mm[_EINDEX]);
2721 2703
   #if HAS_POSITION_FLOAT
2722 2704
     position_float[A_AXIS] = a;
2723 2705
     position_float[B_AXIS] = b;
@@ -2770,7 +2752,7 @@ void Planner::set_e_position_mm(const float &e) {
2770 2752
   #else
2771 2753
     const float e_new = e;
2772 2754
   #endif
2773
-  position[E_AXIS] = LROUND(axis_steps_per_mm[axis_index] * e_new);
2755
+  position[E_AXIS] = LROUND(settings.axis_steps_per_mm[axis_index] * e_new);
2774 2756
   #if HAS_POSITION_FLOAT
2775 2757
     position_float[E_AXIS] = e_new;
2776 2758
   #endif
@@ -2792,7 +2774,7 @@ void Planner::reset_acceleration_rates() {
2792 2774
   #endif
2793 2775
   uint32_t highest_rate = 1;
2794 2776
   LOOP_XYZE_N(i) {
2795
-    max_acceleration_steps_per_s2[i] = max_acceleration_mm_per_s2[i] * axis_steps_per_mm[i];
2777
+    max_acceleration_steps_per_s2[i] = settings.max_acceleration_mm_per_s2[i] * settings.axis_steps_per_mm[i];
2796 2778
     if (AXIS_CONDITION) NOLESS(highest_rate, max_acceleration_steps_per_s2[i]);
2797 2779
   }
2798 2780
   cutoff_long = 4294967295UL / highest_rate; // 0xFFFFFFFFUL
@@ -2801,9 +2783,9 @@ void Planner::reset_acceleration_rates() {
2801 2783
   #endif
2802 2784
 }
2803 2785
 
2804
-// Recalculate position, steps_to_mm if axis_steps_per_mm changes!
2786
+// Recalculate position, steps_to_mm if settings.axis_steps_per_mm changes!
2805 2787
 void Planner::refresh_positioning() {
2806
-  LOOP_XYZE_N(i) steps_to_mm[i] = 1.0f / axis_steps_per_mm[i];
2788
+  LOOP_XYZE_N(i) steps_to_mm[i] = 1.0f / settings.axis_steps_per_mm[i];
2807 2789
   set_position_mm(current_position);
2808 2790
   reset_acceleration_rates();
2809 2791
 }

+ 50
- 40
Marlin/src/module/planner.h Visa fil

@@ -19,6 +19,7 @@
19 19
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 20
  *
21 21
  */
22
+#pragma once
22 23
 
23 24
 /**
24 25
  * planner.h
@@ -29,9 +30,6 @@
29 30
  * Copyright (c) 2009-2011 Simen Svale Skogsrud
30 31
  */
31 32
 
32
-#ifndef PLANNER_H
33
-#define PLANNER_H
34
-
35 33
 #include "../Marlin.h"
36 34
 
37 35
 #include "motion.h"
@@ -159,6 +157,42 @@ typedef struct {
159 157
 
160 158
 #define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
161 159
 
160
+typedef struct {
161
+  uint32_t max_acceleration_mm_per_s2[XYZE_N],  // (mm/s^2) M201 XYZE
162
+           min_segment_time_us;                 // (µs) M205 B
163
+  float axis_steps_per_mm[XYZE_N],              // (steps) M92 XYZE - Steps per millimeter
164
+        max_feedrate_mm_s[XYZE_N],              // (mm/s) M203 XYZE - Max speeds
165
+        acceleration,                           // (mm/s^2) M204 S - Normal acceleration. DEFAULT ACCELERATION for all printing moves.
166
+        retract_acceleration,                   // (mm/s^2) M204 R - Retract acceleration. Filament pull-back and push-forward while standing still in the other axes
167
+        travel_acceleration,                    // (mm/s^2) M204 T - Travel acceleration. DEFAULT ACCELERATION for all NON printing moves.
168
+        min_feedrate_mm_s,                      // (mm/s) M205 S - Minimum linear feedrate
169
+        min_travel_feedrate_mm_s;               // (mm/s) M205 T - Minimum travel feedrate
170
+} planner_settings_t;
171
+
172
+#ifndef XY_SKEW_FACTOR
173
+  #define XY_SKEW_FACTOR 0
174
+#endif
175
+#ifndef XZ_SKEW_FACTOR
176
+  #define XZ_SKEW_FACTOR 0
177
+#endif
178
+#ifndef YZ_SKEW_FACTOR
179
+  #define YZ_SKEW_FACTOR 0
180
+#endif
181
+
182
+typedef struct {
183
+  #if ENABLED(SKEW_CORRECTION_GCODE)
184
+    float xy;
185
+    #if ENABLED(SKEW_CORRECTION_FOR_Z)
186
+      float xz, yz;
187
+    #else
188
+      const float xz = XZ_SKEW_FACTOR, yz = YZ_SKEW_FACTOR;
189
+    #endif
190
+  #else
191
+    const float xy = XY_SKEW_FACTOR,
192
+                xz = XZ_SKEW_FACTOR, yz = YZ_SKEW_FACTOR;
193
+  #endif
194
+} skew_factor_t;
195
+
162 196
 class Planner {
163 197
   public:
164 198
 
@@ -199,17 +233,10 @@ class Planner {
199 233
                                                       // May be auto-adjusted by a filament width sensor
200 234
     #endif
201 235
 
202
-    static uint32_t max_acceleration_mm_per_s2[XYZE_N],    // (mm/s^2) M201 XYZE
203
-                    max_acceleration_steps_per_s2[XYZE_N], // (steps/s^2) Derived from mm_per_s2
204
-                    min_segment_time_us;                   // (µs) M205 B
205
-    static float max_feedrate_mm_s[XYZE_N],     // (mm/s) M203 XYZE - Max speeds
206
-                 axis_steps_per_mm[XYZE_N],     // (steps) M92 XYZE - Steps per millimeter
207
-                 steps_to_mm[XYZE_N],           // (mm) Millimeters per step
208
-                 min_feedrate_mm_s,             // (mm/s) M205 S - Minimum linear feedrate
209
-                 acceleration,                  // (mm/s^2) M204 S - Normal acceleration. DEFAULT ACCELERATION for all printing moves.
210
-                 retract_acceleration,          // (mm/s^2) M204 R - Retract acceleration. Filament pull-back and push-forward while standing still in the other axes
211
-                 travel_acceleration,           // (mm/s^2) M204 T - Travel acceleration. DEFAULT ACCELERATION for all NON printing moves.
212
-                 min_travel_feedrate_mm_s;      // (mm/s) M205 T - Minimum travel feedrate
236
+    static planner_settings_t settings;
237
+
238
+    static uint32_t max_acceleration_steps_per_s2[XYZE_N]; // (steps/s^2) Derived from mm_per_s2
239
+    static float steps_to_mm[XYZE_N];           // Millimeters per step
213 240
 
214 241
     #if ENABLED(JUNCTION_DEVIATION)
215 242
       static float junction_deviation_mm;       // (mm) M205 J
@@ -256,22 +283,7 @@ class Planner {
256 283
       static float position_cart[XYZE];
257 284
     #endif
258 285
 
259
-    #if ENABLED(SKEW_CORRECTION)
260
-      #if ENABLED(SKEW_CORRECTION_GCODE)
261
-        static float xy_skew_factor;
262
-      #else
263
-        static constexpr float xy_skew_factor = XY_SKEW_FACTOR;
264
-      #endif
265
-      #if ENABLED(SKEW_CORRECTION_FOR_Z)
266
-        #if ENABLED(SKEW_CORRECTION_GCODE)
267
-          static float xz_skew_factor, yz_skew_factor;
268
-        #else
269
-          static constexpr float xz_skew_factor = XZ_SKEW_FACTOR, yz_skew_factor = YZ_SKEW_FACTOR;
270
-        #endif
271
-      #else
272
-        static constexpr float xz_skew_factor = 0, yz_skew_factor = 0;
273
-      #endif
274
-    #endif
286
+    static skew_factor_t skew_factor;
275 287
 
276 288
     #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
277 289
       static bool abort_on_endstop_hit;
@@ -419,8 +431,8 @@ class Planner {
419 431
 
420 432
       FORCE_INLINE static void skew(float &cx, float &cy, const float &cz) {
421 433
         if (WITHIN(cx, X_MIN_POS + 1, X_MAX_POS) && WITHIN(cy, Y_MIN_POS + 1, Y_MAX_POS)) {
422
-          const float sx = cx - cy * xy_skew_factor - cz * (xz_skew_factor - (xy_skew_factor * yz_skew_factor)),
423
-                      sy = cy - cz * yz_skew_factor;
434
+          const float sx = cx - cy * skew_factor.xy - cz * (skew_factor.xz - (skew_factor.xy * skew_factor.yz)),
435
+                      sy = cy - cz * skew_factor.yz;
424 436
           if (WITHIN(sx, X_MIN_POS, X_MAX_POS) && WITHIN(sy, Y_MIN_POS, Y_MAX_POS)) {
425 437
             cx = sx; cy = sy;
426 438
           }
@@ -431,8 +443,8 @@ class Planner {
431 443
 
432 444
       FORCE_INLINE static void unskew(float &cx, float &cy, const float &cz) {
433 445
         if (WITHIN(cx, X_MIN_POS, X_MAX_POS) && WITHIN(cy, Y_MIN_POS, Y_MAX_POS)) {
434
-          const float sx = cx + cy * xy_skew_factor + cz * xz_skew_factor,
435
-                      sy = cy + cz * yz_skew_factor;
446
+          const float sx = cx + cy * skew_factor.xy + cz * skew_factor.xz,
447
+                      sy = cy + cz * skew_factor.yz;
436 448
           if (WITHIN(sx, X_MIN_POS, X_MAX_POS) && WITHIN(sy, Y_MIN_POS, Y_MAX_POS)) {
437 449
             cx = sx; cy = sy;
438 450
           }
@@ -848,9 +860,9 @@ class Planner {
848 860
         #define GET_MAX_E_JERK(N) SQRT(SQRT(0.5) * junction_deviation_mm * (N) * RECIPROCAL(1.0 - SQRT(0.5)))
849 861
         #if ENABLED(DISTINCT_E_FACTORS)
850 862
           for (uint8_t i = 0; i < EXTRUDERS; i++)
851
-            max_e_jerk[i] = GET_MAX_E_JERK(max_acceleration_mm_per_s2[E_AXIS + i]);
863
+            max_e_jerk[i] = GET_MAX_E_JERK(settings.max_acceleration_mm_per_s2[E_AXIS + i]);
852 864
         #else
853
-          max_e_jerk = GET_MAX_E_JERK(max_acceleration_mm_per_s2[E_AXIS]);
865
+          max_e_jerk = GET_MAX_E_JERK(settings.max_acceleration_mm_per_s2[E_AXIS]);
854 866
         #endif
855 867
       }
856 868
     #endif
@@ -927,15 +939,13 @@ class Planner {
927 939
       FORCE_INLINE static float limit_value_by_axis_maximum(const float &max_value, float (&unit_vec)[XYZE]) {
928 940
         float limit_value = max_value;
929 941
         LOOP_XYZE(idx) if (unit_vec[idx]) // Avoid divide by zero
930
-          NOMORE(limit_value, ABS(max_acceleration_mm_per_s2[idx] / unit_vec[idx]));
942
+          NOMORE(limit_value, ABS(settings.max_acceleration_mm_per_s2[idx] / unit_vec[idx]));
931 943
         return limit_value;
932 944
       }
933 945
 
934 946
     #endif // JUNCTION_DEVIATION
935 947
 };
936 948
 
937
-#define PLANNER_XY_FEEDRATE() (MIN(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]))
949
+#define PLANNER_XY_FEEDRATE() (MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]))
938 950
 
939 951
 extern Planner planner;
940
-
941
-#endif // PLANNER_H

+ 2
- 2
Marlin/src/module/stepper.cpp Visa fil

@@ -2413,7 +2413,7 @@ void Stepper::report_positions() {
2413 2413
 #if HAS_MOTOR_CURRENT_PWM
2414 2414
 
2415 2415
   void Stepper::refresh_motor_power() {
2416
-    for (uint8_t i = 0; i < COUNT(motor_current_setting); ++i) {
2416
+    LOOP_L_N(i, COUNT(motor_current_setting)) {
2417 2417
       switch (i) {
2418 2418
         #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
2419 2419
           case 0:
@@ -2443,7 +2443,7 @@ void Stepper::report_positions() {
2443 2443
 
2444 2444
     #elif HAS_MOTOR_CURRENT_PWM
2445 2445
 
2446
-      if (WITHIN(driver, 0, 2))
2446
+      if (WITHIN(driver, 0, COUNT(motor_current_setting) - 1))
2447 2447
         motor_current_setting[driver] = current; // update motor_current_setting
2448 2448
 
2449 2449
       #define _WRITE_CURRENT_PWM(P) analogWrite(MOTOR_CURRENT_PWM_## P ##_PIN, 255L * current / (MOTOR_CURRENT_PWM_RANGE))

+ 13
- 13
Marlin/src/module/stepper_indirection.cpp Visa fil

@@ -606,43 +606,43 @@ void reset_stepper_drivers() {
606 606
   #endif
607 607
 
608 608
   #if AXIS_IS_TMC(X)
609
-    _TMC_INIT(X, planner.axis_steps_per_mm[X_AXIS]);
609
+    _TMC_INIT(X, planner.settings.axis_steps_per_mm[X_AXIS]);
610 610
   #endif
611 611
   #if AXIS_IS_TMC(X2)
612
-    _TMC_INIT(X2, planner.axis_steps_per_mm[X_AXIS]);
612
+    _TMC_INIT(X2, planner.settings.axis_steps_per_mm[X_AXIS]);
613 613
   #endif
614 614
   #if AXIS_IS_TMC(Y)
615
-    _TMC_INIT(Y, planner.axis_steps_per_mm[Y_AXIS]);
615
+    _TMC_INIT(Y, planner.settings.axis_steps_per_mm[Y_AXIS]);
616 616
   #endif
617 617
   #if AXIS_IS_TMC(Y2)
618
-    _TMC_INIT(Y2, planner.axis_steps_per_mm[Y_AXIS]);
618
+    _TMC_INIT(Y2, planner.settings.axis_steps_per_mm[Y_AXIS]);
619 619
   #endif
620 620
   #if AXIS_IS_TMC(Z)
621
-    _TMC_INIT(Z, planner.axis_steps_per_mm[Z_AXIS]);
621
+    _TMC_INIT(Z, planner.settings.axis_steps_per_mm[Z_AXIS]);
622 622
   #endif
623 623
   #if AXIS_IS_TMC(Z2)
624
-    _TMC_INIT(Z2, planner.axis_steps_per_mm[Z_AXIS]);
624
+    _TMC_INIT(Z2, planner.settings.axis_steps_per_mm[Z_AXIS]);
625 625
   #endif
626 626
   #if AXIS_IS_TMC(Z3)
627
-    _TMC_INIT(Z3, planner.axis_steps_per_mm[Z_AXIS]);
627
+    _TMC_INIT(Z3, planner.settings.axis_steps_per_mm[Z_AXIS]);
628 628
   #endif
629 629
   #if AXIS_IS_TMC(E0)
630
-    _TMC_INIT(E0, planner.axis_steps_per_mm[E_AXIS_N(0)]);
630
+    _TMC_INIT(E0, planner.settings.axis_steps_per_mm[E_AXIS_N(0)]);
631 631
   #endif
632 632
   #if AXIS_IS_TMC(E1)
633
-    _TMC_INIT(E1, planner.axis_steps_per_mm[E_AXIS_N(1)]);
633
+    _TMC_INIT(E1, planner.settings.axis_steps_per_mm[E_AXIS_N(1)]);
634 634
   #endif
635 635
   #if AXIS_IS_TMC(E2)
636
-    _TMC_INIT(E2, planner.axis_steps_per_mm[E_AXIS_N(2)]);
636
+    _TMC_INIT(E2, planner.settings.axis_steps_per_mm[E_AXIS_N(2)]);
637 637
   #endif
638 638
   #if AXIS_IS_TMC(E3)
639
-    _TMC_INIT(E3, planner.axis_steps_per_mm[E_AXIS_N(3)]);
639
+    _TMC_INIT(E3, planner.settings.axis_steps_per_mm[E_AXIS_N(3)]);
640 640
   #endif
641 641
   #if AXIS_IS_TMC(E4)
642
-    _TMC_INIT(E4, planner.axis_steps_per_mm[E_AXIS_N(4)]);
642
+    _TMC_INIT(E4, planner.settings.axis_steps_per_mm[E_AXIS_N(4)]);
643 643
   #endif
644 644
   #if AXIS_IS_TMC(E5)
645
-    _TMC_INIT(E5, planner.axis_steps_per_mm[E_AXIS_N(5)]);
645
+    _TMC_INIT(E5, planner.settings.axis_steps_per_mm[E_AXIS_N(5)]);
646 646
   #endif
647 647
 
648 648
   #if USE_SENSORLESS

+ 138
- 152
Marlin/src/module/temperature.cpp Visa fil

@@ -116,13 +116,7 @@ int16_t Temperature::current_temperature_raw[HOTENDS] = { 0 },
116 116
     millis_t Temperature::watch_bed_next_ms = 0;
117 117
   #endif
118 118
   #if ENABLED(PIDTEMPBED)
119
-    float Temperature::bedKp, Temperature::bedKi, Temperature::bedKd, // Initialized by settings.load()
120
-          Temperature::temp_iState_bed = { 0 },
121
-          Temperature::temp_dState_bed = { 0 },
122
-          Temperature::pTerm_bed,
123
-          Temperature::iTerm_bed,
124
-          Temperature::dTerm_bed,
125
-          Temperature::pid_error_bed;
119
+    PID_t Temperature::bed_pid; // Initialized by settings.load()
126 120
   #else
127 121
     millis_t Temperature::next_bed_check_ms;
128 122
   #endif
@@ -141,17 +135,7 @@ int16_t Temperature::current_temperature_raw[HOTENDS] = { 0 },
141 135
 
142 136
 // Initialized by settings.load()
143 137
 #if ENABLED(PIDTEMP)
144
-  #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
145
-    float Temperature::Kp[HOTENDS], Temperature::Ki[HOTENDS], Temperature::Kd[HOTENDS];
146
-    #if ENABLED(PID_EXTRUSION_SCALING)
147
-      float Temperature::Kc[HOTENDS];
148
-    #endif
149
-  #else
150
-    float Temperature::Kp, Temperature::Ki, Temperature::Kd;
151
-    #if ENABLED(PID_EXTRUSION_SCALING)
152
-      float Temperature::Kc;
153
-    #endif
154
-  #endif
138
+  hotend_pid_t Temperature::pid[HOTENDS];
155 139
 #endif
156 140
 
157 141
 #if ENABLED(BABYSTEPPING)
@@ -182,21 +166,11 @@ int16_t Temperature::current_temperature_raw[HOTENDS] = { 0 },
182 166
 volatile bool Temperature::temp_meas_ready = false;
183 167
 
184 168
 #if ENABLED(PIDTEMP)
185
-  float Temperature::temp_iState[HOTENDS] = { 0 },
186
-        Temperature::temp_dState[HOTENDS] = { 0 },
187
-        Temperature::pTerm[HOTENDS],
188
-        Temperature::iTerm[HOTENDS],
189
-        Temperature::dTerm[HOTENDS];
190
-
191 169
   #if ENABLED(PID_EXTRUSION_SCALING)
192
-    float Temperature::cTerm[HOTENDS];
193 170
     long Temperature::last_e_position;
194 171
     long Temperature::lpq[LPQ_MAX_LEN];
195 172
     int Temperature::lpq_ptr = 0;
196 173
   #endif
197
-
198
-  float Temperature::pid_error[HOTENDS];
199
-  bool Temperature::pid_reset[HOTENDS];
200 174
 #endif
201 175
 
202 176
 uint16_t Temperature::raw_temp_value[MAX_EXTRUDERS] = { 0 };
@@ -254,6 +228,8 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS];
254 228
 
255 229
 #if HAS_PID_HEATING
256 230
 
231
+  inline void say_default_() { SERIAL_PROTOCOLPGM("#define DEFAULT_"); }
232
+
257 233
   /**
258 234
    * PID Autotuning (M303)
259 235
    *
@@ -269,9 +245,8 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS];
269 245
     long t_high = 0, t_low = 0;
270 246
 
271 247
     long bias, d;
272
-    float Ku, Tu,
273
-          workKp = 0, workKi = 0, workKd = 0,
274
-          max = 0, min = 10000;
248
+    PID_t tune_pid = { 0, 0, 0 };
249
+    float max = 0, min = 10000;
275 250
 
276 251
     #if HAS_PID_FOR_BOTH
277 252
       #define GHV(B,H) (hotend < 0 ? (B) : (H))
@@ -375,32 +350,32 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS];
375 350
               SERIAL_PROTOCOLPAIR(MSG_T_MIN, min);
376 351
               SERIAL_PROTOCOLPAIR(MSG_T_MAX, max);
377 352
               if (cycles > 2) {
378
-                Ku = (4.0f * d) / (float(M_PI) * (max - min) * 0.5f);
379
-                Tu = ((float)(t_low + t_high) * 0.001f);
353
+                float Ku = (4.0f * d) / (float(M_PI) * (max - min) * 0.5f),
354
+                      Tu = ((float)(t_low + t_high) * 0.001f);
380 355
                 SERIAL_PROTOCOLPAIR(MSG_KU, Ku);
381 356
                 SERIAL_PROTOCOLPAIR(MSG_TU, Tu);
382
-                workKp = 0.6f * Ku;
383
-                workKi = 2 * workKp / Tu;
384
-                workKd = workKp * Tu * 0.125f;
357
+                tune_pid.Kp = 0.6f * Ku;
358
+                tune_pid.Ki = 2 * tune_pid.Kp / Tu;
359
+                tune_pid.Kd = tune_pid.Kp * Tu * 0.125f;
385 360
                 SERIAL_PROTOCOLLNPGM("\n" MSG_CLASSIC_PID);
386
-                SERIAL_PROTOCOLPAIR(MSG_KP, workKp);
387
-                SERIAL_PROTOCOLPAIR(MSG_KI, workKi);
388
-                SERIAL_PROTOCOLLNPAIR(MSG_KD, workKd);
361
+                SERIAL_PROTOCOLPAIR(MSG_KP, tune_pid.Kp);
362
+                SERIAL_PROTOCOLPAIR(MSG_KI, tune_pid.Ki);
363
+                SERIAL_PROTOCOLLNPAIR(MSG_KD, tune_pid.Kd);
389 364
                 /**
390
-                workKp = 0.33*Ku;
391
-                workKi = workKp/Tu;
392
-                workKd = workKp*Tu/3;
365
+                tune_pid.Kp = 0.33*Ku;
366
+                tune_pid.Ki = tune_pid.Kp/Tu;
367
+                tune_pid.Kd = tune_pid.Kp*Tu/3;
393 368
                 SERIAL_PROTOCOLLNPGM(" Some overshoot");
394
-                SERIAL_PROTOCOLPAIR(" Kp: ", workKp);
395
-                SERIAL_PROTOCOLPAIR(" Ki: ", workKi);
396
-                SERIAL_PROTOCOLPAIR(" Kd: ", workKd);
397
-                workKp = 0.2*Ku;
398
-                workKi = 2*workKp/Tu;
399
-                workKd = workKp*Tu/3;
369
+                SERIAL_PROTOCOLPAIR(" Kp: ", tune_pid.Kp);
370
+                SERIAL_PROTOCOLPAIR(" Ki: ", tune_pid.Ki);
371
+                SERIAL_PROTOCOLPAIR(" Kd: ", tune_pid.Kd);
372
+                tune_pid.Kp = 0.2*Ku;
373
+                tune_pid.Ki = 2*tune_pid.Kp/Tu;
374
+                tune_pid.Kd = tune_pid.Kp*Tu/3;
400 375
                 SERIAL_PROTOCOLLNPGM(" No overshoot");
401
-                SERIAL_PROTOCOLPAIR(" Kp: ", workKp);
402
-                SERIAL_PROTOCOLPAIR(" Ki: ", workKi);
403
-                SERIAL_PROTOCOLPAIR(" Kd: ", workKd);
376
+                SERIAL_PROTOCOLPAIR(" Kp: ", tune_pid.Kp);
377
+                SERIAL_PROTOCOLPAIR(" Ki: ", tune_pid.Ki);
378
+                SERIAL_PROTOCOLPAIR(" Kd: ", tune_pid.Kd);
404 379
                 */
405 380
               }
406 381
             }
@@ -467,39 +442,36 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS];
467 442
         SERIAL_PROTOCOLLNPGM(MSG_PID_AUTOTUNE_FINISHED);
468 443
 
469 444
         #if HAS_PID_FOR_BOTH
470
-          const char* estring = GHV("bed", "");
471
-          SERIAL_PROTOCOLPAIR("#define DEFAULT_", estring); SERIAL_PROTOCOLPAIR("Kp ", workKp); SERIAL_EOL();
472
-          SERIAL_PROTOCOLPAIR("#define DEFAULT_", estring); SERIAL_PROTOCOLPAIR("Ki ", workKi); SERIAL_EOL();
473
-          SERIAL_PROTOCOLPAIR("#define DEFAULT_", estring); SERIAL_PROTOCOLPAIR("Kd ", workKd); SERIAL_EOL();
445
+          const char * const estring = GHV(PSTR("bed"), PSTR(""));
446
+          say_default_(); serialprintPGM(estring); SERIAL_PROTOCOLLNPAIR("Kp ", tune_pid.Kp);
447
+          say_default_(); serialprintPGM(estring); SERIAL_PROTOCOLLNPAIR("Ki ", tune_pid.Ki);
448
+          say_default_(); serialprintPGM(estring); SERIAL_PROTOCOLLNPAIR("Kd ", tune_pid.Kd);
474 449
         #elif ENABLED(PIDTEMP)
475
-          SERIAL_PROTOCOLPAIR("#define DEFAULT_Kp ", workKp); SERIAL_EOL();
476
-          SERIAL_PROTOCOLPAIR("#define DEFAULT_Ki ", workKi); SERIAL_EOL();
477
-          SERIAL_PROTOCOLPAIR("#define DEFAULT_Kd ", workKd); SERIAL_EOL();
450
+          say_default_(); SERIAL_PROTOCOLLNPAIR("Kp ", tune_pid.Kp);
451
+          say_default_(); SERIAL_PROTOCOLLNPAIR("Ki ", tune_pid.Ki);
452
+          say_default_(); SERIAL_PROTOCOLLNPAIR("Kd ", tune_pid.Kd);
478 453
         #else
479
-          SERIAL_PROTOCOLPAIR("#define DEFAULT_bedKp ", workKp); SERIAL_EOL();
480
-          SERIAL_PROTOCOLPAIR("#define DEFAULT_bedKi ", workKi); SERIAL_EOL();
481
-          SERIAL_PROTOCOLPAIR("#define DEFAULT_bedKd ", workKd); SERIAL_EOL();
454
+          say_default_(); SERIAL_PROTOCOLLNPAIR("bedKp ", tune_pid.Kp);
455
+          say_default_(); SERIAL_PROTOCOLLNPAIR("bedKi ", tune_pid.Ki);
456
+          say_default_(); SERIAL_PROTOCOLLNPAIR("bedKd ", tune_pid.Kd);
482 457
         #endif
483 458
 
484 459
         #define _SET_BED_PID() do { \
485
-          bedKp = workKp; \
486
-          bedKi = scalePID_i(workKi); \
487
-          bedKd = scalePID_d(workKd); \
460
+          bed_pid.Kp = tune_pid.Kp; \
461
+          bed_pid.Ki = scalePID_i(tune_pid.Ki); \
462
+          bed_pid.Kd = scalePID_d(tune_pid.Kd); \
488 463
         }while(0)
489 464
 
490 465
         #define _SET_EXTRUDER_PID() do { \
491
-          PID_PARAM(Kp, hotend) = workKp; \
492
-          PID_PARAM(Ki, hotend) = scalePID_i(workKi); \
493
-          PID_PARAM(Kd, hotend) = scalePID_d(workKd); \
466
+          PID_PARAM(Kp, hotend) = tune_pid.Kp; \
467
+          PID_PARAM(Ki, hotend) = scalePID_i(tune_pid.Ki); \
468
+          PID_PARAM(Kd, hotend) = scalePID_d(tune_pid.Kd); \
494 469
           updatePID(); }while(0)
495 470
 
496 471
         // Use the result? (As with "M303 U1")
497 472
         if (set_result) {
498 473
           #if HAS_PID_FOR_BOTH
499
-            if (hotend < 0)
500
-              _SET_BED_PID();
501
-            else
502
-              _SET_EXTRUDER_PID();
474
+            if (hotend < 0) _SET_BED_PID(); else _SET_EXTRUDER_PID();
503 475
           #elif ENABLED(PIDTEMP)
504 476
             _SET_EXTRUDER_PID();
505 477
           #else
@@ -612,15 +584,19 @@ void Temperature::min_temp_error(const int8_t e) {
612 584
 float Temperature::get_pid_output(const int8_t e) {
613 585
   #if HOTENDS == 1
614 586
     UNUSED(e);
615
-    #define _HOTEND_TEST     true
587
+    #define _HOTEND_TEST true
616 588
   #else
617
-    #define _HOTEND_TEST     e == active_extruder
589
+    #define _HOTEND_TEST (e == active_extruder)
618 590
   #endif
619
-  float pid_output;
620 591
   #if ENABLED(PIDTEMP)
621 592
     #if DISABLED(PID_OPENLOOP)
622
-      pid_error[HOTEND_INDEX] = target_temperature[HOTEND_INDEX] - current_temperature[HOTEND_INDEX];
623
-      dTerm[HOTEND_INDEX] = PID_K2 * PID_PARAM(Kd, HOTEND_INDEX) * (current_temperature[HOTEND_INDEX] - temp_dState[HOTEND_INDEX]) + float(PID_K1) * dTerm[HOTEND_INDEX];
593
+      static hotend_pid_t work_pid[HOTENDS];
594
+      static float temp_iState[HOTENDS] = { 0 },
595
+                   temp_dState[HOTENDS] = { 0 };
596
+      static bool pid_reset[HOTENDS] = { false };
597
+      float pid_output,
598
+            pid_error = target_temperature[HOTEND_INDEX] - current_temperature[HOTEND_INDEX];
599
+      work_pid[HOTEND_INDEX].Kd = PID_K2 * PID_PARAM(Kd, HOTEND_INDEX) * (current_temperature[HOTEND_INDEX] - temp_dState[HOTEND_INDEX]) + float(PID_K1) * work_pid[HOTEND_INDEX].Kd;
624 600
       temp_dState[HOTEND_INDEX] = current_temperature[HOTEND_INDEX];
625 601
       #if HEATER_IDLE_HANDLER
626 602
         if (heater_idle_timeout_exceeded[HOTEND_INDEX]) {
@@ -629,57 +605,60 @@ float Temperature::get_pid_output(const int8_t e) {
629 605
         }
630 606
         else
631 607
       #endif
632
-      if (pid_error[HOTEND_INDEX] > PID_FUNCTIONAL_RANGE) {
633
-        pid_output = BANG_MAX;
634
-        pid_reset[HOTEND_INDEX] = true;
635
-      }
636
-      else if (pid_error[HOTEND_INDEX] < -(PID_FUNCTIONAL_RANGE) || target_temperature[HOTEND_INDEX] == 0
637
-        #if HEATER_IDLE_HANDLER
638
-          || heater_idle_timeout_exceeded[HOTEND_INDEX]
639
-        #endif
640
-        ) {
641
-        pid_output = 0;
642
-        pid_reset[HOTEND_INDEX] = true;
643
-      }
644
-      else {
645
-        if (pid_reset[HOTEND_INDEX]) {
646
-          temp_iState[HOTEND_INDEX] = 0.0;
647
-          pid_reset[HOTEND_INDEX] = false;
648
-        }
649
-        pTerm[HOTEND_INDEX] = PID_PARAM(Kp, HOTEND_INDEX) * pid_error[HOTEND_INDEX];
650
-        temp_iState[HOTEND_INDEX] += pid_error[HOTEND_INDEX];
651
-        iTerm[HOTEND_INDEX] = PID_PARAM(Ki, HOTEND_INDEX) * temp_iState[HOTEND_INDEX];
652
-
653
-        pid_output = pTerm[HOTEND_INDEX] + iTerm[HOTEND_INDEX] - dTerm[HOTEND_INDEX];
654
-
655
-        #if ENABLED(PID_EXTRUSION_SCALING)
656
-          cTerm[HOTEND_INDEX] = 0;
657
-          if (_HOTEND_TEST) {
658
-            const long e_position = stepper.position(E_AXIS);
659
-            if (e_position > last_e_position) {
660
-              lpq[lpq_ptr] = e_position - last_e_position;
661
-              last_e_position = e_position;
608
+          if (pid_error > PID_FUNCTIONAL_RANGE) {
609
+            pid_output = BANG_MAX;
610
+            pid_reset[HOTEND_INDEX] = true;
611
+          }
612
+          else if (pid_error < -(PID_FUNCTIONAL_RANGE) || target_temperature[HOTEND_INDEX] == 0
613
+            #if HEATER_IDLE_HANDLER
614
+              || heater_idle_timeout_exceeded[HOTEND_INDEX]
615
+            #endif
616
+          ) {
617
+            pid_output = 0;
618
+            pid_reset[HOTEND_INDEX] = true;
619
+          }
620
+          else {
621
+            if (pid_reset[HOTEND_INDEX]) {
622
+              temp_iState[HOTEND_INDEX] = 0.0;
623
+              pid_reset[HOTEND_INDEX] = false;
662 624
             }
663
-            else
664
-              lpq[lpq_ptr] = 0;
625
+            temp_iState[HOTEND_INDEX] += pid_error;
626
+            work_pid[HOTEND_INDEX].Kp = PID_PARAM(Kp, HOTEND_INDEX) * pid_error;
627
+            work_pid[HOTEND_INDEX].Ki = PID_PARAM(Ki, HOTEND_INDEX) * temp_iState[HOTEND_INDEX];
628
+
629
+            pid_output = work_pid[HOTEND_INDEX].Kp + work_pid[HOTEND_INDEX].Ki - work_pid[HOTEND_INDEX].Kd;
630
+
631
+            #if ENABLED(PID_EXTRUSION_SCALING)
632
+              work_pid[HOTEND_INDEX].Kc = 0;
633
+              if (_HOTEND_TEST) {
634
+                const long e_position = stepper.position(E_AXIS);
635
+                if (e_position > last_e_position) {
636
+                  lpq[lpq_ptr] = e_position - last_e_position;
637
+                  last_e_position = e_position;
638
+                }
639
+                else
640
+                  lpq[lpq_ptr] = 0;
641
+
642
+                if (++lpq_ptr >= lpq_len) lpq_ptr = 0;
643
+                work_pid[HOTEND_INDEX].Kc = (lpq[lpq_ptr] * planner.steps_to_mm[E_AXIS]) * PID_PARAM(Kc, HOTEND_INDEX);
644
+                pid_output += work_pid[HOTEND_INDEX].Kc;
645
+              }
646
+            #endif // PID_EXTRUSION_SCALING
665 647
 
666
-            if (++lpq_ptr >= lpq_len) lpq_ptr = 0;
667
-            cTerm[HOTEND_INDEX] = (lpq[lpq_ptr] * planner.steps_to_mm[E_AXIS]) * PID_PARAM(Kc, HOTEND_INDEX);
668
-            pid_output += cTerm[HOTEND_INDEX];
648
+            if (pid_output > PID_MAX) {
649
+              if (pid_error > 0) temp_iState[HOTEND_INDEX] -= pid_error; // conditional un-integration
650
+              pid_output = PID_MAX;
651
+            }
652
+            else if (pid_output < 0) {
653
+              if (pid_error < 0) temp_iState[HOTEND_INDEX] -= pid_error; // conditional un-integration
654
+              pid_output = 0;
655
+            }
669 656
           }
670
-        #endif // PID_EXTRUSION_SCALING
671 657
 
672
-        if (pid_output > PID_MAX) {
673
-          if (pid_error[HOTEND_INDEX] > 0) temp_iState[HOTEND_INDEX] -= pid_error[HOTEND_INDEX]; // conditional un-integration
674
-          pid_output = PID_MAX;
675
-        }
676
-        else if (pid_output < 0) {
677
-          if (pid_error[HOTEND_INDEX] < 0) temp_iState[HOTEND_INDEX] -= pid_error[HOTEND_INDEX]; // conditional un-integration
678
-          pid_output = 0;
679
-        }
680
-      }
681
-    #else
682
-      pid_output = constrain(target_temperature[HOTEND_INDEX], 0, PID_MAX);
658
+    #else // PID_OPENLOOP
659
+
660
+      const float pid_output = constrain(target_temperature[HOTEND_INDEX], 0, PID_MAX);
661
+
683 662
     #endif // PID_OPENLOOP
684 663
 
685 664
     #if ENABLED(PID_DEBUG)
@@ -687,11 +666,13 @@ float Temperature::get_pid_output(const int8_t e) {
687 666
       SERIAL_ECHOPAIR(MSG_PID_DEBUG, HOTEND_INDEX);
688 667
       SERIAL_ECHOPAIR(MSG_PID_DEBUG_INPUT, current_temperature[HOTEND_INDEX]);
689 668
       SERIAL_ECHOPAIR(MSG_PID_DEBUG_OUTPUT, pid_output);
690
-      SERIAL_ECHOPAIR(MSG_PID_DEBUG_PTERM, pTerm[HOTEND_INDEX]);
691
-      SERIAL_ECHOPAIR(MSG_PID_DEBUG_ITERM, iTerm[HOTEND_INDEX]);
692
-      SERIAL_ECHOPAIR(MSG_PID_DEBUG_DTERM, dTerm[HOTEND_INDEX]);
693
-      #if ENABLED(PID_EXTRUSION_SCALING)
694
-        SERIAL_ECHOPAIR(MSG_PID_DEBUG_CTERM, cTerm[HOTEND_INDEX]);
669
+      #if DISABLED(PID_OPENLOOP)
670
+        SERIAL_ECHOPAIR(MSG_PID_DEBUG_PTERM, work_pid[HOTEND_INDEX].Kp);
671
+        SERIAL_ECHOPAIR(MSG_PID_DEBUG_ITERM, work_pid[HOTEND_INDEX].Ki);
672
+        SERIAL_ECHOPAIR(MSG_PID_DEBUG_DTERM, work_pid[HOTEND_INDEX].Kd);
673
+        #if ENABLED(PID_EXTRUSION_SCALING)
674
+          SERIAL_ECHOPAIR(MSG_PID_DEBUG_CTERM, work_pid[HOTEND_INDEX].Kc);
675
+        #endif
695 676
       #endif
696 677
       SERIAL_EOL();
697 678
     #endif // PID_DEBUG
@@ -709,47 +690,52 @@ float Temperature::get_pid_output(const int8_t e) {
709 690
 }
710 691
 
711 692
 #if ENABLED(PIDTEMPBED)
693
+
712 694
   float Temperature::get_pid_output_bed() {
713
-    float pid_output;
695
+
714 696
     #if DISABLED(PID_OPENLOOP)
715
-      pid_error_bed = target_temperature_bed - current_temperature_bed;
716
-      pTerm_bed = bedKp * pid_error_bed;
717
-      temp_iState_bed += pid_error_bed;
718
-      iTerm_bed = bedKi * temp_iState_bed;
719 697
 
720
-      dTerm_bed = PID_K2 * bedKd * (current_temperature_bed - temp_dState_bed) + PID_K1 * dTerm_bed;
721
-      temp_dState_bed = current_temperature_bed;
698
+      static PID_t work_pid = { 0 };
699
+      static float temp_iState = 0, temp_dState = 0;
700
+
701
+      float pid_error = target_temperature_bed - current_temperature_bed;
702
+      temp_iState += pid_error;
703
+      work_pid.Kp = bed_pid.Kp * pid_error;
704
+      work_pid.Ki = bed_pid.Ki * temp_iState;
705
+      work_pid.Kd = PID_K2 * bed_pid.Kd * (current_temperature_bed - temp_dState) + PID_K1 * work_pid.Kd;
722 706
 
723
-      pid_output = pTerm_bed + iTerm_bed - dTerm_bed;
707
+      temp_dState = current_temperature_bed;
708
+
709
+      float pid_output = work_pid.Kp + work_pid.Ki - work_pid.Kd;
724 710
       if (pid_output > MAX_BED_POWER) {
725
-        if (pid_error_bed > 0) temp_iState_bed -= pid_error_bed; // conditional un-integration
711
+        if (pid_error > 0) temp_iState -= pid_error; // conditional un-integration
726 712
         pid_output = MAX_BED_POWER;
727 713
       }
728 714
       else if (pid_output < 0) {
729
-        if (pid_error_bed < 0) temp_iState_bed -= pid_error_bed; // conditional un-integration
715
+        if (pid_error < 0) temp_iState -= pid_error; // conditional un-integration
730 716
         pid_output = 0;
731 717
       }
732
-    #else
733
-      pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER);
718
+
719
+    #else // PID_OPENLOOP
720
+
721
+      const float pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER);
722
+
734 723
     #endif // PID_OPENLOOP
735 724
 
736 725
     #if ENABLED(PID_BED_DEBUG)
737 726
       SERIAL_ECHO_START();
738
-      SERIAL_ECHOPGM(" PID_BED_DEBUG ");
739
-      SERIAL_ECHOPGM(": Input ");
740
-      SERIAL_ECHO(current_temperature_bed);
741
-      SERIAL_ECHOPGM(" Output ");
742
-      SERIAL_ECHO(pid_output);
743
-      SERIAL_ECHOPGM(" pTerm ");
744
-      SERIAL_ECHO(pTerm_bed);
745
-      SERIAL_ECHOPGM(" iTerm ");
746
-      SERIAL_ECHO(iTerm_bed);
747
-      SERIAL_ECHOPGM(" dTerm ");
748
-      SERIAL_ECHOLN(dTerm_bed);
749
-    #endif // PID_BED_DEBUG
727
+      SERIAL_ECHOPAIR(" PID_BED_DEBUG : Input ", current_temperature_bed);
728
+      SERIAL_ECHOPAIR(" Output ", pid_output);
729
+      #if DISABLED(PID_OPENLOOP)
730
+        SERIAL_ECHOPAIR(MSG_PID_DEBUG_PTERM, work_pid.Kp);
731
+        SERIAL_ECHOPAIR(MSG_PID_DEBUG_ITERM, work_pid.Ki);
732
+        SERIAL_ECHOLNPAIR(MSG_PID_DEBUG_DTERM, work_pid.Kd);
733
+      #endif
734
+    #endif
750 735
 
751 736
     return pid_output;
752 737
   }
738
+
753 739
 #endif // PIDTEMPBED
754 740
 
755 741
 /**

+ 32
- 38
Marlin/src/module/temperature.h Visa fil

@@ -48,6 +48,35 @@
48 48
   #define HOTEND_INDEX  e
49 49
 #endif
50 50
 
51
+// PID storage
52
+typedef struct { float Kp, Ki, Kd;     } PID_t;
53
+typedef struct { float Kp, Ki, Kd, Kc; } PIDC_t;
54
+#if ENABLED(PID_EXTRUSION_SCALING)
55
+  typedef PIDC_t hotend_pid_t;
56
+#else
57
+  typedef PID_t hotend_pid_t;
58
+#endif
59
+
60
+#define DUMMY_PID_VALUE 3000.0f
61
+
62
+#if ENABLED(PIDTEMP)
63
+  #define _PID_Kp(H) Temperature::pid[H].Kp
64
+  #define _PID_Ki(H) Temperature::pid[H].Ki
65
+  #define _PID_Kd(H) Temperature::pid[H].Kd
66
+  #if ENABLED(PID_EXTRUSION_SCALING)
67
+    #define _PID_Kc(H) Temperature::pid[H].Kc
68
+  #else
69
+    #define _PID_Kc(H) 1
70
+  #endif
71
+#else
72
+  #define _PID_Kp(H) DUMMY_PID_VALUE
73
+  #define _PID_Ki(H) DUMMY_PID_VALUE
74
+  #define _PID_Kd(H) DUMMY_PID_VALUE
75
+  #define _PID_Kc(H) 1
76
+#endif
77
+
78
+#define PID_PARAM(F,H) _PID_##F(H)
79
+
51 80
 /**
52 81
  * States for ADC reading in the ISR
53 82
  */
@@ -132,25 +161,7 @@ class Temperature {
132 161
     #endif
133 162
 
134 163
     #if ENABLED(PIDTEMP)
135
-
136
-      #if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
137
-
138
-        static float Kp[HOTENDS], Ki[HOTENDS], Kd[HOTENDS];
139
-        #if ENABLED(PID_EXTRUSION_SCALING)
140
-          static float Kc[HOTENDS];
141
-        #endif
142
-        #define PID_PARAM(param, h) Temperature::param[h]
143
-
144
-      #else
145
-
146
-        static float Kp, Ki, Kd;
147
-        #if ENABLED(PID_EXTRUSION_SCALING)
148
-          static float Kc;
149
-        #endif
150
-        #define PID_PARAM(param, h) Temperature::param
151
-
152
-      #endif // PID_PARAMS_PER_HOTEND
153
-
164
+      static hotend_pid_t pid[HOTENDS];
154 165
     #endif
155 166
 
156 167
     #if HAS_HEATED_BED
@@ -158,7 +169,7 @@ class Temperature {
158 169
       static int16_t current_temperature_bed_raw, target_temperature_bed;
159 170
       static uint8_t soft_pwm_amount_bed;
160 171
       #if ENABLED(PIDTEMPBED)
161
-        static float bedKp, bedKi, bedKd;
172
+        static PID_t bed_pid;
162 173
       #endif
163 174
     #endif
164 175
 
@@ -210,21 +221,11 @@ class Temperature {
210 221
     #endif
211 222
 
212 223
     #if ENABLED(PIDTEMP)
213
-      static float temp_iState[HOTENDS],
214
-                   temp_dState[HOTENDS],
215
-                   pTerm[HOTENDS],
216
-                   iTerm[HOTENDS],
217
-                   dTerm[HOTENDS];
218
-
219 224
       #if ENABLED(PID_EXTRUSION_SCALING)
220
-        static float cTerm[HOTENDS];
221 225
         static long last_e_position;
222 226
         static long lpq[LPQ_MAX_LEN];
223 227
         static int lpq_ptr;
224 228
       #endif
225
-
226
-      static float pid_error[HOTENDS];
227
-      static bool pid_reset[HOTENDS];
228 229
     #endif
229 230
 
230 231
     // Init min and max temp with extreme values to prevent false errors during startup
@@ -239,14 +240,7 @@ class Temperature {
239 240
         static uint16_t watch_target_bed_temp;
240 241
         static millis_t watch_bed_next_ms;
241 242
       #endif
242
-      #if ENABLED(PIDTEMPBED)
243
-        static float temp_iState_bed,
244
-                     temp_dState_bed,
245
-                     pTerm_bed,
246
-                     iTerm_bed,
247
-                     dTerm_bed,
248
-                     pid_error_bed;
249
-      #else
243
+      #if DISABLED(PIDTEMPBED)
250 244
         static millis_t next_bed_check_ms;
251 245
       #endif
252 246
       #if HEATER_IDLE_HANDLER

+ 31
- 33
Marlin/src/module/tool_change.cpp Visa fil

@@ -30,9 +30,7 @@
30 30
 #include "../Marlin.h"
31 31
 
32 32
 #if ENABLED(SINGLENOZZLE)
33
-  float singlenozzle_swap_length      = SINGLENOZZLE_SWAP_LENGTH;
34
-  int16_t singlenozzle_prime_speed    = SINGLENOZZLE_SWAP_PRIME_SPEED,
35
-          singlenozzle_retract_speed  = SINGLENOZZLE_SWAP_RETRACT_SPEED;
33
+  singlenozzle_settings_t sn_settings;  // Initialized by settings.load()
36 34
   uint16_t singlenozzle_temp[EXTRUDERS];
37 35
   #if FAN_COUNT > 0
38 36
     uint8_t singlenozzle_fan_speed[EXTRUDERS];
@@ -152,7 +150,7 @@
152 150
       #if ENABLED(DEBUG_LEVELING_FEATURE)
153 151
         if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
154 152
       #endif
155
-      planner.buffer_line(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
153
+      planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
156 154
       planner.synchronize();
157 155
 
158 156
       // STEP 2
@@ -163,7 +161,7 @@
163 161
           DEBUG_POS("Moving ParkPos", current_position);
164 162
         }
165 163
       #endif
166
-      planner.buffer_line(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder);
164
+      planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
167 165
       planner.synchronize();
168 166
 
169 167
       // STEP 3
@@ -181,7 +179,7 @@
181 179
       #if ENABLED(DEBUG_LEVELING_FEATURE)
182 180
         if (DEBUGGING(LEVELING)) DEBUG_POS("Move away from parked extruder", current_position);
183 181
       #endif
184
-      planner.buffer_line(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder);
182
+      planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
185 183
       planner.synchronize();
186 184
 
187 185
       // STEP 5
@@ -196,12 +194,12 @@
196 194
 
197 195
       // STEP 6
198 196
       current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
199
-      planner.buffer_line(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder);
197
+      planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
200 198
       current_position[X_AXIS] = grabpos;
201 199
       #if ENABLED(DEBUG_LEVELING_FEATURE)
202 200
         if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Unpark extruder", current_position);
203 201
       #endif
204
-      planner.buffer_line(current_position, planner.max_feedrate_mm_s[X_AXIS]/2, active_extruder);
202
+      planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS]/2, active_extruder);
205 203
       planner.synchronize();
206 204
 
207 205
       // Step 7
@@ -209,7 +207,7 @@
209 207
       #if ENABLED(DEBUG_LEVELING_FEATURE)
210 208
         if (DEBUGGING(LEVELING)) DEBUG_POS("(7) Move midway between hotends", current_position);
211 209
       #endif
212
-      planner.buffer_line(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder);
210
+      planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
213 211
       planner.synchronize();
214 212
       #if ENABLED(DEBUG_LEVELING_FEATURE)
215 213
         SERIAL_ECHOLNPGM("Autopark done.");
@@ -259,7 +257,7 @@
259 257
     #if ENABLED(DEBUG_LEVELING_FEATURE)
260 258
       if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
261 259
     #endif
262
-    planner.buffer_line(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
260
+    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
263 261
     planner.synchronize();
264 262
 
265 263
     // STEP 2
@@ -270,14 +268,14 @@
270 268
         DEBUG_POS("Move X SwitchPos", current_position);
271 269
       }
272 270
     #endif
273
-    planner.buffer_line(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder);
271
+    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
274 272
     planner.synchronize();
275 273
 
276 274
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
277 275
     #if ENABLED(DEBUG_LEVELING_FEATURE)
278 276
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
279 277
     #endif
280
-    planner.buffer_line(current_position, planner.max_feedrate_mm_s[Y_AXIS], active_extruder);
278
+    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
281 279
     planner.synchronize();
282 280
 
283 281
     // STEP 3
@@ -291,14 +289,14 @@
291 289
     #if ENABLED(DEBUG_LEVELING_FEATURE)
292 290
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
293 291
     #endif
294
-    planner.buffer_line(current_position,(planner.max_feedrate_mm_s[Y_AXIS] * 0.5), active_extruder);
292
+    planner.buffer_line(current_position,(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5), active_extruder);
295 293
     planner.synchronize();
296 294
     safe_delay(200);
297 295
     current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
298 296
     #if ENABLED(DEBUG_LEVELING_FEATURE)
299 297
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
300 298
     #endif
301
-    planner.buffer_line(current_position, planner.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
299
+    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
302 300
     planner.synchronize();
303 301
 
304 302
     // STEP 4
@@ -309,13 +307,13 @@
309 307
     #if ENABLED(DEBUG_LEVELING_FEATURE)
310 308
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
311 309
     #endif
312
-    planner.buffer_line(current_position, planner.max_feedrate_mm_s[X_AXIS], active_extruder);
310
+    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
313 311
     planner.synchronize();
314 312
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
315 313
     #if ENABLED(DEBUG_LEVELING_FEATURE)
316 314
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
317 315
     #endif
318
-    planner.buffer_line(current_position, planner.max_feedrate_mm_s[Y_AXIS], active_extruder);
316
+    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
319 317
     planner.synchronize();
320 318
 
321 319
     // STEP 5
@@ -326,7 +324,7 @@
326 324
     #if ENABLED(DEBUG_LEVELING_FEATURE)
327 325
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
328 326
     #endif
329
-    planner.buffer_line(current_position, planner.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder);
327
+    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder);
330 328
     planner.synchronize();
331 329
 
332 330
     safe_delay(200);
@@ -337,7 +335,7 @@
337 335
     #if ENABLED(DEBUG_LEVELING_FEATURE)
338 336
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
339 337
     #endif
340
-    planner.buffer_line(current_position, planner.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
338
+    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
341 339
     planner.synchronize();
342 340
 
343 341
     // STEP 6
@@ -413,9 +411,9 @@ inline void invalid_extruder_error(const uint8_t e) {
413 411
       #define CUR_Z current_position[Z_AXIS]
414 412
       #define CUR_E current_position[E_AXIS]
415 413
 
416
-      planner.buffer_line(CUR_X, CUR_Y, raised_z, CUR_E, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
417
-      planner.buffer_line(xhome, CUR_Y, raised_z, CUR_E, planner.max_feedrate_mm_s[X_AXIS], active_extruder);
418
-      planner.buffer_line(xhome, CUR_Y, CUR_Z,    CUR_E, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
414
+      planner.buffer_line(CUR_X, CUR_Y, raised_z, CUR_E, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
415
+      planner.buffer_line(xhome, CUR_Y, raised_z, CUR_E, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
416
+      planner.buffer_line(xhome, CUR_Y, CUR_Z,    CUR_E, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
419 417
 
420 418
       planner.synchronize();
421 419
     }
@@ -556,7 +554,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
556 554
             #if ENABLED(SWITCHING_NOZZLE)
557 555
               // Always raise by at least 1 to avoid workpiece
558 556
               current_position[Z_AXIS] += MAX(-zdiff, 0.0) + 1;
559
-              planner.buffer_line(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
557
+              planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
560 558
               move_nozzle_servo(tmp_extruder);
561 559
             #endif
562 560
           #endif
@@ -595,7 +593,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
595 593
           #if DISABLED(SWITCHING_NOZZLE)
596 594
             // Do a small lift to avoid the workpiece in the move back (below)
597 595
             current_position[Z_AXIS] += 1.0;
598
-            planner.buffer_line(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
596
+            planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
599 597
           #endif
600 598
           #if ENABLED(DEBUG_LEVELING_FEATURE)
601 599
             if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination);
@@ -616,7 +614,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
616 614
         #if ENABLED(SWITCHING_NOZZLE)
617 615
           else {
618 616
             // Move back down. (Including when the new tool is higher.)
619
-            do_blocking_move_to_z(destination[Z_AXIS], planner.max_feedrate_mm_s[Z_AXIS]);
617
+            do_blocking_move_to_z(destination[Z_AXIS], planner.settings.max_feedrate_mm_s[Z_AXIS]);
620 618
           }
621 619
         #endif
622 620
       } // (tmp_extruder != active_extruder)
@@ -663,12 +661,12 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
663 661
 
664 662
           set_destination_from_current();
665 663
 
666
-          if (singlenozzle_swap_length) {
664
+          if (sn_settings.swap_length) {
667 665
             #if ENABLED(ADVANCED_PAUSE_FEATURE)
668
-              do_pause_e_move(-singlenozzle_swap_length, MMM_TO_MMS(singlenozzle_retract_speed));
666
+              do_pause_e_move(-sn_settings.swap_length, MMM_TO_MMS(sn_settings.retract_speed));
669 667
             #else
670
-              current_position[E_AXIS] -= singlenozzle_swap_length / planner.e_factor[active_extruder];
671
-              planner.buffer_line(current_position, MMM_TO_MMS(singlenozzle_retract_speed), active_extruder);
668
+              current_position[E_AXIS] -= sn_settings.swap_length / planner.e_factor[active_extruder];
669
+              planner.buffer_line(current_position, MMM_TO_MMS(sn_settings.retract_speed), active_extruder);
672 670
             #endif
673 671
           }
674 672
 
@@ -680,7 +678,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
680 678
             #endif
681 679
           );
682 680
 
683
-          planner.buffer_line(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
681
+          planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
684 682
 
685 683
           #if ENABLED(SINGLENOZZLE_SWAP_PARK)
686 684
             current_position[X_AXIS] = singlenozzle_change_point.x;
@@ -699,12 +697,12 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
699 697
 
700 698
           active_extruder = tmp_extruder;
701 699
 
702
-          if (singlenozzle_swap_length) {
700
+          if (sn_settings.swap_length) {
703 701
             #if ENABLED(ADVANCED_PAUSE_FEATURE)
704
-              do_pause_e_move(singlenozzle_swap_length, singlenozzle_prime_speed);
702
+              do_pause_e_move(sn_settings.swap_length, sn_settings.prime_speed);
705 703
             #else
706
-              current_position[E_AXIS] += singlenozzle_swap_length / planner.e_factor[tmp_extruder];
707
-              planner.buffer_line(current_position, singlenozzle_prime_speed, tmp_extruder);
704
+              current_position[E_AXIS] += sn_settings.swap_length / planner.e_factor[tmp_extruder];
705
+              planner.buffer_line(current_position, sn_settings.prime_speed, tmp_extruder);
708 706
             #endif
709 707
           }
710 708
 

+ 7
- 9
Marlin/src/module/tool_change.h Visa fil

@@ -19,11 +19,9 @@
19 19
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 20
  *
21 21
  */
22
+#pragma once
22 23
 
23
-#ifndef TOOL_CHANGE_H
24
-#define TOOL_CHANGE_H
25
-
26
-#include "../inc/MarlinConfig.h"
24
+#include "../inc/MarlinConfigPre.h"
27 25
 
28 26
 #if DO_SWITCH_EXTRUDER
29 27
   void move_extruder_servo(const uint8_t e);
@@ -51,9 +49,11 @@
51 49
 #endif // PARKING_EXTRUDER
52 50
 
53 51
 #if ENABLED(SINGLENOZZLE)
54
-  extern float singlenozzle_swap_length;
55
-  extern int16_t singlenozzle_prime_speed,
56
-                 singlenozzle_retract_speed;
52
+  typedef struct {
53
+    float swap_length;
54
+    int16_t prime_speed, retract_speed;
55
+  } singlenozzle_settings_t;
56
+  extern singlenozzle_settings_t sn_settings;
57 57
   extern uint16_t singlenozzle_temp[EXTRUDERS];
58 58
   #if FAN_COUNT > 0
59 59
     extern uint8_t singlenozzle_fan_speed[EXTRUDERS];
@@ -65,5 +65,3 @@
65 65
  * previous tool out of the way and the new tool into place.
66 66
  */
67 67
 void tool_change(const uint8_t tmp_extruder, const float fr_mm_s=0.0, bool no_move=false);
68
-
69
-#endif // TOOL_CHANGE_H

Laddar…
Avbryt
Spara