Skip to content

Commit b6b4bf0

Browse files
authored
Merge pull request #8345 from tcm0116/1.1.x-delta_height
[1.1.x] Add delta_height variable in lieu of using home_offset
2 parents d60619f + 658e1eb commit b6b4bf0

File tree

5 files changed

+84
-92
lines changed

5 files changed

+84
-92
lines changed

Marlin/Conditionals_post.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@
10301030
// Updated G92 behavior shifts the workspace
10311031
#define HAS_POSITION_SHIFT DISABLED(NO_WORKSPACE_OFFSETS)
10321032
// The home offset also shifts the coordinate space
1033-
#define HAS_HOME_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) || ENABLED(DELTA))
1033+
#define HAS_HOME_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) && DISABLED(DELTA))
10341034
// Either offset yields extra calculations on all moves
10351035
#define HAS_WORKSPACE_OFFSET (HAS_POSITION_SHIFT || HAS_HOME_OFFSET)
10361036
// M206 doesn't apply to DELTA

Marlin/Marlin.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ void report_current_position();
304304
#endif
305305

306306
#if ENABLED(DELTA)
307-
extern float delta_endstop_adj[ABC],
307+
extern float delta_height,
308+
delta_endstop_adj[ABC],
308309
delta_radius,
309310
delta_diagonal_rod,
310311
delta_calibration_radius,

Marlin/Marlin_main.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,8 @@ static uint8_t target_extruder;
627627
float delta[ABC];
628628

629629
// Initialized by settings.load()
630-
float delta_endstop_adj[ABC] = { 0 },
630+
float delta_height,
631+
delta_endstop_adj[ABC] = { 0 },
631632
delta_radius,
632633
delta_tower_angle_trim[ABC],
633634
delta_tower[ABC][2],
@@ -1443,6 +1444,12 @@ bool get_target_extruder_from_command(const uint16_t code) {
14431444
soft_endstop_max[axis] = base_max_pos(axis) + offs;
14441445
}
14451446
}
1447+
#elif ENABLED(DELTA)
1448+
soft_endstop_min[axis] = base_min_pos(axis) + offs;
1449+
soft_endstop_max[axis] = (axis == Z_AXIS ? delta_height : base_max_pos(axis)) + offs;
1450+
#else
1451+
soft_endstop_min[axis] = base_min_pos(axis) + offs;
1452+
soft_endstop_max[axis] = base_max_pos(axis) + offs;
14461453
#endif
14471454

14481455
#if ENABLED(DEBUG_LEVELING_FEATURE)
@@ -1568,6 +1575,10 @@ static void set_axis_is_at_home(const AxisEnum axis) {
15681575
soft_endstop_max[axis] = base_max_pos(axis); // + (cartes[axis] - base_home_pos(axis));
15691576
}
15701577
else
1578+
#elif ENABLED(DELTA)
1579+
if (axis == Z_AXIS)
1580+
current_position[axis] = delta_height;
1581+
else
15711582
#endif
15721583
{
15731584
current_position[axis] = base_home_pos(axis);
@@ -2377,11 +2388,7 @@ static void clean_up_after_endstop_or_probe_move() {
23772388
}
23782389
#endif
23792390

2380-
return current_position[Z_AXIS] + zprobe_zoffset
2381-
#if ENABLED(DELTA)
2382-
+ home_offset[Z_AXIS] // Account for delta height adjustment
2383-
#endif
2384-
;
2391+
return current_position[Z_AXIS] + zprobe_zoffset;
23852392
}
23862393

