Various fixes, cleanup
This commit is contained in:
committed by
InsanityAutomation
parent
777abb71b5
commit
9a6d6a4405
@@ -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.");
|
||||
|
||||
@@ -67,7 +67,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");
|
||||
|
||||
@@ -341,7 +341,7 @@ void menu_motion() {
|
||||
//
|
||||
// Auto Z-Align
|
||||
//
|
||||
#if ANY(Z_STEPPER_AUTO_ALIGN, MECHANICAL_GANTRY_CALIBRATION)
|
||||
#if EITHER(Z_STEPPER_AUTO_ALIGN, MECHANICAL_GANTRY_CALIBRATION)
|
||||
GCODES_ITEM(MSG_AUTO_Z_ALIGN, PSTR("G34"));
|
||||
#endif
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ typedef struct SettingsDataStruct {
|
||||
#if HAS_DIGIPOTSS
|
||||
uint32_t motor_current_setting[COUNT(stepper.motor_current_setting)];
|
||||
#else
|
||||
uint32_t motor_current_setting[3]; // M907 X Z E
|
||||
uint32_t motor_current_setting[3]; // M907 X Z E
|
||||
#endif
|
||||
|
||||
//
|
||||
@@ -2114,19 +2114,19 @@ void MarlinSettings::postprocess() {
|
||||
// Motor Current PWM
|
||||
//
|
||||
{
|
||||
SERIAL_ECHOLN("DIGIPOTS Loading");
|
||||
_FIELD_TEST(motor_current_setting);
|
||||
#if HAS_DIGIPOTSS
|
||||
uint32_t motor_current_setting[] = DIGIPOT_MOTOR_CURRENT;
|
||||
#else
|
||||
uint32_t motor_current_setting[3]; // M907 X Z E
|
||||
uint32_t motor_current_setting[3];
|
||||
#endif
|
||||
_FIELD_TEST(motor_current_setting);
|
||||
DEBUG_ECHOLNPGM("DIGIPOTS Loading");
|
||||
EEPROM_READ(motor_current_setting);
|
||||
DEBUG_ECHOLNPGM("DIGIPOTS Loaded");
|
||||
#if HAS_MOTOR_CURRENT_PWM || HAS_DIGIPOTSS
|
||||
if (!validating)
|
||||
COPY(stepper.motor_current_setting, motor_current_setting);
|
||||
#endif
|
||||
SERIAL_ECHOLN("DIGIPOTS Loaded");
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2809,13 +2809,14 @@ void MarlinSettings::reset() {
|
||||
//
|
||||
// DIGIPOTS
|
||||
//
|
||||
SERIAL_ECHOLN("Writing Digipot");
|
||||
#if HAS_DIGIPOTSS
|
||||
static constexpr uint32_t tmp_motor_current_setting[] = DIGIPOT_MOTOR_CURRENT;
|
||||
DEBUG_ECHOLNPGM("Writing Digipot");
|
||||
LOOP_L_N(q, COUNT(tmp_motor_current_setting))
|
||||
stepper.digipot_current(q, tmp_motor_current_setting[q]);
|
||||
DEBUG_ECHOLNPGM("Digipot Written");
|
||||
#endif
|
||||
SERIAL_ECHOLN("Digipot Written");
|
||||
|
||||
//
|
||||
// CNC Coordinate System
|
||||
//
|
||||
@@ -3715,21 +3716,23 @@ SERIAL_ECHOLN("Digipot Written");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_MOTOR_CURRENT_PWM
|
||||
#if HAS_MOTOR_CURRENT_PWM || HAS_DIGIPOTSS
|
||||
CONFIG_ECHO_HEADING("Stepper motor currents:");
|
||||
CONFIG_ECHO_START();
|
||||
SERIAL_ECHOLNPAIR_P(
|
||||
PSTR(" M907 X"), stepper.motor_current_setting[0]
|
||||
, SP_Z_STR, stepper.motor_current_setting[1]
|
||||
, SP_E_STR, stepper.motor_current_setting[2]
|
||||
);
|
||||
#elif HASDIGIPOTSS
|
||||
CONFIG_ECHO_HEADING("Stepper motor currents:");
|
||||
CONFIG_ECHO_START();
|
||||
LOOP_L_N(q, COUNT(stepper.motor_current_setting)) {
|
||||
SERIAL_ECHOPAIR_P( "M907 ", axis_codes[q]);
|
||||
SERIAL_ECHOLN_P(stepper.motor_current_setting[q]);
|
||||
}
|
||||
#if HAS_MOTOR_CURRENT_PWM
|
||||
SERIAL_ECHOLNPAIR_P(
|
||||
PSTR(" M907 X"), stepper.motor_current_setting[0]
|
||||
, SP_Z_STR, stepper.motor_current_setting[1]
|
||||
, SP_E_STR, stepper.motor_current_setting[2]
|
||||
);
|
||||
#elif HAS_DIGIPOTSS
|
||||
SERIAL_ECHOPGM(" M907");
|
||||
LOOP_L_N(q, COUNT(stepper.motor_current_setting)) {
|
||||
SERIAL_CHAR(' ');
|
||||
SERIAL_CHAR(axis_codes[q]);
|
||||
SERIAL_ECHO(stepper.motor_current_setting[q]);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user