Various fixes, cleanup
This commit is contained in:
committed by
InsanityAutomation
parent
959919bcfe
commit
0d367432e6
@@ -155,23 +155,28 @@ void GcodeSuite::G34() {
|
||||
z_maxdiff = 0.0f,
|
||||
amplification = z_auto_align_amplification;
|
||||
|
||||
// These are needed after the for-loop
|
||||
uint8_t iteration;
|
||||
bool err_break = false;
|
||||
float z_measured_min;
|
||||
|
||||
#if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
|
||||
bool adjustment_reverse = false;
|
||||
#endif
|
||||
|
||||
// 'iteration' is declared above and is also used after the for-loop.
|
||||
// *not* the same as LOOP_L_N(iteration, z_auto_align_iterations)
|
||||
for (iteration = 0; iteration < z_auto_align_iterations; ++iteration) {
|
||||
#if HAS_DISPLAY
|
||||
PGM_P const msg_iteration = GET_TEXT(MSG_ITERATION);
|
||||
const iter_str_len = strlen_P(iter_str_len);
|
||||
#endif
|
||||
|
||||
// Final z and iteration values will be used after breaking the loop
|
||||
float z_measured_min;
|
||||
uint8_t iteration = 0;
|
||||
bool err_break = false; // To break out of nested loops
|
||||
while (iteration < z_auto_align_iterations) {
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> probing all positions.");
|
||||
|
||||
SERIAL_ECHOLNPAIR("\nITERATION: ", int(iteration + 1));
|
||||
const int iter = iteration + 1;
|
||||
SERIAL_ECHOLNPAIR("\nIteration: ", iter);
|
||||
#if HAS_DISPLAY
|
||||
ui.set_status("\nITERATION: ", int(iteration + 1));
|
||||
char str[iter_str_len + 2 + 1];
|
||||
sprintf_P(str, msg_iteration, iter);
|
||||
ui.set_status(str);
|
||||
#endif
|
||||
|
||||
// Initialize minimum value
|
||||
@@ -194,10 +199,8 @@ void GcodeSuite::G34() {
|
||||
// current_position.z has been manually altered in the "dirty trick" above.
|
||||
const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true, false);
|
||||
if (isnan(z_probed_height)) {
|
||||
SERIAL_ECHOLNPGM(MSG_LCD_PROBING_FAILED);
|
||||
#if HAS_DISPLAY
|
||||
ui.set_status_P(MSG_LCD_PROBING_FAILED)
|
||||
#endif
|
||||
SERIAL_ECHOLNPGM("Probing failed");
|
||||
LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
|
||||
err_break = true;
|
||||
break;
|
||||
}
|
||||
@@ -257,13 +260,19 @@ void GcodeSuite::G34() {
|
||||
#endif
|
||||
);
|
||||
#if HAS_DISPLAY
|
||||
ui.set_status("\n"
|
||||
"DIFFERENCE Z1-Z2=", ABS(z_measured[0] - z_measured[1])
|
||||
char msg[30], fstr[16];
|
||||
sprintf_P(
|
||||
PSTR("DIFFERENCE Z1-Z2=%s"
|
||||
#if NUM_Z_STEPPER_DRIVERS == 3
|
||||
" Z2-Z3=%s Z3-Z1=%s"
|
||||
#endif
|
||||
), dtostrf(ABS(z_measured[0] - z_measured[1]), 1, 3, fstr)
|
||||
#if NUM_Z_STEPPER_DRIVERS == 3
|
||||
, " Z2-Z3=", ABS(z_measured[1] - z_measured[2])
|
||||
, " Z3-Z1=", ABS(z_measured[2] - z_measured[0])
|
||||
, dtostrf(ABS(z_measured[1] - z_measured[2]), 1, 3, fstr)
|
||||
, dtostrf(ABS(z_measured[2] - z_measured[0]), 1, 3, fstr)
|
||||
#endif
|
||||
);
|
||||
ui.set_status(msg);
|
||||
#endif
|
||||
|
||||
#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
|
||||
@@ -283,10 +292,8 @@ void GcodeSuite::G34() {
|
||||
|
||||
// If it's getting worse, stop and throw an error
|
||||
if (last_z_align_level_indicator < z_align_level_indicator * 0.7f) {
|
||||
SERIAL_ECHOLNPGM(DECREASING_ACCURACY);
|
||||
#if HAS_DISPLAY
|
||||
ui.set_status_P(DECREASING_ACCURACY);
|
||||
#endif
|
||||
SERIAL_ECHOLNPGM("Decreasing Accuracy Detected.");
|
||||
LCD_MESSAGEPGM(MSG_DECREASING_ACCURACY));
|
||||
err_break = true;
|
||||
break;
|
||||
}
|
||||
@@ -310,10 +317,8 @@ void GcodeSuite::G34() {
|
||||
|
||||
// Check for less accuracy compared to last move
|
||||
if (last_z_align_move[zstepper] < z_align_abs * 0.7f) {
|
||||
SERIAL_ECHOLNPGM(DECREASING_ACCURACY);
|
||||
#if HAS_DISPLAY
|
||||
ui.set_status_P(DECREASING_ACCURACY);
|
||||
#endif
|
||||
SERIAL_ECHOLNPGM("Decreasing Accuracy Detected.");
|
||||
LCD_MESSAGEPGM(MSG_DECREASING_ACCURACY));
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " last_z_align_move = ", last_z_align_move[zstepper]);
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " z_align_abs = ", z_align_abs);
|
||||
adjustment_reverse = !adjustment_reverse;
|
||||
@@ -353,13 +358,12 @@ void GcodeSuite::G34() {
|
||||
|
||||
if (success_break) {
|
||||
SERIAL_ECHOLNPGM("Target accuracy achieved.");
|
||||
#if HAS_DISPLAY
|
||||
ui.set_status_P(PGM_P("Target accuracy achieved."));
|
||||
#endif
|
||||
LCD_MESSAGEPGM(MSG_ACCURACY_ACHIEVED);
|
||||
break;
|
||||
}
|
||||
|
||||
} // for (iteration)
|
||||
iteration++;
|
||||
} // while (iteration < z_auto_align_iterations)
|
||||
|
||||
if (err_break)
|
||||
SERIAL_ECHOLNPGM("G34 aborted.");
|
||||
|
||||
@@ -68,7 +68,8 @@ namespace Language_en {
|
||||
PROGMEM Language_Str MSG_AUTO_HOME_Z = _UxGT("Home Z");
|
||||
PROGMEM Language_Str MSG_AUTO_Z_ALIGN = _UxGT("Auto Z-Align");
|
||||
PROGMEM Language_Str MSG_ASSISTED_TRAMMING = _UxGT("Assisted Tramming");
|
||||
PROGMEM Language_Str DECREASING_ACCURACY = _UxGT("Decreasing accuracy detected.");
|
||||
PROGMEM Language_Str MSG_DECREASING_ACCURACY = _UxGT("Accuracy Decreasing!");
|
||||
PROGMEM Language_Str MSG_ACCURACY_ACHIEVED = _UxGT("Accuracy Achieved");
|
||||
PROGMEM Language_Str MSG_LEVEL_BED_HOMING = _UxGT("Homing XYZ");
|
||||
PROGMEM Language_Str MSG_LEVEL_BED_WAITING = _UxGT("Click to Begin");
|
||||
PROGMEM Language_Str MSG_LEVEL_BED_NEXT_POINT = _UxGT("Next Point");
|
||||
|
||||
Reference in New Issue
Block a user