Browse Source

🎨 steps_to_mm => mm_per_step (#22847)

espr14 2 years ago
parent
commit
228eb9c404
No account linked to committer's email address

+ 1
- 1
Marlin/src/feature/encoder_i2c.cpp View File

@@ -173,7 +173,7 @@ void I2CPositionEncoder::update() {
173 173
             LOOP_L_N(i, I2CPE_ERR_PRST_ARRAY_SIZE) sumP += errPrst[i];
174 174
             const int32_t errorP = int32_t(sumP * RECIPROCAL(I2CPE_ERR_PRST_ARRAY_SIZE));
175 175
             SERIAL_CHAR(axis_codes[encoderAxis]);
176
-            SERIAL_ECHOLNPGM(" : CORRECT ERR ", errorP * planner.steps_to_mm[encoderAxis], "mm");
176
+            SERIAL_ECHOLNPGM(" : CORRECT ERR ", errorP * planner.mm_per_step[encoderAxis], "mm");
177 177
             babystep.add_steps(encoderAxis, -LROUND(errorP));
178 178
             errPrstIdx = 0;
179 179
           }

+ 1
- 1
Marlin/src/feature/runout.h View File

@@ -373,7 +373,7 @@ class FilamentSensorBase {
373 373
           // Only trigger on extrusion with XYZ movement to allow filament change and retract/recover.
374 374
           const uint8_t e = b->extruder;
375 375
           const int32_t steps = b->steps.e;
376
-          runout_mm_countdown[e] -= (TEST(b->direction_bits, E_AXIS) ? -steps : steps) * planner.steps_to_mm[E_AXIS_N(e)];
376
+          runout_mm_countdown[e] -= (TEST(b->direction_bits, E_AXIS) ? -steps : steps) * planner.mm_per_step[E_AXIS_N(e)];
377 377
         }
378 378
       }
379 379
   };

+ 1
- 1
Marlin/src/gcode/config/M92.cpp View File

@@ -76,7 +76,7 @@ void GcodeSuite::M92() {
76 76
     if (parser.seen('H') || wanted) {
77 77
       const uint16_t argH = parser.ushortval('H'),
78 78
                      micro_steps = argH ?: Z_MICROSTEPS;
79
-      const float z_full_step_mm = micro_steps * planner.steps_to_mm[Z_AXIS];
79
+      const float z_full_step_mm = micro_steps * planner.mm_per_step[Z_AXIS];
80 80
       SERIAL_ECHO_START();
81 81
       SERIAL_ECHOPGM("{ micro_steps:", micro_steps, ", z_full_step_mm:", z_full_step_mm);
82 82
       if (wanted) {

+ 4
- 4
Marlin/src/lcd/extui/ui_api.cpp View File

@@ -755,7 +755,7 @@ namespace ExtUI {
755 755
      * what nozzle is printing.
756 756
      */
757 757
     void smartAdjustAxis_steps(const int16_t steps, const axis_t axis, bool linked_nozzles) {
758
-      const float mm = steps * planner.steps_to_mm[axis];
758
+      const float mm = steps * planner.mm_per_step[axis];
759 759
       UNUSED(mm);
760 760
 
761 761
       if (!babystepAxis_steps(steps, axis)) return;
@@ -791,12 +791,12 @@ namespace ExtUI {
791 791
      * steps that is at least mm long.
792 792
      */
793 793
     int16_t mmToWholeSteps(const_float_t mm, const axis_t axis) {
794
-      const float steps = mm / planner.steps_to_mm[axis];
794
+      const float steps = mm / planner.mm_per_step[axis];
795 795
       return steps > 0 ? CEIL(steps) : FLOOR(steps);
796 796
     }
797 797
 
798 798
     float mmFromWholeSteps(int16_t steps, const axis_t axis) {
799
-      return steps * planner.steps_to_mm[axis];
799
+      return steps * planner.mm_per_step[axis];
800 800
     }
801 801
 
802 802
   #endif // BABYSTEPPING
@@ -806,7 +806,7 @@ namespace ExtUI {
806 806
       #if HAS_BED_PROBE
807 807
         + probe.offset.z
808 808
       #elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
809
-        + planner.steps_to_mm[Z_AXIS] * babystep.axis_total[BS_AXIS_IND(Z_AXIS)]
809
+        + planner.mm_per_step[Z_AXIS] * babystep.axis_total[BS_AXIS_IND(Z_AXIS)]
810 810
       #endif
811 811
     );
812 812
   }

+ 1
- 1
Marlin/src/lcd/menu/menu.cpp View File

@@ -315,7 +315,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
315 315
       const int16_t babystep_increment = int16_t(ui.encoderPosition) * (BABYSTEP_SIZE_Z);
316 316
       ui.encoderPosition = 0;
317 317
 
318
-      const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
318
+      const float diff = planner.mm_per_step[Z_AXIS] * babystep_increment,
319 319
                   new_probe_offset = probe.offset.z + diff,
320 320
                   new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET
321 321
                     , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff

+ 1
- 1
Marlin/src/lcd/menu/menu_advanced.cpp View File

@@ -532,7 +532,7 @@ void menu_advanced_steps_per_mm() {
532 532
         if (e == active_extruder)
533 533
           planner.refresh_positioning();
534 534
         else
535
-          planner.steps_to_mm[E_AXIS_N(e)] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS_N(e)];
535
+          planner.mm_per_step[E_AXIS_N(e)] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS_N(e)];
536 536
       });
537 537
   #elif E_STEPPERS
538 538
     EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); });

