Skip to content

Commit 589d611

Browse files
committed
merge followup
1 parent bbe502b commit 589d611

File tree

3 files changed

+74
-75
lines changed

3 files changed

+74
-75
lines changed

Marlin/Configuration.h

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,8 +1543,6 @@
15431543
// with NOZZLE_AS_PROBE this can be negative for a wider probing area.
15441544
#define PROBING_MARGIN 10
15451545

1546-
1547-
15481546
// X and Y axis travel speed (mm/min) between probes
15491547
#define XY_PROBE_FEEDRATE (133*60)
15501548

@@ -2055,38 +2053,38 @@
20552053

20562054
//#define UBL_MESH_WIZARD // Run several commands in a row to get a complete mesh
20572055

2058-
//#define AVOID_BED_CLIPS
2059-
2060-
#if ENABLED(AVOID_BED_CLIPS)
2061-
2062-
#define BED_CLIP_XSIZE 23. // Width, should be padded a few mm above physical width
2063-
#define BED_CLIP_YSIZE 14. // Height, also should be padded
2064-
2065-
#define BED_CLIP1_XMIN (X_BED_SIZE/4.0 - BED_CLIP_XSIZE/2.0)
2066-
#define BED_CLIP1_XMAX (X_BED_SIZE/4.0 + BED_CLIP_XSIZE/2.0)
2067-
#define BED_CLIP1_YMIN (0.0)
2068-
#define BED_CLIP1_YMAX (BED_CLIP_YSIZE)
2069-
2070-
#define BED_CLIP2_XMIN (3*X_BED_SIZE/4.0 - BED_CLIP_XSIZE/2.0)
2071-
#define BED_CLIP2_XMAX (3*X_BED_SIZE/4.0 + BED_CLIP_XSIZE/2.0)
2072-
#define BED_CLIP2_YMIN (0.0)
2073-
#define BED_CLIP2_YMAX (BED_CLIP_YSIZE)
2074-
2075-
#define BED_CLIP3_XMIN (X_BED_SIZE/4.0 - BED_CLIP_XSIZE/2.0)
2076-
#define BED_CLIP3_XMAX (X_BED_SIZE/4.0 + BED_CLIP_XSIZE/2.0)
2077-
#define BED_CLIP3_YMIN (Y_BED_SIZE-BED_CLIP_YSIZE)
2078-
#define BED_CLIP3_YMAX (Y_BED_SIZE)
2079-
2080-
#define BED_CLIP4_XMIN (3*X_BED_SIZE/4.0 - BED_CLIP_XSIZE/2.0)
2081-
#define BED_CLIP4_XMAX (3*X_BED_SIZE/4.0 + BED_CLIP_XSIZE/2.0)
2082-
#define BED_CLIP4_YMIN (Y_BED_SIZE-BED_CLIP_YSIZE)
2083-
#define BED_CLIP4_YMAX (Y_BED_SIZE)
2084-
2085-
// In this case, the probed grid can (and must, or else the function will abort) be set inward,
2086-
// as it's only used to compute a linear transformation for the mesh itself.
2087-
#define MARGIN_FOR_G29J_MESH_TILT (BED_CLIP_YSIZE+1)
2088-
2089-
#endif
2056+
/**
2057+
* Probing not allowed within the position of an obstacle.
2058+
*/
2059+
//#define AVOID_OBSTACLES
2060+
#if ENABLED(AVOID_OBSTACLES)
2061+
#define OBSTACLE_XSIZE 23.0f // Width, should be padded a few mm above physical width
2062+
#define OBSTACLE_YSIZE 14.0f // Height, also should be padded
2063+
2064+
#define OBSTACLE1_XMIN ((X_BED_SIZE) / 4.0f - (OBSTACLE_XSIZE) / 2.0f)
2065+
#define OBSTACLE1_XMAX ((X_BED_SIZE) / 4.0f + (OBSTACLE_XSIZE) / 2.0f)
2066+
#define OBSTACLE1_YMIN 0.0f
2067+
#define OBSTACLE1_YMAX OBSTACLE_YSIZE
2068+
2069+
#define OBSTACLE2_XMIN ((X_BED_SIZE) * 3.0f / 4.0f - (OBSTACLE_XSIZE) / 2.0f)
2070+
#define OBSTACLE2_XMAX ((X_BED_SIZE) * 3.0f / 4.0f + (OBSTACLE_XSIZE) / 2.0f)
2071+
#define OBSTACLE2_YMIN 0.0f
2072+
#define OBSTACLE2_YMAX OBSTACLE_YSIZE
2073+
2074+
#define OBSTACLE3_XMIN ((X_BED_SIZE) / 4.0f - (OBSTACLE_XSIZE) / 2.0f)
2075+
#define OBSTACLE3_XMAX ((X_BED_SIZE) / 4.0f + (OBSTACLE_XSIZE) / 2.0f)
2076+
#define OBSTACLE3_YMIN ((Y_BED_SIZE) - (OBSTACLE_YSIZE))
2077+
#define OBSTACLE3_YMAX Y_BED_SIZE
2078+
2079+
#define OBSTACLE4_XMIN ((X_BED_SIZE) * 3.0f / 4.0f - (OBSTACLE_XSIZE) / 2.0f)
2080+
#define OBSTACLE4_XMAX ((X_BED_SIZE) * 3.0f / 4.0f + (OBSTACLE_XSIZE) / 2.0f)
2081+
#define OBSTACLE4_YMIN ((Y_BED_SIZE) - (OBSTACLE_YSIZE))
2082+
#define OBSTACLE4_YMAX Y_BED_SIZE
2083+
2084+
// In this case, the probed grid can (and must, or else the function will abort) be set inward,
2085+
// as it's only used to compute a linear transformation for the mesh itself.
2086+
#define MARGIN_FOR_G29J_MESH_TILT ((OBSTACLE_YSIZE) + 1)
2087+
#endif // AVOID_OBSTACLES
20902088

