Browse Source

Tweaks to core motion code

Scott Lahteine 7 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
   LOOP_XYZE(i) {
3354
   LOOP_XYZE(i) {
3355
     if (parser.seen(axis_codes[i])) {
3355
     if (parser.seen(axis_codes[i])) {
3356
       const float v = parser.value_axis_units((AxisEnum)i) + (axis_relative_modes[i] || relative_mode ? current_position[i] : 0);
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
     else
3359
     else
3360
       destination[i] = current_position[i];
3360
       destination[i] = current_position[i];
12716
 
12716
 
12717
 #endif // AUTO_BED_LEVELING_BILINEAR
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
    * Prepare a linear move in a DELTA or SCARA setup.
12723
    * Prepare a linear move in a DELTA or SCARA setup.
12723
    *
12724
    *
12724
    * This calls planner.buffer_line several times, adding
12725
    * This calls planner.buffer_line several times, adding
12725
    * small incremental moves for DELTA or SCARA.
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
   inline bool prepare_kinematic_move_to(float rtarget[XYZE]) {
12731
   inline bool prepare_kinematic_move_to(float rtarget[XYZE]) {
12728
 
12732
 
12841
     return false;
12845
     return false;
12842
   }
12846
   }
12843
 
12847
 
12844
-#else // !IS_KINEMATIC || UBL_DELTA
12848
+#else // !IS_KINEMATIC
12845
 
12849
 
12846
   /**
12850
   /**
12847
    * Prepare a linear move in a Cartesian setup.
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
    * Returns true if current_position[] was set to destination[]
12856
    * Returns true if current_position[] was set to destination[]
12851
    */
12857
    */
12852
   inline bool prepare_move_to_destination_cartesian() {
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
         #if ENABLED(AUTO_BED_LEVELING_UBL)
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
         #else
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
           if (current_position[X_AXIS] != destination[X_AXIS] || current_position[Y_AXIS] != destination[Y_AXIS]) {
12869
           if (current_position[X_AXIS] != destination[X_AXIS] || current_position[Y_AXIS] != destination[Y_AXIS]) {
12864
             #if ENABLED(MESH_BED_LEVELING)
12870
             #if ENABLED(MESH_BED_LEVELING)
12865
-              mesh_line_to_destination(fr_scaled);
12871
+              mesh_line_to_destination(MMS_SCALED(feedrate_mm_s));
12866
             #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
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
             #endif
12874
             #endif
12869
             return true;
12875
             return true;
12870
           }
12876
           }
12871
-          else {
12872
-            line_to_destination();
12873
-            return false;
12874
-          }
12875
         #endif
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
     return false;
12882
     return false;
12881
   }
12883
   }
12882
 
12884
 
12883
-#endif // !IS_KINEMATIC || UBL_DELTA
12885
+#endif // !IS_KINEMATIC
12886
+#endif // !UBL_DELTA
12884
 
12887
 
12885
 #if ENABLED(DUAL_X_CARRIAGE)
12888
 #if ENABLED(DUAL_X_CARRIAGE)
12886
 
12889
 

+ 2
- 4
Marlin/ubl_motion.cpp View File

489
     // We don't want additional apply_leveling() performed by regular buffer_line or buffer_line_kinematic,
489
     // We don't want additional apply_leveling() performed by regular buffer_line or buffer_line_kinematic,
490
     // so we call _buffer_line directly here.  Per-segmented leveling and kinematics performed first.
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
       #if ENABLED(DELTA)  // apply delta inverse_kinematics
494
       #if ENABLED(DELTA)  // apply delta inverse_kinematics
495
 
495
 
507
 
507
 
508
         planner._buffer_line(delta_A, delta_B, delta_C, e, fr, active_extruder);
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
         const float lseg[XYZ] = { rx, ry, rz };
512
         const float lseg[XYZ] = { rx, ry, rz };
513
 
513
 
524
 
524
 
525
       #else // CARTESIAN
525
       #else // CARTESIAN
526
 
526
 
527
-        // Cartesian _buffer_line seems to take LOGICAL, not RAW coordinates
528
-
529
         planner._buffer_line(rx, ry, rz, e, fr, active_extruder);
527
         planner._buffer_line(rx, ry, rz, e, fr, active_extruder);
530
 
528
 
531
       #endif
529
       #endif

Loading…
Cancel
Save