From 2e40a2746098fc7a989444bf37be9572a943b8fd Mon Sep 17 00:00:00 2001
From: espr14 <espr14@gmail.com>
Date: Mon, 11 Jan 2021 15:40:12 +0100
Subject: [PATCH 1/8] Alignment, comments

---
 Firmware/mesh_bed_calibration.cpp | 190 +++++++++++++++---------------
 1 file changed, 97 insertions(+), 93 deletions(-)

diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp
index 897e3a9e..8c2a4976 100644
--- a/Firmware/mesh_bed_calibration.cpp
+++ b/Firmware/mesh_bed_calibration.cpp
@@ -2226,104 +2226,104 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 		}
 		#endif // SUPPORT_VERBOSITY
 #ifdef MESH_BED_CALIBRATION_SHOW_LCD
-    uint8_t next_line;
-    lcd_display_message_fullscreen_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE1), next_line);
-    if (next_line > 3)
-        next_line = 3;
+        uint8_t next_line;
+        lcd_display_message_fullscreen_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE1), next_line);
+        if (next_line > 3)
+            next_line = 3;
 #endif /* MESH_BED_CALIBRATION_SHOW_LCD */
 
-    // Collect the rear 2x3 points.
-	current_position[Z_AXIS] = MESH_HOME_Z_SEARCH + FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP * iteration * 0.3;
-	for (int k = 0; k < 4; ++k) {
-		// Don't let the manage_inactivity() function remove power from the motors.
-		refresh_cmd_timeout();
+        // Collect the rear 2x3 points.
+        current_position[Z_AXIS] = MESH_HOME_Z_SEARCH + FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP * iteration * 0.3;
+        for (int k = 0; k < 4; ++k) {
+            // Don't let the manage_inactivity() function remove power from the motors.
+            refresh_cmd_timeout();
 #ifdef MESH_BED_CALIBRATION_SHOW_LCD
-		lcd_set_cursor(0, next_line);
-		lcd_print(k + 1);
-		lcd_puts_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE2));
+            lcd_set_cursor(0, next_line);
+            lcd_print(k + 1);
+            lcd_puts_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE2));
 
-		if (iteration > 0) {
-			lcd_puts_at_P(0, next_line + 1, _i("Iteration "));////MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION c=20
-			lcd_print(int(iteration + 1));
-		}
+            if (iteration > 0) {
+                lcd_puts_at_P(0, next_line + 1, _i("Iteration "));////MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION c=20
+                lcd_print(int(iteration + 1));
+            }
 #endif /* MESH_BED_CALIBRATION_SHOW_LCD */
-		float *pt = pts + k * 2;
-		// Go up to z_initial.
+            float *pt = pts + k * 2;
+            // Go up to z_initial.
 
