Browse Source

Tweaks to core motion code

Scott Lahteine 6 years ago
parent
commit
2559745f54
2 changed files with 27 additions and 26 deletions
  1. 25
    22
      Marlin/Marlin_main.cpp
  2. 2
    4
      Marlin/ubl_motion.cpp

+ 25
- 22
Marlin/Marlin_main.cpp View File

@@ -3354,7 +3354,7 @@ void gcode_get_destination() {
3354 3354
   LOOP_XYZE(i) {
3355 3355
     if (parser.seen(axis_codes[i])) {
3356 3356
       const float v = parser.value_axis_units((AxisEnum)i) + (axis_relative_modes[i] || relative_mode ? current_position[i] : 0);
3357
-      destination[i] = (i == E_AXIS ? v : LOGICAL_TO_NATIVE(v, i));
3357
+      destination[i] = i == E_AXIS ? v : LOGICAL_TO_NATIVE(v, i);
3358 3358
     }
3359 3359
     else
3360 3360
       destination[i] = current_position[i];
@@ -12716,13 +12716,17 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12716 12716
 
12717 12717
 #endif // AUTO_BED_LEVELING_BILINEAR
12718 12718
 
12719
-#if IS_KINEMATIC && !UBL_DELTA
12719
+#if !UBL_DELTA
12720
+#if IS_KINEMATIC
12720 12721
 
12721 12722
   /**
12722 12723
    * Prepare a linear move in a DELTA or SCARA setup.
12723 12724
    *
12724 12725
    * This calls planner.buffer_line several times, adding
12725 12726
    * small incremental moves for DELTA or SCARA.
12727
+   *
12728
+   * For Unified Bed Leveling (Delta or Segmented Cartesian)
12729
+   * the ubl.prepare_segmented_line_to method replaces this.
12726 12730
    */
12727 12731
   inline bool prepare_kinematic_move_to(float rtarget[XYZE]) {
12728 12732
 
@@ -12841,46 +12845,45 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
12841 12845
     return false;
12842 12846
   }
12843 12847
 
12844
-#else // !IS_KINEMATIC || UBL_DELTA
12848
+#else // !IS_KINEMATIC
12845 12849
 
12846 12850
   /**
12847 12851
    * Prepare a linear move in a Cartesian setup.
12848
-   * If Mesh Bed Leveling is enabled, perform a mesh move.
12852
+   *
12853
+   * When a mesh-based leveling system is active, moves are segmented
12854
+   * according to the configuration of the leveling system.
12849 12855
    *
12850 12856
    * Returns true if current_position[] was set to destination[]
12851 12857
    */
12852 12858
   inline bool prepare_move_to_destination_cartesian() {
12853
-    const float fr_scaled = MMS_SCALED(feedrate_mm_s);
12854
-      #if HAS_MESH
12855
-        if (!planner.leveling_active) {
12856
-          line_to_destination(fr_scaled);
12857
-          return false;
12858
-        }
12859
+    #if HAS_MESH
12860
+      if (planner.leveling_active) {
12859 12861
         #if ENABLED(AUTO_BED_LEVELING_UBL)
12860
-          ubl.line_to_destination_cartesian(fr_scaled, active_extruder);  // UBL's motion routine needs to know about all moves,
12861
-          return true;                                                    // even purely Z-Axis moves
12862
+          ubl.line_to_destination_cartesian(MMS_SCALED(feedrate_mm_s), active_extruder);  // UBL's motion routine needs to know about
12863
+          return true;                                                                    // all moves, including Z-only moves.
12862 12864
         #else
12865
+          /**
12866
+           * For MBL and ABL-BILINEAR only segment moves when X or Y are involved.
12867
+           * Otherwise fall through to do a direct single move.
12868
+           */
12863 12869
           if (current_position[X_AXIS] != destination[X_AXIS] || current_position[Y_AXIS] != destination[Y_AXIS]) {
12864 12870
             #if ENABLED(MESH_BED_LEVELING)
12865
-              mesh_line_to_destination(fr_scaled);
12871
+              mesh_line_to_destination(MMS_SCALED(feedrate_mm_s));
12866 12872
             #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
12867
-              bilinear_line_to_destination(fr_scaled);
12873
+              bilinear_line_to_destination(MMS_SCALED(feedrate_mm_s));
12868 12874
             #endif
12869 12875
             return true;
12870 12876
           }
12871
-          else {
12872
-            line_to_destination();
12873
-            return false;
12874
-          }
12875 12877
         #endif
12876
-      #else
12877
-        line_to_destination();
12878
-      #endif // HAS_MESH
12878
+      }
12879
+    #endif // HAS_MESH
12879 12880
 
12881
+    line_to_destination(MMS_SCALED(feedrate_mm_s));
12880 12882
     return false;
12881 12883
   }
12882 12884
 
12883
-#endif // !IS_KINEMATIC || UBL_DELTA
12885
+#endif // !IS_KINEMATIC
12886
+#endif // !UBL_DELTA
12884 12887
 
12885 12888
 #if ENABLED(DUAL_X_CARRIAGE)
12886 12889
 

+ 2
- 4
Marlin/ubl_motion.cpp View File

@@ -489,7 +489,7 @@
489 489
     // We don't want additional apply_leveling() performed by regular buffer_line or buffer_line_kinematic,
490 490
     // so we call _buffer_line directly here.  Per-segmented leveling and kinematics performed first.
491 491
 
492
-    inline void _O2 ubl_buffer_segment_raw( float rx, float ry, float rz, float e, float fr ) {
492
+    inline void _O2 ubl_buffer_segment_raw(const float &rx, const float &ry, const float rz, const float &e, const float &fr) {
493 493
 
494 494
       #if ENABLED(DELTA)  // apply delta inverse_kinematics
495 495
 
@@ -507,7 +507,7 @@
507 507
 
508 508
         planner._buffer_line(delta_A, delta_B, delta_C, e, fr, active_extruder);
509 509
 
510
-      #elif IS_SCARA  // apply scara inverse_kinematics (should be changed to save raw->logical->raw)
510
+      #elif IS_SCARA  // apply scara inverse_kinematics
511 511
 
512 512
         const float lseg[XYZ] = { rx, ry, rz };
513 513
 
@@ -524,8 +524,6 @@
524 524
 
525 525
       #else // CARTESIAN
526 526
 
527
-        // Cartesian _buffer_line seems to take LOGICAL, not RAW coordinates
528
-
529 527
         planner._buffer_line(rx, ry, rz, e, fr, active_extruder);
530 528
 
531 529
       #endif

Loading…
Cancel
Save