Pārlūkot izejas kodu

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 gadus atpakaļ
vecāks
revīzija
d556dc1865
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
35 mainītis faili ar 1139 papildinājumiem un 1234 dzēšanām
  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 Parādīt failu

25
 #include <string.h>
25
 #include <string.h>
26
 
26
 
27
 typedef uint32_t millis_t;
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 Parādīt failu

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

+ 2
- 2
Marlin/src/feature/I2CPositionEncoder.h Parādīt failu

155
         case I2CPE_ENC_TYPE_LINEAR:
155
         case I2CPE_ENC_TYPE_LINEAR:
156
           return count / encoderTicksPerUnit;
156
           return count / encoderTicksPerUnit;
157
         case I2CPE_ENC_TYPE_ROTARY:
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
         case I2CPE_ENC_TYPE_LINEAR:
199
         case I2CPE_ENC_TYPE_LINEAR:
200
           return encoderTicksPerUnit;
200
           return encoderTicksPerUnit;
201
         case I2CPE_ENC_TYPE_ROTARY:
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 Parādīt failu

803
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
803
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
804
 
804
 
805
       do_blocking_move_to(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
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
       planner.synchronize();
807
       planner.synchronize();
808
 
808
 
809
       SERIAL_PROTOCOLPGM("Place shim under nozzle");
809
       SERIAL_PROTOCOLPGM("Place shim under nozzle");

+ 26
- 28
Marlin/src/feature/fwretract.cpp Parādīt failu

43
 // private:
43
 // private:
44
 
44
 
45
 #if EXTRUDERS > 1
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
 #endif
47
 #endif
48
 
48
 
49
 // public:
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
       FWRetract::current_hop;
60
       FWRetract::current_hop;
63
 
61
 
64
 void FWRetract::reset() {
62
 void FWRetract::reset() {
65
   autoretract_enabled = false;
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
   current_hop = 0.0;
72
   current_hop = 0.0;
75
 
73
 
76
   for (uint8_t i = 0; i < EXTRUDERS; ++i) {
74
   for (uint8_t i = 0; i < EXTRUDERS; ++i) {
132
               unscale_e = RECIPROCAL(planner.e_factor[active_extruder]),
130
               unscale_e = RECIPROCAL(planner.e_factor[active_extruder]),
133
               unscale_fr = 100.0 / feedrate_percentage, // Disable feedrate scaling for retract moves
131
               unscale_fr = 100.0 / feedrate_percentage, // Disable feedrate scaling for retract moves
134
               base_retract = (
132
               base_retract = (
135
-                (swapping ? swap_retract_length : retract_length)
133
+                (swapping ? settings.swap_retract_length : settings.retract_length)
136
                 #if ENABLED(RETRACT_SYNC_MIXING)
134
                 #if ENABLED(RETRACT_SYNC_MIXING)
137
                   * (MIXING_STEPPERS)
135
                   * (MIXING_STEPPERS)
138
                 #endif
136
                 #endif
152
   if (retracting) {
150
   if (retracting) {
153
     // Retract by moving from a faux E position back to the current E position
151
     // Retract by moving from a faux E position back to the current E position
154
     feedrate_mm_s = (
152
     feedrate_mm_s = (
155
-      retract_feedrate_mm_s * unscale_fr
153
+      settings.retract_feedrate_mm_s * unscale_fr
156
       #if ENABLED(RETRACT_SYNC_MIXING)
154
       #if ENABLED(RETRACT_SYNC_MIXING)
157
         * (MIXING_STEPPERS)
155
         * (MIXING_STEPPERS)
158
       #endif
156
       #endif
162
     planner.synchronize();                                // Wait for move to complete
160
     planner.synchronize();                                // Wait for move to complete
163
 
161
 
164
     // Is a Z hop set, and has the hop not yet been done?
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
       prepare_move_to_destination();                      // Raise up, set_current_to_destination
166
       prepare_move_to_destination();                      // Raise up, set_current_to_destination
169
       planner.synchronize();                              // Wait for move to complete
167
       planner.synchronize();                              // Wait for move to complete
170
     }
168
     }
173
     // If a hop was done and Z hasn't changed, undo the Z hop
171
     // If a hop was done and Z hasn't changed, undo the Z hop
174
     if (current_hop) {
172
     if (current_hop) {
175
       current_hop = 0.0;
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
       prepare_move_to_destination();                      // Lower Z, set_current_to_destination
175
       prepare_move_to_destination();                      // Lower Z, set_current_to_destination
178
       planner.synchronize();                              // Wait for move to complete
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
     if (extra_recover != 0.0) {
180
     if (extra_recover != 0.0) {
183
       current_position[E_AXIS] -= extra_recover;          // Adjust the current E position by the extra amount to recover
181
       current_position[E_AXIS] -= extra_recover;          // Adjust the current E position by the extra amount to recover
184
       sync_plan_position_e();                             // Sync the planner position so the extra amount is recovered
182
       sync_plan_position_e();                             // Sync the planner position so the extra amount is recovered
186
 
184
 
187
     current_retract[active_extruder] = 0.0;
185
     current_retract[active_extruder] = 0.0;
188
     feedrate_mm_s = (
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
       #if ENABLED(RETRACT_SYNC_MIXING)
188
       #if ENABLED(RETRACT_SYNC_MIXING)
191
         * (MIXING_STEPPERS)
189
         * (MIXING_STEPPERS)
192
       #endif
190
       #endif

+ 13
- 18
Marlin/src/feature/fwretract.h Parādīt failu

19
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
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
  * fwretract.h - Define firmware-based retraction interface
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
 class FWRetract {
30
 class FWRetract {
33
 private:
31
 private:
36
   #endif
34
   #endif
37
 
35
 
38
 public:
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
                current_hop;                        // Hop value used by planner
47
                current_hop;                        // Hop value used by planner
51
 
48
 
52
   FWRetract() { reset(); }
49
   FWRetract() { reset(); }
54
   static void reset();
51
   static void reset();
55
 
52
 
56
   static void refresh_autoretract() {
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
   static void enable_autoretract(const bool enable) {
57
   static void enable_autoretract(const bool enable) {
72
 };
69
 };
73
 
70
 
74
 extern FWRetract fwretract;
71
 extern FWRetract fwretract;
75
-
76
-#endif // FWRETRACT_H

+ 10
- 11
Marlin/src/feature/pause.cpp Parādīt failu

25
  * This may be combined with related G-codes if features are consolidated.
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
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
30
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
31
 
31
 
59
 
59
 
60
 AdvancedPauseMenuResponse advanced_pause_menu_response;
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
 #if ENABLED(SDSUPPORT)
64
 #if ENABLED(SDSUPPORT)
66
   #include "../sd/cardreader.h"
65
   #include "../sd/cardreader.h"
191
   // Fast Load Filament
190
   // Fast Load Filament
192
   if (fast_load_length) {
191
   if (fast_load_length) {
193
     #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
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
     #endif
195
     #endif
197
 
196
 
198
     do_pause_e_move(fast_load_length, FILAMENT_CHANGE_FAST_LOAD_FEEDRATE);
197
     do_pause_e_move(fast_load_length, FILAMENT_CHANGE_FAST_LOAD_FEEDRATE);
199
 
198
 
200
     #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
199
     #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
201
-      planner.retract_acceleration = saved_acceleration;
200
+      planner.settings.retract_acceleration = saved_acceleration;
202
     #endif
201
     #endif
203
   }
202
   }
204
 
203
 
295
   safe_delay(FILAMENT_UNLOAD_DELAY);
294
   safe_delay(FILAMENT_UNLOAD_DELAY);
296
 
295
 
297
   // Quickly purge
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
   // Unload filament
299
   // Unload filament
301
   #if FILAMENT_CHANGE_UNLOAD_ACCEL > 0
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
   #endif
303
   #endif
305
 
304
 
306
   do_pause_e_move(unload_length, FILAMENT_CHANGE_UNLOAD_FEEDRATE);
305
   do_pause_e_move(unload_length, FILAMENT_CHANGE_UNLOAD_FEEDRATE);
307
 
306
 
308
   #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
307
   #if FILAMENT_CHANGE_FAST_LOAD_ACCEL > 0
309
-    planner.retract_acceleration = saved_acceleration;
308
+    planner.settings.retract_acceleration = saved_acceleration;
310
   #endif
309
   #endif
311
 
310
 
312
   // Disable extruders steppers for manual filament changing (only on boards that have separate ENABLE_PINS)
311
   // Disable extruders steppers for manual filament changing (only on boards that have separate ENABLE_PINS)
559
   #if ENABLED(FWRETRACT)
558
   #if ENABLED(FWRETRACT)
560
     // If retracted before goto pause
559
     // If retracted before goto pause
561
     if (fwretract.retracted[active_extruder])
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
   #endif
562
   #endif
564
 
563
 
565
   // If resume_position is negative
564
   // If resume_position is negative

+ 2
- 7
Marlin/src/feature/pause.h Parādīt failu

19
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
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
  * feature/pause.h - Pause feature support functions
25
  * feature/pause.h - Pause feature support functions
25
  * This may be combined with related G-codes if features are consolidated.
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
 #include "../libs/nozzle.h"
29
 #include "../libs/nozzle.h"
32
 
30
 
33
 #include "../inc/MarlinConfigPre.h"
31
 #include "../inc/MarlinConfigPre.h"
62
 
60
 
63
 extern AdvancedPauseMenuResponse advanced_pause_menu_response;
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
 extern uint8_t did_pause_print;
65
 extern uint8_t did_pause_print;
69
 
66
 
89
                           const bool pause_for_user=false, const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT DXC_PARAMS);
86
                           const bool pause_for_user=false, const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT DXC_PARAMS);
90
 
87
 
91
 bool unload_filament(const float &unload_length, const bool show_lcd=false, const AdvancedPauseMode mode=ADVANCED_PAUSE_MODE_PAUSE_PRINT);
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 Parādīt failu

456
 
456
 
457
   static void tmc_debug_loop(const TMC_debug_enum i) {
457
   static void tmc_debug_loop(const TMC_debug_enum i) {
458
     #if AXIS_IS_TMC(X)
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
     #endif
460
     #endif
461
     #if AXIS_IS_TMC(X2)
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
     #endif
463
     #endif
464
 
464
 
465
     #if AXIS_IS_TMC(Y)
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
     #endif
467
     #endif
468
     #if AXIS_IS_TMC(Y2)
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
     #endif
470
     #endif
471
 
471
 
472
     #if AXIS_IS_TMC(Z)
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
     #endif
474
     #endif
475
     #if AXIS_IS_TMC(Z2)
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
     #endif
477
     #endif
478
     #if AXIS_IS_TMC(Z3)
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
     #endif
480
     #endif
481
 
481
 
482
     #if AXIS_IS_TMC(E0)
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
     #endif
484
     #endif
485
     #if AXIS_IS_TMC(E1)
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
         #if ENABLED(DISTINCT_E_FACTORS)
487
         #if ENABLED(DISTINCT_E_FACTORS)
488
           + 1
488
           + 1
489
         #endif
489
         #endif
490
       ]);
490
       ]);
491
     #endif
491
     #endif
492
     #if AXIS_IS_TMC(E2)
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
         #if ENABLED(DISTINCT_E_FACTORS)
494
         #if ENABLED(DISTINCT_E_FACTORS)
495
           + 2
495
           + 2
496
         #endif
496
         #endif
497
       ]);
497
       ]);
498
     #endif
498
     #endif
499
     #if AXIS_IS_TMC(E3)
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
         #if ENABLED(DISTINCT_E_FACTORS)
501
         #if ENABLED(DISTINCT_E_FACTORS)
502
           + 3
502
           + 3
503
         #endif
503
         #endif
504
       ]);
504
       ]);
505
     #endif
505
     #endif
506
     #if AXIS_IS_TMC(E4)
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
         #if ENABLED(DISTINCT_E_FACTORS)
508
         #if ENABLED(DISTINCT_E_FACTORS)
509
           + 4
509
           + 4
510
         #endif
510
         #endif
511
       ]);
511
       ]);
512
     #endif
512
     #endif
513
     #if AXIS_IS_TMC(E5)
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
         #if ENABLED(DISTINCT_E_FACTORS)
515
         #if ENABLED(DISTINCT_E_FACTORS)
516
           + 5
516
           + 5
517
         #endif
517
         #endif

+ 4
- 4
Marlin/src/gcode/bedlevel/G26.cpp Parādīt failu

232
 
232
 
233
   if (z != last_z) {
233
   if (z != last_z) {
234
     last_z = z;
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
     destination[X_AXIS] = current_position[X_AXIS];
237
     destination[X_AXIS] = current_position[X_AXIS];
238
     destination[Y_AXIS] = current_position[Y_AXIS];
238
     destination[Y_AXIS] = current_position[Y_AXIS];
245
 
245
 
246
   // Check if X or Y is involved in the movement.
246
   // Check if X or Y is involved in the movement.
247
   // Yes: a 'normal' movement. No: a retract() or recover()
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
   if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
250
   if (g26_debug_flag) SERIAL_ECHOLNPAIR("in move_to() feed_value for XY:", feed_value);
251
 
251
 
496
           Total_Prime += 0.25;
496
           Total_Prime += 0.25;
497
           if (Total_Prime >= EXTRUDE_MAXLENGTH) return G26_ERR;
497
           if (Total_Prime >= EXTRUDE_MAXLENGTH) return G26_ERR;
498
         #endif
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
         set_destination_from_current();
500
         set_destination_from_current();
501
         planner.synchronize();    // Without this synchronize, the purge is more consistent,
501
         planner.synchronize();    // Without this synchronize, the purge is more consistent,
502
                                   // but because the planner has a buffer, we won't be able
502
                                   // but because the planner has a buffer, we won't be able
519
     #endif
519
     #endif
520
     set_destination_from_current();
520
     set_destination_from_current();
521
     destination[E_AXIS] += g26_prime_length;
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
     set_destination_from_current();
523
     set_destination_from_current();
524
     retract_filament(destination);
524
     retract_filament(destination);
525
   }
525
   }

+ 9
- 9
Marlin/src/gcode/calibrate/M852.cpp Parādīt failu

42
     ++ijk;
42
     ++ijk;
43
     const float value = parser.value_linear_units();
43
     const float value = parser.value_linear_units();
44
     if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
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
         ++setval;
47
         ++setval;
48
       }