-		go_to_current(homing_feedrate[Z_AXIS] / 60.f);
-		#ifdef SUPPORT_VERBOSITY
-		if (verbosity_level >= 20) {
-			// Go to Y0, wait, then go to Y-4.
-			current_position[Y_AXIS] = 0.f;
-			go_to_current(homing_feedrate[X_AXIS] / 60.f);
-			SERIAL_ECHOLNPGM("At Y0");
-			delay_keep_alive(5000);
-			current_position[Y_AXIS] = Y_MIN_POS;
-			go_to_current(homing_feedrate[X_AXIS] / 60.f);
-			SERIAL_ECHOLNPGM("At Y-4");
-			delay_keep_alive(5000);
-		}
-		#endif // SUPPORT_VERBOSITY
-		// Go to the measurement point position.
-		//if (iteration == 0) {
-			current_position[X_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2);
-			current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2 + 1);
-		/*}
-		else {
-			// if first iteration failed, count corrected point coordinates as initial
-			// Use the corrected coordinate, which is a result of find_bed_offset_and_skew().
-			
-			current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[0] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[0];
-			current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[1];
+            go_to_current(homing_feedrate[Z_AXIS] / 60.f);
+            #ifdef SUPPORT_VERBOSITY
+            if (verbosity_level >= 20) {
+                // Go to Y0, wait, then go to Y-4.
+                current_position[Y_AXIS] = 0.f;
+                go_to_current(homing_feedrate[X_AXIS] / 60.f);
+                SERIAL_ECHOLNPGM("At Y0");
+                delay_keep_alive(5000);
+                current_position[Y_AXIS] = Y_MIN_POS;
+                go_to_current(homing_feedrate[X_AXIS] / 60.f);
+                SERIAL_ECHOLNPGM("At Y-4");
+                delay_keep_alive(5000);
+            }
+            #endif // SUPPORT_VERBOSITY
+            // Go to the measurement point position.
+            //if (iteration == 0) {
+                current_position[X_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2);
+                current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2 + 1);
+            /*}
+            else {
+                // if first iteration failed, count corrected point coordinates as initial
+                // Use the corrected coordinate, which is a result of find_bed_offset_and_skew().
+                
+                current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[0] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[0];
+                current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[1];
 
-			// The calibration points are very close to the min Y.
-			if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION)
-				current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION;
+                // The calibration points are very close to the min Y.
+                if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION)
+                    current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION;
 
-		}*/
-		#ifdef SUPPORT_VERBOSITY
-		if (verbosity_level >= 20) {
-			SERIAL_ECHOPGM("current_position[X_AXIS]:");
-			MYSERIAL.print(current_position[X_AXIS], 5);
-			SERIAL_ECHOLNPGM("");
-			SERIAL_ECHOPGM("current_position[Y_AXIS]:");
-			MYSERIAL.print(current_position[Y_AXIS], 5);
-			SERIAL_ECHOLNPGM("");
-			SERIAL_ECHOPGM("current_position[Z_AXIS]:");
-			MYSERIAL.print(current_position[Z_AXIS], 5);
-			SERIAL_ECHOLNPGM("");
-		}
-		#endif // SUPPORT_VERBOSITY
+            }*/
+            #ifdef SUPPORT_VERBOSITY
+            if (verbosity_level >= 20) {
+                SERIAL_ECHOPGM("current_position[X_AXIS]:");
+                MYSERIAL.print(current_position[X_AXIS], 5);
+                SERIAL_ECHOLNPGM("");
+                SERIAL_ECHOPGM("current_position[Y_AXIS]:");
+                MYSERIAL.print(current_position[Y_AXIS], 5);
+                SERIAL_ECHOLNPGM("");
+                SERIAL_ECHOPGM("current_position[Z_AXIS]:");
+                MYSERIAL.print(current_position[Z_AXIS], 5);
+                SERIAL_ECHOLNPGM("");
+            }
+            #endif // SUPPORT_VERBOSITY
 
-		go_to_current(homing_feedrate[X_AXIS] / 60.f);
-		#ifdef SUPPORT_VERBOSITY
-		if (verbosity_level >= 10)
-			delay_keep_alive(3000);
-		#endif // SUPPORT_VERBOSITY
-		if (!find_bed_induction_sensor_point_xy(verbosity_level))
-			return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
+            go_to_current(homing_feedrate[X_AXIS] / 60.f);
+            #ifdef SUPPORT_VERBOSITY
+            if (verbosity_level >= 10)
+                delay_keep_alive(3000);
+            #endif // SUPPORT_VERBOSITY
+            if (!find_bed_induction_sensor_point_xy(verbosity_level))
+                return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND
 #ifndef NEW_XYZCAL
 #ifndef HEATBED_V2
 		
