Browse Source

Unify reset_bed_level for linear/non-linear

Scott Lahteine 8 years ago
parent
commit
4f75ce6957
2 changed files with 25 additions and 38 deletions
  1. 0
    1
      Marlin/Marlin.h
  2. 25
    37
      Marlin/Marlin_main.cpp

+ 0
- 1
Marlin/Marlin.h View File

@@ -220,7 +220,6 @@ void disable_all_steppers();
220 220
 void FlushSerialRequestResend();
221 221
 void ok_to_send();
222 222
 
223
-void reset_bed_level();
224 223
 void kill(const char*);
225 224
 
226 225
 void quickstop_stepper();

+ 25
- 37
Marlin/Marlin_main.cpp View File

@@ -1955,10 +1955,6 @@ static void clean_up_after_endstop_or_probe_move() {
1955 1955
     // Prevent stepper_inactive_time from running out and EXTRUDER_RUNOUT_PREVENT from extruding
1956 1956
     refresh_cmd_timeout();
1957 1957
 
1958
-    #if ENABLED(AUTO_BED_LEVELING_LINEAR)
1959
-      planner.bed_level_matrix.set_to_identity();
1960
-    #endif
1961
-
1962 1958
     #if ENABLED(PROBE_DOUBLE_TOUCH)
1963 1959
 
1964 1960
       // Do a first probe at the fast speed
@@ -2152,22 +2148,23 @@ static void clean_up_after_endstop_or_probe_move() {
2152 2148
       }
2153 2149
     }
2154 2150
 
2155
-    /**
2156
-     * Reset calibration results to zero.
2157
-     */
2158
-    void reset_bed_level() {
2159
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
2160
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
2161
-      #endif
2162
-      for (int y = 0; y < AUTO_BED_LEVELING_GRID_POINTS; y++) {
2163
-        for (int x = 0; x < AUTO_BED_LEVELING_GRID_POINTS; x++) {
2164
-          bed_level_grid[x][y] = 0.0;
2165
-        }
2166
-      }
2167
-    }
2168
-
2169 2151
   #endif // DELTA
2170 2152
 
2153
+  /**
2154
+   * Reset calibration results to zero.
2155
+   */
2156
+  void reset_bed_level() {
2157
+    #if ENABLED(DEBUG_LEVELING_FEATURE)
2158
+      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
2159
+    #endif
2160
+    #if ENABLED(AUTO_BED_LEVELING_LINEAR)
2161
+      planner.bed_level_matrix.set_to_identity();
2162
+    #elif ENABLED(AUTO_BED_LEVELING_NONLINEAR)
2163
+      memset(bed_level_grid, 0, sizeof(bed_level_grid));
2164
+      nonlinear_grid_spacing[X_AXIS] = nonlinear_grid_spacing[Y_AXIS] = 0;
2165
+    #endif
2166
+  }
2167
+
2171 2168
 #endif // AUTO_BED_LEVELING_FEATURE
2172 2169
 
2173 2170
 /**
@@ -2848,11 +2845,7 @@ inline void gcode_G28() {
2848 2845
   stepper.synchronize();
2849 2846
 
2850 2847
   // For auto bed leveling, clear the level matrix
2851
-  #if ENABLED(AUTO_BED_LEVELING_LINEAR)
2852
-    planner.bed_level_matrix.set_to_identity();
2853
-  #endif
2854
-
2855
-  #if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
2848
+  #if ENABLED(AUTO_BED_LEVELING_FEATURE)
2856 2849
     reset_bed_level();
2857 2850
   #endif
2858 2851
 
@@ -3396,11 +3389,9 @@ inline void gcode_G28() {
3396 3389
 
3397 3390
     if (!dryrun) {
3398 3391
 
3399
-      #if ENABLED(AUTO_BED_LEVELING_LINEAR)
3400
-        // Reset the bed_level_matrix because leveling
3401
-        // needs to be done without leveling enabled.
3402
-        planner.bed_level_matrix.set_to_identity();
3403
-      #endif
3392
+      // Reset the bed_level_matrix because leveling
3393
+      // needs to be done without leveling enabled.
3394
+      reset_bed_level();
3404 3395
 
3405 3396
       //
3406 3397
       // Re-orient the current position without leveling
@@ -3408,10 +3399,6 @@ inline void gcode_G28() {
3408 3399
       //
3409 3400
       #if IS_KINEMATIC
3410 3401
 
3411
-        #if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
3412
-          reset_bed_level();
3413
-        #endif
3414
-
3415 3402
         // For DELTA/SCARA we need to apply forward kinematics.
3416 3403
         // This returns raw positions and we remap to the space.
3417 3404
         get_cartesian_from_steppers();
@@ -3757,6 +3744,10 @@ inline void gcode_G28() {
3757 3744
    */
3758 3745
   inline void gcode_G30() {
3759 3746
 
3747
+    #if ENABLED(AUTO_BED_LEVELING_FEATURE)
3748
+      reset_bed_level();
3749
+    #endif
3750
+
3760 3751
     setup_for_endstop_or_probe_move();
3761 3752
 
3762 3753
     // TODO: clear the leveling matrix or the planner will be set incorrectly
@@ -4199,12 +4190,9 @@ inline void gcode_M42() {
4199 4190
     if (verbose_level > 2)
4200 4191
       SERIAL_PROTOCOLLNPGM("Positioning the probe...");
4201 4192
 
4202
-    #if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
4203
-      // we don't do bed level correction in M48 because we want the raw data when we probe
4193
+    // we don't do bed level correction in M48 because we want the raw data when we probe
4194
+    #if ENABLED(AUTO_BED_LEVELING_FEATURE)
4204 4195
       reset_bed_level();
4205
-    #elif ENABLED(AUTO_BED_LEVELING_LINEAR)
4206
-      // we don't do bed level correction in M48 because we want the raw data when we probe
4207
-      planner.bed_level_matrix.set_to_identity();
4208 4196
     #endif
4209 4197
 
4210 4198
     setup_for_endstop_or_probe_move();

Loading…
Cancel
Save