+ 3
- 3
Marlin/src/lcd/menu/menu_tune.cpp View File

@@ -65,8 +65,8 @@
65 65
       babystep.add_steps(axis, steps);
66 66
     }
67 67
     if (ui.should_draw()) {
68
-      const float spm = planner.steps_to_mm[axis];
69
-      MenuEditItemBase::draw_edit_screen(msg, BABYSTEP_TO_STR(spm * babystep.accum));
68
+      const float mps = planner.mm_per_step[axis];
69
+      MenuEditItemBase::draw_edit_screen(msg, BABYSTEP_TO_STR(mps * babystep.accum));
70 70
       #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
71 71
         const bool in_view = TERN1(HAS_MARLINUI_U8GLIB, PAGE_CONTAINS(LCD_PIXEL_HEIGHT - MENU_FONT_HEIGHT, LCD_PIXEL_HEIGHT - 1));
72 72
         if (in_view) {
@@ -81,7 +81,7 @@
81 81
             lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
82 82
             lcd_put_wchar(':');
83 83
           #endif
84
-          lcd_put_u8str(BABYSTEP_TO_STR(spm * babystep.axis_total[BS_TOTAL_IND(axis)]));
84
+          lcd_put_u8str(BABYSTEP_TO_STR(mps * babystep.axis_total[BS_TOTAL_IND(axis)]));
85 85
         }
86 86
       #endif
87 87
     }

+ 1
- 1
Marlin/src/lcd/tft/ui_1024x600.cpp View File

@@ -667,7 +667,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
667 667
     #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
668 668
       const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z;
669 669
       const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0;
670
-      const float bsDiff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
670
+      const float bsDiff = planner.mm_per_step[Z_AXIS] * babystep_increment,
671 671
                   new_probe_offset = probe.offset.z + bsDiff,
672 672
                   new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET
673 673
                     , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff

+ 1
- 1
Marlin/src/lcd/tft/ui_320x240.cpp View File

@@ -652,7 +652,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
652 652
     #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
653 653
       const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z;
654 654
       const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0;
655
-      const float bsDiff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
655
+      const float bsDiff = planner.mm_per_step[Z_AXIS] * babystep_increment,
656 656
                   new_probe_offset = probe.offset.z + bsDiff,
657 657
                   new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET
658 658
                     , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff

+ 1
- 1
Marlin/src/lcd/tft/ui_480x320.cpp View File

@@ -654,7 +654,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
654 654
     #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
655 655
       const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z;
656 656
       const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0;
657
-      const float bsDiff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
657
+      const float bsDiff = planner.mm_per_step[Z_AXIS] * babystep_increment,
658 658
                   new_probe_offset = probe.offset.z + bsDiff,
659 659
                   new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET
660 660
                     , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff

+ 3
- 3
Marlin/src/module/motion.cpp View File