23872394
/**
@@ -3930,14 +3937,13 @@ inline void gcode_G4() {
39303937
sync_plan_position();
39313938

39323939
// Move all carriages together linearly until an endstop is hit.
3933-
current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (DELTA_HEIGHT + home_offset[Z_AXIS] + 10);
3940+
current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (delta_height + 10);
39343941
feedrate_mm_s = homing_feedrate(X_AXIS);
39353942
buffer_line_to_current_position();
39363943
stepper.synchronize();
39373944

39383945
// If an endstop was not hit, then damage can occur if homing is continued.
3939-
// This can occur if the delta height (DELTA_HEIGHT + home_offset[Z_AXIS]) is
3940-
// not set correctly.
3946+
// This can occur if the delta height not set correctly.
39413947
if (!(Endstops::endstop_hit_bits & (_BV(X_MAX) | _BV(Y_MAX) | _BV(Z_MAX)))) {
39423948
LCD_MESSAGEPGM(MSG_ERR_HOMING_FAILED);
39433949
SERIAL_ERROR_START();
@@ -5475,7 +5481,7 @@ void home_all_axes() { gcode_G28(true); }
54755481
}
54765482

54775483
static void print_G33_settings(const bool end_stops, const bool tower_angles) {
5478-
SERIAL_PROTOCOLPAIR(".Height:", DELTA_HEIGHT + home_offset[Z_AXIS]);
5484+
SERIAL_PROTOCOLPAIR(".Height:", delta_height);
54795485
if (end_stops) {
54805486
print_signed_float(PSTR("Ex"), delta_endstop_adj[A_AXIS]);
54815487
print_signed_float(PSTR("Ey"), delta_endstop_adj[B_AXIS]);
@@ -5723,7 +5729,7 @@ void home_all_axes() { gcode_G28(true); }
57235729
delta_endstop_adj[(axis + 1) % 3] -= 1.0 / 4.5;
57245730
delta_endstop_adj[(axis + 2) % 3] += 1.0 / 4.5;
57255731
z_temp = MAX3(delta_endstop_adj[A_AXIS], delta_endstop_adj[B_AXIS], delta_endstop_adj[C_AXIS]);
5726-
home_offset[Z_AXIS] -= z_temp;
5732+
delta_height -= z_temp;
57275733
LOOP_XYZ(axis) delta_endstop_adj[axis] -= z_temp;
57285734
recalc_delta_settings(delta_radius, delta_diagonal_rod, delta_tower_angle_trim);
57295735

@@ -5743,7 +5749,7 @@ void home_all_axes() { gcode_G28(true); }
57435749
delta_endstop_adj[(axis+1) % 3] += 1.0/4.5;
57445750
delta_endstop_adj[(axis+2) % 3] -= 1.0/4.5;
57455751
z_temp = MAX3(delta_endstop_adj[A_AXIS], delta_endstop_adj[B_AXIS], delta_endstop_adj[C_AXIS]);
5746-
home_offset[Z_AXIS] -= z_temp;
5752+
delta_height -= z_temp;
57475753
LOOP_XYZ(axis) delta_endstop_adj[axis] -= z_temp;
57485754
recalc_delta_settings(delta_radius, delta_diagonal_rod, delta_tower_angle_trim);
57495755
switch (axis) {
@@ -5852,7 +5858,7 @@ void home_all_axes() { gcode_G28(true); }
58525858
delta_endstop_adj[C_AXIS]
58535859
},
58545860
dr_old = delta_radius,
5855-
zh_old = home_offset[Z_AXIS],
5861+
zh_old = delta_height,
58565862
ta_old[ABC] = {
58575863
delta_tower_angle_trim[A_AXIS],
58585864
delta_tower_angle_trim[B_AXIS],
@@ -5931,7 +5937,7 @@ void home_all_axes() { gcode_G28(true); }
59315937
if (zero_std_dev < zero_std_dev_min) {
59325938
COPY(e_old, delta_endstop_adj);
59335939
dr_old = delta_radius;
5934-
zh_old = home_offset[Z_AXIS];
5940+
zh_old = delta_height;
59355941
COPY(ta_old, delta_tower_angle_trim);
59365942
}
59375943

@@ -6015,7 +6021,7 @@ void home_all_axes() { gcode_G28(true); }
60156021
else if (zero_std_dev >= test_precision) { // step one back
60166022
COPY(delta_endstop_adj, e_old);
60176023
delta_radius = dr_old;
6018-
home_offset[Z_AXIS] = zh_old;
6024+
delta_height = zh_old;
60196025
COPY(delta_tower_angle_trim, ta_old);
60206026
}
60216027

@@ -6029,7 +6035,7 @@ void home_all_axes() { gcode_G28(true); }
60296035

60306036
// adjust delta_height and endstops by the max amount
60316037
const float z_temp = MAX3(delta_endstop_adj[A_AXIS], delta_endstop_adj[B_AXIS], delta_endstop_adj[C_AXIS]);
6032-
home_offset[Z_AXIS] -= z_temp;
6038+
delta_height -= z_temp;
60336039
LOOP_XYZ(axis) delta_endstop_adj[axis] -= z_temp;
60346040
}
60356041
recalc_delta_settings(delta_radius, delta_diagonal_rod, delta_tower_angle_trim);
@@ -8981,7 +8987,7 @@ inline void gcode_M205() {
89818987
*/
89828988
inline void gcode_M665() {
89838989
if (parser.seen('H')) {
8984-
home_offset[Z_AXIS] = parser.value_linear_units() - DELTA_HEIGHT;
8990+
delta_height = parser.value_linear_units();
89858991
update_software_endstops(Z_AXIS);
89868992
}
89878993
if (parser.seen('L')) delta_diagonal_rod = parser.value_linear_units();
@@ -10089,7 +10095,7 @@ inline void gcode_M502() {
1008910095
#endif
1009010096

1009110097
#if ENABLED(DELTA) // correct the delta_height
10092-
home_offset[Z_AXIS] -= diff;
10098+
delta_height -= diff;
1009310099
#endif
1009410100
}
1009510101

Marlin/configuration_store.cpp

Lines changed: 56 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
*/
3838

39-
#define EEPROM_VERSION "V44"
39+
#define EEPROM_VERSION "V45"
4040

4141
// Change EEPROM version if these are changed:
4242
#define EEPROM_OFFSET 100
@@ -91,81 +91,82 @@
9191
* 324 G29 A planner.leveling_active (bool)
9292
* 325 G29 S ubl.storage_slot (int8_t)
9393
*
94-
* DELTA: 40 bytes
95-
* 352 M666 XYZ delta_endstop_adj (float x3)
96-
* 364 M665 R delta_radius (float)
97-
* 368 M665 L delta_diagonal_rod (float)
98-
* 372 M665 S delta_segments_per_second (float)
99-
* 376 M665 B delta_calibration_radius (float)
100-
* 380 M665 X delta_tower_angle_trim[A] (float)
101-
* 384 M665 Y delta_tower_angle_trim[B] (float)
102-
* 388 M665 Z delta_tower_angle_trim[C] (float)
94+
* DELTA: 44 bytes
95+
* 352 M666 H delta_height (float)
96+
* 364 M666 XYZ delta_endstop_adj (float x3)
97+
* 368 M665 R delta_radius (float)
98+
* 372 M665 L delta_diagonal_rod (float)
99+
* 376 M665 S delta_segments_per_second (float)
100+
* 380 M665 B delta_calibration_radius (float)
101+
* 384 M665 X delta_tower_angle_trim[A] (float)
102+
* 388 M665 Y delta_tower_angle_trim[B] (float)
103+
* 392 M665 Z delta_tower_angle_trim[C] (float)
103104
*
104105
* [XYZ]_DUAL_ENDSTOPS: 12 bytes
105106
* 352 M666 X x_endstop_adj (float)
106107
* 356 M666 Y y_endstop_adj (float)
107108
* 360 M666 Z z_endstop_adj (float)
108109
*
109110
* ULTIPANEL: 6 bytes
110-
* 392 M145 S0 H lcd_preheat_hotend_temp (int x2)
111-
* 396 M145 S0 B lcd_preheat_bed_temp (int x2)
112-
* 400 M145 S0 F lcd_preheat_fan_speed (int x2)
111+
* 396 M145 S0 H lcd_preheat_hotend_temp (int x2)
112+
* 400 M145 S0 B lcd_preheat_bed_temp (int x2)
113+
* 404 M145 S0 F lcd_preheat_fan_speed (int x2)
113114
*
114115
* PIDTEMP: 82 bytes
115-
* 404 M301 E0 PIDC Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
116-
* 420 M301 E1 PIDC Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
117-
* 436 M301 E2 PIDC Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
118-
* 452 M301 E3 PIDC Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
119-
* 468 M301 E4 PIDC Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
120-
* 484 M301 L lpq_len (int)
116+
* 408 M301 E0 PIDC Kp[0], Ki[0], Kd[0], Kc[0] (float x4)
117+
* 428 M301 E1 PIDC Kp[1], Ki[1], Kd[1], Kc[1] (float x4)
118+
* 440 M301 E2 PIDC Kp[2], Ki[2], Kd[2], Kc[2] (float x4)
119+
* 456 M301 E3 PIDC Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
120+
* 472 M301 E4 PIDC Kp[3], Ki[3], Kd[3], Kc[3] (float x4)
121+
* 488 M301 L lpq_len (int)
121122
*
122123
* PIDTEMPBED: 12 bytes
123-
* 486 M304 PID thermalManager.bedKp, .bedKi, .bedKd (float x3)
124+
* 490 M304 PID thermalManager.bedKp, .bedKi, .bedKd (float x3)
124125
*
125126
* DOGLCD: 2 bytes
126-
* 498 M250 C lcd_contrast (uint16_t)
127+
* 502 M250 C lcd_contrast (uint16_t)
127128
*
128129
* FWRETRACT: 33 bytes
129-
* 500 M209 S autoretract_enabled (bool)
130-
* 501 M207 S retract_length (float)
131-
* 505 M207 F retract_feedrate_mm_s (float)
132-
* 509 M207 Z retract_zlift (float)
133-
* 513 M208 S retract_recover_length (float)
134-
* 517 M208 F retract_recover_feedrate_mm_s (float)
135-
* 521 M207 W swap_retract_length (float)
136-
* 525 M208 W swap_retract_recover_length (float)
137-
* 529 M208 R swap_retract_recover_feedrate_mm_s (float)
130+
* 504 M209 S autoretract_enabled (bool)
131+
* 505 M207 S retract_length (float)
132+
* 509 M207 F retract_feedrate_mm_s (float)
133+
* 513 M207 Z retract_zlift (float)
134+
* 517 M208 S retract_recover_length (float)
135+
* 521 M208 F retract_recover_feedrate_mm_s (float)
136+
* 525 M207 W swap_retract_length (float)
137+
* 529 M208 W swap_retract_recover_length (float)
138+
* 533 M208 R swap_retract_recover_feedrate_mm_s (float)
138139
*
139140
* Volumetric Extrusion: 21 bytes
140-
* 533 M200 D volumetric_enabled (bool)
141-
* 534 M200 T D filament_size (float x5) (T0..3)
141+
* 537 M200 D volumetric_enabled (bool)
142+
* 538 M200 T D filament_size (float x5) (T0..3)
142143
*
143144
* HAVE_TMC2130: 22 bytes
144-
* 554 M906 X Stepper X current (uint16_t)
145-
* 556 M906 Y Stepper Y current (uint16_t)
146-
* 558 M906 Z Stepper Z current (uint16_t)
147-
* 560 M906 X2 Stepper X2 current (uint16_t)
148-
* 562 M906 Y2 Stepper Y2 current (uint16_t)
149-
* 564 M906 Z2 Stepper Z2 current (uint16_t)
150-
* 566 M906 E0 Stepper E0 current (uint16_t)
151-
* 568 M906 E1 Stepper E1 current (uint16_t)
152-
* 570 M906 E2 Stepper E2 current (uint16_t)
153-
* 572 M906 E3 Stepper E3 current (uint16_t)
154-
* 574 M906 E4 Stepper E4 current (uint16_t)
145+
* 558 M906 X Stepper X current (uint16_t)
146+
* 560 M906 Y Stepper Y current (uint16_t)
147+
* 562 M906 Z Stepper Z current (uint16_t)
148+
* 564 M906 X2 Stepper X2 current (uint16_t)
149+
* 566 M906 Y2 Stepper Y2 current (uint16_t)
150+
* 568 M906 Z2 Stepper Z2 current (uint16_t)
151+
* 570 M906 E0 Stepper E0 current (uint16_t)
152+
* 572 M906 E1 Stepper E1 current (uint16_t)
153+
* 574 M906 E2 Stepper E2 current (uint16_t)
154+
* 576 M906 E3 Stepper E3 current (uint16_t)
155+
* 578 M906 E4 Stepper E4 current (uint16_t)
155156
*
156157
* LIN_ADVANCE: 8 bytes
157-
* 576 M900 K extruder_advance_k (float)
158-
* 580 M900 WHD advance_ed_ratio (float)
158+
* 580 M900 K extruder_advance_k (float)
159+
* 584 M900 WHD advance_ed_ratio (float)
159160
*
160161
* HAS_MOTOR_CURRENT_PWM:
161-
* 584 M907 X Stepper XY current (uint32_t)
162-
* 588 M907 Z Stepper Z current (uint32_t)
163-
* 592 M907 E Stepper E current (uint32_t)
162+
* 588 M907 X Stepper XY current (uint32_t)
163+
* 592 M907 Z Stepper Z current (uint32_t)
164+
* 596 M907 E Stepper E current (uint32_t)
164165
*
165166
* CNC_COORDINATE_SYSTEMS 108 bytes
166-
* 596 G54-G59.3 coordinate_system (float x 27)
167+
* 600 G54-G59.3 coordinate_system (float x 27)
167168
*
168-
* 704 Minimum end-point
169+
* 708 Minimum end-point
169170
* 2025 (704 + 36 + 9 + 288 + 988) Maximum end-point
170171
*
171172
* ========================================================================
@@ -354,15 +355,7 @@ void MarlinSettings::postprocess() {
354355
#if !HAS_HOME_OFFSET
355356
const float home_offset[XYZ] = { 0 };
356357
#endif
357-
#if ENABLED(DELTA)
358-
dummy = 0.0;
359-
EEPROM_WRITE(dummy);
360-
EEPROM_WRITE(dummy);
361-
dummy = DELTA_HEIGHT + home_offset[Z_AXIS];
362-
EEPROM_WRITE(dummy);
363-
#else
364-
EEPROM_WRITE(home_offset);
365-
#endif
358+
EEPROM_WRITE(home_offset);
366359

367360
#if HOTENDS > 1
368361
// Skip hotend 0 which must be 0
@@ -465,6 +458,7 @@ void MarlinSettings::postprocess() {
465458

466459
// 10 floats for DELTA / [XYZ]_DUAL_ENDSTOPS
467460
#if ENABLED(DELTA)
461+
EEPROM_WRITE(delta_height); // 1 float
468462
EEPROM_WRITE(delta_endstop_adj); // 3 floats
469463
EEPROM_WRITE(delta_radius); // 1 float
470464
EEPROM_WRITE(delta_diagonal_rod); // 1 float
@@ -786,12 +780,6 @@ void MarlinSettings::postprocess() {
786780
#endif
787781
EEPROM_READ(home_offset);
788782

789-
#if ENABLED(DELTA)
790-
home_offset[X_AXIS] = 0.0;
791-
home_offset[Y_AXIS] = 0.0;
792-
home_offset[Z_AXIS] -= DELTA_HEIGHT;
793-
#endif
794-
795783
//
796784
// Hotend Offsets, if any
797785
//
@@ -897,6 +885,7 @@ void MarlinSettings::postprocess() {
897885
//
898886

899887
#if ENABLED(DELTA)
888+
EEPROM_READ(delta_height); // 1 float
900889
EEPROM_READ(delta_endstop_adj); // 3 floats
901890
EEPROM_READ(delta_radius); // 1 float
902891
EEPROM_READ(delta_diagonal_rod); // 1 float
@@ -1347,13 +1336,13 @@ void MarlinSettings::reset() {
13471336
#if ENABLED(DELTA)
13481337
const float adj[ABC] = DELTA_ENDSTOP_ADJ,
13491338
dta[ABC] = DELTA_TOWER_ANGLE_TRIM;
1339+
delta_height = DELTA_HEIGHT;
13501340
COPY(delta_endstop_adj, adj);
13511341
delta_radius = DELTA_RADIUS;
13521342
delta_diagonal_rod = DELTA_DIAGONAL_ROD;
13531343
delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
13541344
delta_calibration_radius = DELTA_CALIBRATION_RADIUS;
13551345
COPY(delta_tower_angle_trim, dta);
1356-
home_offset[Z_AXIS] = 0;
13571346

13581347
#elif ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
13591348

@@ -1790,7 +1779,7 @@ void MarlinSettings::reset() {
17901779
CONFIG_ECHO_START;
17911780
SERIAL_ECHOPAIR(" M665 L", LINEAR_UNIT(delta_diagonal_rod));
17921781
SERIAL_ECHOPAIR(" R", LINEAR_UNIT(delta_radius));
1793-
SERIAL_ECHOPAIR(" H", LINEAR_UNIT(DELTA_HEIGHT + home_offset[Z_AXIS]));
1782+
SERIAL_ECHOPAIR(" H", LINEAR_UNIT(delta_height));
17941783
SERIAL_ECHOPAIR(" S", delta_segments_per_second);
17951784
SERIAL_ECHOPAIR(" B", LINEAR_UNIT(delta_calibration_radius));
17961785
SERIAL_ECHOPAIR(" X", LINEAR_UNIT(delta_tower_angle_trim[A_AXIS]));

Marlin/ultralcd.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,19 +2742,15 @@ void kill_screen(const char* lcd_msg) {
27422742
void _goto_tower_z() { _man_probe_pt(cos(RADIANS( 90)) * delta_calibration_radius, sin(RADIANS( 90)) * delta_calibration_radius); }
27432743
void _goto_center() { _man_probe_pt(0,0); }
27442744

2745-
static float _delta_height = DELTA_HEIGHT;
27462745
void _lcd_set_delta_height() {
2747-
home_offset[Z_AXIS] = _delta_height - DELTA_HEIGHT;
27482746
update_software_endstops(Z_AXIS);
27492747
}
27502748

27512749
void lcd_delta_settings() {
27522750
START_MENU();
27532751
MENU_BACK(MSG_DELTA_CALIBRATE);
2754-
float Tz = 0.00;
27552752
MENU_ITEM_EDIT(float52, MSG_DELTA_DIAG_ROG, &delta_diagonal_rod, DELTA_DIAGONAL_ROD - 5.0, DELTA_DIAGONAL_ROD + 5.0);
2756-
_delta_height = DELTA_HEIGHT + home_offset[Z_AXIS];
2757-
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float52, MSG_DELTA_HEIGHT, &_delta_height, _delta_height - 10.0, _delta_height + 10.0, _lcd_set_delta_height);
2753+
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float52, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10.0, delta_height + 10.0, _lcd_set_delta_height);
27582754
MENU_ITEM_EDIT(float43, "Ex", &delta_endstop_adj[A_AXIS], -5.0, 5.0);
27592755
MENU_ITEM_EDIT(float43, "Ey", &delta_endstop_adj[B_AXIS], -5.0, 5.0);
27602756
MENU_ITEM_EDIT(float43, "Ez", &delta_endstop_adj[C_AXIS], -5.0, 5.0);

0 commit comments

Comments
 (0)