瀏覽代碼

Use a macro for kinematic sync_plan_position

Scott Lahteine 9 年之前
父節點
當前提交
b4a9d2366c
共有 1 個檔案被更改,包括 33 行新增88 行删除
  1. 33
    88
      Marlin/Marlin_main.cpp

+ 33
- 88
Marlin/Marlin_main.cpp 查看文件

@@ -582,6 +582,9 @@ static void report_current_position();
582 582
     calculate_delta(current_position);
583 583
     planner.set_position_mm(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
584 584
   }
585
+  #define SYNC_PLAN_POSITION_KINEMATIC() sync_plan_position_delta()
586
+#else
587
+  #define SYNC_PLAN_POSITION_KINEMATIC() sync_plan_position()
585 588
 #endif
586 589
 
587 590
 #if ENABLED(SDSUPPORT)
@@ -866,7 +869,7 @@ void setup() {
866 869
 
867 870
   #if ENABLED(DELTA) || ENABLED(SCARA)
868 871
     // Vital to init kinematic equivalent for X0 Y0 Z0
869
-    sync_plan_position_delta();
872
+    SYNC_PLAN_POSITION_KINEMATIC();
870 873
   #endif
871 874
 
872 875
   thermalManager.init();    // Initialize temperature loop
@@ -1997,7 +2000,7 @@ static void setup_for_endstop_move() {
1997 2000
         if (DEBUGGING(LEVELING)) DEBUG_POS("run_z_probe (DELTA) 2", current_position);
1998 2001
       #endif
1999 2002
 
2000
-      sync_plan_position_delta();
2003
+      SYNC_PLAN_POSITION_KINEMATIC();
2001 2004
 
2002 2005
     #else // !DELTA
2003 2006
 
@@ -2036,11 +2039,7 @@ static void setup_for_endstop_move() {
2036 2039
       // Get the current stepper position after bumping an endstop
2037 2040
       current_position[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
2038 2041
 
2039
-      #if ENABLED(SCARA)
2040
-        sync_plan_position_delta();
2041
-      #else
2042
-        sync_plan_position();
2043
-      #endif
2042
+      SYNC_PLAN_POSITION_KINEMATIC();
2044 2043
 
2045 2044
       #if ENABLED(DEBUG_LEVELING_FEATURE)
2046 2045
         if (DEBUGGING(LEVELING)) DEBUG_POS("run_z_probe", current_position);
@@ -2084,11 +2083,7 @@ static void setup_for_endstop_move() {
2084 2083
           if (DEBUGGING(LEVELING)) DEBUG_POS("<<< set_bed_level_equation_lsq", corrected_position);
2085 2084
         #endif
2086 2085
 
2087
-        #if ENABLED(SCARA)
2088
-          sync_plan_position_delta();
2089
-        #else
2090
-          sync_plan_position();
2091
-        #endif
2086
+        SYNC_PLAN_POSITION_KINEMATIC();
2092 2087
       }
2093 2088
 
2094 2089
     #endif // !DELTA
@@ -2128,11 +2123,7 @@ static void setup_for_endstop_move() {
2128 2123
         if (DEBUGGING(LEVELING)) DEBUG_POS("set_bed_level_equation_3pts", corrected_position);
2129 2124
       #endif
2130 2125
 
2131
-      #if ENABLED(DELTA) || ENABLED(SCARA)
2132
-        sync_plan_position_delta();
2133
-      #else
2134
-        sync_plan_position();
2135
-      #endif
2126
+      SYNC_PLAN_POSITION_KINEMATIC();
2136 2127
     }
2137 2128
 
2138 2129
   #endif // !AUTO_BED_LEVELING_GRID
@@ -2334,11 +2325,7 @@ static void homeaxis(AxisEnum axis) {
2334 2325
 
2335 2326
     // Set the axis position as setup for the move
2336 2327
     current_position[axis] = 0;
2337
-    #if ENABLED(DELTA) || ENABLED(SCARA)
2338
-      sync_plan_position_delta();
2339
-    #else
2340
-      sync_plan_position();
2341
-    #endif
2328
+    SYNC_PLAN_POSITION_KINEMATIC();
2342 2329
 
2343 2330
     // Homing Z towards the bed? Deploy the Z probe or endstop.
2344 2331
     #if HAS_BED_PROBE
@@ -2363,11 +2350,7 @@ static void homeaxis(AxisEnum axis) {
2363 2350
 
2364 2351
     // Set the axis position as setup for the move
2365 2352
     current_position[axis] = 0;
2366
-    #if ENABLED(DELTA) || ENABLED(SCARA)
2367
-      sync_plan_position_delta();
2368
-    #else
2369
-      sync_plan_position();
2370
-    #endif
2353
+    SYNC_PLAN_POSITION_KINEMATIC();
2371 2354
 
2372 2355
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2373 2356
       if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(false)");
@@ -2408,7 +2391,7 @@ static void homeaxis(AxisEnum axis) {
2408 2391
           lockZ1 = (z_endstop_adj < 0);
2409 2392
 
2410 2393
         if (lockZ1) stepper.set_z_lock(true); else stepper.set_z2_lock(true);
2411
-        sync_plan_position();
2394
+        SYNC_PLAN_POSITION_KINEMATIC();
2412 2395
 
2413 2396
         // Move to the adjusted endstop height
2414 2397
         feedrate = homing_feedrate[axis];
@@ -2428,7 +2411,7 @@ static void homeaxis(AxisEnum axis) {
2428 2411
           if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(false)");
2429 2412
         #endif
2430 2413
         endstops.enable(false); // Disable endstops while moving away
2431
-        sync_plan_position_delta();
2414
+        SYNC_PLAN_POSITION_KINEMATIC();
2432 2415
         destination[axis] = endstop_adj[axis];
2433 2416
         #if ENABLED(DEBUG_LEVELING_FEATURE)
2434 2417
           if (DEBUGGING(LEVELING)) {
@@ -2456,11 +2439,7 @@ static void homeaxis(AxisEnum axis) {
2456 2439
     // Set the axis position to its home position (plus home offsets)
2457 2440
     set_axis_is_at_home(axis);
2458 2441
 
2459
-    #if ENABLED(DELTA) || ENABLED(SCARA)
2460
-      sync_plan_position_delta();
2461
-    #else
2462
-      sync_plan_position();
2463
-    #endif
2442
+    SYNC_PLAN_POSITION_KINEMATIC();
2464 2443
 
2465 2444
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2466 2445
       if (DEBUGGING(LEVELING)) DEBUG_POS("> AFTER set_axis_is_at_home", current_position);
@@ -2511,11 +2490,7 @@ static void homeaxis(AxisEnum axis) {
2511 2490
 
2512 2491
       if (retract_zlift > 0.01) {
2513 2492
         current_position[Z_AXIS] -= retract_zlift;
2514
-        #if ENABLED(DELTA) || ENABLED(SCARA)
2515
-          sync_plan_position_delta();
2516
-        #else
2517
-          sync_plan_position();
2518
-        #endif
2493
+        SYNC_PLAN_POSITION_KINEMATIC();
2519 2494
         prepare_move_to_destination();
2520 2495
       }
2521 2496
     }
@@ -2523,11 +2498,7 @@ static void homeaxis(AxisEnum axis) {
2523 2498
 
2524 2499
       if (retract_zlift > 0.01) {
2525 2500
         current_position[Z_AXIS] += retract_zlift;
2526
-        #if ENABLED(DELTA) || ENABLED(SCARA)
2527
-          sync_plan_position_delta();
2528
-        #else
2529
-          sync_plan_position();
2530
-        #endif
2501
+        SYNC_PLAN_POSITION_KINEMATIC();
2531 2502
       }
2532 2503
 
2533 2504
       feedrate = retract_recover_feedrate * 60;
@@ -2838,7 +2809,7 @@ inline void gcode_G28() {
2838 2809
     HOMEAXIS(Y);
2839 2810
     HOMEAXIS(Z);
2840 2811
 
2841
-    sync_plan_position_delta();
2812
+    SYNC_PLAN_POSITION_KINEMATIC();
2842 2813
 
2843 2814
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2844 2815
       if (DEBUGGING(LEVELING)) DEBUG_POS("(DELTA)", current_position);
@@ -2900,7 +2871,7 @@ inline void gcode_G28() {
2900 2871
           int x_axis_home_dir = home_dir(X_AXIS);
2901 2872
         #endif
2902 2873
 
2903
-        sync_plan_position();
2874
+        SYNC_PLAN_POSITION_KINEMATIC();
2904 2875
 
2905 2876
         float mlx = max_length(X_AXIS), mly = max_length(Y_AXIS),
2906 2877
               mlratio = mlx > mly ? mly / mlx : mlx / mly;
@@ -2913,7 +2884,7 @@ inline void gcode_G28() {
2913 2884
 
2914 2885
         set_axis_is_at_home(X_AXIS);
2915 2886
         set_axis_is_at_home(Y_AXIS);
2916
-        sync_plan_position();
2887
+        SYNC_PLAN_POSITION_KINEMATIC();
2917 2888
 
2918 2889
         #if ENABLED(DEBUG_LEVELING_FEATURE)
2919 2890
           if (DEBUGGING(LEVELING)) DEBUG_POS("> QUICK_HOME 1", current_position);
@@ -2997,7 +2968,7 @@ inline void gcode_G28() {
2997 2968
              * enough to reach Z_SAFE_HOMING XY positions.
2998 2969
              * Just make sure the planner is in sync.
2999 2970
              */
3000
-            sync_plan_position();
2971
+            SYNC_PLAN_POSITION_KINEMATIC();
3001 2972
 
3002 2973
             /**
3003 2974
              * Set the Z probe (or just the nozzle) destination to the safe
@@ -3082,11 +3053,7 @@ inline void gcode_G28() {
3082 3053
 
3083 3054
     #endif // Z_HOME_DIR < 0
3084 3055
 
3085
-    #if ENABLED(SCARA)
3086
-      sync_plan_position_delta();
3087
-    #else
3088
-      sync_plan_position();
3089
-    #endif
3056
+    SYNC_PLAN_POSITION_KINEMATIC();
3090 3057
 
3091 3058
   #endif // !DELTA (gcode_G28)
3092 3059
 
@@ -3104,7 +3071,7 @@ inline void gcode_G28() {
3104 3071
     if (mbl.has_mesh()) {
3105 3072
       if (home_all_axis || (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && homeZ)) {
3106 3073
         current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
3107
-        sync_plan_position();
3074
+        SYNC_PLAN_POSITION_KINEMATIC();
3108 3075
         mbl.set_active(true);
3109 3076
         #if ENABLED(MESH_G28_REST_ORIGIN)
3110 3077
           current_position[Z_AXIS] = 0.0;
@@ -3120,7 +3087,7 @@ inline void gcode_G28() {
3120 3087
       }
3121 3088
       else if ((axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) && (homeX || homeY)) {
3122 3089
         current_position[Z_AXIS] = pre_home_z;
3123
-        sync_plan_position();
3090
+        SYNC_PLAN_POSITION_KINEMATIC();
3124 3091
         mbl.set_active(true);
3125 3092
         current_position[Z_AXIS] = pre_home_z -
3126 3093
           mbl.get_z(current_position[X_AXIS] - home_offset[X_AXIS],
@@ -3248,7 +3215,7 @@ inline void gcode_G28() {
3248 3215
         if (probe_point == 0) {
3249 3216
           // For the intial G29 S2 make Z a positive value (e.g., 4.0)
3250 3217
           current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
3251
-          sync_plan_position();
3218
+          SYNC_PLAN_POSITION_KINEMATIC();
3252 3219
         }
3253 3220
         else {
3254 3221
           // For G29 S2 after adjusting Z.
@@ -3328,7 +3295,7 @@ inline void gcode_G28() {
3328 3295
             mbl.get_z(current_position[X_AXIS] - home_offset[X_AXIS],
3329 3296
                       current_position[Y_AXIS] - home_offset[Y_AXIS]) - MESH_HOME_SEARCH_Z;
3330 3297
           mbl.reset();
3331
-          sync_plan_position();
3298
+          SYNC_PLAN_POSITION_KINEMATIC();
3332 3299
         }
3333 3300
         else
3334 3301
           mbl.reset();
@@ -3496,11 +3463,7 @@ inline void gcode_G28() {
3496 3463
           if (DEBUGGING(LEVELING)) DEBUG_POS("AFTER matrix.set_to_identity", uncorrected_position);
3497 3464
         #endif
3498 3465
 
3499
-        #if ENABLED(SCARA)
3500
-          sync_plan_position_delta();
3501
-        #else
3502
-          sync_plan_position();
3503
-        #endif
3466
+        SYNC_PLAN_POSITION_KINEMATIC();
3504 3467
 
3505 3468
       #endif // !DELTA
3506 3469
     }
@@ -3818,11 +3781,7 @@ inline void gcode_G28() {
3818 3781
           #endif
3819 3782
         ;
3820 3783
         // current_position[Z_AXIS] += home_offset[Z_AXIS]; // The Z probe determines Z=0, not "Z home"
3821
-        #if ENABLED(SCARA)
3822
-          sync_plan_position_delta();
3823
-        #else
3824
-          sync_plan_position();
3825
-        #endif
3784
+        SYNC_PLAN_POSITION_KINEMATIC();
3826 3785
 
3827 3786
         #if ENABLED(DEBUG_LEVELING_FEATURE)
3828 3787
           if (DEBUGGING(LEVELING)) DEBUG_POS("> corrected Z in G29", current_position);
@@ -3919,16 +3878,10 @@ inline void gcode_G92() {
3919 3878
       }
3920 3879
     }
3921 3880
   }
3922
-  if (didXYZ) {
3923
-    #if ENABLED(DELTA) || ENABLED(SCARA)
3924
-      sync_plan_position_delta();
3925
-    #else
3926
-      sync_plan_position();
3927
-    #endif
3928
-  }
3929
-  else if (didE) {
3881
+  if (didXYZ)
3882
+    SYNC_PLAN_POSITION_KINEMATIC();
3883
+  else if (didE)
3930 3884
     sync_plan_position_e();
3931
-  }
3932 3885
 }
3933 3886
 
3934 3887
 #if ENABLED(ULTIPANEL)
@@ -5420,7 +5373,7 @@ inline void gcode_M206() {
5420 5373
     if (code_seen('P')) set_home_offset(Y_AXIS, code_value_axis_units(Y_AXIS)); // Psi
5421 5374
   #endif
5422 5375
 
5423
-  sync_plan_position();
5376
+  SYNC_PLAN_POSITION_KINEMATIC();
5424 5377
   report_current_position();
5425 5378
 }
5426 5379
 
@@ -6171,11 +6124,7 @@ inline void gcode_M428() {
6171 6124
   }
6172 6125
 
6173 6126
   if (!err) {
6174
-    #if ENABLED(DELTA) || ENABLED(SCARA)
6175
-      sync_plan_position_delta();
6176
-    #else
6177
-      sync_plan_position();
6178
-    #endif
6127
+    SYNC_PLAN_POSITION_KINEMATIC();
6179 6128
     report_current_position();
6180 6129
     LCD_MESSAGEPGM(MSG_HOME_OFFSETS_APPLIED);
6181 6130
     #if HAS_BUZZER
@@ -6741,11 +6690,7 @@ inline void gcode_T(uint8_t tmp_extruder) {
6741 6690
       #endif // !DUAL_X_CARRIAGE
6742 6691
 
6743 6692
       // Tell the planner the new "current position"
6744
-      #if ENABLED(DELTA) || ENABLED(SCARA)
6745
-        sync_plan_position_delta();
6746
-      #else
6747
-        sync_plan_position();
6748
-      #endif
6693
+      SYNC_PLAN_POSITION_KINEMATIC();
6749 6694
 
6750 6695
       // Move to the "old position" (move the extruder into place)
6751 6696
       if (!no_move && IsRunning()) prepare_move_to_destination();
@@ -7694,7 +7639,7 @@ void mesh_buffer_line(float x, float y, float z, const float e, float feed_rate,
7694 7639
         planner.set_position_mm(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
7695 7640
         planner.buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset,
7696 7641
                          current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], planner.max_feedrate[X_AXIS], 1);
7697
-        sync_plan_position();
7642
+        SYNC_PLAN_POSITION_KINEMATIC();
7698 7643
         stepper.synchronize();
7699 7644
         extruder_duplication_enabled = true;
7700 7645
         active_extruder_parked = false;

Loading…
取消
儲存