@@ -1682,7 +1682,7 @@ void prepare_line_to_destination() {
1682 1682
       int16_t phaseDelta = (home_phase[axis] - phaseCurrent) * stepperBackoutDir;
1683 1683
 
1684 1684
       // Check if home distance within endstop assumed repeatability noise of .05mm and warn.
1685
-      if (ABS(phaseDelta) * planner.steps_to_mm[axis] / phasePerUStep < 0.05f)
1685
+      if (ABS(phaseDelta) * planner.mm_per_step[axis] / phasePerUStep < 0.05f)
1686 1686
         SERIAL_ECHOLNPGM("Selected home phase ", home_phase[axis],
1687 1687
                          " too close to endstop trigger phase ", phaseCurrent,
1688 1688
                          ". Pick a different phase for ", AS_CHAR(AXIS_CHAR(axis)));
@@ -1691,7 +1691,7 @@ void prepare_line_to_destination() {
1691 1691
       if (phaseDelta < 0) phaseDelta += 1024;
1692 1692
 
1693 1693
       // Convert TMC µsteps(phase) to whole Marlin µsteps to effector backout direction to mm
1694
-      const float mmDelta = int16_t(phaseDelta / phasePerUStep) * effectorBackoutDir * planner.steps_to_mm[axis];
1694
+      const float mmDelta = int16_t(phaseDelta / phasePerUStep) * effectorBackoutDir * planner.mm_per_step[axis];
1695 1695
 
1696 1696
       // Optional debug messages
1697 1697
       if (DEBUGGING(LEVELING)) {
@@ -1999,7 +1999,7 @@ void prepare_line_to_destination() {
1999 1999
       // Delta homing treats the axes as normal linear axes.
2000 2000
 
2001 2001
       const float adjDistance = delta_endstop_adj[axis],
2002
-                  minDistance = (MIN_STEPS_PER_SEGMENT) * planner.steps_to_mm[axis];
2002
+                  minDistance = (MIN_STEPS_PER_SEGMENT) * planner.mm_per_step[axis];
2003 2003
 
2004 2004
       // Retrace by the amount specified in delta_endstop_adj if more than min steps.
2005 2005
       if (adjDistance * (Z_HOME_DIR) < 0 && ABS(adjDistance) > minDistance) { // away from endstop, more than min distance

+ 36
- 36
Marlin/src/module/planner.cpp View File

@@ -138,7 +138,7 @@ planner_settings_t Planner::settings;           // Initialized by settings.load(
138 138
 
139 139
 uint32_t Planner::max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) Derived from mm_per_s2
140 140
 
141
-float Planner::steps_to_mm[DISTINCT_AXES];      // (mm) Millimeters per step
141
+float Planner::mm_per_step[DISTINCT_AXES];      // (mm) Millimeters per step
142 142
 
143 143
 #if HAS_JUNCTION_DEVIATION
144 144
   float Planner::junction_deviation_mm;         // (mm) M205 J
@@ -1702,7 +1702,7 @@ void Planner::endstop_triggered(const AxisEnum axis) {
1702 1702
 }
1703 1703
 
1704 1704
 float Planner::triggered_position_mm(const AxisEnum axis) {
1705
-  return stepper.triggered_position(axis) * steps_to_mm[axis];
1705
+  return stepper.triggered_position(axis) * mm_per_step[axis];
1706 1706
 }
1707 1707
 
1708 1708
 void Planner::finish_and_disable() {
@@ -1759,7 +1759,7 @@ float Planner::get_axis_position_mm(const AxisEnum axis) {
1759 1759
 
1760 1760
   #endif
1761 1761
 
1762
-  return axis_steps * steps_to_mm[axis];
1762
+  return axis_steps * mm_per_step[axis];
1763 1763
 }
1764 1764
 
1765 1765
 /**
@@ -2015,51 +2015,51 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2015 2015
   } steps_dist_mm;
2016 2016
   #if IS_CORE
2017 2017
     #if CORE_IS_XY
2018
-      steps_dist_mm.head.x = da * steps_to_mm[A_AXIS];
2019
-      steps_dist_mm.head.y = db * steps_to_mm[B_AXIS];
2020
-      steps_dist_mm.z      = dc * steps_to_mm[Z_AXIS];
2021
-      steps_dist_mm.a      = (da + db) * steps_to_mm[A_AXIS];
2022
-      steps_dist_mm.b      = CORESIGN(da - db) * steps_to_mm[B_AXIS];
2018
+      steps_dist_mm.head.x = da * mm_per_step[A_AXIS];
2019
+      steps_dist_mm.head.y = db * mm_per_step[B_AXIS];
2020
+      steps_dist_mm.z      = dc * mm_per_step[Z_AXIS];
2021
+      steps_dist_mm.a      = (da + db) * mm_per_step[A_AXIS];
2022
+      steps_dist_mm.b      = CORESIGN(da - db) * mm_per_step[B_AXIS];
2023 2023
     #elif CORE_IS_XZ
2024
-      steps_dist_mm.head.x = da * steps_to_mm[A_AXIS];
2025
-      steps_dist_mm.y      = db * steps_to_mm[Y_AXIS];
2026
-      steps_dist_mm.head.z = dc * steps_to_mm[C_AXIS];
2027
-      steps_dist_mm.a      = (da + dc) * steps_to_mm[A_AXIS];
2028
-      steps_dist_mm.c      = CORESIGN(da - dc) * steps_to_mm[C_AXIS];
2024
+      steps_dist_mm.head.x = da * mm_per_step[A_AXIS];
2025
+      steps_dist_mm.y      = db * mm_per_step[Y_AXIS];
2026
+      steps_dist_mm.head.z = dc * mm_per_step[C_AXIS];
2027
+      steps_dist_mm.a      = (da + dc) * mm_per_step[A_AXIS];
2028
+      steps_dist_mm.c      = CORESIGN(da - dc) * mm_per_step[C_AXIS];
2029 2029
     #elif CORE_IS_YZ
2030
-      steps_dist_mm.x      = da * steps_to_mm[X_AXIS];
2031
-      steps_dist_mm.head.y = db * steps_to_mm[B_AXIS];
2032
-      steps_dist_mm.head.z = dc * steps_to_mm[C_AXIS];
2033
-      steps_dist_mm.b      = (db + dc) * steps_to_mm[B_AXIS];
2034
-      steps_dist_mm.c      = CORESIGN(db - dc) * steps_to_mm[C_AXIS];
2030
+      steps_dist_mm.x      = da * mm_per_step[X_AXIS];
2031
+      steps_dist_mm.head.y = db * mm_per_step[B_AXIS];
2032
+      steps_dist_mm.head.z = dc * mm_per_step[C_AXIS];
2033
+      steps_dist_mm.b      = (db + dc) * mm_per_step[B_AXIS];
2034
+      steps_dist_mm.c      = CORESIGN(db - dc) * mm_per_step[C_AXIS];
2035 2035
     #endif
2036 2036
     #if LINEAR_AXES >= 4
2037
-      steps_dist_mm.i = di * steps_to_mm[I_AXIS];
2037
+      steps_dist_mm.i = di * mm_per_step[I_AXIS];
2038 2038
     #endif
2039 2039
     #if LINEAR_AXES >= 5
2040
-      steps_dist_mm.j = dj * steps_to_mm[J_AXIS];
2040
+      steps_dist_mm.j = dj * mm_per_step[J_AXIS];
2041 2041
     #endif
2042 2042
     #if LINEAR_AXES >= 6
2043
-      steps_dist_mm.k = dk * steps_to_mm[K_AXIS];
2043
+      steps_dist_mm.k = dk * mm_per_step[K_AXIS];
2044 2044
     #endif
2045 2045
   #elif ENABLED(MARKFORGED_XY)
2046
-    steps_dist_mm.head.x = da * steps_to_mm[A_AXIS];
2047
-    steps_dist_mm.head.y = db * steps_to_mm[B_AXIS];
2048
-    steps_dist_mm.z      = dc * steps_to_mm[Z_AXIS];
2049
-    steps_dist_mm.a      = (da - db) * steps_to_mm[A_AXIS];
2050
-    steps_dist_mm.b      = db * steps_to_mm[B_AXIS];
2046
+    steps_dist_mm.head.x = da * mm_per_step[A_AXIS];
2047
+    steps_dist_mm.head.y = db * mm_per_step[B_AXIS];
2048
+    steps_dist_mm.z      = dc * mm_per_step[Z_AXIS];
2049
+    steps_dist_mm.a      = (da - db) * mm_per_step[A_AXIS];
2050
+    steps_dist_mm.b      = db * mm_per_step[B_AXIS];
2051 2051
   #else
2052 2052
     LINEAR_AXIS_CODE(
2053
-      steps_dist_mm.a = da * steps_to_mm[A_AXIS],
2054
-      steps_dist_mm.b = db * steps_to_mm[B_AXIS],
2055
-      steps_dist_mm.c = dc * steps_to_mm[C_AXIS],
2056
-      steps_dist_mm.i = di * steps_to_mm[I_AXIS],
2057
-      steps_dist_mm.j = dj * steps_to_mm[J_AXIS],
2058
-      steps_dist_mm.k = dk * steps_to_mm[K_AXIS]
2053
+      steps_dist_mm.a = da * mm_per_step[A_AXIS],
2054
+      steps_dist_mm.b = db * mm_per_step[B_AXIS],
2055
+      steps_dist_mm.c = dc * mm_per_step[C_AXIS],
2056
+      steps_dist_mm.i = di * mm_per_step[I_AXIS],
2057
+      steps_dist_mm.j = dj * mm_per_step[J_AXIS],
2058
+      steps_dist_mm.k = dk * mm_per_step[K_AXIS]
2059 2059
     );
2060 2060
   #endif
2061 2061
 
2062
-  TERN_(HAS_EXTRUDERS, steps_dist_mm.e = esteps_float * steps_to_mm[E_AXIS_N(extruder)]);
2062
+  TERN_(HAS_EXTRUDERS, steps_dist_mm.e = esteps_float * mm_per_step[E_AXIS_N(extruder)]);
2063 2063
 
2064 2064
   TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator += steps_dist_mm.e);
2065 2065
 
@@ -2889,7 +2889,7 @@ bool Planner::buffer_segment(const abce_pos_t &abce
2889 2889
   // When changing extruders recalculate steps corresponding to the E position
2890 2890
   #if ENABLED(DISTINCT_E_FACTORS)
2891 2891
     if (last_extruder != extruder && settings.axis_steps_per_mm[E_AXIS_N(extruder)] != settings.axis_steps_per_mm[E_AXIS_N(last_extruder)]) {
2892
-      position.e = LROUND(position.e * settings.axis_steps_per_mm[E_AXIS_N(extruder)] * steps_to_mm[E_AXIS_N(last_extruder)]);
2892
+      position.e = LROUND(position.e * settings.axis_steps_per_mm[E_AXIS_N(extruder)] * mm_per_step[E_AXIS_N(last_extruder)]);
2893 2893
       last_extruder = extruder;
2894 2894
     }
2895 2895
   #endif
@@ -3168,11 +3168,11 @@ void Planner::reset_acceleration_rates() {
3168 3168
 }
3169 3169
 
3170 3170
 /**
3171
- * Recalculate 'position' and 'steps_to_mm'.
3171
+ * Recalculate 'position' and 'mm_per_step'.
3172 3172
  * Must be called whenever settings.axis_steps_per_mm changes!
3173 3173
  */
3174 3174
 void Planner::refresh_positioning() {
3175
-  LOOP_DISTINCT_AXES(i) steps_to_mm[i] = 1.0f / settings.axis_steps_per_mm[i];
3175
+  LOOP_DISTINCT_AXES(i) mm_per_step[i] = 1.0f / settings.axis_steps_per_mm[i];
3176 3176
   set_position_mm(current_position);
3177 3177
   reset_acceleration_rates();
3178 3178
 }

+ 2
- 2
Marlin/src/module/planner.h View File

@@ -374,7 +374,7 @@ class Planner {
374 374
     #endif
375 375
 
376 376
     static uint32_t max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) Derived from mm_per_s2
377
-    static float steps_to_mm[DISTINCT_AXES];          // Millimeters per step
377
+    static float mm_per_step[DISTINCT_AXES];          // Millimeters per step
378 378
 
379 379
     #if HAS_JUNCTION_DEVIATION
380 380
       static float junction_deviation_mm;             // (mm) M205 J
@@ -489,7 +489,7 @@ class Planner {
489 489
     static void reset_acceleration_rates();
490 490
 
491 491
     /**
492
-     * Recalculate 'position' and 'steps_to_mm'.
492
+     * Recalculate 'position' and 'mm_per_step'.
493 493
      * Must be called whenever settings.axis_steps_per_mm changes!
494 494
      */
495 495
     static void refresh_positioning();

+ 1
- 1
Marlin/src/module/settings.cpp View File

@@ -557,7 +557,7 @@ void MarlinSettings::postprocess() {
557 557
 
558 558
   TERN_(EXTENSIBLE_UI, ExtUI::onPostprocessSettings());
559 559
 
560
-  // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
560
+  // Refresh mm_per_step with the reciprocal of axis_steps_per_mm
561 561
   // and init stepper.count[], planner.position[] with current_position
562 562
   planner.refresh_positioning();
563 563
 

+ 1
- 1
Marlin/src/module/temperature.cpp View File

@@ -1102,7 +1102,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) {
1102 1102
                 lpq[lpq_ptr] = 0;
1103 1103
 
1104 1104
               if (++lpq_ptr >= lpq_len) lpq_ptr = 0;
1105
-              work_pid[ee].Kc = (lpq[lpq_ptr] * planner.steps_to_mm[E_AXIS]) * PID_PARAM(Kc, ee);
1105
+              work_pid[ee].Kc = (lpq[lpq_ptr] * planner.mm_per_step[E_AXIS]) * PID_PARAM(Kc, ee);
1106 1106
               pid_output += work_pid[ee].Kc;
1107 1107
             }
1108 1108
           #endif // PID_EXTRUSION_SCALING

Loading…
Cancel
Save