-			if (k == 0 || k == 1) {
-				// Improve the position of the 1st row sensor points by a zig-zag movement.
-				find_bed_induction_sensor_point_z();
-				int8_t i = 4;
-				for (;;) {
-					if (improve_bed_induction_sensor_point3(verbosity_level))
-						break;
-					if (--i == 0)
-						return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
-					// Try to move the Z axis down a bit to increase a chance of the sensor to trigger.
-					current_position[Z_AXIS] -= 0.025f;
-					enable_endstops(false);
-					enable_z_endstop(false);
-					go_to_current(homing_feedrate[Z_AXIS]);
-				}
-				if (i == 0)
-					// not found
-					return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
-			}
+            if (k == 0 || k == 1) {
+                // Improve the position of the 1st row sensor points by a zig-zag movement.
+                find_bed_induction_sensor_point_z();
+                int8_t i = 4;
+                for (;;) {
+                    if (improve_bed_induction_sensor_point3(verbosity_level))
+                        break;
+                    if (--i == 0)
+                        return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
+                    // Try to move the Z axis down a bit to increase a chance of the sensor to trigger.
+                    current_position[Z_AXIS] -= 0.025f;
+                    enable_endstops(false);
+                    enable_z_endstop(false);
+                    go_to_current(homing_feedrate[Z_AXIS]);
+                }
+                if (i == 0)
+                    // not found
+                    return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
+            }
 #endif //HEATBED_V2
 #endif
 			#ifdef SUPPORT_VERBOSITY
@@ -2375,8 +2375,9 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 				delay_keep_alive(3000);
 			}
 			#endif // SUPPORT_VERBOSITY
-		}
-		delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity
+        }
+        DBG(_n("All 4 calibration points found.\n"));
+        delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity
 		
 		#ifdef SUPPORT_VERBOSITY
 		if (verbosity_level >= 20) {
@@ -2386,7 +2387,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 				// Don't let the manage_inactivity() function remove power from the motors.
 				refresh_cmd_timeout();
 				// Go to the measurement point.
-				// Use the coorrected coordinate, which is a result of find_bed_offset_and_skew().
+				// Use the corrected coordinate, which is a result of find_bed_offset_and_skew().
 				current_position[X_AXIS] = pts[mesh_point * 2];
 				current_position[Y_AXIS] = pts[mesh_point * 2 + 1];
 				go_to_current(homing_feedrate[X_AXIS] / 60);
@@ -2450,7 +2451,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 					// Don't let the manage_inactivity() function remove power from the motors.
 					refresh_cmd_timeout();
 					// Go to the measurement point.
-					// Use the coorrected coordinate, which is a result of find_bed_offset_and_skew().
+					// Use the corrected coordinate, which is a result of find_bed_offset_and_skew().
 					uint8_t ix = mesh_point % MESH_MEAS_NUM_X_POINTS; // from 0 to MESH_NUM_X_POINTS - 1
 					uint8_t iy = mesh_point / MESH_MEAS_NUM_X_POINTS;
 					if (iy & 1) ix = (MESH_MEAS_NUM_X_POINTS - 1) - ix;
@@ -2462,9 +2463,12 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 			}
 			#endif // SUPPORT_VERBOSITY
 			return result;
-		}		
-		if (result == BED_SKEW_OFFSET_DETECTION_FITTING_FAILED && too_far_mask == 2) return result; //if fitting failed and front center point is out of reach, terminate calibration and inform user
-		iteration++;
+		}
+        if (result == BED_SKEW_OFFSET_DETECTION_FITTING_FAILED && too_far_mask == 2){
+            DBG(_n("Calibration failed.\n"));
+            return result; //if fitting failed and front center point is out of reach, terminate calibration and inform user
+        }
+        iteration++;
 	}
 	return result;    
 }

From 904a23b69ebc3f6a53cfe8c8569892f9b7b43d00 Mon Sep 17 00:00:00 2001
From: espr14 <espr14@gmail.com>
Date: Mon, 11 Jan 2021 17:02:41 +0100
Subject: [PATCH 2/8] Report calibration results

---
 Firmware/mesh_bed_calibration.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp
