浏览代码

Use code_value_linear_units for known-linear axes

Scott Lahteine 8 年前
父节点
当前提交
69dfa54a84
共有 1 个文件被更改,包括 64 次插入68 次删除
  1. 64
    68
      Marlin/Marlin_main.cpp

+ 64
- 68
Marlin/Marlin_main.cpp 查看文件

1285
     volumetric_unit_factor = pow(linear_unit_factor, 3.0);
1285
     volumetric_unit_factor = pow(linear_unit_factor, 3.0);
1286
   }
1286
   }
1287
 
1287
 
1288
-  inline float axis_unit_factor(int axis) {
1288
+  inline float axis_unit_factor(const AxisEnum axis) {
1289
     return (axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor);
1289
     return (axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor);
1290
   }
1290
   }
1291
 
1291
 
1292
   inline float code_value_linear_units() { return code_value_float() * linear_unit_factor; }
1292
   inline float code_value_linear_units() { return code_value_float() * linear_unit_factor; }
1293
-  inline float code_value_axis_units(int axis) { return code_value_float() * axis_unit_factor(axis); }
1294
-  inline float code_value_per_axis_unit(int axis) { return code_value_float() / axis_unit_factor(axis); }
1293
+  inline float code_value_axis_units(const AxisEnum axis) { return code_value_float() * axis_unit_factor(axis); }
1294
+  inline float code_value_per_axis_unit(const AxisEnum axis) { return code_value_float() / axis_unit_factor(axis); }
1295
 
1295
 
1296
 #else
1296
 #else
1297
 
1297
 
1298
-  inline float code_value_linear_units() { return code_value_float(); }
1299
-  inline float code_value_axis_units(int axis) { UNUSED(axis); return code_value_float(); }
1300
-  inline float code_value_per_axis_unit(int axis) { UNUSED(axis); return code_value_float(); }
1298
+  #define code_value_linear_units() code_value_float()
1299
+  #define code_value_axis_units(A) code_value_float()
1300
+  #define code_value_per_axis_unit(A) code_value_float()
1301
 
1301
 
1302
 #endif
1302
 #endif
1303
 
1303
 
