diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 5941d988..8a490b22 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -433,7 +433,7 @@ const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42 //Inactivity shutdown variables static unsigned long previous_millis_cmd = 0; -static unsigned long max_inactive_time = 0; +unsigned long max_inactive_time = 0; static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000l; unsigned long starttime=0; @@ -1873,7 +1873,8 @@ void process_commands() // Reset world2machine_rotation_and_skew and world2machine_shift, therefore // the planner will not perform any adjustments in the XY plane. - world2machine_reset(); + // Wait for the motors to stop and update the current position with the absolute values. + world2machine_revert_to_uncorrected(); saved_feedrate = feedrate; saved_feedmultiply = feedmultiply; @@ -1882,9 +1883,8 @@ void process_commands() enable_endstops(true); - for(int8_t i=0; i < NUM_AXIS; i++) { - destination[i] = current_position[i]; - } + for(int8_t i=0; i < NUM_AXIS; i++) + destination[i] = current_position[i]; feedrate = 0.0; home_all_axis = !((code_seen(axis_codes[X_AXIS])) || (code_seen(axis_codes[Y_AXIS])) || (code_seen(axis_codes[Z_AXIS]))); @@ -1997,6 +1997,8 @@ void process_commands() world2machine_initialize(); world2machine(pgm_read_float(bed_ref_points), pgm_read_float(bed_ref_points+1), destination[X_AXIS], destination[Y_AXIS]); world2machine_reset(); + if (destination[Y_AXIS] < Y_MIN_POS) + destination[Y_AXIS] = Y_MIN_POS; destination[Z_AXIS] = MESH_HOME_Z_SEARCH; // Set destination away from bed feedrate = homing_feedrate[Z_AXIS]/10; current_position[Z_AXIS] = 0; @@ -2329,6 +2331,7 @@ void process_commands() // The move to the first calibration point. current_position[X_AXIS] = pgm_read_float(bed_ref_points); current_position[Y_AXIS] = pgm_read_float(bed_ref_points+1); + world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); // mbl.get_meas_xy(0, 0, current_position[X_AXIS], current_position[Y_AXIS], false); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS]/30, active_extruder); // Wait until the move is finished. @@ -2408,6 +2411,7 @@ void process_commands() current_position[X_AXIS] = X_MIN_POS+0.2; current_position[Y_AXIS] = Y_MIN_POS+0.2; current_position[Z_AXIS] = Z_MIN_POS; + world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); plan_buffer_line(current_position[X_AXIS], current_position[X_AXIS], current_position[Z_AXIS], current_position[E_AXIS], XY_AXIS_FEEDRATE, active_extruder); st_synchronize(); @@ -2765,11 +2769,10 @@ void process_commands() case 44: // M45: Reset the bed skew and offset calibration. // Reset the skew and offset in both RAM and EEPROM. reset_bed_offset_and_skew(); - world2machine_reset(); + // Reset world2machine_rotation_and_skew and world2machine_shift, therefore + // the planner will not perform any adjustments in the XY plane. // Wait for the motors to stop and update the current position with the absolute values. - st_synchronize(); - current_position[X_AXIS] = st_get_position_mm(X_AXIS); - current_position[Y_AXIS] = st_get_position_mm(Y_AXIS); + world2machine_revert_to_uncorrected(); break; case 45: // M46: bed skew and offset with manual Z up @@ -2778,7 +2781,10 @@ void process_commands() lcd_update_enable(false); // Let the planner use the uncorrected coordinates. mbl.reset(); - world2machine_reset(); + // Reset world2machine_rotation_and_skew and world2machine_shift, therefore + // the planner will not perform any adjustments in the XY plane. + // Wait for the motors to stop and update the current position with the absolute values. + world2machine_revert_to_uncorrected(); // Let the user move the Z axes up to the end stoppers. if (lcd_calibrate_z_end_stop_manual()) { refresh_cmd_timeout(); @@ -2819,11 +2825,13 @@ void process_commands() st_synchronize(); } lcd_bed_calibration_show_result(result, point_too_far_mask); - lcd_update_enable(true); - lcd_implementation_clear(); - // lcd_return_to_status(); - lcd_update(); + } else { + // Timeouted. } + lcd_update_enable(true); + lcd_implementation_clear(); + // lcd_return_to_status(); + lcd_update(); break; } @@ -2834,7 +2842,10 @@ void process_commands() lcd_update_enable(false); // Let the planner use the uncorrected coordinates. mbl.reset(); - world2machine_reset(); + // Reset world2machine_rotation_and_skew and world2machine_shift, therefore + // the planner will not perform any adjustments in the XY plane. + // Wait for the motors to stop and update the current position with the absolute values. + world2machine_revert_to_uncorrected(); // Move the print head close to the bed. current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS],current_position[Z_AXIS] , current_position[E_AXIS], homing_feedrate[Z_AXIS]/40, active_extruder); diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index fc10b0b5..65fe97dd 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -538,30 +538,30 @@ const char * const MSG_CONFIGURATION_VER_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_CONFIGURATION_VER_PL }; -const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1_EN[] PROGMEM = "Are left and right"; -const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1_CZ[] PROGMEM = "Dojely oba Z voziky"; -const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1_IT[] PROGMEM = "Are left and right"; -const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1_ES[] PROGMEM = "Are left and right"; -const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1_PL[] PROGMEM = "Are left and right"; -const char * const MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1_LANG_TABLE[LANG_NUM] PROGMEM = { - MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1_EN, - MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1_CZ, - MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1_IT, - MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1_ES, - MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1_PL +const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_EN[] PROGMEM = "Are left and right Z~carriages all up?"; +const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_CZ[] PROGMEM = "Dojely oba Z voziky k~hornimu dorazu?"; +const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_IT[] PROGMEM = "Are left and right Z~carriages all up?"; +const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_ES[] PROGMEM = "Are left and right Z~carriages all up?"; +const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_PL[] PROGMEM = "Are left and right Z~carriages all up?"; +const char * const MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LANG_TABLE[LANG_NUM] PROGMEM = { + MSG_CONFIRM_CARRIAGE_AT_THE_TOP_EN, + MSG_CONFIRM_CARRIAGE_AT_THE_TOP_CZ, + MSG_CONFIRM_CARRIAGE_AT_THE_TOP_IT, + MSG_CONFIRM_CARRIAGE_AT_THE_TOP_ES, + MSG_CONFIRM_CARRIAGE_AT_THE_TOP_PL }; -const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2_EN[] PROGMEM = "Z carriages all up?"; -const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2_CZ[] PROGMEM = "k hornimu dorazu?"; -const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2_IT[] PROGMEM = "Z carriages all up?"; -const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2_ES[] PROGMEM = "Z carriages all up?"; -const char MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2_PL[] PROGMEM = "Z carriages all up?"; -const char * const MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2_LANG_TABLE[LANG_NUM] PROGMEM = { - MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2_EN, - MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2_CZ, - MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2_IT, - MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2_ES, - MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2_PL +const char MSG_CONFIRM_NOZZLE_CLEAN_EN[] PROGMEM = "Please clean the nozzle for calibration. Click when done."; +const char MSG_CONFIRM_NOZZLE_CLEAN_CZ[] PROGMEM = "Pro uspesnou kalibraci ocistete prosim tiskovou trysku. Potvrdte tlacitkem."; +const char MSG_CONFIRM_NOZZLE_CLEAN_IT[] PROGMEM = "Please clean the nozzle for calibration. Click when done."; +const char MSG_CONFIRM_NOZZLE_CLEAN_ES[] PROGMEM = "Please clean the nozzle for calibration. Click when done."; +const char MSG_CONFIRM_NOZZLE_CLEAN_PL[] PROGMEM = "Please clean the nozzle for calibration. Click when done."; +const char * const MSG_CONFIRM_NOZZLE_CLEAN_LANG_TABLE[LANG_NUM] PROGMEM = { + MSG_CONFIRM_NOZZLE_CLEAN_EN, + MSG_CONFIRM_NOZZLE_CLEAN_CZ, + MSG_CONFIRM_NOZZLE_CLEAN_IT, + MSG_CONFIRM_NOZZLE_CLEAN_ES, + MSG_CONFIRM_NOZZLE_CLEAN_PL }; const char MSG_CONTRAST_EN[] PROGMEM = "LCD contrast"; @@ -1669,56 +1669,17 @@ const char * const MSG_MOVE_AXIS_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_MOVE_AXIS_PL }; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1_EN[] PROGMEM = "Calibrating X/Y."; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1_CZ[] PROGMEM = "Kalibrace X/Y"; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1_IT[] PROGMEM = "Calibrating X/Y."; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1_ES[] PROGMEM = "Calibrating X/Y."; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1_PL[] PROGMEM = "Calibrating X/Y."; -const char * const MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1_LANG_TABLE[LANG_NUM] PROGMEM = { - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1_EN, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1_CZ, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1_IT, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1_ES, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1_PL -}; - -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2_EN[] PROGMEM = "Move Z carriage up"; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2_CZ[] PROGMEM = "Posunte prosim Z osu"; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2_IT[] PROGMEM = "Move Z carriage up"; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2_ES[] PROGMEM = "Move Z carriage up"; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2_PL[] PROGMEM = "Move Z carriage up"; -const char * const MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2_LANG_TABLE[LANG_NUM] PROGMEM = { - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2_EN, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2_CZ, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2_IT, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2_ES, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2_PL -}; - -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3_EN[] PROGMEM = "to the end stoppers."; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3_CZ[] PROGMEM = "az k hornimu dorazu."; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3_IT[] PROGMEM = "to the end stoppers."; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3_ES[] PROGMEM = "to the end stoppers."; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3_PL[] PROGMEM = "to the end stoppers."; -const char * const MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3_LANG_TABLE[LANG_NUM] PROGMEM = { - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3_EN, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3_CZ, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3_IT, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3_ES, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3_PL -}; - -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4_EN[] PROGMEM = "Click when done."; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4_CZ[] PROGMEM = "Potvrdte tlacitkem."; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4_IT[] PROGMEM = "Click when done."; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4_ES[] PROGMEM = "Click when done."; -const char MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4_PL[] PROGMEM = "Click when done."; -const char * const MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4_LANG_TABLE[LANG_NUM] PROGMEM = { - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4_EN, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4_CZ, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4_IT, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4_ES, - MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4_PL +const char MSG_MOVE_CARRIAGE_TO_THE_TOP_EN[] PROGMEM = "Calibrating X/Y. Move Z carriage up to the end stoppers. Click when done."; +const char MSG_MOVE_CARRIAGE_TO_THE_TOP_CZ[] PROGMEM = "Kalibrace X/Y. Posunte prosim Z osu az k~hornimu dorazu. Potvrdte tlacitkem."; +const char MSG_MOVE_CARRIAGE_TO_THE_TOP_IT[] PROGMEM = "Calibrating X/Y. Move Z carriage up to the end stoppers. Click when done."; +const char MSG_MOVE_CARRIAGE_TO_THE_TOP_ES[] PROGMEM = "Calibrating X/Y. Move Z carriage up to the end stoppers. Click when done."; +const char MSG_MOVE_CARRIAGE_TO_THE_TOP_PL[] PROGMEM = "Calibrating X/Y. Move Z carriage up to the end stoppers. Click when done."; +const char * const MSG_MOVE_CARRIAGE_TO_THE_TOP_LANG_TABLE[LANG_NUM] PROGMEM = { + MSG_MOVE_CARRIAGE_TO_THE_TOP_EN, + MSG_MOVE_CARRIAGE_TO_THE_TOP_CZ, + MSG_MOVE_CARRIAGE_TO_THE_TOP_IT, + MSG_MOVE_CARRIAGE_TO_THE_TOP_ES, + MSG_MOVE_CARRIAGE_TO_THE_TOP_PL }; const char MSG_MOVE_E_EN[] PROGMEM = "Extruder"; diff --git a/Firmware/language_all.h b/Firmware/language_all.h index 9d61170c..9d679dcc 100644 --- a/Firmware/language_all.h +++ b/Firmware/language_all.h @@ -90,10 +90,10 @@ extern const char* const MSG_CNG_SDCARD_LANG_TABLE[LANG_NUM]; #define MSG_CNG_SDCARD LANG_TABLE_SELECT(MSG_CNG_SDCARD_LANG_TABLE) extern const char* const MSG_CONFIGURATION_VER_LANG_TABLE[LANG_NUM]; #define MSG_CONFIGURATION_VER LANG_TABLE_SELECT(MSG_CONFIGURATION_VER_LANG_TABLE) -extern const char* const MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1_LANG_TABLE[LANG_NUM]; -#define MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1 LANG_TABLE_SELECT(MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1_LANG_TABLE) -extern const char* const MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2_LANG_TABLE[LANG_NUM]; -#define MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2 LANG_TABLE_SELECT(MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2_LANG_TABLE) +extern const char* const MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LANG_TABLE[LANG_NUM]; +#define MSG_CONFIRM_CARRIAGE_AT_THE_TOP LANG_TABLE_SELECT(MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LANG_TABLE) +extern const char* const MSG_CONFIRM_NOZZLE_CLEAN_LANG_TABLE[LANG_NUM]; +#define MSG_CONFIRM_NOZZLE_CLEAN LANG_TABLE_SELECT(MSG_CONFIRM_NOZZLE_CLEAN_LANG_TABLE) extern const char* const MSG_CONTRAST_LANG_TABLE[LANG_NUM]; #define MSG_CONTRAST LANG_TABLE_SELECT(MSG_CONTRAST_LANG_TABLE) extern const char* const MSG_CONTROL_LANG_TABLE[LANG_NUM]; @@ -266,14 +266,8 @@ extern const char* const MSG_MOVE_1MM_LANG_TABLE[LANG_NUM]; #define MSG_MOVE_1MM LANG_TABLE_SELECT(MSG_MOVE_1MM_LANG_TABLE) extern const char* const MSG_MOVE_AXIS_LANG_TABLE[LANG_NUM]; #define MSG_MOVE_AXIS LANG_TABLE_SELECT(MSG_MOVE_AXIS_LANG_TABLE) -extern const char* const MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1_LANG_TABLE[LANG_NUM]; -#define MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1 LANG_TABLE_SELECT(MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1_LANG_TABLE) -extern const char* const MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2_LANG_TABLE[LANG_NUM]; -#define MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2 LANG_TABLE_SELECT(MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2_LANG_TABLE) -extern const char* const MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3_LANG_TABLE[LANG_NUM]; -#define MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3 LANG_TABLE_SELECT(MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3_LANG_TABLE) -extern const char* const MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4_LANG_TABLE[LANG_NUM]; -#define MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4 LANG_TABLE_SELECT(MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4_LANG_TABLE) +extern const char* const MSG_MOVE_CARRIAGE_TO_THE_TOP_LANG_TABLE[LANG_NUM]; +#define MSG_MOVE_CARRIAGE_TO_THE_TOP LANG_TABLE_SELECT(MSG_MOVE_CARRIAGE_TO_THE_TOP_LANG_TABLE) extern const char* const MSG_MOVE_E_LANG_TABLE[LANG_NUM]; #define MSG_MOVE_E LANG_TABLE_SELECT(MSG_MOVE_E_LANG_TABLE) extern const char* const MSG_MOVE_E1_LANG_TABLE[LANG_NUM]; diff --git a/Firmware/language_cz.h b/Firmware/language_cz.h index a8b5621c..9ed4fea2 100644 --- a/Firmware/language_cz.h +++ b/Firmware/language_cz.h @@ -282,13 +282,9 @@ #define MSG_CALIBRATE_BED "Kalibrace X/Y" #define MSG_CALIBRATE_BED_RESET "Reset X/Y kalibr." -#define MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1 "Kalibrace X/Y" -#define MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2 "Posunte prosim Z osu" -#define MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3 "az k hornimu dorazu." -#define MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4 "Potvrdte tlacitkem." - -#define MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1 "Dojely oba Z voziky" -#define MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2 "k hornimu dorazu?" +#define MSG_MOVE_CARRIAGE_TO_THE_TOP "Kalibrace X/Y. Posunte prosim Z osu az k~hornimu dorazu. Potvrdte tlacitkem." +#define MSG_CONFIRM_NOZZLE_CLEAN "Pro uspesnou kalibraci ocistete prosim tiskovou trysku. Potvrdte tlacitkem." +#define MSG_CONFIRM_CARRIAGE_AT_THE_TOP "Dojely oba Z voziky k~hornimu dorazu?" #define MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Hledam kalibracni" #define MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 "bod podlozky" diff --git a/Firmware/language_en.h b/Firmware/language_en.h index 42cd30c0..8715f855 100644 --- a/Firmware/language_en.h +++ b/Firmware/language_en.h @@ -275,13 +275,9 @@ #define MSG_CALIBRATE_BED "Calibrate X/Y" #define MSG_CALIBRATE_BED_RESET "Reset X/Y calibr." -#define MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1 "Calibrating X/Y." -#define MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2 "Move Z carriage up" -#define MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3 "to the end stoppers." -#define MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4 "Click when done." - -#define MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1 "Are left and right" -#define MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2 "Z carriages all up?" +#define MSG_MOVE_CARRIAGE_TO_THE_TOP "Calibrating X/Y. Move Z carriage up to the end stoppers. Click when done." +#define MSG_CONFIRM_NOZZLE_CLEAN "Please clean the nozzle for calibration. Click when done." +#define MSG_CONFIRM_CARRIAGE_AT_THE_TOP "Are left and right Z~carriages all up?" #define MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 "Searching bed" #define MSG_FIND_BED_OFFSET_AND_SKEW_LINE2 "calibration point" diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index ebc7ddbf..3a86b4fa 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -557,6 +557,21 @@ void world2machine_reset() world2machine_update(vx, vy, cntr); } +void world2machine_revert_to_uncorrected() +{ + if (world2machine_correction_mode != WORLD2MACHINE_CORRECTION_NONE) { + // Reset the machine correction matrix. + const float vx[] = { 1.f, 0.f }; + const float vy[] = { 0.f, 1.f }; + const float cntr[] = { 0.f, 0.f }; + world2machine_update(vx, vy, cntr); + // Wait for the motors to stop and update the current position with the absolute values. + st_synchronize(); + current_position[X_AXIS] = st_get_position_mm(X_AXIS); + current_position[Y_AXIS] = st_get_position_mm(Y_AXIS); + } +} + static inline bool vec_undef(const float v[2]) { const uint32_t *vx = (const uint32_t*)v; @@ -1150,13 +1165,12 @@ canceled: // Searching the front points, where one cannot move the sensor head in front of the sensor point. // Searching in a zig-zag movement in a plane for the maximum width of the response. +// This function may set the current_position[Y_AXIS] below Y_MIN_POS, if the function succeeded. +// If this function failed, the Y coordinate will never be outside the working space. #define IMPROVE_BED_INDUCTION_SENSOR_POINT3_SEARCH_RADIUS (4.f) #define IMPROVE_BED_INDUCTION_SENSOR_POINT3_SEARCH_STEP_FINE_Y (0.1f) inline bool improve_bed_induction_sensor_point3(int verbosity_level) { - if (current_position[Y_AXIS] < Y_MIN_POS_FOR_BED_CALIBRATION) - current_position[Y_AXIS] = Y_MIN_POS_FOR_BED_CALIBRATION; - float center_old_x = current_position[X_AXIS]; float center_old_y = current_position[Y_AXIS]; float a, b; @@ -1411,7 +1425,10 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level) // the induction sensor is probably too high. Returning false will force // the sensor to be lowered a tiny bit. result = xmax >= MIN_BED_SENSOR_POINT_RESPONSE_DMR; - ymax = 0.5f * (y0 + y1); + if (y0 > Y_MIN_POS_FOR_BED_CALIBRATION + 0.2f) + // Only in case both left and right y tangents are known, use them. + // If y0 is close to the bed edge, it may not be symmetric to the right tangent. + ymax = 0.5f * ymax + 0.25f * (y0 + y1); } } @@ -1426,15 +1443,22 @@ inline bool improve_bed_induction_sensor_point3(int verbosity_level) SERIAL_ECHO(current_position[Y_AXIS]); SERIAL_ECHOLNPGM(""); } - go_xy(current_position[X_AXIS], current_position[Y_AXIS], homing_feedrate[X_AXIS] / 60.f); + + // Don't clamp current_position[Y_AXIS], because the out-of-reach Y coordinate may actually be true. + // Only clamp the coordinate to go. + go_xy(current_position[X_AXIS], max(Y_MIN_POS, current_position[Y_AXIS]), homing_feedrate[X_AXIS] / 60.f); // delay_keep_alive(3000); } - return result; + if (result) + return true; + // otherwise clamp the Y coordinate canceled: // Go back to the center. enable_z_endstop(false); + if (current_position[Y_AXIS] < Y_MIN_POS) + current_position[Y_AXIS] = Y_MIN_POS; go_xy(current_position[X_AXIS], current_position[Y_AXIS], homing_feedrate[X_AXIS] / 60.f); return false; } @@ -1563,8 +1587,12 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level #endif if (verbosity_level >= 10) delay_keep_alive(3000); + // Save the detected point position and then clamp the Y coordinate, which may have been estimated + // to lie outside the machine working space. pt[0] = current_position[X_AXIS]; pt[1] = current_position[Y_AXIS]; + if (current_position[Y_AXIS] < Y_MIN_POS) + current_position[Y_AXIS] = Y_MIN_POS; // Start searching for the other points at 3mm above the last point. current_position[Z_AXIS] += 3.f; cntr[0] += pt[0]; @@ -1738,6 +1766,8 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8 pts[mesh_point*2 ] += current_position[X_AXIS]; pts[mesh_point*2+1] += current_position[Y_AXIS]; } + if (current_position[Y_AXIS] < Y_MIN_POS) + current_position[Y_AXIS] = Y_MIN_POS; ++ iter; } else if (n_errors -- == 0) { // Give up. diff --git a/Firmware/mesh_bed_calibration.h b/Firmware/mesh_bed_calibration.h index 70d00908..29e23d1a 100644 --- a/Firmware/mesh_bed_calibration.h +++ b/Firmware/mesh_bed_calibration.h @@ -24,6 +24,8 @@ extern float world2machine_shift[2]; // Resets the transformation to identity. extern void world2machine_reset(); +// Resets the transformation to identity and update current_position[X,Y] from the servos. +extern void world2machine_revert_to_uncorrected(); // Loads the transformation from the EEPROM, if available. extern void world2machine_initialize(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 2a79f757..31f5d259 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1023,6 +1023,7 @@ static void _lcd_move(const char *name, int axis, int min, int max) { if (min_software_endstops && current_position[axis] < min) current_position[axis] = min; if (max_software_endstops && current_position[axis] > max) current_position[axis] = max; encoderPosition = 0; + world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis] / 60, active_extruder); lcdDrawUpdate = 1; } @@ -1202,10 +1203,7 @@ void lcd_adjust_z() { // Otherwise the Z calibration is not changed and false is returned. bool lcd_calibrate_z_end_stop_manual() { - const unsigned long max_inactive_time = 60 * 1000; // 60 seconds - unsigned long previous_millis_cmd = millis(); - int8_t cursor_pos; - int8_t enc_dif = 0; + bool clean_nozzle_asked = false; // Don't know where we are. Let's claim we are Z=0, so the soft end stops will not be triggered when moving up. current_position[Z_AXIS] = 0; @@ -1213,21 +1211,13 @@ bool lcd_calibrate_z_end_stop_manual() // Until confirmed by the confirmation dialog. for (;;) { - previous_millis_cmd = millis(); - lcd_implementation_clear(); - lcd.setCursor(0, 0); - lcd_printPGM(MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE1); - lcd.setCursor(0, 1); - lcd_printPGM(MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE2); - lcd.setCursor(0, 2); - lcd_printPGM(MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE3); - lcd.setCursor(0, 3); - lcd_printPGM(MSG_MOVE_CARRIAGE_TO_THE_TOP_LINE4); + unsigned long previous_millis_cmd = millis(); + lcd_display_message_fullscreen_P(MSG_MOVE_CARRIAGE_TO_THE_TOP); // Until the user finishes the z up movement. encoderDiff = 0; encoderPosition = 0; for (;;) { - if (millis() - previous_millis_cmd > max_inactive_time) + if (millis() - previous_millis_cmd > LCD_TIMEOUT_TO_STATUS) goto canceled; manage_heater(); manage_inactivity(true); @@ -1256,59 +1246,24 @@ bool lcd_calibrate_z_end_stop_manual() } } - // Let the user confirm, that the Z carriage is at the top end stoppers. - lcd_implementation_clear(); - lcd.setCursor(0, 0); - lcd_printPGM(MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE1); - lcd.setCursor(0, 1); - lcd_printPGM(MSG_CONFIRM_CARRIAGE_AT_THE_TOP_LINE2); - lcd.setCursor(1, 2); - lcd_printPGM(MSG_YES); - lcd.setCursor(1, 3); - lcd_printPGM(MSG_NO); - cursor_pos = 3; - lcd.setCursor(0, cursor_pos); - lcd_printPGM(PSTR(">")); - - previous_millis_cmd = millis(); - enc_dif = encoderDiff; - for (;;) { - if (millis() - previous_millis_cmd > max_inactive_time) - goto canceled; - manage_heater(); - manage_inactivity(true); - if (abs((enc_dif - encoderDiff)) > 4) { - if (abs(enc_dif - encoderDiff) > 1) { - lcd.setCursor(0, 2); - if (enc_dif > encoderDiff && cursor_pos == 4) { - lcd_printPGM((PSTR(" "))); - lcd.setCursor(0, 3); - lcd_printPGM((PSTR(">"))); - -- cursor_pos; - } else if (enc_dif < encoderDiff && cursor_pos == 3) { - ++ cursor_pos; - lcd_printPGM((PSTR(">"))); - lcd.setCursor(0, 3); - lcd_printPGM((PSTR(" "))); - } - enc_dif = encoderDiff; - } - } - if (lcd_clicked()) { - while (lcd_clicked()) ; - delay(10); - while (lcd_clicked()) ; - if (cursor_pos == 3) { - // Perform another round of the Z up dialog. - break; - } - goto calibrated; - } + if (! clean_nozzle_asked) { + lcd_show_fullscreen_message_and_wait_P(MSG_CONFIRM_NOZZLE_CLEAN); + clean_nozzle_asked = true; } + + // Let the user confirm, that the Z carriage is at the top end stoppers. + int8_t result = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_CONFIRM_CARRIAGE_AT_THE_TOP); + if (result == -1) + goto canceled; + else if (result == 1) + goto calibrated; + // otherwise perform another round of the Z up dialog. } calibrated: - current_position[Z_AXIS] = Z_MAX_POS; + // Let the machine think the Z axis is a bit higher than it is, so it will not home into the bed + // during the search for the induction points. + current_position[Z_AXIS] = Z_MAX_POS-3.f; plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); return true; @@ -1353,7 +1308,7 @@ void lcd_display_message_fullscreen_P(const char *msg) } } -static void lcd_show_fullscreen_message_and_wait_P(const char *msg) +void lcd_show_fullscreen_message_and_wait_P(const char *msg) { lcd_display_message_fullscreen_P(msg); @@ -1369,6 +1324,51 @@ static void lcd_show_fullscreen_message_and_wait_P(const char *msg) } } +int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting) +{ + lcd_display_message_fullscreen_P(msg); + + lcd.setCursor(1, 2); + lcd_printPGM(MSG_YES); + lcd.setCursor(0, 3); + lcd_printPGM(PSTR(">")); + lcd_printPGM(MSG_NO); + bool yes = false; + + // Wait for user confirmation or a timeout. + unsigned long previous_millis_cmd = millis(); + int8_t enc_dif = encoderDiff; + for (;;) { + if (allow_timeouting && millis() - previous_millis_cmd > LCD_TIMEOUT_TO_STATUS) + return -1; + manage_heater(); + manage_inactivity(true); + if (abs((enc_dif - encoderDiff)) > 4) { + if (abs(enc_dif - encoderDiff) > 1) { + lcd.setCursor(0, 2); + if (enc_dif > encoderDiff && yes) { + lcd_printPGM((PSTR(" "))); + lcd.setCursor(0, 3); + lcd_printPGM((PSTR(">"))); + yes = false; + } else if (enc_dif < encoderDiff && ! yes) { + lcd_printPGM((PSTR(">"))); + lcd.setCursor(0, 3); + lcd_printPGM((PSTR(" "))); + yes = true; + } + enc_dif = encoderDiff; + } + } + if (lcd_clicked()) { + while (lcd_clicked()) ; + delay(10); + while (lcd_clicked()) ; + return yes; + } + } +} + void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, uint8_t point_too_far_mask) { const char *msg = NULL; diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 51feb1da..42312606 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -39,6 +39,9 @@ static void lcd_menu_statistics(); extern void lcd_display_message_fullscreen_P(const char *msg); + extern void lcd_show_fullscreen_message_and_wait_P(const char *msg); + // 0: no, 1: yes, -1: timeouted + extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true); // Ask the user to move the Z axis up to the end stoppers and let // the user confirm that it has been done.