index 8c2a4976..6ef990b1 100644
--- a/Firmware/mesh_bed_calibration.cpp
+++ b/Firmware/mesh_bed_calibration.cpp
@@ -369,7 +369,9 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
     BedSkewOffsetDetectionResultType result = BED_SKEW_OFFSET_DETECTION_PERFECT;
     {
         angleDiff = fabs(a2 - a1);
-		eeprom_update_float((float*)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later 
+        DBG(_n("Measured XY skew: %f\n"), a2 - a1);
+        DBG(_n("Measured Y-bed skew: %f\n"), a2);
+        eeprom_update_float((float*)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later 
         if (angleDiff > bed_skew_angle_mild)
             result = (angleDiff > bed_skew_angle_extreme) ?
                 BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME :
@@ -2407,6 +2409,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 		delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity
 		
 		if (result >= 0) {
+            DBG(_n("Calibration success.\n"));
 			world2machine_update(vec_x, vec_y, cntr);
 #if 1
 			// Fearlessly store the calibration values into the eeprom.
@@ -2465,7 +2468,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 			return result;
 		}
         if (result == BED_SKEW_OFFSET_DETECTION_FITTING_FAILED && too_far_mask == 2){
-            DBG(_n("Calibration failed.\n"));
+            DBG(_n("Fitting failed => calibration failed.\n"));
             return result; //if fitting failed and front center point is out of reach, terminate calibration and inform user
         }
         iteration++;

From 211e5f5f37df763e7bf744012a569c3c4636a61c Mon Sep 17 00:00:00 2001
From: espr14 <espr14@gmail.com>
Date: Mon, 11 Jan 2021 17:31:26 +0100
Subject: [PATCH 3/8] Define DBG output

---
 Firmware/mesh_bed_calibration.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp
index 6ef990b1..f19c8c9c 100644
--- a/Firmware/mesh_bed_calibration.cpp
+++ b/Firmware/mesh_bed_calibration.cpp
@@ -12,6 +12,8 @@
 #include "tmc2130.h"
 #endif //TMC2130
 
+#define DBG(args...) printf_P(args)
+
 uint8_t world2machine_correction_mode;
 float   world2machine_rotation_and_skew[2][2];
 float   world2machine_rotation_and_skew_inv[2][2];

From 09892bec52fd843e2a8bf40f89232fcafe0fbf1d Mon Sep 17 00:00:00 2001
From: espr14 <espr14@gmail.com>
Date: Mon, 11 Jan 2021 18:46:56 +0100
Subject: [PATCH 4/8] Reverse

---
 Firmware/mesh_bed_calibration.cpp | 181 +++++++++++++++---------------
 1 file changed, 90 insertions(+), 91 deletions(-)

diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp
index f19c8c9c..dc13eaac 100644
--- a/Firmware/mesh_bed_calibration.cpp
+++ b/Firmware/mesh_bed_calibration.cpp
@@ -2230,104 +2230,104 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 		}
 		#endif // SUPPORT_VERBOSITY
 #ifdef MESH_BED_CALIBRATION_SHOW_LCD
-        uint8_t next_line;
-        lcd_display_message_fullscreen_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE1), next_line);
-        if (next_line > 3)
-            next_line = 3;
+    uint8_t next_line;
+    lcd_display_message_fullscreen_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE1), next_line);
+    if (next_line > 3)
+        next_line = 3;
 #endif /* MESH_BED_CALIBRATION_SHOW_LCD */
 
