diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 5f45ad60..145c7e6b 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2382,7 +2382,7 @@ void process_commands() st_synchronize(); // Go down until endstop is hit - const float Z_CALIBRATION_THRESHOLD = 0.5f; + const float Z_CALIBRATION_THRESHOLD = 1.f; if (! find_bed_induction_sensor_point_z((has_z && mesh_point > 0) ? z0 - Z_CALIBRATION_THRESHOLD : -10.f)) { kill_message = MSG_BED_LEVELING_FAILED_POINT_LOW; break; diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 12dbdddb..95f1db19 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -749,7 +749,7 @@ error: #define FIND_BED_INDUCTION_SENSOR_POINT_X_RADIUS (8.f) #define FIND_BED_INDUCTION_SENSOR_POINT_Y_RADIUS (6.f) #define FIND_BED_INDUCTION_SENSOR_POINT_XY_STEP (1.f) -#define FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP (0.5f) +#define FIND_BED_INDUCTION_SENSOR_POINT_Z_STEP (0.2f) inline bool find_bed_induction_sensor_point_xy() { float feedrate = homing_feedrate[X_AXIS] / 60.f; @@ -1039,6 +1039,7 @@ inline bool improve_bed_induction_sensor_point2(bool lift_z_on_min_y, int8_t ver float center_old_x = current_position[X_AXIS]; float center_old_y = current_position[Y_AXIS]; float a, b; + bool point_small = false; enable_endstops(false); @@ -1078,8 +1079,14 @@ inline bool improve_bed_induction_sensor_point2(bool lift_z_on_min_y, int8_t ver SERIAL_ECHOLNPGM(""); } // We force the calibration routine to move the Z axis slightly down to make the response more pronounced. - current_position[X_AXIS] = center_old_x; - goto canceled; + if (b - a < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) { + // Don't use the new X value. + current_position[X_AXIS] = center_old_x; + goto canceled; + } else { + // Use the new value, but force the Z axis to go a bit lower. + point_small = true; + } } if (verbosity_level >= 5) { debug_output_point(PSTR("left" ), a, current_position[Y_AXIS], current_position[Z_AXIS]); @@ -1142,8 +1149,14 @@ inline bool improve_bed_induction_sensor_point2(bool lift_z_on_min_y, int8_t ver SERIAL_ECHO(b - a); SERIAL_ECHOLNPGM(""); } - current_position[Y_AXIS] = center_old_y; - goto canceled; + if (b - a < 0.5f * MIN_BED_SENSOR_POINT_RESPONSE_DMR) { + // Don't use the new Y value. + current_position[Y_AXIS] = center_old_y; + goto canceled; + } else { + // Use the new value, but force the Z axis to go a bit lower. + point_small = true; + } } if (verbosity_level >= 5) { debug_output_point(PSTR("top" ), current_position[X_AXIS], a, current_position[Z_AXIS]); @@ -1156,7 +1169,11 @@ inline bool improve_bed_induction_sensor_point2(bool lift_z_on_min_y, int8_t ver go_xy(current_position[X_AXIS], current_position[Y_AXIS], homing_feedrate[X_AXIS] / 60.f); } - return true; + // If point is small but not too small, then force the Z axis to be lowered a bit, + // but use the new value. This is important when the initial position was off in one axis, + // for example if the initial calibration was shifted in the Y axis systematically. + // Then this first step will center. + return ! point_small; canceled: // Go back to the center. diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index da7b1647..0dacfb0d 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1370,12 +1370,18 @@ static inline bool pgm_is_whitespace(const char *c) return pgm_read_byte(c) == ' ' || pgm_read_byte(c) == '\t' || pgm_read_byte(c) == '\r' || pgm_read_byte(c) == '\n'; } -void lcd_display_message_fullscreen_P(const char *msg) +static inline bool pgm_is_interpunction(const char *c) +{ + return pgm_read_byte(c) == '.' || pgm_read_byte(c) == ',' || pgm_read_byte(c) == ';' || pgm_read_byte(c) == '?' || pgm_read_byte(c) == '!'; +} + +const char* lcd_display_message_fullscreen_P(const char *msg) { // Disable update of the screen by the usual lcd_update() routine. lcd_update_enable(false); lcd_implementation_clear(); lcd.setCursor(0, 0); + const char *msgend = msg; for (int8_t row = 0; row < 4; ++ row) { while (pgm_is_whitespace(msg)) ++ msg; @@ -1384,8 +1390,8 @@ void lcd_display_message_fullscreen_P(const char *msg) break; lcd.setCursor(0, row); const char *msgend2 = msg + min(strlen_P(msg), 20); - const char *msgend = msgend2; - if (pgm_read_byte(msgend) != 0 && ! pgm_is_whitespace(msgend)) { + msgend = msgend2; + if (pgm_read_byte(msgend) != 0 && ! pgm_is_whitespace(msgend) && ! pgm_is_interpunction(msgend)) { // Splitting a word. Find the start of the current word. while (msgend > msg && ! pgm_is_whitespace(msgend - 1)) -- msgend; @@ -1400,6 +1406,8 @@ void lcd_display_message_fullscreen_P(const char *msg) lcd.print(c); } } + + return (pgm_read_byte(msgend) == 0) ? NULL : msgend; } void lcd_show_fullscreen_message_and_wait_P(const char *msg) diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 8a0cd503..32e50d5b 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -40,7 +40,7 @@ static void lcd_selftest_error(int _error_no, const char *_error_1, const char *_error_2); static void lcd_menu_statistics(); - extern void lcd_display_message_fullscreen_P(const char *msg); + extern const char* lcd_display_message_fullscreen_P(const char *msg); extern void lcd_wait_for_click(); extern void lcd_show_fullscreen_message_and_wait_P(const char *msg); // 0: no, 1: yes, -1: timeouted