Parcourir la source

Add UBL support for G2/G3 and G5 (#10648)

Scott Lahteine il y a 7 ans
Parent
révision
19f189b4e5
Aucun compte lié à l'adresse e-mail de l'auteur

+ 8
- 0
Marlin/src/gcode/motion/G2_G3.cpp Voir le fichier

@@ -199,6 +199,10 @@ void plan_arc(
199 199
       ADJUST_DELTA(raw);
200 200
       planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], raw[Z_AXIS], raw[E_AXIS], HYPOT(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB) * inverse_secs, active_extruder);
201 201
       oldA = delta[A_AXIS]; oldB = delta[B_AXIS];
202
+    #elif HAS_UBL_AND_CURVES
203
+      float pos[XYZ] = { raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS] };
204
+      planner.apply_leveling(pos);
205
+      planner.buffer_segment(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS], raw[E_AXIS], fr_mm_s, active_extruder);
202 206
     #else
203 207
       planner.buffer_line_kinematic(raw, fr_mm_s, active_extruder);
204 208
     #endif
@@ -211,6 +215,10 @@ void plan_arc(
211 215
     const float diff2 = HYPOT2(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB);
212 216
     if (diff2)
213 217
       planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], cart[Z_AXIS], cart[E_AXIS], SQRT(diff2) * inverse_secs, active_extruder);
218
+  #elif HAS_UBL_AND_CURVES
219
+    float pos[XYZ] = { cart[X_AXIS], cart[Y_AXIS], cart[Z_AXIS] };
220
+    planner.apply_leveling(pos);
221
+    planner.buffer_segment(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS], cart[E_AXIS], fr_mm_s, active_extruder);
214 222
   #else
215 223
     planner.buffer_line_kinematic(cart, fr_mm_s, active_extruder);
216 224
   #endif

+ 1
- 0
Marlin/src/inc/Conditionals_post.h Voir le fichier

@@ -1058,6 +1058,7 @@
1058 1058
 #define HAS_MESH       (ENABLED(AUTO_BED_LEVELING_BILINEAR) || ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(MESH_BED_LEVELING))
1059 1059
 #define PLANNER_LEVELING      (OLDSCHOOL_ABL || ENABLED(MESH_BED_LEVELING) || UBL_SEGMENTED || ENABLED(SKEW_CORRECTION))
1060 1060
 #define HAS_PROBING_PROCEDURE (HAS_ABL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST))
1061
+#define HAS_UBL_AND_CURVES (ENABLED(AUTO_BED_LEVELING_UBL) && !PLANNER_LEVELING && (ENABLED(ARC_SUPPORT) || ENABLED(BEZIER_CURVE_SUPPORT)))
1061 1062
 
1062 1063
 #if ENABLED(AUTO_BED_LEVELING_UBL)
1063 1064
   #undef LCD_BED_LEVELING

+ 5
- 1
Marlin/src/module/planner.cpp Voir le fichier

@@ -1190,7 +1190,7 @@ void Planner::check_axes_activity() {
1190 1190
   }
1191 1191
 #endif
1192 1192
 
1193
-#if PLANNER_LEVELING
1193
+#if PLANNER_LEVELING || HAS_UBL_AND_CURVES
1194 1194
   /**
1195 1195
    * rx, ry, rz - Cartesian positions in mm
1196 1196
    *              Leveled XYZ on completion
@@ -1242,6 +1242,10 @@ void Planner::check_axes_activity() {
1242 1242
     #endif
1243 1243
   }
1244 1244
 
1245
+#endif
1246
+
1247
+#if PLANNER_LEVELING
1248
+
1245 1249
   void Planner::unapply_leveling(float raw[XYZ]) {
1246 1250
 
1247 1251
     if (leveling_active) {

+ 12
- 7
Marlin/src/module/planner.h Voir le fichier

@@ -404,19 +404,24 @@ class Planner {
404 404
 
405 405
     #endif // SKEW_CORRECTION
406 406
 
407
-    #if PLANNER_LEVELING
408
-
409
-      #define ARG_X float rx
410
-      #define ARG_Y float ry
411
-      #define ARG_Z float rz
407
+    #if PLANNER_LEVELING || HAS_UBL_AND_CURVES
412 408
 
413 409
       /**
414 410
        * Apply leveling to transform a cartesian position
415 411
        * as it will be given to the planner and steppers.
416 412
        */
417 413
       static void apply_leveling(float &rx, float &ry, float &rz);
418
-      static void apply_leveling(float (&raw)[XYZ]) { apply_leveling(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS]); }
419
-      static void unapply_leveling(float raw[XYZ]);
414
+      FORCE_INLINE static void apply_leveling(float (&raw)[XYZ]) { apply_leveling(raw[X_AXIS], raw[Y_AXIS], raw[Z_AXIS]); }
415
+
416
+      #if PLANNER_LEVELING
417
+
418
+        #define ARG_X float rx
419
+        #define ARG_Y float ry
420
+        #define ARG_Z float rz
421
+
422
+        static void unapply_leveling(float raw[XYZ]);
423
+
424
+      #endif
420 425
 
421 426
     #else
422 427
 

+ 8
- 1
Marlin/src/module/planner_bezier.cpp Voir le fichier

@@ -190,7 +190,14 @@ void cubic_b_spline(const float position[NUM_AXIS], const float target[NUM_AXIS]
190 190
     bez_target[Z_AXIS] = interp(position[Z_AXIS], target[Z_AXIS], t);
191 191
     bez_target[E_AXIS] = interp(position[E_AXIS], target[E_AXIS], t);
192 192
     clamp_to_software_endstops(bez_target);
193
-    planner.buffer_line_kinematic(bez_target, fr_mm_s, extruder);
193
+
194
+    #if HAS_UBL_AND_CURVES
195
+      float pos[XYZ] = { bez_target[X_AXIS], bez_target[Y_AXIS], bez_target[Z_AXIS] };
196
+      planner.apply_leveling(pos);
197
+      planner.buffer_segment(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS], bez_target[E_AXIS], fr_mm_s, active_extruder);
198
+    #else
199
+      planner.buffer_line_kinematic(bez_target, fr_mm_s, extruder);
200
+    #endif
194 201
   }
195 202
 }
196 203
 

Chargement…
Annuler
Enregistrer