-        // Collect the rear 2x3 points.
-        current_position[Z_AXIS] = MESH_HOME_Z_SEARCH + FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP * iteration * 0.3;
-        for (int k = 0; k < 4; ++k) {
-            // Don't let the manage_inactivity() function remove power from the motors.
-            refresh_cmd_timeout();
+    // Collect the rear 2x3 points.
+	current_position[Z_AXIS] = MESH_HOME_Z_SEARCH + FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP * iteration * 0.3;
+	for (int k = 0; k < 4; ++k) {
+		// Don't let the manage_inactivity() function remove power from the motors.
+		refresh_cmd_timeout();
 #ifdef MESH_BED_CALIBRATION_SHOW_LCD
-            lcd_set_cursor(0, next_line);
-            lcd_print(k + 1);
-            lcd_puts_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE2));
+		lcd_set_cursor(0, next_line);
+		lcd_print(k + 1);
+		lcd_puts_P(_T(MSG_FIND_BED_OFFSET_AND_SKEW_LINE2));
 
-            if (iteration > 0) {
-                lcd_puts_at_P(0, next_line + 1, _i("Iteration "));////MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION c=20
-                lcd_print(int(iteration + 1));
-            }
+		if (iteration > 0) {
+			lcd_puts_at_P(0, next_line + 1, _i("Iteration "));////MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION c=20
+			lcd_print(int(iteration + 1));
+		}
 #endif /* MESH_BED_CALIBRATION_SHOW_LCD */
-            float *pt = pts + k * 2;
-            // Go up to z_initial.
+		float *pt = pts + k * 2;
+		// Go up to z_initial.
 
-            go_to_current(homing_feedrate[Z_AXIS] / 60.f);
-            #ifdef SUPPORT_VERBOSITY
-            if (verbosity_level >= 20) {
-                // Go to Y0, wait, then go to Y-4.
-                current_position[Y_AXIS] = 0.f;
-                go_to_current(homing_feedrate[X_AXIS] / 60.f);
-                SERIAL_ECHOLNPGM("At Y0");
-                delay_keep_alive(5000);
-                current_position[Y_AXIS] = Y_MIN_POS;
-                go_to_current(homing_feedrate[X_AXIS] / 60.f);
-                SERIAL_ECHOLNPGM("At Y-4");
-                delay_keep_alive(5000);
-            }
-            #endif // SUPPORT_VERBOSITY
-            // Go to the measurement point position.
-            //if (iteration == 0) {
-                current_position[X_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2);
-                current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2 + 1);
-            /*}
-            else {
-                // if first iteration failed, count corrected point coordinates as initial
-                // Use the corrected coordinate, which is a result of find_bed_offset_and_skew().
-                
-                current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[0] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[0];
-                current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[1];
+		go_to_current(homing_feedrate[Z_AXIS] / 60.f);
+		#ifdef SUPPORT_VERBOSITY
+		if (verbosity_level >= 20) {
+			// Go to Y0, wait, then go to Y-4.
+			current_position[Y_AXIS] = 0.f;
+			go_to_current(homing_feedrate[X_AXIS] / 60.f);
+			SERIAL_ECHOLNPGM("At Y0");
+			delay_keep_alive(5000);
+			current_position[Y_AXIS] = Y_MIN_POS;
+			go_to_current(homing_feedrate[X_AXIS] / 60.f);
+			SERIAL_ECHOLNPGM("At Y-4");
+			delay_keep_alive(5000);
+		}
+		#endif // SUPPORT_VERBOSITY
+		// Go to the measurement point position.
+		//if (iteration == 0) {
+			current_position[X_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2);
+			current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + k * 2 + 1);
+		/*}
+		else {
+			// if first iteration failed, count corrected point coordinates as initial
+			// Use the corrected coordinate, which is a result of find_bed_offset_and_skew().
+			
+			current_position[X_AXIS] = vec_x[0] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[0] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[0];
+			current_position[Y_AXIS] = vec_x[1] * pgm_read_float(bed_ref_points_4 + k * 2) + vec_y[1] * pgm_read_float(bed_ref_points_4 + k * 2 + 1) + cntr[1];
 
-                // The calibration points are very close to the min Y.
-                if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION)
-                    current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION;
+			// The calibration points are very close to the min Y.
+			if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION)
+				current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION;
 
-            }*/
-            #ifdef SUPPORT_VERBOSITY
-            if (verbosity_level >= 20) {
-                SERIAL_ECHOPGM("current_position[X_AXIS]:");
-                MYSERIAL.print(current_position[X_AXIS], 5);
-                SERIAL_ECHOLNPGM("");
-                SERIAL_ECHOPGM("current_position[Y_AXIS]:");
-                MYSERIAL.print(current_position[Y_AXIS], 5);
-                SERIAL_ECHOLNPGM("");
-                SERIAL_ECHOPGM("current_position[Z_AXIS]:");
-                MYSERIAL.print(current_position[Z_AXIS], 5);
-                SERIAL_ECHOLNPGM("");
-            }
-            #endif // SUPPORT_VERBOSITY
+		}*/
+		#ifdef SUPPORT_VERBOSITY
+		if (verbosity_level >= 20) {
+			SERIAL_ECHOPGM("current_position[X_AXIS]:");
+			MYSERIAL.print(current_position[X_AXIS], 5);
+			SERIAL_ECHOLNPGM("");
+			SERIAL_ECHOPGM("current_position[Y_AXIS]:");
+			MYSERIAL.print(current_position[Y_AXIS], 5);
+			SERIAL_ECHOLNPGM("");
+			SERIAL_ECHOPGM("current_position[Z_AXIS]:");
+			MYSERIAL.print(current_position[Z_AXIS], 5);
+			SERIAL_ECHOLNPGM("");
+		}
+		#endif // SUPPORT_VERBOSITY
 