3063
 void gcode_get_destination() {
3063
 void gcode_get_destination() {
3064
   LOOP_XYZE(i) {
3064
   LOOP_XYZE(i) {
3065
     if (code_seen(axis_codes[i]))
3065
     if (code_seen(axis_codes[i]))
3066
-      destination[i] = code_value_axis_units(i) + (axis_relative_modes[i] || relative_mode ? current_position[i] : 0);
3066
+      destination[i] = code_value_axis_units((AxisEnum)i) + (axis_relative_modes[i] || relative_mode ? current_position[i] : 0);
3067
     else
3067
     else
3068
       destination[i] = current_position[i];
3068
       destination[i] = current_position[i];
3069
   }
3069
   }
3232
 
3232
 
3233
       float arc_offset[2] = { 0.0, 0.0 };
3233
       float arc_offset[2] = { 0.0, 0.0 };
3234
       if (code_seen('R')) {
3234
       if (code_seen('R')) {
3235
-        const float r = code_value_axis_units(X_AXIS),
3235
+        const float r = code_value_linear_units(),
3236
                     x1 = current_position[X_AXIS], y1 = current_position[Y_AXIS],
3236
                     x1 = current_position[X_AXIS], y1 = current_position[Y_AXIS],
3237
                     x2 = destination[X_AXIS], y2 = destination[Y_AXIS];
3237
                     x2 = destination[X_AXIS], y2 = destination[Y_AXIS];
3238
         if (r && (x2 != x1 || y2 != y1)) {
3238
         if (r && (x2 != x1 || y2 != y1)) {
3248
         }
3248
         }
3249
       }
3249
       }
3250
       else {
3250
       else {
3251
-        if (code_seen('I')) arc_offset[X_AXIS] = code_value_axis_units(X_AXIS);
3252
-        if (code_seen('J')) arc_offset[Y_AXIS] = code_value_axis_units(Y_AXIS);
3251
+        if (code_seen('I')) arc_offset[X_AXIS] = code_value_linear_units();
3252
+        if (code_seen('J')) arc_offset[Y_AXIS] = code_value_linear_units();
3253
       }
3253
       }
3254
 
3254
 
3255
       if (arc_offset[0] || arc_offset[1]) {
3255
       if (arc_offset[0] || arc_offset[1]) {
3302
       gcode_get_destination();
3302
       gcode_get_destination();
3303
 
3303
 
3304
       const float offset[] = {
3304
       const float offset[] = {
3305
-        code_seen('I') ? code_value_axis_units(X_AXIS) : 0.0,
3306
-        code_seen('J') ? code_value_axis_units(Y_AXIS) : 0.0,
3307
-        code_seen('P') ? code_value_axis_units(X_AXIS) : 0.0,
3308
-        code_seen('Q') ? code_value_axis_units(Y_AXIS) : 0.0
3305
+        code_seen('I') ? code_value_linear_units() : 0.0,
3306
+        code_seen('J') ? code_value_linear_units() : 0.0,
3307
+        code_seen('P') ? code_value_linear_units() : 0.0,
3308
+        code_seen('Q') ? code_value_linear_units() : 0.0
3309
       };
3309
       };
3310
 
3310
 
3311
       plan_cubic_move(offset);
3311
       plan_cubic_move(offset);
4023
         }
4023
         }
4024
 
4024
 
4025
         if (code_seen('Z')) {
4025
         if (code_seen('Z')) {
4026
-          mbl.z_values[px][py] = code_value_axis_units(Z_AXIS);
4026
+          mbl.z_values[px][py] = code_value_linear_units();
4027
         }
4027
         }
4028
         else {
4028
         else {
4029
           SERIAL_CHAR('Z'); say_not_entered();
4029
           SERIAL_CHAR('Z'); say_not_entered();
4033
 
4033
 
4034
       case MeshSetZOffset:
4034
       case MeshSetZOffset:
4035
         if (code_seen('Z')) {
4035
         if (code_seen('Z')) {
4036
-          mbl.z_offset = code_value_axis_units(Z_AXIS);
4036
+          mbl.z_offset = code_value_linear_units();
4037
         }
4037
         }
4038
         else {
4038
         else {
4039
           SERIAL_CHAR('Z'); say_not_entered();
4039
           SERIAL_CHAR('Z'); say_not_entered();
4305
 
4305
 
4306
       #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
4306
       #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
4307
 
4307
 
4308
-        zoffset = code_seen('Z') ? code_value_axis_units(Z_AXIS) : 0;
4308
+        zoffset = code_seen('Z') ? code_value_linear_units() : 0;
4309
 
4309
 
4310
       #endif
4310
       #endif
4311
 
4311
 
4313
 
4313
 
4314
         xy_probe_feedrate_mm_s = MMM_TO_MMS(code_seen('S') ? code_value_linear_units() : XY_PROBE_SPEED);
4314
         xy_probe_feedrate_mm_s = MMM_TO_MMS(code_seen('S') ? code_value_linear_units() : XY_PROBE_SPEED);
4315
 
4315
 
4316
-        left_probe_bed_position = code_seen('L') ? (int)code_value_axis_units(X_AXIS) : LOGICAL_X_POSITION(LEFT_PROBE_BED_POSITION);
4317
-        right_probe_bed_position = code_seen('R') ? (int)code_value_axis_units(X_AXIS) : LOGICAL_X_POSITION(RIGHT_PROBE_BED_POSITION);
4318
-        front_probe_bed_position = code_seen('F') ? (int)code_value_axis_units(Y_AXIS) : LOGICAL_Y_POSITION(FRONT_PROBE_BED_POSITION);
4319
-        back_probe_bed_position = code_seen('B') ? (int)code_value_axis_units(Y_AXIS) : LOGICAL_Y_POSITION(BACK_PROBE_BED_POSITION);
4316
+        left_probe_bed_position = code_seen('L') ? (int)code_value_linear_units() : LOGICAL_X_POSITION(LEFT_PROBE_BED_POSITION);
4317
+        right_probe_bed_position = code_seen('R') ? (int)code_value_linear_units() : LOGICAL_X_POSITION(RIGHT_PROBE_BED_POSITION);
4318
+        front_probe_bed_position = code_seen('F') ? (int)code_value_linear_units() : LOGICAL_Y_POSITION(FRONT_PROBE_BED_POSITION);
4319
+        back_probe_bed_position = code_seen('B') ? (int)code_value_linear_units() : LOGICAL_Y_POSITION(BACK_PROBE_BED_POSITION);
4320
 
4320
 
4321
         const bool left_out_l = left_probe_bed_position < LOGICAL_X_POSITION(MIN_PROBE_X),
4321
         const bool left_out_l = left_probe_bed_position < LOGICAL_X_POSITION(MIN_PROBE_X),
4322
                    left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - (MIN_PROBE_EDGE),
4322
                    left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - (MIN_PROBE_EDGE),
4927
    *     S = Stows the probe if 1 (default=1)
4927
    *     S = Stows the probe if 1 (default=1)
4928
    */
4928
    */
4929
   inline void gcode_G30() {
4929
   inline void gcode_G30() {
4930
-    float X_probe_location = code_seen('X') ? code_value_axis_units(X_AXIS) : current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
4931
-          Y_probe_location = code_seen('Y') ? code_value_axis_units(Y_AXIS) : current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
4930
+    float X_probe_location = code_seen('X') ? code_value_linear_units() : current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
4931
+          Y_probe_location = code_seen('Y') ? code_value_linear_units() : current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
4932
 
4932
 
4933
     float pos[XYZ] = { X_probe_location, Y_probe_location, LOGICAL_Z_POSITION(0) };
4933
     float pos[XYZ] = { X_probe_location, Y_probe_location, LOGICAL_Z_POSITION(0) };
4934
     if (!position_is_reachable(pos, true)) return;
4934
     if (!position_is_reachable(pos, true)) return;
5431
   LOOP_XYZE(i) {
5431
   LOOP_XYZE(i) {
5432
     if (code_seen(axis_codes[i])) {
5432
     if (code_seen(axis_codes[i])) {
5433
       #if IS_SCARA
5433
       #if IS_SCARA
5434
-        current_position[i] = code_value_axis_units(i);
5434
+        current_position[i] = code_value_axis_units((AxisEnum)i);
5435
         if (i != E_AXIS) didXYZ = true;
5435
         if (i != E_AXIS) didXYZ = true;
5436
       #else
5436
       #else
5437
         #if HAS_POSITION_SHIFT
5437
         #if HAS_POSITION_SHIFT
5438
-          float p = current_position[i];
5438
+          const float p = current_position[i];
5439
         #endif
5439
         #endif
5440
-        float v = code_value_axis_units(i);
5440
+        float v = code_value_axis_units((AxisEnum)i);
5441
 
5441
 
5442
         current_position[i] = v;
5442
         current_position[i] = v;
5443
 
5443
 
6078
 
6078
 
6079
     bool stow_probe_after_each = code_seen('E');
6079
     bool stow_probe_after_each = code_seen('E');
6080
 
6080
 
6081
-    float X_probe_location = code_seen('X') ? code_value_axis_units(X_AXIS) : X_current + X_PROBE_OFFSET_FROM_EXTRUDER;
6081
+    float X_probe_location = code_seen('X') ? code_value_linear_units() : X_current + X_PROBE_OFFSET_FROM_EXTRUDER;
6082
     #if DISABLED(DELTA)
6082
     #if DISABLED(DELTA)
6083
       if (!WITHIN(X_probe_location, LOGICAL_X_POSITION(MIN_PROBE_X), LOGICAL_X_POSITION(MAX_PROBE_X))) {
6083
       if (!WITHIN(X_probe_location, LOGICAL_X_POSITION(MIN_PROBE_X), LOGICAL_X_POSITION(MAX_PROBE_X))) {
6084
         out_of_range_error(PSTR("X"));
6084
         out_of_range_error(PSTR("X"));
6086
       }
6086
       }
6087
     #endif
6087
     #endif
6088
 
6088
 
6089
-    float Y_probe_location = code_seen('Y') ? code_value_axis_units(Y_AXIS) : Y_current + Y_PROBE_OFFSET_FROM_EXTRUDER;
6089
+    float Y_probe_location = code_seen('Y') ? code_value_linear_units() : Y_current + Y_PROBE_OFFSET_FROM_EXTRUDER;
6090
     #if DISABLED(DELTA)
6090
     #if DISABLED(DELTA)
6091
       if (!WITHIN(Y_probe_location, LOGICAL_Y_POSITION(MIN_PROBE_Y), LOGICAL_Y_POSITION(MAX_PROBE_Y))) {
6091
       if (!WITHIN(Y_probe_location, LOGICAL_Y_POSITION(MIN_PROBE_Y), LOGICAL_Y_POSITION(MAX_PROBE_Y))) {
6092
         out_of_range_error(PSTR("Y"));
6092
         out_of_range_error(PSTR("Y"));
7063
   LOOP_XYZE(i) {
7063
   LOOP_XYZE(i) {
7064
     if (code_seen(axis_codes[i])) {
7064
     if (code_seen(axis_codes[i])) {
7065
       if (i == E_AXIS) {
7065
       if (i == E_AXIS) {
7066
-        float value = code_value_per_axis_unit(E_AXIS + TARGET_EXTRUDER);
7066
+        const float value = code_value_per_axis_unit(E_AXIS + TARGET_EXTRUDER);
7067
         if (value < 20.0) {
7067
         if (value < 20.0) {
7068
           float factor = planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
7068
           float factor = planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
7069
           planner.max_jerk[E_AXIS] *= factor;
7069
           planner.max_jerk[E_AXIS] *= factor;
7250
     RUNPLAN(FILAMENT_CHANGE_RETRACT_FEEDRATE);
7250
     RUNPLAN(FILAMENT_CHANGE_RETRACT_FEEDRATE);
7251
 
7251
 
7252
     // Lift Z axis
7252
     // Lift Z axis
7253
-    const float z_lift = code_seen('Z') ? code_value_axis_units(Z_AXIS) :
7253
+    const float z_lift = code_seen('Z') ? code_value_linear_units() :
7254
       #if defined(FILAMENT_CHANGE_Z_ADD) && FILAMENT_CHANGE_Z_ADD > 0
7254
       #if defined(FILAMENT_CHANGE_Z_ADD) && FILAMENT_CHANGE_Z_ADD > 0
7255
         FILAMENT_CHANGE_Z_ADD
7255
         FILAMENT_CHANGE_Z_ADD
7256
       #else
7256
       #else
7264
     }
7264
     }
7265
 
7265
 
7266
     // Move XY axes to filament change position or given position
7266
     // Move XY axes to filament change position or given position
7267
-    destination[X_AXIS] = code_seen('X') ? code_value_axis_units(X_AXIS) : 0
7267
+    destination[X_AXIS] = code_seen('X') ? code_value_linear_units() : 0
7268
       #ifdef FILAMENT_CHANGE_X_POS
7268
       #ifdef FILAMENT_CHANGE_X_POS
7269
         + FILAMENT_CHANGE_X_POS
7269
         + FILAMENT_CHANGE_X_POS
7270
       #endif
7270
       #endif
7271
     ;
7271
     ;
7272
-    destination[Y_AXIS] = code_seen('Y') ? code_value_axis_units(Y_AXIS) : 0
7272
+    destination[Y_AXIS] = code_seen('Y') ? code_value_linear_units() : 0
7273
       #ifdef FILAMENT_CHANGE_Y_POS
7273
       #ifdef FILAMENT_CHANGE_Y_POS
7274
         + FILAMENT_CHANGE_Y_POS
7274
         + FILAMENT_CHANGE_Y_POS
7275
       #endif
7275
       #endif
7355
         if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
7355
         if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
7356
     }
7356
     }
7357
   }
7357
   }
7358
-  else {
7359
-    //reserved for setting filament diameter via UFID or filament measuring device
7360
-    return;
7361
-  }
7362
   calculate_volumetric_multipliers();
7358
   calculate_volumetric_multipliers();
7363
 }
7359
 }
7364
 
7360
 
7374
   LOOP_XYZE(i) {
7370
   LOOP_XYZE(i) {
7375
     if (code_seen(axis_codes[i])) {
7371
     if (code_seen(axis_codes[i])) {
7376
       const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
7372
       const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
7377
-      planner.max_acceleration_mm_per_s2[a] = code_value_axis_units(a);
7373
+      planner.max_acceleration_mm_per_s2[a] = code_value_axis_units((AxisEnum)a);
7378
     }
7374
     }
7379
   }
7375
   }
7380
   // 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)
7376
   // 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)
7384
 #if 0 // Not used for Sprinter/grbl gen6
7380
 #if 0 // Not used for Sprinter/grbl gen6
7385
   inline void gcode_M202() {
7381
   inline void gcode_M202() {
7386
     LOOP_XYZE(i) {
7382
     LOOP_XYZE(i) {
7387
-      if (code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value_axis_units(i) * planner.axis_steps_per_mm[i];
7383
+      if (code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value_axis_units((AxisEnum)i) * planner.axis_steps_per_mm[i];
7388
     }
7384
     }
7389
   }
7385
   }
7390
 #endif
7386
 #endif
7402
   LOOP_XYZE(i)
7398
   LOOP_XYZE(i)
7403
     if (code_seen(axis_codes[i])) {
7399
     if (code_seen(axis_codes[i])) {
7404
       const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
7400
       const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
7405
-      planner.max_feedrate_mm_s[a] = code_value_axis_units(a);
7401
+      planner.max_feedrate_mm_s[a] = code_value_axis_units((AxisEnum)a);
7406
     }
7402
     }
7407
 }
7403
 }
7408
 
7404
 
7449
   if (code_seen('S')) planner.min_feedrate_mm_s = code_value_linear_units();
7445
   if (code_seen('S')) planner.min_feedrate_mm_s = code_value_linear_units();
7450
   if (code_seen('T')) planner.min_travel_feedrate_mm_s = code_value_linear_units();
7446
   if (code_seen('T')) planner.min_travel_feedrate_mm_s = code_value_linear_units();
7451
   if (code_seen('B')) planner.min_segment_time = code_value_millis();
7447
   if (code_seen('B')) planner.min_segment_time = code_value_millis();
7452
-  if (code_seen('X')) planner.max_jerk[X_AXIS] = code_value_axis_units(X_AXIS);
7453
-  if (code_seen('Y')) planner.max_jerk[Y_AXIS] = code_value_axis_units(Y_AXIS);
7454
-  if (code_seen('Z')) planner.max_jerk[Z_AXIS] = code_value_axis_units(Z_AXIS);
7455
-  if (code_seen('E')) planner.max_jerk[E_AXIS] = code_value_axis_units(E_AXIS);
7448
+  if (code_seen('X')) planner.max_jerk[X_AXIS] = code_value_linear_units();
7449
+  if (code_seen('Y')) planner.max_jerk[Y_AXIS] = code_value_linear_units();
7450
+  if (code_seen('Z')) planner.max_jerk[Z_AXIS] = code_value_linear_units();
7451
+  if (code_seen('E')) planner.max_jerk[E_AXIS] = code_value_linear_units();
7456
 }
7452
 }
7457
 
7453
 
7458
 #if HAS_M206_COMMAND
7454
 #if HAS_M206_COMMAND
7463
   inline void gcode_M206() {
7459
   inline void gcode_M206() {
7464
     LOOP_XYZ(i)
7460
     LOOP_XYZ(i)
7465
       if (code_seen(axis_codes[i]))
7461
       if (code_seen(axis_codes[i]))
7466
-        set_home_offset((AxisEnum)i, code_value_axis_units(i));
7462
+        set_home_offset((AxisEnum)i, code_value_linear_units());
7467
 
7463
 
7468
     #if ENABLED(MORGAN_SCARA)
7464
     #if ENABLED(MORGAN_SCARA)
7469
-      if (code_seen('T')) set_home_offset(A_AXIS, code_value_axis_units(A_AXIS)); // Theta
7470
-      if (code_seen('P')) set_home_offset(B_AXIS, code_value_axis_units(B_AXIS)); // Psi
7465
+      if (code_seen('T')) set_home_offset(A_AXIS, code_value_linear_units()); // Theta
7466
+      if (code_seen('P')) set_home_offset(B_AXIS, code_value_linear_units()); // Psi
7471
     #endif
7467
     #endif
7472
 
7468
 
7473
     SYNC_PLAN_POSITION_KINEMATIC();
7469
     SYNC_PLAN_POSITION_KINEMATIC();
7517
     #endif
7513
     #endif
7518
     LOOP_XYZ(i) {
7514
     LOOP_XYZ(i) {
7519
       if (code_seen(axis_codes[i])) {
7515
       if (code_seen(axis_codes[i])) {
7520
-        endstop_adj[i] = code_value_axis_units(i);
7516
+        endstop_adj[i] = code_value_linear_units();
7521
         #if ENABLED(DEBUG_LEVELING_FEATURE)
7517
         #if ENABLED(DEBUG_LEVELING_FEATURE)
7522
           if (DEBUGGING(LEVELING)) {
7518
           if (DEBUGGING(LEVELING)) {
7523
             SERIAL_ECHOPAIR("endstop_adj[", axis_codes[i]);
7519
             SERIAL_ECHOPAIR("endstop_adj[", axis_codes[i]);
7539
    * M666: For Z Dual Endstop setup, set z axis offset to the z2 axis.
7535
    * M666: For Z Dual Endstop setup, set z axis offset to the z2 axis.
7540
    */
7536
    */
7541
   inline void gcode_M666() {
7537
   inline void gcode_M666() {
7542
-    if (code_seen('Z')) z_endstop_adj = code_value_axis_units(Z_AXIS);
7538
+    if (code_seen('Z')) z_endstop_adj = code_value_linear_units();
7543
     SERIAL_ECHOLNPAIR("Z Endstop Adjustment set to (mm):", z_endstop_adj);
7539
     SERIAL_ECHOLNPAIR("Z Endstop Adjustment set to (mm):", z_endstop_adj);
7544
   }
7540
   }
7545
 
7541
 
7558
   inline void gcode_M207() {
7554
   inline void gcode_M207() {
7559
     if (code_seen('S')) retract_length = code_value_axis_units(E_AXIS);
7555
     if (code_seen('S')) retract_length = code_value_axis_units(E_AXIS);
7560
     if (code_seen('F')) retract_feedrate_mm_s = MMM_TO_MMS(code_value_axis_units(E_AXIS));
7556
     if (code_seen('F')) retract_feedrate_mm_s = MMM_TO_MMS(code_value_axis_units(E_AXIS));
7561
-    if (code_seen('Z')) retract_zlift = code_value_axis_units(Z_AXIS);
7557
+    if (code_seen('Z')) retract_zlift = code_value_linear_units();
7562
     #if EXTRUDERS > 1
7558
     #if EXTRUDERS > 1
7563
       if (code_seen('W')) retract_length_swap = code_value_axis_units(E_AXIS);
7559
       if (code_seen('W')) retract_length_swap = code_value_axis_units(E_AXIS);
7564
     #endif
7560
     #endif
7631
   inline void gcode_M218() {
7627
   inline void gcode_M218() {
7632
     if (get_target_extruder_from_command(218) || target_extruder == 0) return;
7628
     if (get_target_extruder_from_command(218) || target_extruder == 0) return;
7633
 
7629
 
7634
-    if (code_seen('X')) hotend_offset[X_AXIS][target_extruder] = code_value_axis_units(X_AXIS);
7635
-    if (code_seen('Y')) hotend_offset[Y_AXIS][target_extruder] = code_value_axis_units(Y_AXIS);
7630
+    if (code_seen('X')) hotend_offset[X_AXIS][target_extruder] = code_value_linear_units();
7631
+    if (code_seen('Y')) hotend_offset[Y_AXIS][target_extruder] = code_value_linear_units();
7636
 
7632
 
7637
     #if ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_EXTRUDER)
7633
     #if ENABLED(DUAL_X_CARRIAGE) || ENABLED(SWITCHING_EXTRUDER)
7638
-      if (code_seen('Z')) hotend_offset[Z_AXIS][target_extruder] = code_value_axis_units(Z_AXIS);
7634
+      if (code_seen('Z')) hotend_offset[Z_AXIS][target_extruder] = code_value_linear_units();
7639
     #endif
7635
     #endif
7640
 
7636
 
7641
     SERIAL_ECHO_START;
7637
     SERIAL_ECHO_START;
8285
     int8_t px = 0, py = 0;
8281
     int8_t px = 0, py = 0;
8286
     float z = 0;
8282
     float z = 0;
8287
     bool hasX, hasY, hasZ, hasI, hasJ;
8283
     bool hasX, hasY, hasZ, hasI, hasJ;
8288
-    if ((hasX = code_seen('X'))) px = mbl.probe_index_x(code_value_axis_units(X_AXIS));
8289
-    if ((hasY = code_seen('Y'))) py = mbl.probe_index_y(code_value_axis_units(Y_AXIS));
8290
-    if ((hasI = code_seen('I'))) px = code_value_axis_units(X_AXIS);
8291
-    if ((hasJ = code_seen('J'))) py = code_value_axis_units(Y_AXIS);
8292
-    if ((hasZ = code_seen('Z'))) z = code_value_axis_units(Z_AXIS);
8284
+    if ((hasX = code_seen('X'))) px = mbl.probe_index_x(code_value_linear_units());
8285
+    if ((hasY = code_seen('Y'))) py = mbl.probe_index_y(code_value_linear_units());
8286
+    if ((hasI = code_seen('I'))) px = code_value_linear_units();
8287
+    if ((hasJ = code_seen('J'))) py = code_value_linear_units();
8288
+    if ((hasZ = code_seen('Z'))) z = code_value_linear_units();
8293
 
8289
 
8294
     if (hasX && hasY && hasZ) {
8290
     if (hasX && hasY && hasZ) {
8295
 
8291
 
8325
     int8_t px = 0, py = 0;
8321
     int8_t px = 0, py = 0;
8326
     float z = 0;
8322
     float z = 0;
8327
     bool hasI, hasJ, hasZ;
8323
     bool hasI, hasJ, hasZ;
8328
-    if ((hasI = code_seen('I'))) px = code_value_axis_units(X_AXIS);
8329
-    if ((hasJ = code_seen('J'))) py = code_value_axis_units(Y_AXIS);
8330
-    if ((hasZ = code_seen('Z'))) z = code_value_axis_units(Z_AXIS);
8324
+    if ((hasI = code_seen('I'))) px = code_value_linear_units();
8325
+    if ((hasJ = code_seen('J'))) py = code_value_linear_units();
8326
+    if ((hasZ = code_seen('Z'))) z = code_value_linear_units();
8331
 
8327
 
8332
     if (hasI && hasJ && hasZ) {
8328
     if (hasI && hasJ && hasZ) {
8333
       if (WITHIN(px, 0, GRID_MAX_POINTS_X - 1) && WITHIN(py, 0, GRID_MAX_POINTS_X - 1)) {
8329
       if (WITHIN(px, 0, GRID_MAX_POINTS_X - 1) && WITHIN(py, 0, GRID_MAX_POINTS_X - 1)) {
8474
     SERIAL_ECHO_START;
8470
     SERIAL_ECHO_START;
8475
     SERIAL_ECHOPGM(MSG_ZPROBE_ZOFFSET " ");
8471
     SERIAL_ECHOPGM(MSG_ZPROBE_ZOFFSET " ");
8476
     if (code_seen('Z')) {
8472
     if (code_seen('Z')) {
8477
-      const float value = code_value_axis_units(Z_AXIS);
8473
+      const float value = code_value_linear_units();
8478
       if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
8474
       if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
8479
         zprobe_zoffset = value;
8475
         zprobe_zoffset = value;
8480
         refresh_zprobe_zoffset();
8476
         refresh_zprobe_zoffset();
8557
     RUNPLAN(FILAMENT_CHANGE_RETRACT_FEEDRATE);
8553
     RUNPLAN(FILAMENT_CHANGE_RETRACT_FEEDRATE);
8558
 
8554
 
8559
     // Lift Z axis
8555
     // Lift Z axis
8560
-    float z_lift = code_seen('Z') ? code_value_axis_units(Z_AXIS) :
8556
+    float z_lift = code_seen('Z') ? code_value_linear_units() :
8561
       #if defined(FILAMENT_CHANGE_Z_ADD) && FILAMENT_CHANGE_Z_ADD > 0
8557
       #if defined(FILAMENT_CHANGE_Z_ADD) && FILAMENT_CHANGE_Z_ADD > 0
8562
         FILAMENT_CHANGE_Z_ADD
8558
         FILAMENT_CHANGE_Z_ADD
8563
       #else
8559
       #else
8572
     }
8568
     }
8573
 
8569
 
8574
     // Move XY axes to filament exchange position
8570
     // Move XY axes to filament exchange position
8575
-    if (code_seen('X')) destination[X_AXIS] = code_value_axis_units(X_AXIS);
8571
+    if (code_seen('X')) destination[X_AXIS] = code_value_linear_units();
8576
     #ifdef FILAMENT_CHANGE_X_POS
8572
     #ifdef FILAMENT_CHANGE_X_POS
8577
       else destination[X_AXIS] = FILAMENT_CHANGE_X_POS;
8573
       else destination[X_AXIS] = FILAMENT_CHANGE_X_POS;
8578
     #endif
8574
     #endif
8579
 
8575
 
8580
-    if (code_seen('Y')) destination[Y_AXIS] = code_value_axis_units(Y_AXIS);
8576
+    if (code_seen('Y')) destination[Y_AXIS] = code_value_linear_units();
8581
     #ifdef FILAMENT_CHANGE_Y_POS
8577
     #ifdef FILAMENT_CHANGE_Y_POS
8582
       else destination[Y_AXIS] = FILAMENT_CHANGE_Y_POS;
8578
       else destination[Y_AXIS] = FILAMENT_CHANGE_Y_POS;
8583
     #endif
8579
     #endif
8766
       case DXC_AUTO_PARK_MODE:
8762
       case DXC_AUTO_PARK_MODE:
8767
         break;
8763
         break;
8768
       case DXC_DUPLICATION_MODE:
8764
       case DXC_DUPLICATION_MODE:
8769
-        if (code_seen('X')) duplicate_extruder_x_offset = max(code_value_axis_units(X_AXIS), X2_MIN_POS - x_home_pos(0));
8765
+        if (code_seen('X')) duplicate_extruder_x_offset = max(code_value_linear_units(), X2_MIN_POS - x_home_pos(0));
8770
         if (code_seen('R')) duplicate_extruder_temp_offset = code_value_temp_diff();
8766
         if (code_seen('R')) duplicate_extruder_temp_offset = code_value_temp_diff();
8771
         SERIAL_ECHO_START;
8767
         SERIAL_ECHO_START;
8772
         SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
8768
         SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
9127
    *
9123
    *
9128
    */
9124
    */
9129
   inline void gcode_M163() {
9125
   inline void gcode_M163() {
9130
-    int mix_index = code_seen('S') ? code_value_int() : 0;
9126
+    const int mix_index = code_seen('S') ? code_value_int() : 0;
9131
     if (mix_index < MIXING_STEPPERS) {
9127
     if (mix_index < MIXING_STEPPERS) {
9132
       float mix_value = code_seen('P') ? code_value_float() : 0.0;
9128
       float mix_value = code_seen('P') ? code_value_float() : 0.0;
9133
       NOLESS(mix_value, 0.0);
9129
       NOLESS(mix_value, 0.0);
9144
      *
9140
      *
9145
      */
9141
      */
9146
     inline void gcode_M164() {
9142
     inline void gcode_M164() {
9147
-      int tool_index = code_seen('S') ? code_value_int() : 0;
9143
+      const int tool_index = code_seen('S') ? code_value_int() : 0;
9148
       if (tool_index < MIXING_VIRTUAL_TOOLS) {
9144
       if (tool_index < MIXING_VIRTUAL_TOOLS) {
9149
         normalize_mix();
9145
         normalize_mix();
9150
         for (uint8_t i = 0; i < MIXING_STEPPERS; i++)
9146
         for (uint8_t i = 0; i < MIXING_STEPPERS; i++)
9542
 
9538
 
9543
     tool_change(
9539
     tool_change(
9544
       tmp_extruder,
9540
       tmp_extruder,
9545
-      code_seen('F') ? MMM_TO_MMS(code_value_axis_units(X_AXIS)) : 0.0,
9541
+      code_seen('F') ? MMM_TO_MMS(code_value_linear_units()) : 0.0,
9546
       (tmp_extruder == active_extruder) || (code_seen('S') && code_value_bool())
9542
       (tmp_extruder == active_extruder) || (code_seen('S') && code_value_bool())
9547
     );
9543
     );
9548
 
9544
 

正在加载...
取消
保存