Skip to content

Commit f5f6c37

Browse files
🐛 LCD Bed Tramming fixes (#26962)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent 08fe8a3 commit f5f6c37

File tree

11 files changed

+47
-61
lines changed

11 files changed

+47
-61
lines changed

Marlin/Configuration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2218,7 +2218,7 @@
22182218
#if ENABLED(LCD_BED_TRAMMING)
22192219
#define BED_TRAMMING_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets
22202220
#define BED_TRAMMING_HEIGHT 0.0 // (mm) Z height of nozzle at tramming points
2221-
#define BED_TRAMMING_Z_HOP 4.0 // (mm) Z height of nozzle between tramming points
2221+
#define BED_TRAMMING_Z_HOP 4.0 // (mm) Z raise between tramming points
22222222
//#define BED_TRAMMING_INCLUDE_CENTER // Move to the center after the last corner
22232223
//#define BED_TRAMMING_USE_PROBE
22242224
#if ENABLED(BED_TRAMMING_USE_PROBE)

Marlin/src/inc/SanityCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,9 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
15451545
#error "BED_TRAMMING_USE_PROBE is incompatible with SENSORLESS_PROBING."
15461546
#endif
15471547
#endif
1548+
static_assert(BED_TRAMMING_Z_HOP >= 0, "BED_TRAMMING_Z_HOP must be >= 0.");
1549+
#elif ANY(DGUS_LCD_UI_RELOADED, DGUS_LCD_UI_E3S1PRO)
1550+
#error "LCD_BED_TRAMMING is required for the selected display."
15481551
#endif
15491552

15501553
/**

Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -780,11 +780,11 @@ void ChironTFT::panelProcess(uint8_t req) {
780780
DEBUG_ECHOLNPGM("Moving to mesh point at x: ", pos.x, " y: ", pos.y, " z: ", pos_z);
781781
#endif
782782
// Go up before moving
783-
setAxisPosition_mm(3.0,Z);
783+
setAxisPosition_mm(3.0f, Z);
784784

785-
setAxisPosition_mm(17 + (93 * pos.x), X);
786-
setAxisPosition_mm(20 + (93 * pos.y), Y);
787-
setAxisPosition_mm(0.0, Z);
785+
setAxisPosition_mm(17.0f + (93.0f * pos.x), X);
786+
setAxisPosition_mm(20.0f + (93.0f * pos.y), Y);
787+
setAxisPosition_mm(0.0f, Z);
788788
#if ACDEBUG(AC_INFO)
789789
DEBUG_ECHOLNPGM("Current Z: ", getAxisPosition_mm(Z));
790790
#endif

Marlin/src/lcd/extui/dgus_e3s1pro/DGUSReturnKeyCodeHandler.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -401,15 +401,14 @@ static void _gotoTrammingPoint(unsigned char point) {
401401
switch (point) {
402402
default: return;
403403
case 1: x = X_CENTER; y = Y_CENTER; break;
404-
case 2: x = X_MIN_POS + lfrb[0]; y = Y_MIN_POS + lfrb[1]; break;
405-
case 3: x = X_MAX_POS - lfrb[2]; y = Y_MIN_POS + lfrb[1]; break;
406-
case 4: x = X_MAX_POS - lfrb[2]; y = Y_MAX_POS - lfrb[3]; break;
407-
case 5: x = X_MIN_POS + lfrb[0]; y = Y_MAX_POS - lfrb[3]; break;
404+
case 2: x = X_MIN_BED + lfrb[0]; y = Y_MIN_BED + lfrb[1]; break;
405+
case 3: x = X_MAX_BED - lfrb[2]; y = Y_MIN_BED + lfrb[1]; break;
406+
case 4: x = X_MAX_BED - lfrb[2]; y = Y_MAX_BED - lfrb[3]; break;
407+
case 5: x = X_MIN_BED + lfrb[0]; y = Y_MAX_BED - lfrb[3]; break;
408408
}
409409

410-
if (ExtUI::getAxisPosition_mm(ExtUI::Z) < (Z_MIN_POS) + (BED_TRAMMING_Z_HOP))
411-
ExtUI::setAxisPosition_mm((Z_MIN_POS) + (BED_TRAMMING_Z_HOP), ExtUI::Z);
412-
410+
if (BED_TRAMMING_Z_HOP)
411+
ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) + (BED_TRAMMING_Z_HOP), ExtUI::Z);
413412
ExtUI::setAxisPosition_mm(x, ExtUI::X);
414413
ExtUI::setAxisPosition_mm(y, ExtUI::Y);
415414
ExtUI::setAxisPosition_mm((Z_MIN_POS) + (BED_TRAMMING_HEIGHT), ExtUI::Z);

Marlin/src/lcd/extui/dgus_e3s1pro/config/DGUS_Constants.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,3 @@
4545
#ifndef DGUS_STATUS_EXPIRATION_MS
4646
#define DGUS_STATUS_EXPIRATION_MS 30000
4747
#endif
48-
49-
#ifndef BED_TRAMMING_Z_HOP
50-
#define BED_TRAMMING_Z_HOP 4.0
51-
#endif
52-
53-
#ifndef BED_TRAMMING_HEIGHT
54-
#define BED_TRAMMING_HEIGHT 0.0
55-
#endif
56-
57-
static_assert(BED_TRAMMING_Z_HOP >= 0, "BED_TRAMMING_Z_HOP must be >= 0. Please update your configuration.");

Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -474,29 +474,28 @@ void DGUSRxHandler::moveToPoint(DGUS_VP &vp, void *data_ptr) {
474474
y = DGUS_LEVEL_CENTER_Y;
475475
break;
476476
case 2:
477-
x = X_MIN_POS + lfrb[0];
478-
y = Y_MIN_POS + lfrb[1];
477+
x = X_MIN_BED + lfrb[0];
478+
y = Y_MIN_BED + lfrb[1];
479479
break;
480480
case 3:
481-
x = X_MAX_POS - lfrb[2];
482-
y = Y_MIN_POS + lfrb[1];
481+
x = X_MAX_BED - lfrb[2];
482+
y = Y_MIN_BED + lfrb[1];
483483
break;
484484
case 4:
485-
x = X_MAX_POS - lfrb[2];
486-
y = Y_MAX_POS - lfrb[3];
485+
x = X_MAX_BED - lfrb[2];
486+
y = Y_MAX_BED - lfrb[3];
487487
break;
488488
case 5:
489-
x = X_MIN_POS + lfrb[0];
490-
y = Y_MAX_POS - lfrb[3];
489+
x = X_MIN_BED + lfrb[0];
490+
y = Y_MAX_BED - lfrb[3];
491491
break;
492492
}
493493

494-
if (ExtUI::getAxisPosition_mm(ExtUI::Z) < Z_MIN_POS + BED_TRAMMING_Z_HOP) {
495-
ExtUI::setAxisPosition_mm(Z_MIN_POS + BED_TRAMMING_Z_HOP, ExtUI::Z);
496-
}
494+
if (BED_TRAMMING_Z_HOP)
495+
ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) + (BED_TRAMMING_Z_HOP), ExtUI::Z);
497496
ExtUI::setAxisPosition_mm(x, ExtUI::X);
498497
ExtUI::setAxisPosition_mm(y, ExtUI::Y);
499-
ExtUI::setAxisPosition_mm(Z_MIN_POS + BED_TRAMMING_HEIGHT, ExtUI::Z);
498+
ExtUI::setAxisPosition_mm((Z_MIN_POS) + (BED_TRAMMING_HEIGHT), ExtUI::Z);
500499
}
501500

502501
void DGUSRxHandler::probe(DGUS_VP &vp, void *data_ptr) {

Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Constants.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,6 @@
7373
#define DGUS_DEFAULT_FILAMENT_LEN 10
7474
#endif
7575

76-
#ifndef BED_TRAMMING_Z_HOP
77-
#define BED_TRAMMING_Z_HOP 4.0
78-
#endif
79-
80-
#ifndef BED_TRAMMING_HEIGHT
81-
#define BED_TRAMMING_HEIGHT 0.0
82-
#endif
83-
84-
static_assert(BED_TRAMMING_Z_HOP >= 0, "BED_TRAMMING_Z_HOP must be >= 0. Please update your configuration.");
85-
8676
#ifndef DGUS_LEVEL_CENTER_X
8777
#define DGUS_LEVEL_CENTER_X ((X_BED_SIZE) / 2)
8878
#endif

Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,35 +1162,35 @@ void RTS::handleData() {
11621162

11631163
#if ENABLED(LCD_BED_TRAMMING)
11641164
case 6: // Bed Tramming, Centre 1
1165-
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
1165+
if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z));
11661166
setAxisPosition_mm(X_CENTER, axis_t(X));
11671167
setAxisPosition_mm(Y_CENTER, axis_t(Y));
11681168
waitway = 6;
11691169
break;
11701170

11711171
case 7: // Bed Tramming, Front Left 2
1172-
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
1172+
if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z));
11731173
setAxisPosition_mm(X_MIN_BED + lfrb[0], axis_t(X));
11741174
setAxisPosition_mm(Y_MIN_BED + lfrb[1], axis_t(Y));
11751175
waitway = 6;
11761176
break;
11771177

11781178
case 8: // Bed Tramming, Front Right 3
1179-
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
1179+
if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z));
11801180
setAxisPosition_mm(X_MAX_BED - lfrb[2], axis_t(X));
11811181
setAxisPosition_mm(Y_MIN_BED + lfrb[1], axis_t(Y));
11821182
waitway = 6;
11831183
break;
11841184

11851185
case 9: // Bed Tramming, Back Right 4
1186-
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
1186+
if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z));
11871187
setAxisPosition_mm(X_MAX_BED - lfrb[2], axis_t(X));
11881188
setAxisPosition_mm(Y_MAX_BED - lfrb[3], axis_t(Y));
11891189
waitway = 6;
11901190
break;
11911191

11921192
case 10: // Bed Tramming, Back Left 5
1193-
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
1193+
if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z));
11941194
setAxisPosition_mm(X_MIN_BED + lfrb[0], axis_t(X));
11951195
setAxisPosition_mm(Y_MAX_BED - lfrb[3], axis_t(Y));
11961196
waitway = 6;

Marlin/src/lcd/menu/menu_bed_tramming.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@
3636
#include "../../feature/bedlevel/bedlevel.h"
3737
#endif
3838

39-
#ifndef BED_TRAMMING_Z_HOP
40-
#define BED_TRAMMING_Z_HOP 4.0
41-
#endif
42-
#ifndef BED_TRAMMING_HEIGHT
43-
#define BED_TRAMMING_HEIGHT 0.0
44-
#endif
45-
4639
#if ALL(HAS_STOWABLE_PROBE, BED_TRAMMING_USE_PROBE) && DISABLED(BLTOUCH)
4740
#define NEEDS_PROBE_DEPLOY 1
4841
#endif
@@ -151,7 +144,7 @@ static void _lcd_goto_next_corner() {
151144
}
152145
}
153146

154-
float z = BED_TRAMMING_Z_HOP;
147+
float z = current_position.z + (BED_TRAMMING_Z_HOP);
155148
#if ALL(BED_TRAMMING_USE_PROBE, BLTOUCH)
156149
z += bltouch.z_extra_clearance();
157150
#endif
@@ -235,7 +228,7 @@ static void _lcd_goto_next_corner() {
235228
}
236229

237230
bool _lcd_bed_tramming_probe(const bool verify=false) {
238-
if (verify) line_to_z(BED_TRAMMING_Z_HOP); // do clearance if needed
231+
if (verify) line_to_z(current_position.z + (BED_TRAMMING_Z_HOP)); // do clearance if needed
239232
TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action
240233
do_blocking_move_to_z(last_z - BED_TRAMMING_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance
241234
if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered
@@ -253,7 +246,7 @@ static void _lcd_goto_next_corner() {
253246

254247
// Raise the probe after the last point to give clearance for stow
255248
if (TERN0(NEEDS_PROBE_DEPLOY, good_points == nr_edge_points - 1))
256-
line_to_z(BED_TRAMMING_Z_HOP);
249+
do_z_clearance(BED_TRAMMING_Z_HOP);
257250

258251
return true; // probe triggered
259252
}

Marlin/src/module/motion.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,14 @@ void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*
714714
fr_mm_s
715715
);
716716
}
717+
/**
718+
* Move Z to a particular height so the nozzle or deployed probe clears the bed.
719+
* (Use do_z_clearance_by for clearance over the current position.)
720+
* - For a probe, add clearance for the probe distance
721+
* - Constrain to the Z max physical position
722+
* - If lowering is not allowed then skip a downward move
723+
* - Execute the move at the probing (or homing) feedrate
724+
*/
717725
void do_z_clearance(const_float_t zclear, const bool with_probe/*=true*/, const bool lower_allowed/*=false*/) {
718726
UNUSED(with_probe);
719727
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*
727735
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("do_z_clearance_by(", zclear, ")");
728736
do_z_clearance(current_position.z + zclear, false);
729737
}
738+
/**
739+
* Move Z to Z_POST_CLEARANCE,
740+
* The axis is allowed to move down.
741+
*/
730742
void do_move_after_z_homing() {
731743
DEBUG_SECTION(mzah, "do_move_after_z_homing", DEBUGGING(LEVELING));
732-
#if defined(Z_AFTER_HOMING) || ALL(DWIN_LCD_PROUI, INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING)
744+
#ifdef Z_POST_CLEARANCE
733745
do_z_clearance(Z_POST_CLEARANCE, true, true);
734746
#elif ENABLED(USE_PROBE_FOR_Z_HOMING)
735747
probe.move_z_after_probing();

Marlin/src/module/probe.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
999999
default: break;
10001000
case PROBE_PT_RAISE:
10011001
if (raise_after_is_relative)
1002-
do_z_clearance(current_position.z + z_clearance, false);
1002+
do_z_clearance_by(z_clearance);
10031003
else
10041004
do_z_clearance(z_clearance);
10051005
break;

0 commit comments

Comments
 (0)