-            go_to_current(homing_feedrate[X_AXIS] / 60.f);
-            #ifdef SUPPORT_VERBOSITY
-            if (verbosity_level >= 10)
-                delay_keep_alive(3000);
-            #endif // SUPPORT_VERBOSITY
-            if (!find_bed_induction_sensor_point_xy(verbosity_level))
-                return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND
+		go_to_current(homing_feedrate[X_AXIS] / 60.f);
+		#ifdef SUPPORT_VERBOSITY
+		if (verbosity_level >= 10)
+			delay_keep_alive(3000);
+		#endif // SUPPORT_VERBOSITY
+		if (!find_bed_induction_sensor_point_xy(verbosity_level))
+			return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
 #ifndef NEW_XYZCAL
 #ifndef HEATBED_V2
 		
-            if (k == 0 || k == 1) {
-                // Improve the position of the 1st row sensor points by a zig-zag movement.
-                find_bed_induction_sensor_point_z();
-                int8_t i = 4;
-                for (;;) {
-                    if (improve_bed_induction_sensor_point3(verbosity_level))
-                        break;
-                    if (--i == 0)
-                        return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
-                    // Try to move the Z axis down a bit to increase a chance of the sensor to trigger.
-                    current_position[Z_AXIS] -= 0.025f;
-                    enable_endstops(false);
-                    enable_z_endstop(false);
-                    go_to_current(homing_feedrate[Z_AXIS]);
-                }
-                if (i == 0)
-                    // not found
-                    return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
-            }
+			if (k == 0 || k == 1) {
+				// Improve the position of the 1st row sensor points by a zig-zag movement.
+				find_bed_induction_sensor_point_z();
+				int8_t i = 4;
+				for (;;) {
+					if (improve_bed_induction_sensor_point3(verbosity_level))
+						break;
+					if (--i == 0)
+						return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
+					// Try to move the Z axis down a bit to increase a chance of the sensor to trigger.
+					current_position[Z_AXIS] -= 0.025f;
+					enable_endstops(false);
+					enable_z_endstop(false);
+					go_to_current(homing_feedrate[Z_AXIS]);
+				}
+				if (i == 0)
+					// not found
+					return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
+			}
 #endif //HEATBED_V2
 #endif
 			#ifdef SUPPORT_VERBOSITY
@@ -2379,9 +2379,8 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 				delay_keep_alive(3000);
 			}
 			#endif // SUPPORT_VERBOSITY
