Ver código fonte

Update position for UBL non-segmented activate/deactivate

Scott Lahteine 7 anos atrás
pai
commit
e05c825a05
1 arquivos alterados com 15 adições e 1 exclusões
  1. 15
    1
      Marlin/src/feature/bedlevel/bedlevel.cpp

+ 15
- 1
Marlin/src/feature/bedlevel/bedlevel.cpp Ver arquivo

@@ -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

Carregando…
Cancelar
Salvar