瀏覽代碼

Use unapply_leveling in set_current_from_steppers_for_axis

Scott Lahteine 8 年之前
父節點
當前提交
fafafcf9d1
共有 1 個文件被更改,包括 11 次插入48 次删除
  1. 11
    48
      Marlin/Marlin_main.cpp

+ 11
- 48
Marlin/Marlin_main.cpp 查看文件

@@ -2139,39 +2139,7 @@ static void clean_up_after_endstop_or_probe_move() {
2139 2139
 
2140 2140
 #endif // AUTO_BED_LEVELING_FEATURE
2141 2141
 
2142
-#if ENABLED(AUTO_BED_LEVELING_LINEAR)
2143
-
2144
-  /**
2145
-   * Get the stepper positions, apply the rotation matrix
2146
-   * using the home XY and Z0 position as the fulcrum.
2147
-   */
2148
-  vector_3 untilted_stepper_position() {
2149
-    get_cartesian_from_steppers();
2150
-
2151
-    vector_3 pos = vector_3(
2152
-      cartes[X_AXIS] - X_TILT_FULCRUM,
2153
-      cartes[Y_AXIS] - Y_TILT_FULCRUM,
2154
-      cartes[Z_AXIS]
2155
-    );
2156
-
2157
-    matrix_3x3 inverse = matrix_3x3::transpose(planner.bed_level_matrix);
2158
-
2159
-    //pos.debug("untilted_stepper_position offset");
2160
-    //bed_level_matrix.debug("untilted_stepper_position");
2161
-    //inverse.debug("in untilted_stepper_position");
2162
-
2163
-    pos.apply_rotation(inverse);
2164
-
2165
-    pos.x = LOGICAL_X_POSITION(pos.x + X_TILT_FULCRUM);
2166
-    pos.y = LOGICAL_Y_POSITION(pos.y + Y_TILT_FULCRUM);
2167
-    pos.z = LOGICAL_Z_POSITION(pos.z);
2168
-
2169
-    //pos.debug("after rotation and reorientation");
2170
-
2171
-    return pos;
2172
-  }
2173
-
2174
-#elif ENABLED(AUTO_BED_LEVELING_NONLINEAR)
2142
+#if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
2175 2143
 
2176 2144
   /**
2177 2145
    * Extrapolate a single point from its neighbors
@@ -6067,11 +6035,9 @@ inline void gcode_M400() { stepper.synchronize(); }
6067 6035
 
6068 6036
 void quickstop_stepper() {
6069 6037
   stepper.quick_stop();
6070
-  #if DISABLED(SCARA)
6071
-    stepper.synchronize();
6072
-    LOOP_XYZ(i) set_current_from_steppers_for_axis((AxisEnum)i);
6073
-    SYNC_PLAN_POSITION_KINEMATIC();
6074
-  #endif
6038
+  stepper.synchronize();
6039
+  set_current_from_steppers_for_axis(ALL_AXES);
6040
+  SYNC_PLAN_POSITION_KINEMATIC();
6075 6041
 }
6076 6042
 
6077 6043
 #if ENABLED(MESH_BED_LEVELING)
@@ -8020,19 +7986,16 @@ void get_cartesian_from_steppers() {
8020 7986
  * Set the current_position for an axis based on
8021 7987
  * the stepper positions, removing any leveling that
8022 7988
  * may have been applied.
8023
- *
8024
- * << INCOMPLETE! Still needs to unapply leveling! >>
8025 7989
  */
8026 7990
 void set_current_from_steppers_for_axis(const AxisEnum axis) {
8027
-  #if ENABLED(AUTO_BED_LEVELING_LINEAR)
8028
-    vector_3 pos = untilted_stepper_position();
8029
-    current_position[axis] = axis == X_AXIS ? pos.x : axis == Y_AXIS ? pos.y : pos.z;
8030
-  #elif IS_KINEMATIC
8031
-    get_cartesian_from_steppers();
8032
-    current_position[axis] = LOGICAL_POSITION(cartes[axis], axis);
8033
-  #else
8034
-    current_position[axis] = stepper.get_axis_position_mm(axis); // CORE handled transparently
7991
+  get_cartesian_from_steppers();
7992
+  #if PLANNER_LEVELING
7993
+    planner.unapply_leveling(cartes[X_AXIS], cartes[Y_AXIS], cartes[Z_AXIS]);
8035 7994
   #endif
7995
+  if (axis == ALL_AXES)
7996
+    memcpy(current_position, cartes, sizeof(cartes));
7997
+  else
7998
+    current_position[axis] = cartes[axis];
8036 7999
 }
8037 8000
 
8038 8001
 #if ENABLED(MESH_BED_LEVELING)

Loading…
取消
儲存