Преглед на файлове

Merge pull request #4342 from AnHardt/rep-cons-g28

Introduce line_to_axis_pos() for use in homeaxis()
Scott Lahteine преди 9 години
родител
ревизия
0f9953b031
променени са 1 файла, в които са добавени 44 реда и са изтрити 37 реда
  1. 44
    37
      Marlin/Marlin_main.cpp

+ 44
- 37
Marlin/Marlin_main.cpp Целия файл

@@ -1613,9 +1613,20 @@ inline float set_homing_bump_feedrate(AxisEnum axis) {
1613 1613
 inline void line_to_current_position() {
1614 1614
   planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMM_TO_MMS(feedrate_mm_m), active_extruder);
1615 1615
 }
1616
+
1616 1617
 inline void line_to_z(float zPosition) {
1617 1618
   planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], MMM_TO_MMS(feedrate_mm_m), active_extruder);
1618 1619
 }
1620
+
1621
+inline void line_to_axis_pos(AxisEnum axis, float where, float fr_mm_m = 0.0) {
1622
+  float old_feedrate_mm_m = feedrate_mm_m;
1623
+  current_position[axis] = where;
1624
+  feedrate_mm_m = (fr_mm_m != 0.0) ? fr_mm_m : homing_feedrate_mm_m[axis];
1625
+  planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMM_TO_MMS(feedrate_mm_m), active_extruder);
1626
+  stepper.synchronize(); // The lost one
1627
+  feedrate_mm_m = old_feedrate_mm_m;
1628
+}
1629
+
1619 1630
 //
1620 1631
 // line_to_destination
1621 1632
 // Move the planner, not necessarily synced with current_position
@@ -1708,11 +1719,6 @@ static void do_blocking_move_to(float x, float y, float z, float fr_mm_m = 0.0)
1708 1719
   feedrate_mm_m = old_feedrate_mm_m;
1709 1720
 }
1710 1721
 
1711
-inline void do_blocking_move_to_axis_pos(AxisEnum axis, float where, float fr_mm_m = 0.0) {
1712
-  current_position[axis] = where;
1713
-  do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_m);
1714
-}
1715
-
1716 1722
 inline void do_blocking_move_to_x(float x, float fr_mm_m = 0.0) {
1717 1723
   do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_m);
1718 1724
 }
@@ -2425,19 +2431,17 @@ static void homeaxis(AxisEnum axis) {
2425 2431
   #endif
2426 2432
 
2427 2433
   // Move towards the endstop until an endstop is triggered
2428
-  do_blocking_move_to_axis_pos(axis, 1.5 * max_length(axis) * axis_home_dir, homing_feedrate_mm_m[axis]);
2434
+  line_to_axis_pos(axis, 1.5 * max_length(axis) * axis_home_dir);
2429 2435
 
2430 2436
   // Set the axis position as setup for the move
2431 2437
   current_position[axis] = 0;
2432 2438
   sync_plan_position();
2433 2439
 
2434 2440
   // Move away from the endstop by the axis HOME_BUMP_MM
2435
-  do_blocking_move_to_axis_pos(axis, -home_bump_mm(axis) * axis_home_dir, homing_feedrate_mm_m[axis]);
2436
-
2437
-  // Slow down the feedrate for the next move
2441
+  line_to_axis_pos(axis, -home_bump_mm(axis) * axis_home_dir);
2438 2442
 
2439 2443
   // Move slowly towards the endstop until triggered
2440
-  do_blocking_move_to_axis_pos(axis, 2 * home_bump_mm(axis) * axis_home_dir, set_homing_bump_feedrate(axis));
2444
+  line_to_axis_pos(axis, 2 * home_bump_mm(axis) * axis_home_dir, set_homing_bump_feedrate(axis));
2441 2445
 
2442 2446
   #if ENABLED(DEBUG_LEVELING_FEATURE)
2443 2447
     if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position);
@@ -2458,7 +2462,7 @@ static void homeaxis(AxisEnum axis) {
2458 2462
       sync_plan_position();
2459 2463
 
2460 2464
       // Move to the adjusted endstop height
2461
-      do_blocking_move_to_z(adj, homing_feedrate_mm_m[axis]);
2465
+      line_to_axis_pos(axis, adj);
2462 2466
 
2463 2467
       if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
2464 2468
       stepper.set_homing_flag(false);
@@ -2475,7 +2479,7 @@ static void homeaxis(AxisEnum axis) {
2475 2479
           DEBUG_POS("", current_position);
2476 2480
         }
2477 2481
       #endif
2478
-      do_blocking_move_to_axis_pos(axis, endstop_adj[axis], set_homing_bump_feedrate(axis));
2482
+      line_to_axis_pos(axis, endstop_adj[axis]);
2479 2483
     }
2480 2484
   #endif
2481 2485
 
@@ -2825,10 +2829,28 @@ inline void gcode_G4() {
2825 2829
   }
2826 2830
 #endif
2827 2831
 