20912089
#elif ENABLED(MESH_BED_LEVELING)
20922090

Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,28 +1479,25 @@ void unified_bed_leveling::smart_fill_mesh() {
14791479

14801480
void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_3_pt_leveling) {
14811481

1482-
#if ENABLED(MARGIN_FOR_G29J_MESH_TILT)
1483-
const float x_min = _MAX(X_MIN_POS,probe.min_x()) + MARGIN_FOR_G29J_MESH_TILT;
1484-
const float x_max = _MIN(X_MAX_POS,probe.max_x()) - MARGIN_FOR_G29J_MESH_TILT;
1485-
const float y_min = _MAX(Y_MIN_POS,probe.min_y()) + MARGIN_FOR_G29J_MESH_TILT;
1486-
const float y_max = _MIN(Y_MAX_POS,probe.max_y()) - MARGIN_FOR_G29J_MESH_TILT;
1482+
#ifdef MARGIN_FOR_G29J_MESH_TILT
1483+
const float x_min = _MAX(X_MIN_POS, probe.min_x()) + (MARGIN_FOR_G29J_MESH_TILT),
1484+
x_max = _MIN(X_MAX_POS, probe.max_x()) - (MARGIN_FOR_G29J_MESH_TILT),
1485+
y_min = _MAX(Y_MIN_POS, probe.min_y()) + (MARGIN_FOR_G29J_MESH_TILT),
1486+
y_max = _MIN(Y_MAX_POS, probe.max_y()) - (MARGIN_FOR_G29J_MESH_TILT);
14871487
#else
1488-
const float x_min = probe.min_x();
1489-
const float x_max = probe.max_x();
1490-
const float y_min = probe.min_y();
1491-
const float y_max = probe.max_y();
1488+
const float x_min = probe.min_x(), x_max = probe.max_x(),
1489+
y_min = probe.min_y(), y_max = probe.max_y();
14921490
#endif
14931491
const float dx = (x_max - x_min) / (param.J_grid_size - 1),
14941492
dy = (y_max - y_min) / (param.J_grid_size - 1);
14951493

1496-
14971494
xy_float_t points[3];
14981495
probe.get_three_points(points);
14991496

15001497
float measured_z;
15011498
bool abort_flag = false;
15021499

1503-
#ifdef VALIDATE_MESH_TILT
1500+
#if ENABLED(VALIDATE_MESH_TILT)
15041501
float z1, z2, z3; // Needed for algorithm validation below
15051502
#endif
15061503

@@ -1516,7 +1513,7 @@ void unified_bed_leveling::smart_fill_mesh() {
15161513
abort_flag = true;
15171514
else {
15181515
measured_z -= get_z_correction(points[0]);
1519-
#ifdef VALIDATE_MESH_TILT
1516+
#if ENABLED(VALIDATE_MESH_TILT)
15201517
z1 = measured_z;
15211518
#endif
15221519
if (param.V_verbosity > 3) {
@@ -1531,7 +1528,7 @@ void unified_bed_leveling::smart_fill_mesh() {
15311528
TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
15321529

15331530
measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, param.V_verbosity);
1534-
#ifdef VALIDATE_MESH_TILT
1531+
#if ENABLED(VALIDATE_MESH_TILT)
15351532
z2 = measured_z;
15361533
#endif
15371534
if (isnan(measured_z))
@@ -1551,7 +1548,7 @@ void unified_bed_leveling::smart_fill_mesh() {
15511548
TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
15521549

15531550
measured_z = probe.probe_at_point(points[2], PROBE_PT_LAST_STOW, param.V_verbosity);
1554-
#ifdef VALIDATE_MESH_TILT
1551+
#if ENABLED(VALIDATE_MESH_TILT)
15551552
z3 = measured_z;
15561553
#endif
15571554
if (isnan(measured_z))
@@ -1700,7 +1697,7 @@ void unified_bed_leveling::smart_fill_mesh() {
17001697
* The Z error between the probed point locations and the get_z_correction()
17011698
* numbers for those locations should be 0.
17021699
*/
1703-
#ifdef VALIDATE_MESH_TILT
1700+
#if ENABLED(VALIDATE_MESH_TILT)
17041701
auto d_from = []{ DEBUG_ECHOPGM("D from "); };
17051702
auto normed = [&](const xy_pos_t &pos, const_float_t zadd) {
17061703
return normal.x * pos.x + normal.y * pos.y + zadd;

Marlin/src/module/probe.h

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ class Probe {
7676
public:
7777

7878
#if ENABLED(SENSORLESS_PROBING)
79-
typedef struct {
80-
bool x:1, y:1, z:1;
81-
} sense_bool_t;
79+
typedef struct { bool x:1, y:1, z:1; } sense_bool_t;
8280
static sense_bool_t test_sensitivity;
8381
#endif
8482

@@ -94,18 +92,24 @@ class Probe {
9492

9593
static bool set_deployed(const bool deploy);
9694

97-
#if ENABLED(AVOID_BED_CLIPS)
98-
static bool bed_clip_check(const_float_t rx, const_float_t ry) {
99-
return (!((BED_CLIP1_XMIN <= rx) && (rx < BED_CLIP1_XMAX)) || !((BED_CLIP1_YMIN <= ry) && (ry <= BED_CLIP1_YMAX)))
100-
&& (!((BED_CLIP2_XMIN <= rx) && (rx < BED_CLIP2_XMAX)) || !((BED_CLIP2_YMIN <= ry) && (ry <= BED_CLIP2_YMAX)))
101-
&& (!((BED_CLIP3_XMIN <= rx) && (rx < BED_CLIP3_XMAX)) || !((BED_CLIP3_YMIN <= ry) && (ry <= BED_CLIP3_YMAX)))
102-
&& (!((BED_CLIP4_XMIN <= rx) && (rx < BED_CLIP4_XMAX)) || !((BED_CLIP4_YMIN <= ry) && (ry <= BED_CLIP4_YMAX)));
95+
static bool obstacle_check(const_float_t rx, const_float_t ry) {
96+
return (true && !(false
97+
#if ENABLED(AVOID_OBSTACLES)
98+
#if defined(OBSTACLE1_XMIN) && defined(OBSTACLE1_XMAX) && defined(OBSTACLE1_YMIN) && defined(OBSTACLE1_YMAX)
99+
|| (WITHIN(rx, OBSTACLE1_XMIN, OBSTACLE1_XMAX) && WITHIN(ry, OBSTACLE1_YMIN, OBSTACLE1_YMAX))
100+
#endif
101+
#if defined(OBSTACLE2_XMIN) && defined(OBSTACLE2_XMAX) && defined(OBSTACLE2_YMIN) && defined(OBSTACLE2_YMAX)
102+
|| (WITHIN(rx, OBSTACLE2_XMIN, OBSTACLE2_XMAX) && WITHIN(ry, OBSTACLE2_YMIN, OBSTACLE2_YMAX))
103+
#endif
104+
#if defined(OBSTACLE3_XMIN) && defined(OBSTACLE3_XMAX) && defined(OBSTACLE3_YMIN) && defined(OBSTACLE3_YMAX)
105+
|| (WITHIN(rx, OBSTACLE3_XMIN, OBSTACLE3_XMAX) && WITHIN(ry, OBSTACLE3_YMIN, OBSTACLE3_YMAX))
106+
#endif
107+
#if defined(OBSTACLE4_XMIN) && defined(OBSTACLE4_XMAX) && defined(OBSTACLE4_YMIN) && defined(OBSTACLE4_YMAX)
108+
|| (WITHIN(rx, OBSTACLE4_XMIN, OBSTACLE4_XMAX) && WITHIN(ry, OBSTACLE4_YMIN, OBSTACLE4_YMAX))
109+
#endif
110+
#endif
111+
));
103112
}
104-
#else
105-
static bool bed_clip_check(const_float_t rx, const_float_t ry) {
106-
return true;
107-
}
108-
#endif
109113

110114
#if IS_KINEMATIC
111115

@@ -115,17 +119,17 @@ class Probe {
115119
static bool can_reach(const_float_t rx, const_float_t ry, const bool probe_relative=true) {
116120
if (probe_relative) {
117121
return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y) // The nozzle can go where it needs to go?
118-
&& position_is_reachable(rx, ry, PROBING_MARGIN); // Can the probe also go near there?
122+
&& position_is_reachable(rx, ry, PROBING_MARGIN); // Can the probe also go near there?
119123
}
120124
else {
121125
return position_is_reachable(rx, ry)
122-
&& position_is_reachable(rx + offset_xy.x, ry + offset_xy.y, PROBING_MARGIN);
126+
&& position_is_reachable(rx + offset_xy.x, ry + offset_xy.y, PROBING_MARGIN);
123127
}
124128
}
125129
#else
126130
static bool can_reach(const_float_t rx, const_float_t ry, const bool=true) {
127131
return position_is_reachable(rx, ry)
128-
&& position_is_reachable(rx, ry, PROBING_MARGIN);
132+
&& position_is_reachable(rx, ry, PROBING_MARGIN);
129133
}
130134
#endif
131135

@@ -140,18 +144,18 @@ class Probe {
140144
*/
141145
static bool can_reach(const_float_t rx, const_float_t ry, const bool probe_relative=true) {
142146
if (probe_relative) {
143-
return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y)
144-
&& COORDINATE_OKAY(rx, min_x() - fslop, max_x() + fslop)
145-
&& COORDINATE_OKAY(ry, min_y() - fslop, max_y() + fslop)
146-
&& bed_clip_check(rx,ry)
147-
&& bed_clip_check(rx - offset_xy.x, ry - offset_xy.y);
147+
return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y)
148+
&& COORDINATE_OKAY(rx, min_x() - fslop, max_x() + fslop)
149+
&& COORDINATE_OKAY(ry, min_y() - fslop, max_y() + fslop)
150+
&& obstacle_check(rx, ry)
151+
&& obstacle_check(rx - offset_xy.x, ry - offset_xy.y);
148152
}
149153
else {
150154
return position_is_reachable(rx, ry)
151-
&& COORDINATE_OKAY(rx + offset_xy.x, min_x() - fslop, max_x() + fslop)
152-
&& COORDINATE_OKAY(ry + offset_xy.y, min_y() - fslop, max_y() + fslop)
153-
&& bed_clip_check(rx,ry)
154-
&& bed_clip_check(rx + offset_xy.x, ry + offset_xy.y);
155+
&& COORDINATE_OKAY(rx + offset_xy.x, min_x() - fslop, max_x() + fslop)
156+
&& COORDINATE_OKAY(ry + offset_xy.y, min_y() - fslop, max_y() + fslop)
157+
&& obstacle_check(rx, ry)
158+
&& obstacle_check(rx + offset_xy.x, ry + offset_xy.y);
155159
}
156160
}
157161

0 commit comments

Comments
 (0)