|
@@ -1685,6 +1685,14 @@ static void setup_for_endstop_move() {
|
1685
|
1685
|
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z);
|
1686
|
1686
|
}
|
1687
|
1687
|
|
|
1688
|
+ inline void raise_z_after_probing() {
|
|
1689
|
+ #if Z_RAISE_AFTER_PROBING > 0
|
|
1690
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
1691
|
+ if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("raise_z_after_probing()");
|
|
1692
|
+ #endif
|
|
1693
|
+ do_blocking_move_to_z(current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING);
|
|
1694
|
+ #endif
|
|
1695
|
+ }
|
1688
|
1696
|
#endif //HAS_BED_PROBE
|
1689
|
1697
|
|
1690
|
1698
|
#if HAS_Z_SERVO_ENDSTOP
|
|
@@ -1710,18 +1718,6 @@ static void setup_for_endstop_move() {
|
1710
|
1718
|
|
1711
|
1719
|
#endif
|
1712
|
1720
|
|
1713
|
|
-#if HAS_BED_PROBE
|
1714
|
|
-
|
1715
|
|
- inline void raise_z_after_probing() {
|
1716
|
|
- #if Z_RAISE_AFTER_PROBING > 0
|
1717
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
1718
|
|
- if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("raise_z_after_probing()");
|
1719
|
|
- #endif
|
1720
|
|
- do_blocking_move_to_z(current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING);
|
1721
|
|
- #endif
|
1722
|
|
- }
|
1723
|
|
-#endif
|
1724
|
|
-
|
1725
|
1721
|
#if ENABLED(Z_PROBE_SLED)
|
1726
|
1722
|
|
1727
|
1723
|
#ifndef SLED_DOCKING_OFFSET
|
|
@@ -1964,89 +1960,6 @@ static void setup_for_endstop_move() {
|
1964
|
1960
|
endstops.enable_z_probe(false);
|
1965
|
1961
|
}
|
1966
|
1962
|
|
1967
|
|
-#endif // HAS_BED_PROBE
|
1968
|
|
-
|
1969
|
|
-#if ENABLED(AUTO_BED_LEVELING_FEATURE)
|
1970
|
|
-
|
1971
|
|
- #if ENABLED(AUTO_BED_LEVELING_GRID)
|
1972
|
|
-
|
1973
|
|
- #if DISABLED(DELTA)
|
1974
|
|
-
|
1975
|
|
- static void set_bed_level_equation_lsq(double* plane_equation_coefficients) {
|
1976
|
|
-
|
1977
|
|
- //planner.bed_level_matrix.debug("bed level before");
|
1978
|
|
-
|
1979
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
1980
|
|
- planner.bed_level_matrix.set_to_identity();
|
1981
|
|
- if (DEBUGGING(LEVELING)) {
|
1982
|
|
- vector_3 uncorrected_position = planner.adjusted_position();
|
1983
|
|
- DEBUG_POS(">>> set_bed_level_equation_lsq", uncorrected_position);
|
1984
|
|
- DEBUG_POS(">>> set_bed_level_equation_lsq", current_position);
|
1985
|
|
- }
|
1986
|
|
- #endif
|
1987
|
|
-
|
1988
|
|
- vector_3 planeNormal = vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1);
|
1989
|
|
- planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
1990
|
|
-
|
1991
|
|
- vector_3 corrected_position = planner.adjusted_position();
|
1992
|
|
- current_position[X_AXIS] = corrected_position.x;
|
1993
|
|
- current_position[Y_AXIS] = corrected_position.y;
|
1994
|
|
- current_position[Z_AXIS] = corrected_position.z;
|
1995
|
|
-
|
1996
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
1997
|
|
- if (DEBUGGING(LEVELING)) DEBUG_POS("<<< set_bed_level_equation_lsq", corrected_position);
|
1998
|
|
- #endif
|
1999
|
|
-
|
2000
|
|
- sync_plan_position();
|
2001
|
|
- }
|
2002
|
|
-
|
2003
|
|
- #endif // !DELTA
|
2004
|
|
-
|
2005
|
|
- #else // !AUTO_BED_LEVELING_GRID
|
2006
|
|
-
|
2007
|
|
- static void set_bed_level_equation_3pts(float z_at_pt_1, float z_at_pt_2, float z_at_pt_3) {
|
2008
|
|
-
|
2009
|
|
- planner.bed_level_matrix.set_to_identity();
|
2010
|
|
-
|
2011
|
|
- vector_3 pt1 = vector_3(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, z_at_pt_1);
|
2012
|
|
- vector_3 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2);
|
2013
|
|
- vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3);
|
2014
|
|
- vector_3 planeNormal = vector_3::cross(pt1 - pt2, pt3 - pt2).get_normal();
|
2015
|
|
-
|
2016
|
|
- if (planeNormal.z < 0) {
|
2017
|
|
- planeNormal.x = -planeNormal.x;
|
2018
|
|
- planeNormal.y = -planeNormal.y;
|
2019
|
|
- planeNormal.z = -planeNormal.z;
|
2020
|
|
- }
|
2021
|
|
-
|
2022
|
|
- planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
2023
|
|
-
|
2024
|
|
- vector_3 corrected_position = planner.adjusted_position();
|
2025
|
|
-
|
2026
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
2027
|
|
- if (DEBUGGING(LEVELING)) {
|
2028
|
|
- vector_3 uncorrected_position = corrected_position;
|
2029
|
|
- DEBUG_POS("set_bed_level_equation_3pts", uncorrected_position);
|
2030
|
|
- }
|
2031
|
|
- #endif
|
2032
|
|
-
|
2033
|
|
- current_position[X_AXIS] = corrected_position.x;
|
2034
|
|
- current_position[Y_AXIS] = corrected_position.y;
|
2035
|
|
- current_position[Z_AXIS] = corrected_position.z;
|
2036
|
|
-
|
2037
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
2038
|
|
- if (DEBUGGING(LEVELING)) DEBUG_POS("set_bed_level_equation_3pts", corrected_position);
|
2039
|
|
- #endif
|
2040
|
|
-
|
2041
|
|
- sync_plan_position();
|
2042
|
|
- }
|
2043
|
|
-
|
2044
|
|
- #endif // !AUTO_BED_LEVELING_GRID
|
2045
|
|
-
|
2046
|
|
-#endif // AUTO_BED_LEVELING_FEATURE
|
2047
|
|
-
|
2048
|
|
-#if HAS_BED_PROBE
|
2049
|
|
-
|
2050
|
1963
|
static void run_z_probe() {
|
2051
|
1964
|
|
2052
|
1965
|
float old_feedrate = feedrate;
|
|
@@ -2138,6 +2051,81 @@ static void setup_for_endstop_move() {
|
2138
|
2051
|
|
2139
|
2052
|
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
|
2140
|
2053
|
|
|
2054
|
+ #if ENABLED(AUTO_BED_LEVELING_GRID)
|
|
2055
|
+
|
|
2056
|
+ #if DISABLED(DELTA)
|
|
2057
|
+
|
|
2058
|
+ static void set_bed_level_equation_lsq(double* plane_equation_coefficients) {
|
|
2059
|
+
|
|
2060
|
+ //planner.bed_level_matrix.debug("bed level before");
|
|
2061
|
+
|
|
2062
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2063
|
+ planner.bed_level_matrix.set_to_identity();
|
|
2064
|
+ if (DEBUGGING(LEVELING)) {
|
|
2065
|
+ vector_3 uncorrected_position = planner.adjusted_position();
|
|
2066
|
+ DEBUG_POS(">>> set_bed_level_equation_lsq", uncorrected_position);
|
|
2067
|
+ DEBUG_POS(">>> set_bed_level_equation_lsq", current_position);
|
|
2068
|
+ }
|
|
2069
|
+ #endif
|
|
2070
|
+
|
|
2071
|
+ vector_3 planeNormal = vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1);
|
|
2072
|
+ planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
|
2073
|
+
|
|
2074
|
+ vector_3 corrected_position = planner.adjusted_position();
|
|
2075
|
+ current_position[X_AXIS] = corrected_position.x;
|
|
2076
|
+ current_position[Y_AXIS] = corrected_position.y;
|
|
2077
|
+ current_position[Z_AXIS] = corrected_position.z;
|
|
2078
|
+
|
|
2079
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2080
|
+ if (DEBUGGING(LEVELING)) DEBUG_POS("<<< set_bed_level_equation_lsq", corrected_position);
|
|
2081
|
+ #endif
|
|
2082
|
+
|
|
2083
|
+ sync_plan_position();
|
|
2084
|
+ }
|
|
2085
|
+
|
|
2086
|
+ #endif // !DELTA
|
|
2087
|
+
|
|
2088
|
+ #else // !AUTO_BED_LEVELING_GRID
|
|
2089
|
+
|
|
2090
|
+ static void set_bed_level_equation_3pts(float z_at_pt_1, float z_at_pt_2, float z_at_pt_3) {
|
|
2091
|
+
|
|
2092
|
+ planner.bed_level_matrix.set_to_identity();
|
|
2093
|
+
|
|
2094
|
+ vector_3 pt1 = vector_3(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, z_at_pt_1);
|
|
2095
|
+ vector_3 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2);
|
|
2096
|
+ vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3);
|
|
2097
|
+ vector_3 planeNormal = vector_3::cross(pt1 - pt2, pt3 - pt2).get_normal();
|
|
2098
|
+
|
|
2099
|
+ if (planeNormal.z < 0) {
|
|
2100
|
+ planeNormal.x = -planeNormal.x;
|
|
2101
|
+ planeNormal.y = -planeNormal.y;
|
|
2102
|
+ planeNormal.z = -planeNormal.z;
|
|
2103
|
+ }
|
|
2104
|
+
|
|
2105
|
+ planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
|
2106
|
+
|
|
2107
|
+ vector_3 corrected_position = planner.adjusted_position();
|
|
2108
|
+
|
|
2109
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2110
|
+ if (DEBUGGING(LEVELING)) {
|
|
2111
|
+ vector_3 uncorrected_position = corrected_position;
|
|
2112
|
+ DEBUG_POS("set_bed_level_equation_3pts", uncorrected_position);
|
|
2113
|
+ }
|
|
2114
|
+ #endif
|
|
2115
|
+
|
|
2116
|
+ current_position[X_AXIS] = corrected_position.x;
|
|
2117
|
+ current_position[Y_AXIS] = corrected_position.y;
|
|
2118
|
+ current_position[Z_AXIS] = corrected_position.z;
|
|
2119
|
+
|
|
2120
|
+ #if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
2121
|
+ if (DEBUGGING(LEVELING)) DEBUG_POS("set_bed_level_equation_3pts", corrected_position);
|
|
2122
|
+ #endif
|
|
2123
|
+
|
|
2124
|
+ sync_plan_position();
|
|
2125
|
+ }
|
|
2126
|
+
|
|
2127
|
+ #endif // !AUTO_BED_LEVELING_GRID
|
|
2128
|
+
|
2141
|
2129
|
inline void do_blocking_move_to_xy(float x, float y) {
|
2142
|
2130
|
do_blocking_move_to(x, y, current_position[Z_AXIS]);
|
2143
|
2131
|
}
|
|
@@ -4176,19 +4164,7 @@ inline void gcode_M42() {
|
4176
|
4164
|
} // code_seen('S')
|
4177
|
4165
|
}
|
4178
|
4166
|
|
4179
|
|
-#if ENABLED(AUTO_BED_LEVELING_FEATURE) && ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
|
4180
|
|
-
|
4181
|
|
- /**
|
4182
|
|
- * This is redundant since the SanityCheck.h already checks for a valid
|
4183
|
|
- * Z_MIN_PROBE_PIN, but here for clarity.
|
4184
|
|
- */
|
4185
|
|
- #if ENABLED(Z_MIN_PROBE_ENDSTOP)
|
4186
|
|
- #if !HAS_Z_MIN_PROBE_PIN
|
4187
|
|
- #error "You must define Z_MIN_PROBE_PIN to enable Z probe repeatability calculation."
|
4188
|
|
- #endif
|
4189
|
|
- #elif !HAS_Z_MIN
|
4190
|
|
- #error "You must define Z_MIN_PIN to enable Z probe repeatability calculation."
|
4191
|
|
- #endif
|
|
4167
|
+#if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
|
4192
|
4168
|
|
4193
|
4169
|
/**
|
4194
|
4170
|
* M48: Z probe repeatability measurement function.
|
|
@@ -4451,7 +4427,7 @@ inline void gcode_M42() {
|
4451
|
4427
|
report_current_position();
|
4452
|
4428
|
}
|
4453
|
4429
|
|
4454
|
|
-#endif // AUTO_BED_LEVELING_FEATURE && Z_MIN_PROBE_REPEATABILITY_TEST
|
|
4430
|
+#endif // Z_MIN_PROBE_REPEATABILITY_TEST
|
4455
|
4431
|
|
4456
|
4432
|
/**
|
4457
|
4433
|
* M75: Start print timer
|
|
@@ -6970,11 +6946,11 @@ void process_next_command() {
|
6970
|
6946
|
gcode_M42();
|
6971
|
6947
|
break;
|
6972
|
6948
|
|
6973
|
|
- #if ENABLED(AUTO_BED_LEVELING_FEATURE) && ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
|
|
6949
|
+ #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
|
6974
|
6950
|
case 48: // M48 Z probe repeatability
|
6975
|
6951
|
gcode_M48();
|
6976
|
6952
|
break;
|
6977
|
|
- #endif // AUTO_BED_LEVELING_FEATURE && Z_MIN_PROBE_REPEATABILITY_TEST
|
|
6953
|
+ #endif // Z_MIN_PROBE_REPEATABILITY_TEST
|
6978
|
6954
|
|
6979
|
6955
|
case 75: // Start print timer
|
6980
|
6956
|
gcode_M75();
|