2832
+#if ENABLED(NOZZLE_PARK_FEATURE)
2833
+  #include "nozzle.h"
2834
+
2835
+  /**
2836
+   * G27: Park the nozzle
2837
+   */
2838
+  inline void gcode_G27() {
2839
+    // Don't allow nozzle parking without homing first
2840
+    if (axis_unhomed_error(true, true, true)) { return; }
2841
+    uint8_t const z_action = code_seen('P') ? code_value_ushort() : 0;
2842
+    Nozzle::park(z_action);
2843
+  }
2844
+#endif // NOZZLE_PARK_FEATURE
2845
+
2828 2846
 #if ENABLED(QUICK_HOME)
2829 2847
 
2830 2848
   static void quick_home_xy() {
2831 2849
 
2850
+    // Pretend the current position is 0,0
2851
+    current_position[X_AXIS] = current_position[Y_AXIS] = 0.0;
2852
+    sync_plan_position();
2853
+
2832 2854
     #if ENABLED(DUAL_X_CARRIAGE)
2833 2855
       int x_axis_home_dir = x_home_dir(active_extruder);
2834 2856
       extruder_duplication_enabled = false;
@@ -2839,30 +2861,16 @@ inline void gcode_G4() {
2839 2861
     float mlx = max_length(X_AXIS),
2840 2862
           mly = max_length(Y_AXIS),
2841 2863
           mlratio = mlx > mly ? mly / mlx : mlx / mly,
2842
-          fr_mm_m = min(homing_feedrate_mm_m[X_AXIS], homing_feedrate_mm_m[Y_AXIS]) * sqrt(sq(mlratio) + 1);
2864
+          fr_mm_m = min(homing_feedrate_mm_m[X_AXIS], homing_feedrate_mm_m[Y_AXIS]) * sqrt(sq(mlratio) + 1.0);
2843 2865
 
2844 2866
     do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_m);
2845 2867
     endstops.hit_on_purpose(); // clear endstop hit flags
2846
-    current_position[X_AXIS] = current_position[Y_AXIS] = 0;
2868
+    current_position[X_AXIS] = current_position[Y_AXIS] = 0.0;
2847 2869
 
2848 2870
   }
2849 2871
 
2850 2872
 #endif // QUICK_HOME
2851 2873
 
2852
-#if ENABLED(NOZZLE_PARK_FEATURE)
2853
-  #include "nozzle.h"
2854
-
2855
-  /**
2856
-   * G27: Park the nozzle
2857
-   */
2858
-  inline void gcode_G27() {
2859
-    // Don't allow nozzle parking without homing first
2860
-    if (axis_unhomed_error(true, true, true)) { return; }
2861
-    uint8_t const z_action = code_seen('P') ? code_value_ushort() : 0;
2862
-    Nozzle::park(z_action);
2863
-  }
2864
-#endif // NOZZLE_PARK_FEATURE
2865
-
2866 2874
 /**
2867 2875
  * G28: Home all axes according to settings
2868 2876
  *
@@ -2931,20 +2939,19 @@ inline void gcode_G28() {
2931 2939
      */
2932 2940
 
2933 2941
     // Pretend the current position is 0,0,0
2934
-    for (int i = X_AXIS; i <= Z_AXIS; i++) current_position[i] = 0;
2942
+    // This is like quick_home_xy() but for 3 towers.
2943
+    current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = 0.0;
2935 2944
     sync_plan_position();
2936 2945
 
2937 2946
     // Move all carriages up together until the first endstop is hit.
2938
-    for (int i = X_AXIS; i <= Z_AXIS; i++) destination[i] = 3 * (Z_MAX_LENGTH);
2947
+    current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = 3.0 * (Z_MAX_LENGTH);
2939 2948
     feedrate_mm_m = 1.732 * homing_feedrate_mm_m[X_AXIS];
2940
-    line_to_destination();
2949
+    line_to_current_position();
2941 2950
     stepper.synchronize();
2942 2951
     endstops.hit_on_purpose(); // clear endstop hit flags
2952
+    current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = 0.0;
2943 2953
 
2944
-    // Destination reached
2945
-    for (int i = X_AXIS; i <= Z_AXIS; i++) current_position[i] = destination[i];
2946
-
2947
-    // take care of back off and rehome now we are all at the top
2954
+    // take care of back off and rehome. Now one carriage is at the top.
2948 2955
     HOMEAXIS(X);
2949 2956
     HOMEAXIS(Y);
2950 2957
     HOMEAXIS(Z);
@@ -5325,7 +5332,7 @@ inline void gcode_M200() {
5325 5332
     if (volumetric_enabled) {
5326 5333
       filament_size[target_extruder] = code_value_linear_units();
5327 5334
       // make sure all extruders have some sane value for the filament size
5328
-      for (int i = 0; i < COUNT(filament_size); i++)
5335
+      for (uint8_t i = 0; i < COUNT(filament_size); i++)
5329 5336
         if (! filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
5330 5337
     }
5331 5338
   }
@@ -8695,6 +8702,6 @@ float calculate_volumetric_multiplier(float diameter) {
8695 8702
 }
8696 8703
 
8697 8704
 void calculate_volumetric_multipliers() {
8698
-  for (int i = 0; i < COUNT(filament_size); i++)
8705
+  for (uint8_t i = 0; i < COUNT(filament_size); i++)
8699 8706
     volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
8700 8707
 }

Loading…
Отказ
Запис