Browse Source

Use set_current_from_steppers_for_axis

Scott Lahteine 9 years ago
parent
commit
bb93b6822a
1 changed files with 10 additions and 19 deletions
  1. 10
    19
      Marlin/Marlin_main.cpp

+ 10
- 19
Marlin/Marlin_main.cpp View File

564
 void get_available_commands();
564
 void get_available_commands();
565
 void process_next_command();
565
 void process_next_command();
566
 void prepare_move_to_destination();
566
 void prepare_move_to_destination();
567
-void set_current_from_steppers();
567
+void set_current_from_steppers_for_axis(AxisEnum axis);
568
 
568
 
569
 #if ENABLED(ARC_SUPPORT)
569
 #if ENABLED(ARC_SUPPORT)
570
   void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise);
570
   void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise);
2116
 
2116
 
2117
     do_blocking_move_to_z(-(Z_MAX_LENGTH + 10), Z_PROBE_SPEED_FAST);
2117
     do_blocking_move_to_z(-(Z_MAX_LENGTH + 10), Z_PROBE_SPEED_FAST);
2118
     endstops.hit_on_purpose();
2118
     endstops.hit_on_purpose();
2119
-    set_current_from_steppers();
2119
+    set_current_from_steppers_for_axis(Z_AXIS);
2120
     SYNC_PLAN_POSITION_KINEMATIC();
2120
     SYNC_PLAN_POSITION_KINEMATIC();
2121
 
2121
 
2122
     // move up the retract distance
2122
     // move up the retract distance
2125
     // move back down slowly to find bed
2125
     // move back down slowly to find bed
2126
     do_blocking_move_to_z(current_position[Z_AXIS] - home_bump_mm(Z_AXIS) * 2, Z_PROBE_SPEED_SLOW);
2126
     do_blocking_move_to_z(current_position[Z_AXIS] - home_bump_mm(Z_AXIS) * 2, Z_PROBE_SPEED_SLOW);
2127
     endstops.hit_on_purpose();
2127
     endstops.hit_on_purpose();
2128
-    set_current_from_steppers();
2128
+    set_current_from_steppers_for_axis(Z_AXIS);
2129
     SYNC_PLAN_POSITION_KINEMATIC();
2129
     SYNC_PLAN_POSITION_KINEMATIC();
2130
 
2130
 
2131
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2131
     #if ENABLED(DEBUG_LEVELING_FEATURE)
6074
   stepper.quick_stop();
6074
   stepper.quick_stop();
6075
   #if DISABLED(SCARA)
6075
   #if DISABLED(SCARA)
6076
     stepper.synchronize();
6076
     stepper.synchronize();
6077
-    set_current_from_steppers();
6078
-    sync_plan_position();                       // ...re-apply to planner position
6077
+    LOOP_XYZ(i) set_current_from_steppers_for_axis((AxisEnum)i);
6078
+    SYNC_PLAN_POSITION_KINEMATIC();
6079
   #endif
6079
   #endif
6080
 }
6080
 }
6081
 
6081
 
7912
 
7912
 
7913
 #endif // DELTA
7913
 #endif // DELTA
7914
 
7914
 
7915
-void set_current_from_steppers() {
7915
+void set_current_from_steppers_for_axis(AxisEnum axis) {
7916
   #if ENABLED(DELTA)
7916
   #if ENABLED(DELTA)
7917
     set_cartesian_from_steppers();
7917
     set_cartesian_from_steppers();
7918
-    current_position[X_AXIS] = cartesian_position[X_AXIS];
7919
-    current_position[Y_AXIS] = cartesian_position[Y_AXIS];
7920
-    current_position[Z_AXIS] = cartesian_position[Z_AXIS];
7918
+    current_position[axis] = LOGICAL_POSITION(cartesian_position[axis], axis);
7921
   #elif ENABLED(AUTO_BED_LEVELING_FEATURE)
7919
   #elif ENABLED(AUTO_BED_LEVELING_FEATURE)
7922
-    vector_3 pos = planner.adjusted_position(); // values directly from steppers...
7923
-    current_position[X_AXIS] = pos.x;
7924
-    current_position[Y_AXIS] = pos.y;
7925
-    current_position[Z_AXIS] = pos.z;
7920
+    vector_3 pos = planner.adjusted_position();
7921
+    current_position[axis] = LOGICAL_POSITION(axis == X_AXIS ? pos.x : axis == Y_AXIS ? pos.y : pos.z, axis);
7926
   #else
7922
   #else
7927
-    current_position[X_AXIS] = stepper.get_axis_position_mm(X_AXIS); // CORE handled transparently
7928
-    current_position[Y_AXIS] = stepper.get_axis_position_mm(Y_AXIS);
7929
-    current_position[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
7923
+    current_position[axis] = LOGICAL_POSITION(stepper.get_axis_position_mm(axis), axis); // CORE handled transparently
7930
   #endif
7924
   #endif
7931
-
7932
-  for (uint8_t i = X_AXIS; i <= Z_AXIS; i++)
7933
-    current_position[i] += LOGICAL_POSITION(0, i);
7934
 }
7925
 }
7935
 
7926
 
7936
 #if ENABLED(MESH_BED_LEVELING)
7927
 #if ENABLED(MESH_BED_LEVELING)

Loading…
Cancel
Save