-        }
-        DBG(_n("All 4 calibration points found.\n"));
-        delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity
+		}
+		delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity
 		
 		#ifdef SUPPORT_VERBOSITY
 		if (verbosity_level >= 20) {
@@ -2391,7 +2390,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 				// Don't let the manage_inactivity() function remove power from the motors.
 				refresh_cmd_timeout();
 				// Go to the measurement point.
-				// Use the corrected coordinate, which is a result of find_bed_offset_and_skew().
+				// Use the coorrected coordinate, which is a result of find_bed_offset_and_skew().
 				current_position[X_AXIS] = pts[mesh_point * 2];
 				current_position[Y_AXIS] = pts[mesh_point * 2 + 1];
 				go_to_current(homing_feedrate[X_AXIS] / 60);
@@ -2456,7 +2455,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 					// Don't let the manage_inactivity() function remove power from the motors.
 					refresh_cmd_timeout();
 					// Go to the measurement point.
-					// Use the corrected coordinate, which is a result of find_bed_offset_and_skew().
+					// Use the coorrected coordinate, which is a result of find_bed_offset_and_skew().
 					uint8_t ix = mesh_point % MESH_MEAS_NUM_X_POINTS; // from 0 to MESH_NUM_X_POINTS - 1
 					uint8_t iy = mesh_point / MESH_MEAS_NUM_X_POINTS;
 					if (iy & 1) ix = (MESH_MEAS_NUM_X_POINTS - 1) - ix;

From b8443b00ad3cee9406532561245d877c65766c6d Mon Sep 17 00:00:00 2001
From: espr14 <espr14@gmail.com>
Date: Mon, 11 Jan 2021 22:18:50 +0100
Subject: [PATCH 5/8] Reverse reverse

---
 Firmware/mesh_bed_calibration.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp
index dc13eaac..594ac4bf 100644
--- a/Firmware/mesh_bed_calibration.cpp
+++ b/Firmware/mesh_bed_calibration.cpp
@@ -2379,8 +2379,9 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 				delay_keep_alive(3000);
 			}
 			#endif // SUPPORT_VERBOSITY
