|
|
|
@ -51,7 +51,7 @@
|
|
|
|
|
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
|
void lcd_return_to_status();
|
|
|
|
|
extern void _lcd_ubl_output_map_lcd();
|
|
|
|
|
void _lcd_ubl_output_map_lcd();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
extern float meshedit_done;
|
|
|
|
@ -97,7 +97,7 @@
|
|
|
|
|
*
|
|
|
|
|
* C G29 P2 C tells the Manual Probe subsystem to not use the current nozzle
|
|
|
|
|
* location in its search for the closest unmeasured Mesh Point. Instead, attempt to
|
|
|
|
|
* start at one end of the uprobed points and Continue sequentually.
|
|
|
|
|
* start at one end of the uprobed points and Continue sequentially.
|
|
|
|
|
*
|
|
|
|
|
* G29 P3 C specifies the Constant for the fill. Otherwise, uses a "reasonable" value.
|
|
|
|
|
*
|
|
|
|
@ -1038,12 +1038,12 @@
|
|
|
|
|
|
|
|
|
|
static uint8_t ubl_state_at_invocation = 0;
|
|
|
|
|
|
|
|
|
|
#if ENABLED(UBL_DEVEL_DEBUGGING)
|
|
|
|
|
#ifdef UBL_DEVEL_DEBUGGING
|
|
|
|
|
static uint8_t ubl_state_recursion_chk = 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void unified_bed_leveling::save_ubl_active_state_and_disable() {
|
|
|
|
|
#if ENABLED(UBL_DEVEL_DEBUGGING)
|
|
|
|
|
#ifdef UBL_DEVEL_DEBUGGING
|
|
|
|
|
ubl_state_recursion_chk++;
|
|
|
|
|
if (ubl_state_recursion_chk != 1) {
|
|
|
|
|
SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
|
|
|
|
@ -1059,7 +1059,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void unified_bed_leveling::restore_ubl_active_state_and_leave() {
|
|
|
|
|
#if ENABLED(UBL_DEVEL_DEBUGGING)
|
|
|
|
|
#ifdef UBL_DEVEL_DEBUGGING
|
|
|
|
|
if (--ubl_state_recursion_chk) {
|
|
|
|
|
SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
|
|
|
|
|
#if ENABLED(NEWPANEL)
|
|
|
|
@ -1143,7 +1143,7 @@
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
safe_delay(50);
|
|
|
|
|
|
|
|
|
|
#if ENABLED(UBL_DEVEL_DEBUGGING)
|
|
|
|
|
#ifdef UBL_DEVEL_DEBUGGING
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("ubl_state_at_invocation :", ubl_state_at_invocation);
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
SERIAL_PROTOCOLLNPAIR("ubl_state_recursion_chk :", ubl_state_recursion_chk);
|
|
|
|
@ -1257,7 +1257,7 @@
|
|
|
|
|
|
|
|
|
|
found_a_NAN = true;
|
|
|
|
|
|
|
|
|
|
int8_t closest_x=-1, closest_y=-1;
|
|
|
|
|
int8_t closest_x = -1, closest_y = -1;
|
|
|
|
|
float d1, d2 = 99999.9;
|
|
|
|
|
for (int8_t k = 0; k < GRID_MAX_POINTS_X; k++) {
|
|
|
|
|
for (int8_t l = 0; l < GRID_MAX_POINTS_Y; l++) {
|
|
|
|
@ -1280,7 +1280,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// at this point d2 should have the closest defined mesh point to invalid mesh point (i,j)
|
|
|
|
|
// At this point d2 should have the closest defined mesh point to invalid mesh point (i,j)
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
if (found_a_real && (closest_x >= 0) && (d2 > out_mesh.distance)) {
|
|
|
|
@ -1523,7 +1523,7 @@
|
|
|
|
|
y_min = max(MIN_PROBE_Y, MESH_MIN_Y),
|
|
|
|
|
y_max = min(MAX_PROBE_Y, MESH_MAX_Y);
|
|
|
|
|
|
|
|
|
|
bool abort_flag=false;
|
|
|
|
|
bool abort_flag = false;
|
|
|
|
|
|
|
|
|
|
float measured_z;
|
|
|
|
|
|
|
|
|
@ -1532,7 +1532,7 @@
|
|
|
|
|
|
|
|
|
|
struct linear_fit_data lsf_results;
|
|
|
|
|
|
|
|
|
|
// float z1, z2, z3; // Needed for algorithm validation down below.
|
|
|
|
|
//float z1, z2, z3; // Needed for algorithm validation down below.
|
|
|
|
|
|
|
|
|
|
incremental_LSF_reset(&lsf_results);
|
|
|
|
|
|
|
|
|
@ -1542,8 +1542,8 @@
|
|
|
|
|
abort_flag = true;
|
|
|
|
|
else {
|
|
|
|
|
measured_z -= get_z_correction(UBL_PROBE_PT_1_X, UBL_PROBE_PT_1_Y);
|
|
|
|
|
// z1 = measured_z;
|
|
|
|
|
if (g29_verbose_level>3) {
|
|
|
|
|
//z1 = measured_z;
|
|
|
|
|
if (g29_verbose_level > 3) {
|
|
|
|
|
serial_spaces(16);
|
|
|
|
|
SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z);
|
|
|
|
|
}
|
|
|
|
@ -1552,12 +1552,12 @@
|
|
|
|
|
|
|
|
|
|
if (!abort_flag) {
|
|
|
|
|
measured_z = probe_pt(UBL_PROBE_PT_2_X, UBL_PROBE_PT_2_Y, false, g29_verbose_level);
|
|
|
|
|
// z2 = measured_z;
|
|
|
|
|
//z2 = measured_z;
|
|
|
|
|
if (isnan(measured_z))
|
|
|
|
|
abort_flag = true;
|
|
|
|
|
else {
|
|
|
|
|
measured_z -= get_z_correction(UBL_PROBE_PT_2_X, UBL_PROBE_PT_2_Y);
|
|
|
|
|
if (g29_verbose_level>3) {
|
|
|
|
|
if (g29_verbose_level > 3) {
|
|
|
|
|
serial_spaces(16);
|
|
|
|
|
SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z);
|
|
|
|
|
}
|
|
|
|
@ -1567,12 +1567,12 @@
|
|
|
|
|
|
|
|
|
|
if (!abort_flag) {
|
|
|
|
|
measured_z = probe_pt(UBL_PROBE_PT_3_X, UBL_PROBE_PT_3_Y, true, g29_verbose_level);
|
|
|
|
|
// z3 = measured_z;
|
|
|
|
|
//z3 = measured_z;
|
|
|
|
|
if (isnan(measured_z))
|
|
|
|
|
abort_flag = true;
|
|
|
|
|
else {
|
|
|
|
|
measured_z -= get_z_correction(UBL_PROBE_PT_3_X, UBL_PROBE_PT_3_Y);
|
|
|
|
|
if (g29_verbose_level>3) {
|
|
|
|
|
if (g29_verbose_level > 3) {
|
|
|
|
|
serial_spaces(16);
|
|
|
|
|
SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z);
|
|
|
|
|
}
|
|
|
|
@ -1584,7 +1584,8 @@
|
|
|
|
|
SERIAL_ECHOPGM("?Error probing point. Aborting operation.\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
else { // !do_3_pt_leveling
|
|
|
|
|
|
|
|
|
|
bool zig_zag = false;
|
|
|
|
|
for (uint8_t ix = 0; ix < g29_grid_size; ix++) {
|
|
|
|
@ -1595,8 +1596,7 @@
|
|
|
|
|
if (!abort_flag) {
|
|
|
|
|
measured_z = probe_pt(rx, ry, parser.seen('E'), g29_verbose_level); // TODO: Needs error handling
|
|
|
|
|
|
|
|
|
|
if (isnan(measured_z))
|
|
|
|
|
abort_flag = true;
|
|
|
|
|
abort_flag = isnan(measured_z);
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
@ -1640,7 +1640,6 @@
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vector_3 normal = vector_3(lsf_results.A, lsf_results.B, 1.0000).get_normal();
|
|
|
|
|
|
|
|
|
|
if (g29_verbose_level > 2) {
|
|
|
|
@ -1714,7 +1713,7 @@
|
|
|
|
|
SERIAL_ECHOPGM("]\n");
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
/**
|
|
|
|
|
* The following code can be used to check the validity of the mesh tilting algorithm.
|
|
|
|
|
* When a 3-Point Mesh Tilt is done, the same algorithm is used as the grid based tilting.
|
|
|
|
|
* The only difference is just 3 points are used in the calculations. That fact guarantees
|
|
|
|
@ -1722,14 +1721,14 @@
|
|
|
|
|
* is calculated. The Z error between the probed point locations and the get_z_correction()
|
|
|
|
|
* numbers for those locations should be 0.000
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
#if 0
|
|
|
|
|
float t, t1, d;
|
|
|
|
|
t = normal.x * (UBL_PROBE_PT_1_X) + normal.y * (UBL_PROBE_PT_1_Y);
|
|
|
|
|
d = t + normal.z * z1;
|
|
|
|
|
SERIAL_ECHOPGM("D from 1st point: ");
|
|
|
|
|
SERIAL_ECHO_F(d, 6);
|
|
|
|
|
SERIAL_ECHOPGM(" Z error: ");
|
|
|
|
|
SERIAL_ECHO_F(normal.z*z1-get_z_correction(UBL_PROBE_PT_1_X, UBL_PROBE_PT_1_Y),6);
|
|
|
|
|
SERIAL_ECHO_F(normal.z*z1-get_z_correction(UBL_PROBE_PT_1_X, UBL_PROBE_PT_1_Y), 6);
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
|
|
|
|
|
t = normal.x * (UBL_PROBE_PT_2_X) + normal.y * (UBL_PROBE_PT_2_Y);
|
|
|
|
@ -1738,7 +1737,7 @@
|
|
|
|
|
SERIAL_ECHOPGM("D from 2nd point: ");
|
|
|
|
|
SERIAL_ECHO_F(d, 6);
|
|
|
|
|
SERIAL_ECHOPGM(" Z error: ");
|
|
|
|
|
SERIAL_ECHO_F(normal.z*z2-get_z_correction(UBL_PROBE_PT_2_X, UBL_PROBE_PT_2_Y),6);
|
|
|
|
|
SERIAL_ECHO_F(normal.z*z2-get_z_correction(UBL_PROBE_PT_2_X, UBL_PROBE_PT_2_Y), 6);
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
|
|
|
|
|
t = normal.x * (UBL_PROBE_PT_3_X) + normal.y * (UBL_PROBE_PT_3_Y);
|
|
|
|
@ -1746,7 +1745,7 @@
|
|
|
|
|
SERIAL_ECHOPGM("D from 3rd point: ");
|
|
|
|
|
SERIAL_ECHO_F(d, 6);
|
|
|
|
|
SERIAL_ECHOPGM(" Z error: ");
|
|
|
|
|
SERIAL_ECHO_F(normal.z*z3-get_z_correction(UBL_PROBE_PT_3_X, UBL_PROBE_PT_3_Y),6);
|
|
|
|
|
SERIAL_ECHO_F(normal.z*z3-get_z_correction(UBL_PROBE_PT_3_X, UBL_PROBE_PT_3_Y), 6);
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
|
|
|
|
|
t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
|
|
|
|
@ -1760,13 +1759,13 @@
|
|
|
|
|
SERIAL_ECHOPGM("D from home location using mesh value for Z: ");
|
|
|
|
|
SERIAL_ECHO_F(d, 6);
|
|
|
|
|
|
|
|
|
|
SERIAL_ECHOPAIR(" Z error: (", Z_SAFE_HOMING_X_POINT );
|
|
|
|
|
SERIAL_ECHOPAIR(" Z error: (", Z_SAFE_HOMING_X_POINT);
|
|
|
|
|
SERIAL_ECHOPAIR(",", Z_SAFE_HOMING_Y_POINT );
|
|
|
|
|
SERIAL_ECHOPGM(") = ");
|
|
|
|
|
SERIAL_ECHO_F( get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT),6);
|
|
|
|
|
SERIAL_ECHO_F(get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT), 6);
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
} // DEBUGGING(LEVELING)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|