diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 72ec272b4d99..4d18840dbd5b 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2218,7 +2218,7 @@ #if ENABLED(LCD_BED_TRAMMING) #define BED_TRAMMING_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets #define BED_TRAMMING_HEIGHT 0.0 // (mm) Z height of nozzle at tramming points - #define BED_TRAMMING_Z_HOP 4.0 // (mm) Z height of nozzle between tramming points + #define BED_TRAMMING_Z_HOP 4.0 // (mm) Z raise between tramming points //#define BED_TRAMMING_INCLUDE_CENTER // Move to the center after the last corner //#define BED_TRAMMING_USE_PROBE #if ENABLED(BED_TRAMMING_USE_PROBE) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 5f14c568ae24..339cd4087caa 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1545,6 +1545,9 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i #error "BED_TRAMMING_USE_PROBE is incompatible with SENSORLESS_PROBING." #endif #endif + static_assert(BED_TRAMMING_Z_HOP >= 0, "BED_TRAMMING_Z_HOP must be >= 0."); +#elif ANY(DGUS_LCD_UI_RELOADED, DGUS_LCD_UI_E3S1PRO) + #error "LCD_BED_TRAMMING is required for the selected display." #endif /** diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index 63b1ef9c195c..5e80b79acf1d 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -780,11 +780,11 @@ void ChironTFT::panelProcess(uint8_t req) { DEBUG_ECHOLNPGM("Moving to mesh point at x: ", pos.x, " y: ", pos.y, " z: ", pos_z); #endif // Go up before moving - setAxisPosition_mm(3.0,Z); + setAxisPosition_mm(3.0f, Z); - setAxisPosition_mm(17 + (93 * pos.x), X); - setAxisPosition_mm(20 + (93 * pos.y), Y); - setAxisPosition_mm(0.0, Z); + setAxisPosition_mm(17.0f + (93.0f * pos.x), X); + setAxisPosition_mm(20.0f + (93.0f * pos.y), Y); + setAxisPosition_mm(0.0f, Z); #if ACDEBUG(AC_INFO) DEBUG_ECHOLNPGM("Current Z: ", getAxisPosition_mm(Z)); #endif diff --git a/Marlin/src/lcd/extui/dgus_e3s1pro/DGUSReturnKeyCodeHandler.cpp b/Marlin/src/lcd/extui/dgus_e3s1pro/DGUSReturnKeyCodeHandler.cpp index f6d2e2bb89f1..342fa46cf3d0 100644 --- a/Marlin/src/lcd/extui/dgus_e3s1pro/DGUSReturnKeyCodeHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_e3s1pro/DGUSReturnKeyCodeHandler.cpp @@ -401,15 +401,14 @@ static void _gotoTrammingPoint(unsigned char point) { switch (point) { default: return; case 1: x = X_CENTER; y = Y_CENTER; break; - case 2: x = X_MIN_POS + lfrb[0]; y = Y_MIN_POS + lfrb[1]; break; - case 3: x = X_MAX_POS - lfrb[2]; y = Y_MIN_POS + lfrb[1]; break; - case 4: x = X_MAX_POS - lfrb[2]; y = Y_MAX_POS - lfrb[3]; break; - case 5: x = X_MIN_POS + lfrb[0]; y = Y_MAX_POS - lfrb[3]; break; + case 2: x = X_MIN_BED + lfrb[0]; y = Y_MIN_BED + lfrb[1]; break; + case 3: x = X_MAX_BED - lfrb[2]; y = Y_MIN_BED + lfrb[1]; break; + case 4: x = X_MAX_BED - lfrb[2]; y = Y_MAX_BED - lfrb[3]; break; + case 5: x = X_MIN_BED + lfrb[0]; y = Y_MAX_BED - lfrb[3]; break; } - if (ExtUI::getAxisPosition_mm(ExtUI::Z) < (Z_MIN_POS) + (BED_TRAMMING_Z_HOP)) - ExtUI::setAxisPosition_mm((Z_MIN_POS) + (BED_TRAMMING_Z_HOP), ExtUI::Z); - + if (BED_TRAMMING_Z_HOP) + ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) + (BED_TRAMMING_Z_HOP), ExtUI::Z); ExtUI::setAxisPosition_mm(x, ExtUI::X); ExtUI::setAxisPosition_mm(y, ExtUI::Y); ExtUI::setAxisPosition_mm((Z_MIN_POS) + (BED_TRAMMING_HEIGHT), ExtUI::Z); diff --git a/Marlin/src/lcd/extui/dgus_e3s1pro/config/DGUS_Constants.h b/Marlin/src/lcd/extui/dgus_e3s1pro/config/DGUS_Constants.h index 3c89f7ad8a78..030fc8167188 100644 --- a/Marlin/src/lcd/extui/dgus_e3s1pro/config/DGUS_Constants.h +++ b/Marlin/src/lcd/extui/dgus_e3s1pro/config/DGUS_Constants.h @@ -45,13 +45,3 @@ #ifndef DGUS_STATUS_EXPIRATION_MS #define DGUS_STATUS_EXPIRATION_MS 30000 #endif - -#ifndef BED_TRAMMING_Z_HOP - #define BED_TRAMMING_Z_HOP 4.0 -#endif - -#ifndef BED_TRAMMING_HEIGHT - #define BED_TRAMMING_HEIGHT 0.0 -#endif - -static_assert(BED_TRAMMING_Z_HOP >= 0, "BED_TRAMMING_Z_HOP must be >= 0. Please update your configuration."); diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp index b8ef8bcacc04..a93832da30e0 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp @@ -474,29 +474,28 @@ void DGUSRxHandler::moveToPoint(DGUS_VP &vp, void *data_ptr) { y = DGUS_LEVEL_CENTER_Y; break; case 2: - x = X_MIN_POS + lfrb[0]; - y = Y_MIN_POS + lfrb[1]; + x = X_MIN_BED + lfrb[0]; + y = Y_MIN_BED + lfrb[1]; break; case 3: - x = X_MAX_POS - lfrb[2]; - y = Y_MIN_POS + lfrb[1]; + x = X_MAX_BED - lfrb[2]; + y = Y_MIN_BED + lfrb[1]; break; case 4: - x = X_MAX_POS - lfrb[2]; - y = Y_MAX_POS - lfrb[3]; + x = X_MAX_BED - lfrb[2]; + y = Y_MAX_BED - lfrb[3]; break; case 5: - x = X_MIN_POS + lfrb[0]; - y = Y_MAX_POS - lfrb[3]; + x = X_MIN_BED + lfrb[0]; + y = Y_MAX_BED - lfrb[3]; break; } - if (ExtUI::getAxisPosition_mm(ExtUI::Z) < Z_MIN_POS + BED_TRAMMING_Z_HOP) { - ExtUI::setAxisPosition_mm(Z_MIN_POS + BED_TRAMMING_Z_HOP, ExtUI::Z); - } + if (BED_TRAMMING_Z_HOP) + ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) + (BED_TRAMMING_Z_HOP), ExtUI::Z); ExtUI::setAxisPosition_mm(x, ExtUI::X); ExtUI::setAxisPosition_mm(y, ExtUI::Y); - ExtUI::setAxisPosition_mm(Z_MIN_POS + BED_TRAMMING_HEIGHT, ExtUI::Z); + ExtUI::setAxisPosition_mm((Z_MIN_POS) + (BED_TRAMMING_HEIGHT), ExtUI::Z); } void DGUSRxHandler::probe(DGUS_VP &vp, void *data_ptr) { diff --git a/Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Constants.h b/Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Constants.h index dda3c888fe18..0562b892395c 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Constants.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Constants.h @@ -73,16 +73,6 @@ #define DGUS_DEFAULT_FILAMENT_LEN 10 #endif -#ifndef BED_TRAMMING_Z_HOP - #define BED_TRAMMING_Z_HOP 4.0 -#endif - -#ifndef BED_TRAMMING_HEIGHT - #define BED_TRAMMING_HEIGHT 0.0 -#endif - -static_assert(BED_TRAMMING_Z_HOP >= 0, "BED_TRAMMING_Z_HOP must be >= 0. Please update your configuration."); - #ifndef DGUS_LEVEL_CENTER_X #define DGUS_LEVEL_CENTER_X ((X_BED_SIZE) / 2) #endif diff --git a/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp b/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp index 15bbf3dc071c..d0f7c4745219 100644 --- a/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp +++ b/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp @@ -1162,35 +1162,35 @@ void RTS::handleData() { #if ENABLED(LCD_BED_TRAMMING) case 6: // Bed Tramming, Centre 1 - setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z)); + if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z)); setAxisPosition_mm(X_CENTER, axis_t(X)); setAxisPosition_mm(Y_CENTER, axis_t(Y)); waitway = 6; break; case 7: // Bed Tramming, Front Left 2 - setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z)); + if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z)); setAxisPosition_mm(X_MIN_BED + lfrb[0], axis_t(X)); setAxisPosition_mm(Y_MIN_BED + lfrb[1], axis_t(Y)); waitway = 6; break; case 8: // Bed Tramming, Front Right 3 - setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z)); + if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z)); setAxisPosition_mm(X_MAX_BED - lfrb[2], axis_t(X)); setAxisPosition_mm(Y_MIN_BED + lfrb[1], axis_t(Y)); waitway = 6; break; case 9: // Bed Tramming, Back Right 4 - setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z)); + if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z)); setAxisPosition_mm(X_MAX_BED - lfrb[2], axis_t(X)); setAxisPosition_mm(Y_MAX_BED - lfrb[3], axis_t(Y)); waitway = 6; break; case 10: // Bed Tramming, Back Left 5 - setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z)); + if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z)); setAxisPosition_mm(X_MIN_BED + lfrb[0], axis_t(X)); setAxisPosition_mm(Y_MAX_BED - lfrb[3], axis_t(Y)); waitway = 6; diff --git a/Marlin/src/lcd/menu/menu_bed_tramming.cpp b/Marlin/src/lcd/menu/menu_bed_tramming.cpp index b6b3e7212485..81372db50af1 100644 --- a/Marlin/src/lcd/menu/menu_bed_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_bed_tramming.cpp @@ -36,13 +36,6 @@ #include "../../feature/bedlevel/bedlevel.h" #endif -#ifndef BED_TRAMMING_Z_HOP - #define BED_TRAMMING_Z_HOP 4.0 -#endif -#ifndef BED_TRAMMING_HEIGHT - #define BED_TRAMMING_HEIGHT 0.0 -#endif - #if ALL(HAS_STOWABLE_PROBE, BED_TRAMMING_USE_PROBE) && DISABLED(BLTOUCH) #define NEEDS_PROBE_DEPLOY 1 #endif @@ -151,7 +144,7 @@ static void _lcd_goto_next_corner() { } } - float z = BED_TRAMMING_Z_HOP; + float z = current_position.z + (BED_TRAMMING_Z_HOP); #if ALL(BED_TRAMMING_USE_PROBE, BLTOUCH) z += bltouch.z_extra_clearance(); #endif @@ -235,7 +228,7 @@ static void _lcd_goto_next_corner() { } bool _lcd_bed_tramming_probe(const bool verify=false) { - if (verify) line_to_z(BED_TRAMMING_Z_HOP); // do clearance if needed + if (verify) line_to_z(current_position.z + (BED_TRAMMING_Z_HOP)); // do clearance if needed TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action do_blocking_move_to_z(last_z - BED_TRAMMING_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered @@ -253,7 +246,7 @@ static void _lcd_goto_next_corner() { // Raise the probe after the last point to give clearance for stow if (TERN0(NEEDS_PROBE_DEPLOY, good_points == nr_edge_points - 1)) - line_to_z(BED_TRAMMING_Z_HOP); + do_z_clearance(BED_TRAMMING_Z_HOP); return true; // probe triggered } diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index e4e419dd767f..3d93e1e9d954 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -714,6 +714,14 @@ void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f* fr_mm_s ); } + /** + * Move Z to a particular height so the nozzle or deployed probe clears the bed. + * (Use do_z_clearance_by for clearance over the current position.) + * - For a probe, add clearance for the probe distance + * - Constrain to the Z max physical position + * - If lowering is not allowed then skip a downward move + * - Execute the move at the probing (or homing) feedrate + */ void do_z_clearance(const_float_t zclear, const bool with_probe/*=true*/, const bool lower_allowed/*=false*/) { UNUSED(with_probe); float zdest = zclear; @@ -727,9 +735,13 @@ void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f* if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("do_z_clearance_by(", zclear, ")"); do_z_clearance(current_position.z + zclear, false); } + /** + * Move Z to Z_POST_CLEARANCE, + * The axis is allowed to move down. + */ void do_move_after_z_homing() { DEBUG_SECTION(mzah, "do_move_after_z_homing", DEBUGGING(LEVELING)); - #if defined(Z_AFTER_HOMING) || ALL(DWIN_LCD_PROUI, INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + #ifdef Z_POST_CLEARANCE do_z_clearance(Z_POST_CLEARANCE, true, true); #elif ENABLED(USE_PROBE_FOR_Z_HOMING) probe.move_z_after_probing(); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 342ce2bb3af3..616414a0277e 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -999,7 +999,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai default: break; case PROBE_PT_RAISE: if (raise_after_is_relative) - do_z_clearance(current_position.z + z_clearance, false); + do_z_clearance_by(z_clearance); else do_z_clearance(z_clearance); break;