-		}
-		delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity
+        }
+        DBG(_n("All 4 calibration points found.\n"));
+        delay_keep_alive(0); //manage_heater, reset watchdog, manage inactivity
 		
 		#ifdef SUPPORT_VERBOSITY
 		if (verbosity_level >= 20) {
@@ -2390,7 +2391,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 				// Don't let the manage_inactivity() function remove power from the motors.
 				refresh_cmd_timeout();
 				// Go to the measurement point.
-				// Use the coorrected coordinate, which is a result of find_bed_offset_and_skew().
+				// Use the corrected coordinate, which is a result of find_bed_offset_and_skew().
 				current_position[X_AXIS] = pts[mesh_point * 2];
 				current_position[Y_AXIS] = pts[mesh_point * 2 + 1];
 				go_to_current(homing_feedrate[X_AXIS] / 60);
@@ -2455,7 +2456,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
 					// Don't let the manage_inactivity() function remove power from the motors.
 					refresh_cmd_timeout();
 					// Go to the measurement point.
-					// Use the coorrected coordinate, which is a result of find_bed_offset_and_skew().
+					// Use the corrected coordinate, which is a result of find_bed_offset_and_skew().
 					uint8_t ix = mesh_point % MESH_MEAS_NUM_X_POINTS; // from 0 to MESH_NUM_X_POINTS - 1
 					uint8_t iy = mesh_point / MESH_MEAS_NUM_X_POINTS;
 					if (iy & 1) ix = (MESH_MEAS_NUM_X_POINTS - 1) - ix;

From e6e44fe18861b1cb63bb99e24514538f6474cfb8 Mon Sep 17 00:00:00 2001
From: espr14 <espr14@gmail.com>
Date: Mon, 11 Jan 2021 23:13:08 +0100
Subject: [PATCH 6/8] Convert to degrees

---
 Firmware/mesh_bed_calibration.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp
index 594ac4bf..6dc52422 100644
--- a/Firmware/mesh_bed_calibration.cpp
+++ b/Firmware/mesh_bed_calibration.cpp
@@ -371,9 +371,9 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
     BedSkewOffsetDetectionResultType result = BED_SKEW_OFFSET_DETECTION_PERFECT;
     {
         angleDiff = fabs(a2 - a1);
-        DBG(_n("Measured XY skew: %f\n"), a2 - a1);
-        DBG(_n("Measured Y-bed skew: %f\n"), a2);
-        eeprom_update_float((float*)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later 
+        DBG(_n("Measured XY skew: %f°\n"), degrees(a2 - a1));
+        DBG(_n("Measured Y-bed skew: %f°\n"), degrees(a2));
+        eeprom_update_float((float *)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later
         if (angleDiff > bed_skew_angle_mild)
             result = (angleDiff > bed_skew_angle_extreme) ?
                 BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME :
@@ -1384,7 +1384,7 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
 
 		//        go_xyz(current_position[X_AXIS], current_position[Y_AXIS], MESH_HOME_Z_SEARCH, homing_feedrate[Z_AXIS]/60);
 		go_xyz(x0, y0, current_position[Z_AXIS], feedrate);
-		// Continously lower the Z axis.
+		// Continuously lower the Z axis.
 		endstops_hit_on_purpose();
 		enable_z_endstop(true);
 		while (current_position[Z_AXIS] > -10.f) {

From 333526f65dde201982345aaa063b234bc7f94b00 Mon Sep 17 00:00:00 2001
From: espr14 <espr14@gmail.com>
Date: Mon, 11 Jan 2021 23:14:12 +0100
Subject: [PATCH 7/8] Single skew output

---
 Firmware/mesh_bed_calibration.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp
index 6dc52422..4f426116 100644
--- a/Firmware/mesh_bed_calibration.cpp
+++ b/Firmware/mesh_bed_calibration.cpp
@@ -371,8 +371,8 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
     BedSkewOffsetDetectionResultType result = BED_SKEW_OFFSET_DETECTION_PERFECT;
     {
         angleDiff = fabs(a2 - a1);
-        DBG(_n("Measured XY skew: %f°\n"), degrees(a2 - a1));
-        DBG(_n("Measured Y-bed skew: %f°\n"), degrees(a2));
+        /// XY skew and Y-bed skew
+        DBG(_n("Measured skews: %f° %f°\n"), degrees(a2 - a1), degrees(a2));
         eeprom_update_float((float *)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later
         if (angleDiff > bed_skew_angle_mild)
             result = (angleDiff > bed_skew_angle_extreme) ?

From d7507649d8202de6653ca4d376d6f19e309a98b1 Mon Sep 17 00:00:00 2001
From: espr14 <espr14@gmail.com>
Date: Tue, 12 Jan 2021 00:28:46 +0100
Subject: [PATCH 8/8] Remove degree char

---
 Firmware/mesh_bed_calibration.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp
index 4f426116..a0efc3aa 100644
--- a/Firmware/mesh_bed_calibration.cpp
+++ b/Firmware/mesh_bed_calibration.cpp
@@ -372,7 +372,7 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS(
     {
         angleDiff = fabs(a2 - a1);
         /// XY skew and Y-bed skew
-        DBG(_n("Measured skews: %f° %f°\n"), degrees(a2 - a1), degrees(a2));
+        DBG(_n("Measured skews: %f %f\n"), degrees(a2 - a1), degrees(a2));
         eeprom_update_float((float *)(EEPROM_XYZ_CAL_SKEW), angleDiff); //storing xyz cal. skew to be able to show in support menu later
         if (angleDiff > bed_skew_angle_mild)
             result = (angleDiff > bed_skew_angle_extreme) ?