48
       }
49
     }
49
     }
57
       ++ijk;
57
       ++ijk;
58
       const float value = parser.value_linear_units();
58
       const float value = parser.value_linear_units();
59
       if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
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
           ++setval;
62
           ++setval;
63
         }
63
         }
64
       }
64
       }
70
       ++ijk;
70
       ++ijk;
71
       const float value = parser.value_linear_units();
71
       const float value = parser.value_linear_units();
72
       if (WITHIN(value, SKEW_FACTOR_MIN, SKEW_FACTOR_MAX)) {
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
           ++setval;
75
           ++setval;
76
         }
76
         }
77
       }
77
       }
94
   if (!ijk) {
94
   if (!ijk) {
95
     SERIAL_ECHO_START();
95
     SERIAL_ECHO_START();
96
     SERIAL_ECHOPGM(MSG_SKEW_FACTOR " XY: ");
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
     SERIAL_EOL();
98
     SERIAL_EOL();
99
     #if ENABLED(SKEW_CORRECTION_FOR_Z)
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
     #else
102
     #else
103
       SERIAL_EOL();
103
       SERIAL_EOL();
104
     #endif
104
     #endif

+ 12
- 12
Marlin/src/gcode/config/M200-M205.cpp Parādīt failu

60
   LOOP_XYZE(i) {
60
   LOOP_XYZE(i) {
61
     if (parser.seen(axis_codes[i])) {
61
     if (parser.seen(axis_codes[i])) {
62
       const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
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
   // 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)
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
   LOOP_XYZE(i)
79
   LOOP_XYZE(i)
80
     if (parser.seen(axis_codes[i])) {
80
     if (parser.seen(axis_codes[i])) {
81
       const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
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
 void GcodeSuite::M204() {
93
 void GcodeSuite::M204() {
94
   bool report = true;
94
   bool report = true;
95
   if (parser.seenval('S')) { // Kept for legacy compatibility. Should NOT BE USED for new developments.
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
     report = false;
97
     report = false;
98
   }
98
   }
99
   if (parser.seenval('P')) {
99
   if (parser.seenval('P')) {
100
-    planner.acceleration = parser.value_linear_units();
100
+    planner.settings.acceleration = parser.value_linear_units();
101
     report = false;
101
     report = false;
102
   }
102
   }
103
   if (parser.seenval('R')) {
103
   if (parser.seenval('R')) {
104
-    planner.retract_acceleration = parser.value_linear_units();
104
+    planner.settings.retract_acceleration = parser.value_linear_units();
105
     report = false;
105
     report = false;
106
   }
106
   }
107
   if (parser.seenval('T')) {
107
   if (parser.seenval('T')) {
108
-    planner.travel_acceleration = parser.value_linear_units();
108
+    planner.settings.travel_acceleration = parser.value_linear_units();
109
     report = false;
109
     report = false;
110
   }
110
   }
111
   if (report) {
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
  *    J = Junction Deviation (mm) (Requires JUNCTION_DEVIATION)
128
  *    J = Junction Deviation (mm) (Requires JUNCTION_DEVIATION)
129
  */
129
  */
130
 void GcodeSuite::M205() {
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
   #if ENABLED(JUNCTION_DEVIATION)
134
   #if ENABLED(JUNCTION_DEVIATION)
135
     if (parser.seen('J')) {
135
     if (parser.seen('J')) {
136
       const float junc_dev = parser.value_linear_units();
136
       const float junc_dev = parser.value_linear_units();

+ 6
- 6
Marlin/src/gcode/config/M217.cpp Parādīt failu

36
     const int16_t port = command_queue_port[cmd_queue_index_r];
36
     const int16_t port = command_queue_port[cmd_queue_index_r];
37
   #endif
37
   #endif
38
   serialprintPGM_P(port, eeprom ? PSTR("  M217") : PSTR("Singlenozzle:"));
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
 
52
 
53
   bool report = true;
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
   if (report) M217_report();
59
   if (report) M217_report();
60
 
60
 

+ 1
- 1
Marlin/src/gcode/config/M218.cpp Parādīt failu

72
 
72
 
73
   #if ENABLED(DELTA)
73
   #if ENABLED(DELTA)
74
     if (target_extruder == active_extruder)
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
   #endif
76
   #endif
77
 }
77
 }
78
 
78
 

+ 6
- 6
Marlin/src/gcode/config/M304.cpp Parādīt failu

28
 #include "../../module/temperature.h"
28
 #include "../../module/temperature.h"
29
 
29
 
30
 void GcodeSuite::M304() {
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
   SERIAL_ECHO_START();
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
 #endif // PIDTEMPBED
41
 #endif // PIDTEMPBED

+ 4
- 4
Marlin/src/gcode/config/M92.cpp Parādīt failu

38
       if (i == E_AXIS) {
38
       if (i == E_AXIS) {
39
         const float value = parser.value_per_axis_unit((AxisEnum)(E_AXIS + TARGET_EXTRUDER));
39
         const float value = parser.value_per_axis_unit((AxisEnum)(E_AXIS + TARGET_EXTRUDER));
40
         if (value < 20) {
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
           #if HAS_CLASSIC_JERK && (DISABLED(JUNCTION_DEVIATION) || DISABLED(LIN_ADVANCE))
42
           #if HAS_CLASSIC_JERK && (DISABLED(JUNCTION_DEVIATION) || DISABLED(LIN_ADVANCE))
43
             planner.max_jerk[E_AXIS] *= factor;
43
             planner.max_jerk[E_AXIS] *= factor;
44
           #endif
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
           planner.max_acceleration_steps_per_s2[E_AXIS + TARGET_EXTRUDER] *= factor;
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
       else {
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 Parādīt failu

36
  *   Z[units]     retract_zlift
36
  *   Z[units]     retract_zlift
37
  */
37
  */
38
 void GcodeSuite::M207() {
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
  *   R[units/min] swap_retract_recover_feedrate_mm_s
51
  *   R[units/min] swap_retract_recover_feedrate_mm_s
52
  */
52
  */
53
 void GcodeSuite::M208() {
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
 #if ENABLED(FWRETRACT_AUTORETRACT)
60
 #if ENABLED(FWRETRACT_AUTORETRACT)

+ 2
- 2
Marlin/src/gcode/feature/pause/M600.cpp Parādīt failu

111
 
111
 
112
   // Unload filament
112
   // Unload filament
113
   const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS)
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
   // Slow load filament
116
   // Slow load filament
117
   constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
117
   constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
118
 
118
 
119
   // Fast load filament
119
   // Fast load filament
120
   const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
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
   const int beep_count = parser.intval('B',
123
   const int beep_count = parser.intval('B',
124
     #ifdef FILAMENT_CHANGE_ALERT_BEEPS
124
     #ifdef FILAMENT_CHANGE_ALERT_BEEPS

+ 4
- 4
Marlin/src/gcode/feature/pause/M603.cpp Parādīt failu

47
 
47
 
48
   // Unload length
48
   // Unload length
49
   if (parser.seen('U')) {
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
     #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
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
     #endif
53
     #endif
54
   }
54
   }
55
 
55
 
56
   // Load length
56
   // Load length
57
   if (parser.seen('L')) {
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
     #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
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
     #endif
61
     #endif
62
   }
62
   }
63
 }
63
 }

+ 3
- 3
Marlin/src/gcode/feature/pause/M701_M702.cpp Parādīt failu

79
   // Load filament
79
   // Load filament
80
   constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
80
   constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
81
   const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)
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
   load_filament(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, FILAMENT_CHANGE_ALERT_BEEPS,
83
   load_filament(slow_load_length, fast_load_length, ADVANCED_PAUSE_PURGE_LENGTH, FILAMENT_CHANGE_ALERT_BEEPS,
84
                 true, thermalManager.still_heating(target_extruder), ADVANCED_PAUSE_MODE_LOAD_FILAMENT
84
                 true, thermalManager.still_heating(target_extruder), ADVANCED_PAUSE_MODE_LOAD_FILAMENT
85
                 #if ENABLED(DUAL_X_CARRIAGE)
85
                 #if ENABLED(DUAL_X_CARRIAGE)
147
     if (!parser.seenval('T')) {
147
     if (!parser.seenval('T')) {
148
       HOTEND_LOOP() {
148
       HOTEND_LOOP() {
149
         if (e != active_extruder) tool_change(e, 0, true);
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
     else
153
     else
155
   {
155
   {
156
     // Unload length
156
     // Unload length
157
     const float unload_length = -ABS(parser.seen('U') ? parser.value_axis_units(E_AXIS) :
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
     unload_filament(unload_length, true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
160
     unload_filament(unload_length, true, ADVANCED_PAUSE_MODE_UNLOAD_FILAMENT);
161
   }
161
   }

+ 4
- 4
Marlin/src/gcode/feature/trinamic/M911-M915.cpp Parādīt failu

161
  */
161
  */
162
 #if ENABLED(HYBRID_THRESHOLD)
162
 #if ENABLED(HYBRID_THRESHOLD)
163
   void GcodeSuite::M913() {
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
     bool report = true;
169
     bool report = true;
170
     const uint8_t index = parser.byteval('I');
170
     const uint8_t index = parser.byteval('I');

+ 1
- 1
Marlin/src/gcode/gcode.h Parādīt failu

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

+ 2
- 2
Marlin/src/gcode/motion/M290.cpp Parādīt failu

64
     for (uint8_t a = X_AXIS; a <= Z_AXIS; a++)
64
     for (uint8_t a = X_AXIS; a <= Z_AXIS; a++)
65
       if (parser.seenval(axis_codes[a]) || (a == Z_AXIS && parser.seenval('S'))) {
65
       if (parser.seenval(axis_codes[a]) || (a == Z_AXIS && parser.seenval('S'))) {
66
         const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2);
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
         #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
68
         #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
69
           if (a == Z_AXIS && (!parser.seen('P') || parser.value_bool())) mod_zprobe_zoffset(offs);
69
           if (a == Z_AXIS && (!parser.seen('P') || parser.value_bool())) mod_zprobe_zoffset(offs);
70
         #endif
70
         #endif
72
   #else
72
   #else
73
     if (parser.seenval('Z') || parser.seenval('S')) {
73
     if (parser.seenval('Z') || parser.seenval('S')) {
74
       const float offs = constrain(parser.value_axis_units(Z_AXIS), -2, 2);
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
       #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
76
       #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
77
         if (!parser.seen('P') || parser.value_bool()) mod_zprobe_zoffset(offs);
77
         if (!parser.seen('P') || parser.value_bool()) mod_zprobe_zoffset(offs);
78
       #endif
78
       #endif

+ 22
- 22
Marlin/src/lcd/extensible_ui/ui_api.cpp Parādīt failu

147
   float getAxisSteps_per_mm(const axis_t axis) {
147
   float getAxisSteps_per_mm(const axis_t axis) {
148
     switch (axis) {
148
     switch (axis) {
149
       case X: case Y: case Z:
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
       case E0: case E1: case E2: case E3: case E4: case E5:
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
       default: return 0;
153
       default: return 0;
154
     }
154
     }
155
   }
155
   }
157
   void setAxisSteps_per_mm(const axis_t axis, const float steps_per_mm) {
157
   void setAxisSteps_per_mm(const axis_t axis, const float steps_per_mm) {
158
     switch (axis) {
158
     switch (axis) {
159
       case X: case Y: case Z:
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
         break;
161
         break;
162
       case E0: case E1: case E2: case E3: case E4: case E5:
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
         break;
164
         break;
165
     }
165
     }
166
   }
166
   }
168
   float getAxisMaxFeedrate_mm_s(const axis_t axis) {
168
   float getAxisMaxFeedrate_mm_s(const axis_t axis) {
169
     switch (axis) {
169
     switch (axis) {
170
       case X: case Y: case Z:
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
       case E0: case E1: case E2: case E3: case E4: case E5:
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
       default: return 0;
174
       default: return 0;
175
     }
175
     }
176
   }
176
   }
178
   void setAxisMaxFeedrate_mm_s(const axis_t axis, const float max_feedrate_mm_s) {
178
   void setAxisMaxFeedrate_mm_s(const axis_t axis, const float max_feedrate_mm_s) {
179
     switch (axis) {
179
     switch (axis) {
180
       case X: case Y: case Z:
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
         break;
182
         break;
183
       case E0: case E1: case E2: case E3: case E4: case E5:
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
         break;
185
         break;
186
       default: return;
186
       default: return;
187
     }
187
     }
190
   float getAxisMaxAcceleration_mm_s2(const axis_t axis) {
190
   float getAxisMaxAcceleration_mm_s2(const axis_t axis) {
191
     switch (axis) {
191
     switch (axis) {
192
       case X: case Y: case Z:
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
       case E0: case E1: case E2: case E3: case E4: case E5:
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
       default: return 0;
196
       default: return 0;
197
     }
197
     }
198
   }
198
   }
200
   void setAxisMaxAcceleration_mm_s2(const axis_t axis, const float max_acceleration_mm_per_s2) {
200
   void setAxisMaxAcceleration_mm_s2(const axis_t axis, const float max_acceleration_mm_per_s2) {
201
     switch (axis) {
201
     switch (axis) {
202
       case X: case Y: case Z:
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
         break;
204
         break;
205
       case E0: case E1: case E2: case E3: case E4: case E5:
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
         break;
207
         break;
208
       default: return;
208
       default: return;
209
     }
209
     }
253
     }
253
     }
254
   #endif
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
   #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
267
   #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
268
     float getZOffset_mm() {
268
     float getZOffset_mm() {

+ 66
- 66
Marlin/src/lcd/ultralcd.cpp Parādīt failu

980
     void singlenozzle_swap_menu() {
980
     void singlenozzle_swap_menu() {
981
       START_MENU();
981
       START_MENU();
982
       MENU_BACK(MSG_MAIN);
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
       END_MENU();
986
       END_MENU();
987
     }
987
     }
988
   #endif
988
   #endif
3818
         if (e == active_extruder)
3818
         if (e == active_extruder)
3819
           _planner_refresh_positioning();
3819
           _planner_refresh_positioning();
3820
         else
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
       void _planner_refresh_e0_positioning() { _planner_refresh_e_positioning(0); }
3823
       void _planner_refresh_e0_positioning() { _planner_refresh_e_positioning(0); }
3824
       void _planner_refresh_e1_positioning() { _planner_refresh_e_positioning(1); }
3824
       void _planner_refresh_e1_positioning() { _planner_refresh_e_positioning(1); }
3842
       MENU_BACK(MSG_ADVANCED_SETTINGS);
3842
       MENU_BACK(MSG_ADVANCED_SETTINGS);
3843
 
3843
 
3844
       // M203 Max Feedrate
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
       #if ENABLED(DISTINCT_E_FACTORS)
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
         #if E_STEPPERS > 2
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
           #if E_STEPPERS > 3
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
             #if E_STEPPERS > 4
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
               #if E_STEPPERS > 5
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
               #endif // E_STEPPERS > 5
3861
               #endif // E_STEPPERS > 5
3862
             #endif // E_STEPPERS > 4
3862
             #endif // E_STEPPERS > 4
3863
           #endif // E_STEPPERS > 3
3863
           #endif // E_STEPPERS > 3
3864
         #endif // E_STEPPERS > 2
3864
         #endif // E_STEPPERS > 2
3865
       #else
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
       #endif
3867
       #endif
3868
 
3868
 
3869
       // M205 S Min Feedrate
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
       // M205 T Min Travel Feedrate
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
       END_MENU();
3875
       END_MENU();
3876
     }
3876
     }
3881
       MENU_BACK(MSG_ADVANCED_SETTINGS);
3881
       MENU_BACK(MSG_ADVANCED_SETTINGS);
3882
 
3882
 
3883
       // M204 P Acceleration
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
       // M204 R Retract Acceleration
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
       // M204 T Travel Acceleration
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
       // M201 settings
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
       #if ENABLED(DISTINCT_E_FACTORS)
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
         #if E_STEPPERS > 2
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
           #if E_STEPPERS > 3
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
             #if E_STEPPERS > 4
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
               #if E_STEPPERS > 5
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
               #endif // E_STEPPERS > 5
3909
               #endif // E_STEPPERS > 5
3910
             #endif // E_STEPPERS > 4
3910
             #endif // E_STEPPERS > 4
3911
           #endif // E_STEPPERS > 3
3911
           #endif // E_STEPPERS > 3
3912
         #endif // E_STEPPERS > 2
3912
         #endif // E_STEPPERS > 2
3913
       #else
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
       #endif
3915
       #endif
3916
 
3916
 
3917
       END_MENU();
3917
       END_MENU();
3950
       START_MENU();
3950
       START_MENU();
3951
       MENU_BACK(MSG_ADVANCED_SETTINGS);
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
       #if ENABLED(DISTINCT_E_FACTORS)
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
         #if E_STEPPERS > 2
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
           #if E_STEPPERS > 3
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
             #if E_STEPPERS > 4
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
               #if E_STEPPERS > 5
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
               #endif // E_STEPPERS > 5
3969
               #endif // E_STEPPERS > 5
3970
             #endif // E_STEPPERS > 4
3970
             #endif // E_STEPPERS > 4
3971
           #endif // E_STEPPERS > 3
3971
           #endif // E_STEPPERS > 3
3972
         #endif // E_STEPPERS > 2
3972
         #endif // E_STEPPERS > 2
3973
       #else
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
       #endif
3975
       #endif
3976
 
3976
 
3977
       END_MENU();
3977
       END_MENU();
4159
         ;
4159
         ;
4160
 
4160
 
4161
         #if EXTRUDERS == 1
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
         #else // EXTRUDERS > 1
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
           #if EXTRUDERS > 2
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
             #if EXTRUDERS > 3
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
               #if EXTRUDERS > 4
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
                 #if EXTRUDERS > 5
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
                 #endif // EXTRUDERS > 5
4175
                 #endif // EXTRUDERS > 5
4176
               #endif // EXTRUDERS > 4
4176
               #endif // EXTRUDERS > 4
4177
             #endif // EXTRUDERS > 3
4177
             #endif // EXTRUDERS > 3
4179
         #endif // EXTRUDERS > 1
4179
         #endif // EXTRUDERS > 1
4180
 
4180
 
4181
         #if EXTRUDERS == 1
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
         #else // EXTRUDERS > 1
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
           #if EXTRUDERS > 2
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
             #if EXTRUDERS > 3
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
               #if EXTRUDERS > 4
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
                 #if EXTRUDERS > 5
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
                 #endif // EXTRUDERS > 5
4195
                 #endif // EXTRUDERS > 5
4196
               #endif // EXTRUDERS > 4
4196
               #endif // EXTRUDERS > 4
4197
             #endif // EXTRUDERS > 3
4197
             #endif // EXTRUDERS > 3
4216
       #if ENABLED(FWRETRACT_AUTORETRACT)
4216
       #if ENABLED(FWRETRACT_AUTORETRACT)
4217
         MENU_ITEM_EDIT_CALLBACK(bool, MSG_AUTORETRACT, &fwretract.autoretract_enabled, fwretract.refresh_autoretract);
4217
         MENU_ITEM_EDIT_CALLBACK(bool, MSG_AUTORETRACT, &fwretract.autoretract_enabled, fwretract.refresh_autoretract);
4218
       #endif
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
       #if EXTRUDERS > 1
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
       #endif
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
       #if EXTRUDERS > 1
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
       #endif
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
       #if EXTRUDERS > 1
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
       #endif
4232
       #endif
4233
       END_MENU();
4233
       END_MENU();
4234
     }
4234
     }

+ 585
- 654
Marlin/src/module/configuration_store.cpp
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 3
- 3
Marlin/src/module/motion.cpp Parādīt failu

817
             #define RAISED_Y raised_parked_position[Y_AXIS]
817
             #define RAISED_Y raised_parked_position[Y_AXIS]
818
             #define RAISED_Z raised_parked_position[Z_AXIS]
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
               if (planner.buffer_line(   CUR_X,    CUR_Y, RAISED_Z, CUR_E, PLANNER_XY_FEEDRATE(),             active_extruder))
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
           delayed_move_time = 0;
823
           delayed_move_time = 0;
824
           active_extruder_parked = false;
824
           active_extruder_parked = false;
825
           #if ENABLED(DEBUG_LEVELING_FEATURE)
825
           #if ENABLED(DEBUG_LEVELING_FEATURE)
841
             if (!planner.buffer_line(
841
             if (!planner.buffer_line(
842
                 dual_x_carriage_mode == DXC_DUPLICATION_MODE ? duplicate_extruder_x_offset + current_position[X_AXIS] : inactive_extruder_x_pos,
842
                 dual_x_carriage_mode == DXC_DUPLICATION_MODE ? duplicate_extruder_x_offset + current_position[X_AXIS] : inactive_extruder_x_pos,
843
                 current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS],
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
             ) break;
846
             ) break;
847
             planner.synchronize();
847
             planner.synchronize();

+ 31
- 49
Marlin/src/module/planner.cpp Parādīt failu

111
 uint16_t Planner::cleaning_buffer_counter;      // A counter to disable queuing of blocks
111
 uint16_t Planner::cleaning_buffer_counter;      // A counter to disable queuing of blocks
112
 uint8_t Planner::delay_before_delivering;       // This counter delays delivery of blocks when queue becomes empty to allow the opportunity of merging blocks
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
 #if ENABLED(JUNCTION_DEVIATION)
120
 #if ENABLED(JUNCTION_DEVIATION)
128
   float Planner::junction_deviation_mm;       // (mm) M205 J
121
   float Planner::junction_deviation_mm;       // (mm) M205 J
177
   constexpr bool Planner::leveling_active;
170
   constexpr bool Planner::leveling_active;
178
 #endif
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
 #if ENABLED(AUTOTEMP)
175
 #if ENABLED(AUTOTEMP)
194
   float Planner::autotemp_max = 250,
176
   float Planner::autotemp_max = 250,
1094
             calculate_trapezoid_for_block(current, current_entry_speed * nomr, next_entry_speed * nomr);
1076
             calculate_trapezoid_for_block(current, current_entry_speed * nomr, next_entry_speed * nomr);
1095
             #if ENABLED(LIN_ADVANCE)
1077
             #if ENABLED(LIN_ADVANCE)
1096
               if (current->use_advance_lead) {
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
                 current->max_adv_steps = current_nominal_speed * comp;
1080
                 current->max_adv_steps = current_nominal_speed * comp;
1099
                 current->final_adv_steps = next_entry_speed * comp;
1081
                 current->final_adv_steps = next_entry_speed * comp;
1100
               }
1082
               }
1133
       calculate_trapezoid_for_block(next, next_entry_speed * nomr, float(MINIMUM_PLANNER_SPEED) * nomr);
1115
       calculate_trapezoid_for_block(next, next_entry_speed * nomr, float(MINIMUM_PLANNER_SPEED) * nomr);
1134
       #if ENABLED(LIN_ADVANCE)
1116
       #if ENABLED(LIN_ADVANCE)
1135
         if (next->use_advance_lead) {
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
           next->max_adv_steps = next_nominal_speed * comp;
1119
           next->max_adv_steps = next_nominal_speed * comp;
1138
           next->final_adv_steps = (MINIMUM_PLANNER_SPEED) * comp;
1120
           next->final_adv_steps = (MINIMUM_PLANNER_SPEED) * comp;
1139
         }
1121
         }
1687
         }
1669
         }
1688
       #endif // PREVENT_COLD_EXTRUSION
1670
       #endif // PREVENT_COLD_EXTRUSION
1689
       #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
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
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
1673
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
1692
           #if HAS_POSITION_FLOAT
1674
           #if HAS_POSITION_FLOAT
1693
             position_float[E_AXIS] = target_float[E_AXIS];
1675
             position_float[E_AXIS] = target_float[E_AXIS];
1946
   }
1928
   }
1947
 
1929
 
1948
   if (esteps)
1930
   if (esteps)
1949
-    NOLESS(fr_mm_s, min_feedrate_mm_s);
1931
+    NOLESS(fr_mm_s, settings.min_feedrate_mm_s);
1950
   else
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
    * This part of the code calculates the total length of the movement.
1936
    * This part of the code calculates the total length of the movement.
2023
 
2005
 
2024
   #if ENABLED(SLOWDOWN)
2006
   #if ENABLED(SLOWDOWN)
2025
     if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) {
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
         // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
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
         inverse_secs = 1000000.0f / nst;
2011
         inverse_secs = 1000000.0f / nst;
2030
         #if defined(XY_FREQUENCY_LIMIT) || ENABLED(ULTRA_LCD)
2012
         #if defined(XY_FREQUENCY_LIMIT) || ENABLED(ULTRA_LCD)
2031
           segment_time_us = nst;
2013
           segment_time_us = nst;
2100
     #if ENABLED(DISTINCT_E_FACTORS)
2082
     #if ENABLED(DISTINCT_E_FACTORS)
2101
       if (i == E_AXIS) i += extruder;
2083
       if (i == E_AXIS) i += extruder;
2102
     #endif
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
   // Max segment time in µs.
2088
   // Max segment time in µs.
2153
   uint32_t accel;
2135
   uint32_t accel;
2154
   if (!block->steps[A_AXIS] && !block->steps[B_AXIS] && !block->steps[C_AXIS]) {
2136
   if (!block->steps[A_AXIS] && !block->steps[B_AXIS] && !block->steps[C_AXIS]) {
2155
     // convert to: acceleration steps/sec^2
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
     #if ENABLED(LIN_ADVANCE)
2139
     #if ENABLED(LIN_ADVANCE)
2158
       block->use_advance_lead = false;
2140
       block->use_advance_lead = false;
2159
     #endif
2141
     #endif
2174
     }while(0)
2156
     }while(0)
2175
 
2157
 
2176
     // Start with print or travel acceleration
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
     #if ENABLED(LIN_ADVANCE)
2161
     #if ENABLED(LIN_ADVANCE)
2180
 
2162
 
2254
   #endif
2236
   #endif
2255
   #if ENABLED(LIN_ADVANCE)
2237
   #if ENABLED(LIN_ADVANCE)
2256
     if (block->use_advance_lead) {
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
       #if ENABLED(LA_DEBUG)
2240
       #if ENABLED(LA_DEBUG)
2259
         if (extruder_advance_K[active_extruder] * block->e_D_ratio * block->acceleration * 2 < SQRT(block->nominal_speed_sqr) * block->e_D_ratio)
2241
         if (extruder_advance_K[active_extruder] * block->e_D_ratio * block->acceleration * 2 < SQRT(block->nominal_speed_sqr) * block->e_D_ratio)
2260
           SERIAL_ECHOLNPGM("More than 2 steps per eISR loop executed.");
2242
           SERIAL_ECHOLNPGM("More than 2 steps per eISR loop executed.");
2566
 
2548
 
2567
   // When changing extruders recalculate steps corresponding to the E position
2549
   // When changing extruders recalculate steps corresponding to the E position
2568
   #if ENABLED(DISTINCT_E_FACTORS)
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
       last_extruder = extruder;
2553
       last_extruder = extruder;
2572
     }
2554
     }
2573
   #endif
2555
   #endif
2575
   // The target position of the tool in absolute steps
2557
   // The target position of the tool in absolute steps
2576
   // Calculate target position in absolute steps
2558
   // Calculate target position in absolute steps
2577
   const int32_t target[ABCE] = {
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
   #if HAS_POSITION_FLOAT
2566
   #if HAS_POSITION_FLOAT
2714
   #if ENABLED(DISTINCT_E_FACTORS)
2696
   #if ENABLED(DISTINCT_E_FACTORS)
2715
     last_extruder = active_extruder;
2697
     last_extruder = active_extruder;
2716
   #endif
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
   #if HAS_POSITION_FLOAT
2703
   #if HAS_POSITION_FLOAT
2722
     position_float[A_AXIS] = a;
2704
     position_float[A_AXIS] = a;
2723
     position_float[B_AXIS] = b;
2705
     position_float[B_AXIS] = b;
2770
   #else
2752
   #else
2771
     const float e_new = e;
2753
     const float e_new = e;
2772
   #endif
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
   #if HAS_POSITION_FLOAT
2756
   #if HAS_POSITION_FLOAT
2775
     position_float[E_AXIS] = e_new;
2757
     position_float[E_AXIS] = e_new;
2776
   #endif
2758
   #endif
2792
   #endif
2774
   #endif
2793
   uint32_t highest_rate = 1;
2775
   uint32_t highest_rate = 1;
2794
   LOOP_XYZE_N(i) {
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
     if (AXIS_CONDITION) NOLESS(highest_rate, max_acceleration_steps_per_s2[i]);
2778
     if (AXIS_CONDITION) NOLESS(highest_rate, max_acceleration_steps_per_s2[i]);
2797
   }
2779
   }
2798
   cutoff_long = 4294967295UL / highest_rate; // 0xFFFFFFFFUL
2780
   cutoff_long = 4294967295UL / highest_rate; // 0xFFFFFFFFUL
2801
   #endif
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
 void Planner::refresh_positioning() {
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
   set_position_mm(current_position);
2789
   set_position_mm(current_position);
2808
   reset_acceleration_rates();
2790
   reset_acceleration_rates();
2809
 }
2791
 }

+ 50
- 40
Marlin/src/module/planner.h Parādīt failu

19
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
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
  * planner.h
25
  * planner.h
29
  * Copyright (c) 2009-2011 Simen Svale Skogsrud
30
  * Copyright (c) 2009-2011 Simen Svale Skogsrud
30
  */
31
  */
31
 
32
 
32
-#ifndef PLANNER_H
33
-#define PLANNER_H
34
-
35
 #include "../Marlin.h"
33
 #include "../Marlin.h"
36
 
34
 
37
 #include "motion.h"
35
 #include "motion.h"
159
 
157
 
160
 #define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
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
 class Planner {
196
 class Planner {
163
   public:
197
   public:
164
 
198
 
199
                                                       // May be auto-adjusted by a filament width sensor
233
                                                       // May be auto-adjusted by a filament width sensor
200
     #endif
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
     #if ENABLED(JUNCTION_DEVIATION)
241
     #if ENABLED(JUNCTION_DEVIATION)
215
       static float junction_deviation_mm;       // (mm) M205 J
242
       static float junction_deviation_mm;       // (mm) M205 J
256
       static float position_cart[XYZE];
283
       static float position_cart[XYZE];
257
     #endif
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
     #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
288
     #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
277
       static bool abort_on_endstop_hit;
289
       static bool abort_on_endstop_hit;
419
 
431
 
420
       FORCE_INLINE static void skew(float &cx, float &cy, const float &cz) {
432
       FORCE_INLINE static void skew(float &cx, float &cy, const float &cz) {
421
         if (WITHIN(cx, X_MIN_POS + 1, X_MAX_POS) && WITHIN(cy, Y_MIN_POS + 1, Y_MAX_POS)) {
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
           if (WITHIN(sx, X_MIN_POS, X_MAX_POS) && WITHIN(sy, Y_MIN_POS, Y_MAX_POS)) {
436
           if (WITHIN(sx, X_MIN_POS, X_MAX_POS) && WITHIN(sy, Y_MIN_POS, Y_MAX_POS)) {
425
             cx = sx; cy = sy;
437
             cx = sx; cy = sy;
426
           }
438
           }
431
 
443
 
432
       FORCE_INLINE static void unskew(float &cx, float &cy, const float &cz) {
444
       FORCE_INLINE static void unskew(float &cx, float &cy, const float &cz) {
433
         if (WITHIN(cx, X_MIN_POS, X_MAX_POS) && WITHIN(cy, Y_MIN_POS, Y_MAX_POS)) {
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
           if (WITHIN(sx, X_MIN_POS, X_MAX_POS) && WITHIN(sy, Y_MIN_POS, Y_MAX_POS)) {
448
           if (WITHIN(sx, X_MIN_POS, X_MAX_POS) && WITHIN(sy, Y_MIN_POS, Y_MAX_POS)) {
437
             cx = sx; cy = sy;
449
             cx = sx; cy = sy;
438
           }
450
           }
848
         #define GET_MAX_E_JERK(N) SQRT(SQRT(0.5) * junction_deviation_mm * (N) * RECIPROCAL(1.0 - SQRT(0.5)))
860
         #define GET_MAX_E_JERK(N) SQRT(SQRT(0.5) * junction_deviation_mm * (N) * RECIPROCAL(1.0 - SQRT(0.5)))
849
         #if ENABLED(DISTINCT_E_FACTORS)
861
         #if ENABLED(DISTINCT_E_FACTORS)
850
           for (uint8_t i = 0; i < EXTRUDERS; i++)
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
         #else
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
         #endif
866
         #endif
855
       }
867
       }
856
     #endif
868
     #endif
927
       FORCE_INLINE static float limit_value_by_axis_maximum(const float &max_value, float (&unit_vec)[XYZE]) {
939
       FORCE_INLINE static float limit_value_by_axis_maximum(const float &max_value, float (&unit_vec)[XYZE]) {
928
         float limit_value = max_value;
940
         float limit_value = max_value;
929
         LOOP_XYZE(idx) if (unit_vec[idx]) // Avoid divide by zero
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
         return limit_value;
943
         return limit_value;
932
       }
944
       }
933
 
945
 
934
     #endif // JUNCTION_DEVIATION
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
 extern Planner planner;
951
 extern Planner planner;
940
-
941
-#endif // PLANNER_H

+ 2
- 2
Marlin/src/module/stepper.cpp Parādīt failu

2413
 #if HAS_MOTOR_CURRENT_PWM
2413
 #if HAS_MOTOR_CURRENT_PWM
2414
 
2414
 
2415
   void Stepper::refresh_motor_power() {
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
       switch (i) {
2417
       switch (i) {
2418
         #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
2418
         #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
2419
           case 0:
2419
           case 0:
2443
 
2443
 
2444
     #elif HAS_MOTOR_CURRENT_PWM
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
         motor_current_setting[driver] = current; // update motor_current_setting
2447
         motor_current_setting[driver] = current; // update motor_current_setting
2448
 
2448
 
2449
       #define _WRITE_CURRENT_PWM(P) analogWrite(MOTOR_CURRENT_PWM_## P ##_PIN, 255L * current / (MOTOR_CURRENT_PWM_RANGE))
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 Parādīt failu

606
   #endif
606
   #endif
607
 
607
 
608
   #if AXIS_IS_TMC(X)
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
   #endif
610
   #endif
611
   #if AXIS_IS_TMC(X2)
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
   #endif
613
   #endif
614
   #if AXIS_IS_TMC(Y)
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
   #endif
616
   #endif
617
   #if AXIS_IS_TMC(Y2)
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
   #endif
619
   #endif
620
   #if AXIS_IS_TMC(Z)
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
   #endif
622
   #endif
623
   #if AXIS_IS_TMC(Z2)
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
   #endif
625
   #endif
626
   #if AXIS_IS_TMC(Z3)
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
   #endif
628
   #endif
629
   #if AXIS_IS_TMC(E0)
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
   #endif
631
   #endif
632
   #if AXIS_IS_TMC(E1)
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
   #endif
634
   #endif
635
   #if AXIS_IS_TMC(E2)
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
   #endif
637
   #endif
638
   #if AXIS_IS_TMC(E3)
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
   #endif
640
   #endif
641
   #if AXIS_IS_TMC(E4)
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
   #endif
643
   #endif
644
   #if AXIS_IS_TMC(E5)
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
   #endif
646
   #endif
647
 
647
 
648
   #if USE_SENSORLESS
648
   #if USE_SENSORLESS

+ 138
- 152
Marlin/src/module/temperature.cpp Parādīt failu

116
     millis_t Temperature::watch_bed_next_ms = 0;
116
     millis_t Temperature::watch_bed_next_ms = 0;
117
   #endif
117
   #endif
118
   #if ENABLED(PIDTEMPBED)
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
   #else
120
   #else
127
     millis_t Temperature::next_bed_check_ms;
121
     millis_t Temperature::next_bed_check_ms;
128
   #endif
122
   #endif
141
 
135
 
142
 // Initialized by settings.load()
136
 // Initialized by settings.load()
143
 #if ENABLED(PIDTEMP)
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
 #endif
139
 #endif
156
 
140
 
157
 #if ENABLED(BABYSTEPPING)
141
 #if ENABLED(BABYSTEPPING)
182
 volatile bool Temperature::temp_meas_ready = false;
166
 volatile bool Temperature::temp_meas_ready = false;
183
 
167
 
184
 #if ENABLED(PIDTEMP)
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
   #if ENABLED(PID_EXTRUSION_SCALING)
169
   #if ENABLED(PID_EXTRUSION_SCALING)
192
-    float Temperature::cTerm[HOTENDS];
193
     long Temperature::last_e_position;
170
     long Temperature::last_e_position;
194
     long Temperature::lpq[LPQ_MAX_LEN];
171
     long Temperature::lpq[LPQ_MAX_LEN];
195
     int Temperature::lpq_ptr = 0;
172
     int Temperature::lpq_ptr = 0;
196
   #endif
173
   #endif
197
-
198
-  float Temperature::pid_error[HOTENDS];
199
-  bool Temperature::pid_reset[HOTENDS];
200
 #endif
174
 #endif
201
 
175
 
202
 uint16_t Temperature::raw_temp_value[MAX_EXTRUDERS] = { 0 };
176
 uint16_t Temperature::raw_temp_value[MAX_EXTRUDERS] = { 0 };
254
 
228
 
255
 #if HAS_PID_HEATING
229
 #if HAS_PID_HEATING
256
 
230
 
231
+  inline void say_default_() { SERIAL_PROTOCOLPGM("#define DEFAULT_"); }
232
+
257
   /**
233
   /**
258
    * PID Autotuning (M303)
234
    * PID Autotuning (M303)
259
    *
235
    *
269
     long t_high = 0, t_low = 0;
245
     long t_high = 0, t_low = 0;
270
 
246
 
271
     long bias, d;
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
     #if HAS_PID_FOR_BOTH
251
     #if HAS_PID_FOR_BOTH
277
       #define GHV(B,H) (hotend < 0 ? (B) : (H))
252
       #define GHV(B,H) (hotend < 0 ? (B) : (H))
375
               SERIAL_PROTOCOLPAIR(MSG_T_MIN, min);
350
               SERIAL_PROTOCOLPAIR(MSG_T_MIN, min);
376
               SERIAL_PROTOCOLPAIR(MSG_T_MAX, max);
351
               SERIAL_PROTOCOLPAIR(MSG_T_MAX, max);
377
               if (cycles > 2) {
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
                 SERIAL_PROTOCOLPAIR(MSG_KU, Ku);
355
                 SERIAL_PROTOCOLPAIR(MSG_KU, Ku);
381
                 SERIAL_PROTOCOLPAIR(MSG_TU, Tu);
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
                 SERIAL_PROTOCOLLNPGM("\n" MSG_CLASSIC_PID);
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
                 SERIAL_PROTOCOLLNPGM(" Some overshoot");
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
                 SERIAL_PROTOCOLLNPGM(" No overshoot");
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
         SERIAL_PROTOCOLLNPGM(MSG_PID_AUTOTUNE_FINISHED);
442
         SERIAL_PROTOCOLLNPGM(MSG_PID_AUTOTUNE_FINISHED);
468
 
443
 
469
         #if HAS_PID_FOR_BOTH
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
         #elif ENABLED(PIDTEMP)
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
         #else
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
         #endif
457
         #endif
483
 
458
 
484
         #define _SET_BED_PID() do { \
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
         }while(0)
463
         }while(0)
489
 
464
 
490
         #define _SET_EXTRUDER_PID() do { \
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
           updatePID(); }while(0)
469
           updatePID(); }while(0)
495
 
470
 
496
         // Use the result? (As with "M303 U1")
471
         // Use the result? (As with "M303 U1")
497
         if (set_result) {
472
         if (set_result) {
498
           #if HAS_PID_FOR_BOTH
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
           #elif ENABLED(PIDTEMP)
475
           #elif ENABLED(PIDTEMP)
504
             _SET_EXTRUDER_PID();
476
             _SET_EXTRUDER_PID();
505
           #else
477
           #else
612
 float Temperature::get_pid_output(const int8_t e) {
584
 float Temperature::get_pid_output(const int8_t e) {
613
   #if HOTENDS == 1
585
   #if HOTENDS == 1
614
     UNUSED(e);
586
     UNUSED(e);
615
-    #define _HOTEND_TEST     true
587
+    #define _HOTEND_TEST true
616
   #else
588
   #else
617
-    #define _HOTEND_TEST     e == active_extruder
589
+    #define _HOTEND_TEST (e == active_extruder)
618
   #endif
590
   #endif
619
-  float pid_output;
620
   #if ENABLED(PIDTEMP)
591
   #if ENABLED(PIDTEMP)
621
     #if DISABLED(PID_OPENLOOP)
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
       temp_dState[HOTEND_INDEX] = current_temperature[HOTEND_INDEX];
600
       temp_dState[HOTEND_INDEX] = current_temperature[HOTEND_INDEX];
625
       #if HEATER_IDLE_HANDLER
601
       #if HEATER_IDLE_HANDLER
626
         if (heater_idle_timeout_exceeded[HOTEND_INDEX]) {
602
         if (heater_idle_timeout_exceeded[HOTEND_INDEX]) {
629
         }
605
         }
630
         else
606
         else
631
       #endif
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
     #endif // PID_OPENLOOP
662
     #endif // PID_OPENLOOP
684
 
663
 
685
     #if ENABLED(PID_DEBUG)
664
     #if ENABLED(PID_DEBUG)
687
       SERIAL_ECHOPAIR(MSG_PID_DEBUG, HOTEND_INDEX);
666
       SERIAL_ECHOPAIR(MSG_PID_DEBUG, HOTEND_INDEX);
688
       SERIAL_ECHOPAIR(MSG_PID_DEBUG_INPUT, current_temperature[HOTEND_INDEX]);
667
       SERIAL_ECHOPAIR(MSG_PID_DEBUG_INPUT, current_temperature[HOTEND_INDEX]);
689
       SERIAL_ECHOPAIR(MSG_PID_DEBUG_OUTPUT, pid_output);
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
       #endif
676
       #endif
696
       SERIAL_EOL();
677
       SERIAL_EOL();
697
     #endif // PID_DEBUG
678
     #endif // PID_DEBUG
709
 }
690
 }
710
 
691
 
711
 #if ENABLED(PIDTEMPBED)
692
 #if ENABLED(PIDTEMPBED)
693
+
712
   float Temperature::get_pid_output_bed() {
694
   float Temperature::get_pid_output_bed() {
713
-    float pid_output;
695
+
714
     #if DISABLED(PID_OPENLOOP)
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
       if (pid_output > MAX_BED_POWER) {
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
         pid_output = MAX_BED_POWER;
712
         pid_output = MAX_BED_POWER;
727
       }
713
       }
728
       else if (pid_output < 0) {
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
         pid_output = 0;
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
     #endif // PID_OPENLOOP
723
     #endif // PID_OPENLOOP
735
 
724
 
736
     #if ENABLED(PID_BED_DEBUG)
725
     #if ENABLED(PID_BED_DEBUG)
737
       SERIAL_ECHO_START();
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
     return pid_output;
736
     return pid_output;
752
   }
737
   }
738
+
753
 #endif // PIDTEMPBED
739
 #endif // PIDTEMPBED
754
 
740
 
755
 /**
741
 /**

+ 32
- 38
Marlin/src/module/temperature.h Parādīt failu

48
   #define HOTEND_INDEX  e
48
   #define HOTEND_INDEX  e
49
 #endif
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
  * States for ADC reading in the ISR
81
  * States for ADC reading in the ISR
53
  */
82
  */
132
     #endif
161
     #endif
133
 
162
 
134
     #if ENABLED(PIDTEMP)
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
     #endif
165
     #endif
155
 
166
 
156
     #if HAS_HEATED_BED
167
     #if HAS_HEATED_BED
158
       static int16_t current_temperature_bed_raw, target_temperature_bed;
169
       static int16_t current_temperature_bed_raw, target_temperature_bed;
159
       static uint8_t soft_pwm_amount_bed;
170
       static uint8_t soft_pwm_amount_bed;
160
       #if ENABLED(PIDTEMPBED)
171
       #if ENABLED(PIDTEMPBED)
161
-        static float bedKp, bedKi, bedKd;
172
+        static PID_t bed_pid;
162
       #endif
173
       #endif
163
     #endif
174
     #endif
164
 
175
 
210
     #endif
221
     #endif
211
 
222
 
212
     #if ENABLED(PIDTEMP)
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
       #if ENABLED(PID_EXTRUSION_SCALING)
224
       #if ENABLED(PID_EXTRUSION_SCALING)
220
-        static float cTerm[HOTENDS];
221
         static long last_e_position;
225
         static long last_e_position;
222
         static long lpq[LPQ_MAX_LEN];
226
         static long lpq[LPQ_MAX_LEN];
223
         static int lpq_ptr;
227
         static int lpq_ptr;
224
       #endif
228
       #endif
225
-
226
-      static float pid_error[HOTENDS];
227
-      static bool pid_reset[HOTENDS];
228
     #endif
229
     #endif
229
 
230
 
230
     // Init min and max temp with extreme values to prevent false errors during startup
231
     // Init min and max temp with extreme values to prevent false errors during startup
239
         static uint16_t watch_target_bed_temp;
240
         static uint16_t watch_target_bed_temp;
240
         static millis_t watch_bed_next_ms;
241
         static millis_t watch_bed_next_ms;
241
       #endif
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
         static millis_t next_bed_check_ms;
244
         static millis_t next_bed_check_ms;
251
       #endif
245
       #endif
252
       #if HEATER_IDLE_HANDLER
246
       #if HEATER_IDLE_HANDLER

+ 31
- 33
Marlin/src/module/tool_change.cpp Parādīt failu

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

+ 7
- 9
Marlin/src/module/tool_change.h Parādīt failu

19
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
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
 #if DO_SWITCH_EXTRUDER
26
 #if DO_SWITCH_EXTRUDER
29
   void move_extruder_servo(const uint8_t e);
27
   void move_extruder_servo(const uint8_t e);
51
 #endif // PARKING_EXTRUDER
49
 #endif // PARKING_EXTRUDER
52
 
50
 
53
 #if ENABLED(SINGLENOZZLE)
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
   extern uint16_t singlenozzle_temp[EXTRUDERS];
57
   extern uint16_t singlenozzle_temp[EXTRUDERS];
58
   #if FAN_COUNT > 0
58
   #if FAN_COUNT > 0
59
     extern uint8_t singlenozzle_fan_speed[EXTRUDERS];
59
     extern uint8_t singlenozzle_fan_speed[EXTRUDERS];
65
  * previous tool out of the way and the new tool into place.
65
  * previous tool out of the way and the new tool into place.
66
  */
66
  */
67
 void tool_change(const uint8_t tmp_extruder, const float fr_mm_s=0.0, bool no_move=false);
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

Notiek ielāde…
Atcelt
Saglabāt