瀏覽代碼

Update position for UBL non-segmented activate/deactivate

Scott Lahteine 7 年之前
父節點
當前提交
e05c825a05
共有 1 個檔案被更改,包括 15 行新增1 行删除
  1. 15
    1
      Marlin/src/feature/bedlevel/bedlevel.cpp

+ 15
- 1
Marlin/src/feature/bedlevel/bedlevel.cpp 查看文件

@@ -99,7 +99,21 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
99 99
           planner.unapply_leveling(current_position);
100 100
         }
101 101
       #else
102
-        planner.leveling_active = enable;                    // just flip the bit, current_position will be wrong until next move.
102
+        // UBL equivalents for apply/unapply_leveling
103
+        #if ENABLED(SKEW_CORRECTION)
104
+          float pos[XYZ] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
105
+          planner.skew(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS]);
106
+        #else
107
+          const float (&pos)[XYZE] = current_position;
108
+        #endif
109
+        if (planner.leveling_active) {
110
+          current_position[Z_AXIS] += ubl.get_z_correction(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS]);
111
+          planner.leveling_active = false;
112
+        }
113
+        else {
114
+          planner.leveling_active = true;
115
+          current_position[Z_AXIS] -= ubl.get_z_correction(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS]);
116
+        }
103 117
       #endif
104 118
 
105 119
     #else // OLDSCHOOL_ABL

Loading…
取消
儲存