Reduce math library code size by 3.4KB (#21575)
This commit is contained in:
parent
1742fb8655
commit
24a095c5c1
@ -112,6 +112,9 @@
|
|||||||
#define SIGN(a) ({__typeof__(a) _a = (a); (_a>0)-(_a<0);})
|
#define SIGN(a) ({__typeof__(a) _a = (a); (_a>0)-(_a<0);})
|
||||||
#define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))
|
#define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))
|
||||||
|
|
||||||
|
#define MFNAN 999999.0f
|
||||||
|
#define ISNAN(V) ((V) == MFNAN)
|
||||||
|
|
||||||
// Macros to constrain values
|
// Macros to constrain values
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ bed_mesh_t z_values;
|
|||||||
* Extrapolate a single point from its neighbors
|
* Extrapolate a single point from its neighbors
|
||||||
*/
|
*/
|
||||||
static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) {
|
static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) {
|
||||||
if (!isnan(z_values[x][y])) return;
|
if (!ISNAN(z_values[x][y])) return;
|
||||||
if (DEBUGGING(LEVELING)) {
|
if (DEBUGGING(LEVELING)) {
|
||||||
DEBUG_ECHOPGM("Extrapolate [");
|
DEBUG_ECHOPGM("Extrapolate [");
|
||||||
if (x < 10) DEBUG_CHAR(' ');
|
if (x < 10) DEBUG_CHAR(' ');
|
||||||
@ -63,12 +63,12 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t
|
|||||||
c1 = z_values[x1][y1], c2 = z_values[x2][y2];
|
c1 = z_values[x1][y1], c2 = z_values[x2][y2];
|
||||||
|
|
||||||
// Treat far unprobed points as zero, near as equal to far
|
// Treat far unprobed points as zero, near as equal to far
|
||||||
if (isnan(a2)) a2 = 0.0;
|
if (ISNAN(a2)) a2 = 0.0;
|
||||||
if (isnan(a1)) a1 = a2;
|
if (ISNAN(a1)) a1 = a2;
|
||||||
if (isnan(b2)) b2 = 0.0;
|
if (ISNAN(b2)) b2 = 0.0;
|
||||||
if (isnan(b1)) b1 = b2;
|
if (ISNAN(b1)) b1 = b2;
|
||||||
if (isnan(c2)) c2 = 0.0;
|
if (ISNAN(c2)) c2 = 0.0;
|
||||||
if (isnan(c1)) c1 = c2;
|
if (ISNAN(c1)) c1 = c2;
|
||||||
|
|
||||||
const float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2;
|
const float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2;
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ void reset_bed_level() {
|
|||||||
bilinear_start.reset();
|
bilinear_start.reset();
|
||||||
bilinear_grid_spacing.reset();
|
bilinear_grid_spacing.reset();
|
||||||
GRID_LOOP(x, y) {
|
GRID_LOOP(x, y) {
|
||||||
z_values[x][y] = NAN;
|
z_values[x][y] = MFNAN;
|
||||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, 0));
|
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, 0));
|
||||||
}
|
}
|
||||||
#elif ABL_PLANAR
|
#elif ABL_PLANAR
|
||||||
@ -177,7 +177,7 @@ void reset_bed_level() {
|
|||||||
LOOP_L_N(x, sx) {
|
LOOP_L_N(x, sx) {
|
||||||
SERIAL_CHAR(' ');
|
SERIAL_CHAR(' ');
|
||||||
const float offset = fn(x, y);
|
const float offset = fn(x, y);
|
||||||
if (!isnan(offset)) {
|
if (!ISNAN(offset)) {
|
||||||
if (offset >= 0) SERIAL_CHAR('+');
|
if (offset >= 0) SERIAL_CHAR('+');
|
||||||
SERIAL_ECHO_F(offset, int(precision));
|
SERIAL_ECHO_F(offset, int(precision));
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,7 @@ public:
|
|||||||
static inline xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); }
|
static inline xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); }
|
||||||
|
|
||||||
static float calc_z0(const_float_t a0, const_float_t a1, const_float_t z1, const_float_t a2, const_float_t z2) {
|
static float calc_z0(const_float_t a0, const_float_t a1, const_float_t z1, const_float_t a2, const_float_t z2) {
|
||||||
|
if (ISNAN(a0) || ISNAN(a1) || ISNAN(z1) || ISNAN(a2) || ISNAN(z2)) return MFNAN;
|
||||||
const float delta_z = (z2 - z1) / (a2 - a1),
|
const float delta_z = (z2 - z1) / (a2 - a1),
|
||||||
delta_a = a0 - a1;
|
delta_a = a0 - a1;
|
||||||
return z1 + delta_a * delta_z;
|
return z1 + delta_a * delta_z;
|
||||||
@ -114,9 +115,11 @@ public:
|
|||||||
const float x1 = index_to_xpos[ind.x], x2 = index_to_xpos[ind.x+1],
|
const float x1 = index_to_xpos[ind.x], x2 = index_to_xpos[ind.x+1],
|
||||||
y1 = index_to_xpos[ind.y], y2 = index_to_xpos[ind.y+1],
|
y1 = index_to_xpos[ind.y], y2 = index_to_xpos[ind.y+1],
|
||||||
z1 = calc_z0(pos.x, x1, z_values[ind.x][ind.y ], x2, z_values[ind.x+1][ind.y ]),
|
z1 = calc_z0(pos.x, x1, z_values[ind.x][ind.y ], x2, z_values[ind.x+1][ind.y ]),
|
||||||
z2 = calc_z0(pos.x, x1, z_values[ind.x][ind.y+1], x2, z_values[ind.x+1][ind.y+1]);
|
z2 = calc_z0(pos.x, x1, z_values[ind.x][ind.y+1], x2, z_values[ind.x+1][ind.y+1]),
|
||||||
|
zf = calc_z0(pos.y, y1, z1, y2, z2);
|
||||||
|
|
||||||
return z_offset + calc_z0(pos.y, y1, z1, y2, z2) * factor;
|
|
||||||
|
return ISNAN(zf) ? zf : z_offset + zf * factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)
|
#if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)
|
||||||
|
@ -48,7 +48,7 @@ void unified_bed_leveling::report_current_mesh() {
|
|||||||
if (!leveling_is_valid()) return;
|
if (!leveling_is_valid()) return;
|
||||||
SERIAL_ECHO_MSG(" G29 I999");
|
SERIAL_ECHO_MSG(" G29 I999");
|
||||||
GRID_LOOP(x, y)
|
GRID_LOOP(x, y)
|
||||||
if (!isnan(z_values[x][y])) {
|
if (!ISNAN(z_values[x][y])) {
|
||||||
SERIAL_ECHO_START();
|
SERIAL_ECHO_START();
|
||||||
SERIAL_ECHOPAIR(" M421 I", x, " J", y);
|
SERIAL_ECHOPAIR(" M421 I", x, " J", y);
|
||||||
SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z_values[x][y], 4);
|
SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z_values[x][y], 4);
|
||||||
@ -99,7 +99,7 @@ void unified_bed_leveling::reset() {
|
|||||||
|
|
||||||
void unified_bed_leveling::invalidate() {
|
void unified_bed_leveling::invalidate() {
|
||||||
set_bed_leveling_enabled(false);
|
set_bed_leveling_enabled(false);
|
||||||
set_all_mesh_points_to_value(NAN);
|
set_all_mesh_points_to_value(MFNAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unified_bed_leveling::set_all_mesh_points_to_value(const_float_t value) {
|
void unified_bed_leveling::set_all_mesh_points_to_value(const_float_t value) {
|
||||||
@ -116,7 +116,7 @@ void unified_bed_leveling::set_all_mesh_points_to_value(const_float_t value) {
|
|||||||
|
|
||||||
void unified_bed_leveling::set_store_from_mesh(const bed_mesh_t &in_values, mesh_store_t &stored_values) {
|
void unified_bed_leveling::set_store_from_mesh(const bed_mesh_t &in_values, mesh_store_t &stored_values) {
|
||||||
auto z_to_store = [](const_float_t z) {
|
auto z_to_store = [](const_float_t z) {
|
||||||
if (isnan(z)) return Z_STEPS_NAN;
|
if (ISNAN(z)) return Z_STEPS_NAN;
|
||||||
const int32_t z_scaled = TRUNC(z * mesh_store_scaling);
|
const int32_t z_scaled = TRUNC(z * mesh_store_scaling);
|
||||||
if (z_scaled == Z_STEPS_NAN || !WITHIN(z_scaled, INT16_MIN, INT16_MAX))
|
if (z_scaled == Z_STEPS_NAN || !WITHIN(z_scaled, INT16_MIN, INT16_MAX))
|
||||||
return Z_STEPS_NAN; // If Z is out of range, return our custom 'NaN'
|
return Z_STEPS_NAN; // If Z is out of range, return our custom 'NaN'
|
||||||
@ -127,7 +127,7 @@ void unified_bed_leveling::set_all_mesh_points_to_value(const_float_t value) {
|
|||||||
|
|
||||||
void unified_bed_leveling::set_mesh_from_store(const mesh_store_t &stored_values, bed_mesh_t &out_values) {
|
void unified_bed_leveling::set_mesh_from_store(const mesh_store_t &stored_values, bed_mesh_t &out_values) {
|
||||||
auto store_to_z = [](const int16_t z_scaled) {
|
auto store_to_z = [](const int16_t z_scaled) {
|
||||||
return z_scaled == Z_STEPS_NAN ? NAN : z_scaled / mesh_store_scaling;
|
return z_scaled == Z_STEPS_NAN ? MFNAN : z_scaled / mesh_store_scaling;
|
||||||
};
|
};
|
||||||
GRID_LOOP(x, y) out_values[x][y] = store_to_z(stored_values[x][y]);
|
GRID_LOOP(x, y) out_values[x][y] = store_to_z(stored_values[x][y]);
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ void unified_bed_leveling::display_map(const int map_type) {
|
|||||||
if (lcd) {
|
if (lcd) {
|
||||||
// TODO: Display on Graphical LCD
|
// TODO: Display on Graphical LCD
|
||||||
}
|
}
|
||||||
else if (isnan(f))
|
else if (ISNAN(f))
|
||||||
SERIAL_ECHOPGM_P(human ? PSTR(" . ") : PSTR("NAN"));
|
SERIAL_ECHOPGM_P(human ? PSTR(" . ") : PSTR("NAN"));
|
||||||
else if (human || csv) {
|
else if (human || csv) {
|
||||||
if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0)
|
if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0)
|
||||||
|
@ -196,7 +196,7 @@ public:
|
|||||||
#ifdef UBL_Z_RAISE_WHEN_OFF_MESH
|
#ifdef UBL_Z_RAISE_WHEN_OFF_MESH
|
||||||
#define _UBL_OUTER_Z_RAISE UBL_Z_RAISE_WHEN_OFF_MESH
|
#define _UBL_OUTER_Z_RAISE UBL_Z_RAISE_WHEN_OFF_MESH
|
||||||
#else
|
#else
|
||||||
#define _UBL_OUTER_Z_RAISE NAN
|
#define _UBL_OUTER_Z_RAISE MFNAN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,39 +264,25 @@ public:
|
|||||||
return UBL_Z_RAISE_WHEN_OFF_MESH;
|
return UBL_Z_RAISE_WHEN_OFF_MESH;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const float z1 = calc_z0(rx0,
|
const uint8_t mx = _MIN(cx, (GRID_MAX_POINTS_X) - 2) + 1, my = _MIN(cy, (GRID_MAX_POINTS_Y) - 2) + 1;
|
||||||
mesh_index_to_xpos(cx), z_values[cx][cy],
|
const float z1 = calc_z0(rx0, mesh_index_to_xpos(cx), z_values[cx][cy], mesh_index_to_xpos(cx + 1), z_values[mx][cy]);
|
||||||
mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, (GRID_MAX_POINTS_X) - 2) + 1][cy]);
|
const float z2 = calc_z0(rx0, mesh_index_to_xpos(cx), z_values[cx][my], mesh_index_to_xpos(cx + 1), z_values[mx][my]);
|
||||||
|
float z0 = calc_z0(ry0, mesh_index_to_ypos(cy), z1, mesh_index_to_ypos(cy + 1), z2);
|
||||||
|
|
||||||
const float z2 = calc_z0(rx0,
|
if (ISNAN(z0)) { // if part of the Mesh is undefined, it will show up as MFNAN
|
||||||
mesh_index_to_xpos(cx), z_values[cx][_MIN(cy, (GRID_MAX_POINTS_Y) - 2) + 1],
|
|
||||||
mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, (GRID_MAX_POINTS_X) - 2) + 1][_MIN(cy, (GRID_MAX_POINTS_Y) - 2) + 1]);
|
|
||||||
|
|
||||||
float z0 = calc_z0(ry0,
|
|
||||||
mesh_index_to_ypos(cy), z1,
|
|
||||||
mesh_index_to_ypos(cy + 1), z2);
|
|
||||||
|
|
||||||
if (DEBUGGING(MESH_ADJUST)) {
|
|
||||||
DEBUG_ECHOPAIR(" raw get_z_correction(", rx0);
|
|
||||||
DEBUG_CHAR(','); DEBUG_ECHO(ry0);
|
|
||||||
DEBUG_ECHOPAIR_F(") = ", z0, 6);
|
|
||||||
DEBUG_ECHOLNPAIR_F(" >>>---> ", z0, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN
|
|
||||||
z0 = 0.0; // in ubl.z_values[][] and propagate through the
|
z0 = 0.0; // in ubl.z_values[][] and propagate through the
|
||||||
// calculations. If our correction is NAN, we throw it out
|
// calculations. If our correction is NAN, we throw it out
|
||||||
// because part of the Mesh is undefined and we don't have the
|
// because part of the Mesh is undefined and we don't have the
|
||||||
// information we need to complete the height correction.
|
// information we need to complete the height correction.
|
||||||
|
|
||||||
|
if (DEBUGGING(MESH_ADJUST)) DEBUG_ECHOLNPAIR("??? Yikes! NAN in ");
|
||||||
|
}
|
||||||
|
|
||||||
if (DEBUGGING(MESH_ADJUST)) {
|
if (DEBUGGING(MESH_ADJUST)) {
|
||||||
DEBUG_ECHOPAIR("??? Yikes! NAN in get_z_correction(", rx0);
|
DEBUG_ECHOPAIR("get_z_correction(", rx0, ", ", ry0);
|
||||||
DEBUG_CHAR(',');
|
DEBUG_ECHOLNPAIR_F(") => ", z0, 6);
|
||||||
DEBUG_ECHO(ry0);
|
|
||||||
DEBUG_CHAR(')');
|
|
||||||
DEBUG_EOL();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return z0;
|
return z0;
|
||||||
}
|
}
|
||||||
static inline float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); }
|
static inline float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); }
|
||||||
@ -315,7 +301,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline bool mesh_is_valid() {
|
static inline bool mesh_is_valid() {
|
||||||
GRID_LOOP(x, y) if (isnan(z_values[x][y])) return false;
|
GRID_LOOP(x, y) if (ISNAN(z_values[x][y])) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ void unified_bed_leveling::G29() {
|
|||||||
// to invalidate the ENTIRE mesh, which can't be done with
|
// to invalidate the ENTIRE mesh, which can't be done with
|
||||||
// find_closest_mesh_point (which only returns REAL points).
|
// find_closest_mesh_point (which only returns REAL points).
|
||||||
if (closest.pos.x < 0) { invalidate_all = true; break; }
|
if (closest.pos.x < 0) { invalidate_all = true; break; }
|
||||||
z_values[closest.pos.x][closest.pos.y] = NAN;
|
z_values[closest.pos.x][closest.pos.y] = MFNAN;
|
||||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(closest.pos, 0.0f));
|
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(closest.pos, 0.0f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -516,7 +516,7 @@ void unified_bed_leveling::G29() {
|
|||||||
if (cpos.x < 0) {
|
if (cpos.x < 0) {
|
||||||
// No more REAL INVALID mesh points to populate, so we ASSUME
|
// No more REAL INVALID mesh points to populate, so we ASSUME
|
||||||
// user meant to populate ALL INVALID mesh points to value
|
// user meant to populate ALL INVALID mesh points to value
|
||||||
GRID_LOOP(x, y) if (isnan(z_values[x][y])) z_values[x][y] = param.C_constant;
|
GRID_LOOP(x, y) if (ISNAN(z_values[x][y])) z_values[x][y] = param.C_constant;
|
||||||
break; // No more invalid Mesh Points to populate
|
break; // No more invalid Mesh Points to populate
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -675,7 +675,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o
|
|||||||
float sum = 0;
|
float sum = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
GRID_LOOP(x, y)
|
GRID_LOOP(x, y)
|
||||||
if (!isnan(z_values[x][y])) {
|
if (!ISNAN(z_values[x][y])) {
|
||||||
sum += z_values[x][y];
|
sum += z_values[x][y];
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
@ -687,7 +687,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o
|
|||||||
//
|
//
|
||||||
float sum_of_diff_squared = 0;
|
float sum_of_diff_squared = 0;
|
||||||
GRID_LOOP(x, y)
|
GRID_LOOP(x, y)
|
||||||
if (!isnan(z_values[x][y]))
|
if (!ISNAN(z_values[x][y]))
|
||||||
sum_of_diff_squared += sq(z_values[x][y] - mean);
|
sum_of_diff_squared += sq(z_values[x][y] - mean);
|
||||||
|
|
||||||
SERIAL_ECHOLNPAIR("# of samples: ", n);
|
SERIAL_ECHOLNPAIR("# of samples: ", n);
|
||||||
@ -698,7 +698,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o
|
|||||||
|
|
||||||
if (cflag)
|
if (cflag)
|
||||||
GRID_LOOP(x, y)
|
GRID_LOOP(x, y)
|
||||||
if (!isnan(z_values[x][y])) {
|
if (!ISNAN(z_values[x][y])) {
|
||||||
z_values[x][y] -= mean + offset;
|
z_values[x][y] -= mean + offset;
|
||||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
|
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
|
||||||
}
|
}
|
||||||
@ -709,7 +709,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o
|
|||||||
*/
|
*/
|
||||||
void unified_bed_leveling::shift_mesh_height() {
|
void unified_bed_leveling::shift_mesh_height() {
|
||||||
GRID_LOOP(x, y)
|
GRID_LOOP(x, y)
|
||||||
if (!isnan(z_values[x][y])) {
|
if (!ISNAN(z_values[x][y])) {
|
||||||
z_values[x][y] += param.C_constant;
|
z_values[x][y] += param.C_constant;
|
||||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
|
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
|
||||||
}
|
}
|
||||||
@ -1017,7 +1017,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
|
|||||||
ui.refresh();
|
ui.refresh();
|
||||||
|
|
||||||
float new_z = z_values[lpos.x][lpos.y];
|
float new_z = z_values[lpos.x][lpos.y];
|
||||||
if (isnan(new_z)) new_z = 0; // Invalid points begin at 0
|
if (ISNAN(new_z)) new_z = 0; // Invalid points begin at 0
|
||||||
new_z = FLOOR(new_z * 1000) * 0.001f; // Chop off digits after the 1000ths place
|
new_z = FLOOR(new_z * 1000) * 0.001f; // Chop off digits after the 1000ths place
|
||||||
|
|
||||||
ui.ubl_mesh_edit_start(new_z);
|
ui.ubl_mesh_edit_start(new_z);
|
||||||
@ -1227,7 +1227,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
|
|||||||
mesh_index_pair farthest { -1, -1, -99999.99 };
|
mesh_index_pair farthest { -1, -1, -99999.99 };
|
||||||
|
|
||||||
GRID_LOOP(i, j) {
|
GRID_LOOP(i, j) {
|
||||||
if (!isnan(z_values[i][j])) continue; // Skip valid mesh points
|
if (!ISNAN(z_values[i][j])) continue; // Skip valid mesh points
|
||||||
|
|
||||||
// Skip unreachable points
|
// Skip unreachable points
|
||||||
if (!probe.can_reach(mesh_index_to_xpos(i), mesh_index_to_ypos(j)))
|
if (!probe.can_reach(mesh_index_to_xpos(i), mesh_index_to_ypos(j)))
|
||||||
@ -1238,7 +1238,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
|
|||||||
xy_int8_t nearby { -1, -1 };
|
xy_int8_t nearby { -1, -1 };
|
||||||
float d1, d2 = 99999.9f;
|
float d1, d2 = 99999.9f;
|
||||||
GRID_LOOP(k, l) {
|
GRID_LOOP(k, l) {
|
||||||
if (isnan(z_values[k][l])) continue;
|
if (ISNAN(z_values[k][l])) continue;
|
||||||
|
|
||||||
found_a_real = true;
|
found_a_real = true;
|
||||||
|
|
||||||
@ -1282,7 +1282,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
|
|||||||
|
|
||||||
static bool test_func(uint8_t i, uint8_t j, void *data) {
|
static bool test_func(uint8_t i, uint8_t j, void *data) {
|
||||||
find_closest_t *d = (find_closest_t*)data;
|
find_closest_t *d = (find_closest_t*)data;
|
||||||
if ( (d->type == (isnan(ubl.z_values[i][j]) ? INVALID : REAL))
|
if ( (d->type == (ISNAN(ubl.z_values[i][j]) ? INVALID : REAL))
|
||||||
|| (d->type == SET_IN_BITMAP && !d->done_flags->marked(i, j))
|
|| (d->type == SET_IN_BITMAP && !d->done_flags->marked(i, j))
|
||||||
) {
|
) {
|
||||||
// Found a Mesh Point of the specified type!
|
// Found a Mesh Point of the specified type!
|
||||||
@ -1326,7 +1326,7 @@ mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const Mesh
|
|||||||
float best_so_far = 99999.99f;
|
float best_so_far = 99999.99f;
|
||||||
|
|
||||||
GRID_LOOP(i, j) {
|
GRID_LOOP(i, j) {
|
||||||
if ( (type == (isnan(z_values[i][j]) ? INVALID : REAL))
|
if ( (type == (ISNAN(z_values[i][j]) ? INVALID : REAL))
|
||||||
|| (type == SET_IN_BITMAP && !done_flags->marked(i, j))
|
|| (type == SET_IN_BITMAP && !done_flags->marked(i, j))
|
||||||
) {
|
) {
|
||||||
// Found a Mesh Point of the specified type!
|
// Found a Mesh Point of the specified type!
|
||||||
@ -1367,12 +1367,12 @@ mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const Mesh
|
|||||||
|
|
||||||
bool unified_bed_leveling::smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) {
|
bool unified_bed_leveling::smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) {
|
||||||
const float v = z_values[x][y];
|
const float v = z_values[x][y];
|
||||||
if (isnan(v)) { // A NAN...
|
if (ISNAN(v)) { // A NAN...
|
||||||
const int8_t dx = x + xdir, dy = y + ydir;
|
const int8_t dx = x + xdir, dy = y + ydir;
|
||||||
const float v1 = z_values[dx][dy];
|
const float v1 = z_values[dx][dy];
|
||||||
if (!isnan(v1)) { // ...next to a pair of real values?
|
if (!ISNAN(v1)) { // ...next to a pair of real values?
|
||||||
const float v2 = z_values[dx + xdir][dy + ydir];
|
const float v2 = z_values[dx + xdir][dy + ydir];
|
||||||
if (!isnan(v2)) {
|
if (!ISNAN(v2)) {
|
||||||
z_values[x][y] = v1 < v2 ? v1 : v1 + v1 - v2;
|
z_values[x][y] = v1 < v2 ? v1 : v1 + v1 - v2;
|
||||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
|
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
|
||||||
return true;
|
return true;
|
||||||
@ -1441,7 +1441,7 @@ void unified_bed_leveling::smart_fill_mesh() {
|
|||||||
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
|
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
|
||||||
|
|
||||||
measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, param.V_verbosity);
|
measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, param.V_verbosity);
|
||||||
if (isnan(measured_z))
|
if (ISNAN(measured_z))
|
||||||
abort_flag = true;
|
abort_flag = true;
|
||||||
else {
|
else {
|
||||||
measured_z -= get_z_correction(points[0]);
|
measured_z -= get_z_correction(points[0]);
|
||||||
@ -1463,7 +1463,7 @@ void unified_bed_leveling::smart_fill_mesh() {
|
|||||||
#ifdef VALIDATE_MESH_TILT
|
#ifdef VALIDATE_MESH_TILT
|
||||||
z2 = measured_z;
|
z2 = measured_z;
|
||||||
#endif
|
#endif
|
||||||
if (isnan(measured_z))
|
if (ISNAN(measured_z))
|
||||||
abort_flag = true;
|
abort_flag = true;
|
||||||
else {
|
else {
|
||||||
measured_z -= get_z_correction(points[1]);
|
measured_z -= get_z_correction(points[1]);
|
||||||
@ -1483,7 +1483,7 @@ void unified_bed_leveling::smart_fill_mesh() {
|
|||||||
#ifdef VALIDATE_MESH_TILT
|
#ifdef VALIDATE_MESH_TILT
|
||||||
z3 = measured_z;
|
z3 = measured_z;
|
||||||
#endif
|
#endif
|
||||||
if (isnan(measured_z))
|
if (ISNAN(measured_z))
|
||||||
abort_flag = true;
|
abort_flag = true;
|
||||||
else {
|
else {
|
||||||
measured_z -= get_z_correction(points[2]);
|
measured_z -= get_z_correction(points[2]);
|
||||||
@ -1522,7 +1522,7 @@ void unified_bed_leveling::smart_fill_mesh() {
|
|||||||
|
|
||||||
measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling
|
measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling
|
||||||
|
|
||||||
abort_flag = isnan(measured_z);
|
abort_flag = ISNAN(measured_z);
|
||||||
|
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
if (DEBUGGING(LEVELING)) {
|
if (DEBUGGING(LEVELING)) {
|
||||||
@ -1673,14 +1673,14 @@ void unified_bed_leveling::smart_fill_mesh() {
|
|||||||
|
|
||||||
const float weight_scaled = weight_factor * _MAX(MESH_X_DIST, MESH_Y_DIST);
|
const float weight_scaled = weight_factor * _MAX(MESH_X_DIST, MESH_Y_DIST);
|
||||||
|
|
||||||
GRID_LOOP(jx, jy) if (!isnan(z_values[jx][jy])) SBI(bitmap[jx], jy);
|
GRID_LOOP(jx, jy) if (!ISNAN(z_values[jx][jy])) SBI(bitmap[jx], jy);
|
||||||
|
|
||||||
xy_pos_t ppos;
|
xy_pos_t ppos;
|
||||||
LOOP_L_N(ix, GRID_MAX_POINTS_X) {
|
LOOP_L_N(ix, GRID_MAX_POINTS_X) {
|
||||||
ppos.x = mesh_index_to_xpos(ix);
|
ppos.x = mesh_index_to_xpos(ix);
|
||||||
LOOP_L_N(iy, GRID_MAX_POINTS_Y) {
|
LOOP_L_N(iy, GRID_MAX_POINTS_Y) {
|
||||||
ppos.y = mesh_index_to_ypos(iy);
|
ppos.y = mesh_index_to_ypos(iy);
|
||||||
if (isnan(z_values[ix][iy])) {
|
if (ISNAN(z_values[ix][iy])) {
|
||||||
// undefined mesh point at (ppos.x,ppos.y), compute weighted LSF from original valid mesh points.
|
// undefined mesh point at (ppos.x,ppos.y), compute weighted LSF from original valid mesh points.
|
||||||
incremental_LSF_reset(&lsf_results);
|
incremental_LSF_reset(&lsf_results);
|
||||||
xy_pos_t rpos;
|
xy_pos_t rpos;
|
||||||
|
@ -85,7 +85,7 @@
|
|||||||
|
|
||||||
// Undefined parts of the Mesh in z_values[][] are NAN.
|
// Undefined parts of the Mesh in z_values[][] are NAN.
|
||||||
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|
||||||
if (!isnan(z0)) end.z += z0;
|
if (!ISNAN(z0)) end.z += z0;
|
||||||
planner.buffer_segment(end, scaled_fr_mm_s, extruder);
|
planner.buffer_segment(end, scaled_fr_mm_s, extruder);
|
||||||
current_position = destination;
|
current_position = destination;
|
||||||
return;
|
return;
|
||||||
@ -150,7 +150,7 @@
|
|||||||
|
|
||||||
// Undefined parts of the Mesh in z_values[][] are NAN.
|
// Undefined parts of the Mesh in z_values[][] are NAN.
|
||||||
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|
||||||
if (isnan(z0)) z0 = 0.0;
|
if (ISNAN(z0)) z0 = 0.0;
|
||||||
|
|
||||||
const float ry = mesh_index_to_ypos(icell.y);
|
const float ry = mesh_index_to_ypos(icell.y);
|
||||||
|
|
||||||
@ -198,7 +198,7 @@
|
|||||||
|
|
||||||
// Undefined parts of the Mesh in z_values[][] are NAN.
|
// Undefined parts of the Mesh in z_values[][] are NAN.
|
||||||
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|
||||||
if (isnan(z0)) z0 = 0.0;
|
if (ISNAN(z0)) z0 = 0.0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Without this check, it's possible to generate a zero length move, as in the case where
|
* Without this check, it's possible to generate a zero length move, as in the case where
|
||||||
@ -253,7 +253,7 @@
|
|||||||
|
|
||||||
// Undefined parts of the Mesh in z_values[][] are NAN.
|
// Undefined parts of the Mesh in z_values[][] are NAN.
|
||||||
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|
||||||
if (isnan(z0)) z0 = 0.0;
|
if (ISNAN(z0)) z0 = 0.0;
|
||||||
|
|
||||||
if (!inf_normalized_flag) {
|
if (!inf_normalized_flag) {
|
||||||
on_axis_distance = use_x_dist ? rx - start.x : next_mesh_line_y - start.y;
|
on_axis_distance = use_x_dist ? rx - start.x : next_mesh_line_y - start.y;
|
||||||
@ -276,7 +276,7 @@
|
|||||||
|
|
||||||
// Undefined parts of the Mesh in z_values[][] are NAN.
|
// Undefined parts of the Mesh in z_values[][] are NAN.
|
||||||
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|
||||||
if (isnan(z0)) z0 = 0.0;
|
if (ISNAN(z0)) z0 = 0.0;
|
||||||
|
|
||||||
if (!inf_normalized_flag) {
|
if (!inf_normalized_flag) {
|
||||||
on_axis_distance = use_x_dist ? next_mesh_line_x - start.x : ry - start.y;
|
on_axis_distance = use_x_dist ? next_mesh_line_x - start.x : ry - start.y;
|
||||||
@ -405,10 +405,10 @@
|
|||||||
z_x0y1 = z_values[icell.x ][icell.y+1], // z at lower right corner
|
z_x0y1 = z_values[icell.x ][icell.y+1], // z at lower right corner
|
||||||
z_x1y1 = z_values[icell.x+1][icell.y+1]; // z at upper right corner
|
z_x1y1 = z_values[icell.x+1][icell.y+1]; // z at upper right corner
|
||||||
|
|
||||||
if (isnan(z_x0y0)) z_x0y0 = 0; // ideally activating planner.leveling_active (G29 A)
|
if (ISNAN(z_x0y0)) z_x0y0 = 0; // ideally activating planner.leveling_active (G29 A)
|
||||||
if (isnan(z_x1y0)) z_x1y0 = 0; // should refuse if any invalid mesh points
|
if (ISNAN(z_x1y0)) z_x1y0 = 0; // should refuse if any invalid mesh points
|
||||||
if (isnan(z_x0y1)) z_x0y1 = 0; // in order to avoid isnan tests per cell,
|
if (ISNAN(z_x0y1)) z_x0y1 = 0; // in order to avoid ISNAN tests per cell,
|
||||||
if (isnan(z_x1y1)) z_x1y1 = 0; // thus guessing zero for undefined points
|
if (ISNAN(z_x1y1)) z_x1y1 = 0; // thus guessing zero for undefined points
|
||||||
|
|
||||||
const xy_pos_t pos = { mesh_index_to_xpos(icell.x), mesh_index_to_ypos(icell.y) };
|
const xy_pos_t pos = { mesh_index_to_xpos(icell.x), mesh_index_to_ypos(icell.y) };
|
||||||
xy_pos_t cell = raw - pos;
|
xy_pos_t cell = raw - pos;
|
||||||
|
@ -105,7 +105,7 @@ void GcodeSuite::G35() {
|
|||||||
do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, Z_CLEARANCE_BETWEEN_PROBES, 7));
|
do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, Z_CLEARANCE_BETWEEN_PROBES, 7));
|
||||||
const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[i], PROBE_PT_RAISE, 0, true);
|
const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[i], PROBE_PT_RAISE, 0, true);
|
||||||
|
|
||||||
if (isnan(z_probed_height)) {
|
if (ISNAN(z_probed_height)) {
|
||||||
SERIAL_ECHOPAIR("G35 failed at point ", i, " (");
|
SERIAL_ECHOPAIR("G35 failed at point ", i, " (");
|
||||||
SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i]));
|
SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i]));
|
||||||
SERIAL_CHAR(')');
|
SERIAL_CHAR(')');
|
||||||
|
@ -287,11 +287,11 @@ G29_TYPE GcodeSuite::G29() {
|
|||||||
G29_RETURN(false);
|
G29_RETURN(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const float rx = RAW_X_POSITION(parser.linearval('X', NAN)),
|
const float rx = RAW_X_POSITION(parser.linearval('X', MFNAN)),
|
||||||
ry = RAW_Y_POSITION(parser.linearval('Y', NAN));
|
ry = RAW_Y_POSITION(parser.linearval('Y', MFNAN));
|
||||||
int8_t i = parser.byteval('I', -1), j = parser.byteval('J', -1);
|
int8_t i = parser.byteval('I', -1), j = parser.byteval('J', -1);
|
||||||
|
|
||||||
if (!isnan(rx) && !isnan(ry)) {
|
if (!ISNAN(rx) && !ISNAN(ry)) {
|
||||||
// Get nearest i / j from rx / ry
|
// Get nearest i / j from rx / ry
|
||||||
i = (rx - bilinear_start.x + 0.5 * abl.gridSpacing.x) / abl.gridSpacing.x;
|
i = (rx - bilinear_start.x + 0.5 * abl.gridSpacing.x) / abl.gridSpacing.x;
|
||||||
j = (ry - bilinear_start.y + 0.5 * abl.gridSpacing.y) / abl.gridSpacing.y;
|
j = (ry - bilinear_start.y + 0.5 * abl.gridSpacing.y) / abl.gridSpacing.y;
|
||||||
@ -608,7 +608,7 @@ G29_TYPE GcodeSuite::G29() {
|
|||||||
|
|
||||||
// Outer loop is X with PROBE_Y_FIRST enabled
|
// Outer loop is X with PROBE_Y_FIRST enabled
|
||||||
// Outer loop is Y with PROBE_Y_FIRST disabled
|
// Outer loop is Y with PROBE_Y_FIRST disabled
|
||||||
for (PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_SIZE && !isnan(abl.measured_z); PR_OUTER_VAR++) {
|
for (PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_SIZE && !ISNAN(abl.measured_z); PR_OUTER_VAR++) {
|
||||||
|
|
||||||
int8_t inStart, inStop, inInc;
|
int8_t inStart, inStop, inInc;
|
||||||
|
|
||||||
@ -644,7 +644,7 @@ G29_TYPE GcodeSuite::G29() {
|
|||||||
|
|
||||||
abl.measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level);
|
abl.measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level);
|
||||||
|
|
||||||
if (isnan(abl.measured_z)) {
|
if (ISNAN(abl.measured_z)) {
|
||||||
set_bed_leveling_enabled(abl.reenable);
|
set_bed_leveling_enabled(abl.reenable);
|
||||||
break; // Breaks out of both loops
|
break; // Breaks out of both loops
|
||||||
}
|
}
|
||||||
@ -690,14 +690,14 @@ G29_TYPE GcodeSuite::G29() {
|
|||||||
// Retain the last probe position
|
// Retain the last probe position
|
||||||
abl.probePos = points[i];
|
abl.probePos = points[i];
|
||||||
abl.measured_z = faux ? 0.001 * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level);
|
abl.measured_z = faux ? 0.001 * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level);
|
||||||
if (isnan(abl.measured_z)) {
|
if (ISNAN(abl.measured_z)) {
|
||||||
set_bed_leveling_enabled(abl.reenable);
|
set_bed_leveling_enabled(abl.reenable);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
points[i].z = abl.measured_z;
|
points[i].z = abl.measured_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!abl.dryrun && !isnan(abl.measured_z)) {
|
if (!abl.dryrun && !ISNAN(abl.measured_z)) {
|
||||||
vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal();
|
vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal();
|
||||||
if (planeNormal.z < 0) planeNormal *= -1;
|
if (planeNormal.z < 0) planeNormal *= -1;
|
||||||
planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
|
||||||
@ -713,7 +713,7 @@ G29_TYPE GcodeSuite::G29() {
|
|||||||
// Stow the probe. No raise for FIX_MOUNTED_PROBE.
|
// Stow the probe. No raise for FIX_MOUNTED_PROBE.
|
||||||
if (probe.stow()) {
|
if (probe.stow()) {
|
||||||
set_bed_leveling_enabled(abl.reenable);
|
set_bed_leveling_enabled(abl.reenable);
|
||||||
abl.measured_z = NAN;
|
abl.measured_z = MFNAN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // !PROBE_MANUALLY
|
#endif // !PROBE_MANUALLY
|
||||||
@ -736,7 +736,7 @@ G29_TYPE GcodeSuite::G29() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Calculate leveling, print reports, correct the position
|
// Calculate leveling, print reports, correct the position
|
||||||
if (!isnan(abl.measured_z)) {
|
if (!ISNAN(abl.measured_z)) {
|
||||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||||
|
|
||||||
if (!abl.dryrun) extrapolate_unprobed_bed_level();
|
if (!abl.dryrun) extrapolate_unprobed_bed_level();
|
||||||
@ -873,7 +873,7 @@ G29_TYPE GcodeSuite::G29() {
|
|||||||
|
|
||||||
// Auto Bed Leveling is complete! Enable if possible.
|
// Auto Bed Leveling is complete! Enable if possible.
|
||||||
planner.leveling_active = !abl.dryrun || abl.reenable;
|
planner.leveling_active = !abl.dryrun || abl.reenable;
|
||||||
} // !isnan(abl.measured_z)
|
} // !ISNAN(abl.measured_z)
|
||||||
|
|
||||||
// Restore state after probing
|
// Restore state after probing
|
||||||
if (!faux) restore_feedrate_and_scaling();
|
if (!faux) restore_feedrate_and_scaling();
|
||||||
@ -897,7 +897,7 @@ G29_TYPE GcodeSuite::G29() {
|
|||||||
|
|
||||||
report_current_position();
|
report_current_position();
|
||||||
|
|
||||||
G29_RETURN(isnan(abl.measured_z));
|
G29_RETURN(ISNAN(abl.measured_z));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAS_ABL_NOT_UBL
|
#endif // HAS_ABL_NOT_UBL
|
||||||
|
@ -62,7 +62,7 @@ void GcodeSuite::M421() {
|
|||||||
SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
|
SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
|
||||||
else {
|
else {
|
||||||
float &zval = ubl.z_values[ij.x][ij.y];
|
float &zval = ubl.z_values[ij.x][ij.y];
|
||||||
zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0);
|
zval = hasN ? MFNAN : parser.value_linear_units() + (hasQ ? zval : 0);
|
||||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval));
|
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi
|
|||||||
if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center
|
if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center
|
||||||
const xy_pos_t center{0};
|
const xy_pos_t center{0};
|
||||||
z_pt[CEN] += calibration_probe(center, stow_after_each);
|
z_pt[CEN] += calibration_probe(center, stow_after_each);
|
||||||
if (isnan(z_pt[CEN])) return false;
|
if (ISNAN(z_pt[CEN])) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_7p_calibration) { // probe extra center points
|
if (_7p_calibration) { // probe extra center points
|
||||||
@ -223,7 +223,7 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi
|
|||||||
r = dcr * 0.1;
|
r = dcr * 0.1;
|
||||||
const xy_pos_t vec = { cos(a), sin(a) };
|
const xy_pos_t vec = { cos(a), sin(a) };
|
||||||
z_pt[CEN] += calibration_probe(vec * r, stow_after_each);
|
z_pt[CEN] += calibration_probe(vec * r, stow_after_each);
|
||||||
if (isnan(z_pt[CEN])) return false;
|
if (ISNAN(z_pt[CEN])) return false;
|
||||||
}
|
}
|
||||||
z_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points);
|
z_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points);
|
||||||
}
|
}
|
||||||
@ -248,7 +248,7 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi
|
|||||||
interpol = FMOD(rad, 1);
|
interpol = FMOD(rad, 1);
|
||||||
const xy_pos_t vec = { cos(a), sin(a) };
|
const xy_pos_t vec = { cos(a), sin(a) };
|
||||||
const float z_temp = calibration_probe(vec * r, stow_after_each);
|
const float z_temp = calibration_probe(vec * r, stow_after_each);
|
||||||
if (isnan(z_temp)) return false;
|
if (ISNAN(z_temp)) return false;
|
||||||
// split probe point to neighbouring calibration points
|
// split probe point to neighbouring calibration points
|
||||||
z_pt[uint8_t(LROUND(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
|
z_pt[uint8_t(LROUND(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
|
||||||
z_pt[uint8_t(LROUND(rad - interpol)) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
|
z_pt[uint8_t(LROUND(rad - interpol)) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
|
||||||
|
@ -229,7 +229,7 @@ void GcodeSuite::G34() {
|
|||||||
// Probing sanity check is disabled, as it would trigger even in normal cases because
|
// Probing sanity check is disabled, as it would trigger even in normal cases because
|
||||||
// current_position.z has been manually altered in the "dirty trick" above.
|
// current_position.z has been manually altered in the "dirty trick" above.
|
||||||
const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true, false);
|
const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true, false);
|
||||||
if (isnan(z_probed_height)) {
|
if (ISNAN(z_probed_height)) {
|
||||||
SERIAL_ECHOLNPGM("Probing failed");
|
SERIAL_ECHOLNPGM("Probing failed");
|
||||||
LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
|
LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
|
||||||
err_break = true;
|
err_break = true;
|
||||||
|
@ -113,7 +113,7 @@ void GcodeSuite::G76() {
|
|||||||
auto g76_probe = [](const TempSensorID sid, uint16_t &targ, const xy_pos_t &nozpos) {
|
auto g76_probe = [](const TempSensorID sid, uint16_t &targ, const xy_pos_t &nozpos) {
|
||||||
do_z_clearance(5.0); // Raise nozzle before probing
|
do_z_clearance(5.0); // Raise nozzle before probing
|
||||||
const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false); // verbose=0, probe_relative=false
|
const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false); // verbose=0, probe_relative=false
|
||||||
if (isnan(measured_z))
|
if (ISNAN(measured_z))
|
||||||
SERIAL_ECHOLNPGM("!Received NAN. Aborting.");
|
SERIAL_ECHOLNPGM("!Received NAN. Aborting.");
|
||||||
else {
|
else {
|
||||||
SERIAL_ECHOLNPAIR_F("Measured: ", measured_z);
|
SERIAL_ECHOLNPAIR_F("Measured: ", measured_z);
|
||||||
@ -208,7 +208,7 @@ void GcodeSuite::G76() {
|
|||||||
report_temps(next_temp_report);
|
report_temps(next_temp_report);
|
||||||
|
|
||||||
const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz);
|
const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz);
|
||||||
if (isnan(measured_z) || target_bed > BED_MAX_TARGET) break;
|
if (ISNAN(measured_z) || target_bed > BED_MAX_TARGET) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
|
SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
|
||||||
@ -267,7 +267,7 @@ void GcodeSuite::G76() {
|
|||||||
if (timeout) break;
|
if (timeout) break;
|
||||||
|
|
||||||
const float measured_z = g76_probe(TSI_PROBE, target_probe, noz_pos_xyz);
|
const float measured_z = g76_probe(TSI_PROBE, target_probe, noz_pos_xyz);
|
||||||
if (isnan(measured_z) || target_probe > cali_info_init[TSI_PROBE].end_temp) break;
|
if (ISNAN(measured_z) || target_probe > cali_info_init[TSI_PROBE].end_temp) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
|
SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
|
||||||
|
@ -134,7 +134,7 @@ void GcodeSuite::M48() {
|
|||||||
|
|
||||||
// Move to the first point, deploy, and probe
|
// Move to the first point, deploy, and probe
|
||||||
const float t = probe.probe_at_point(test_position, raise_after, verbose_level);
|
const float t = probe.probe_at_point(test_position, raise_after, verbose_level);
|
||||||
bool probing_good = !isnan(t);
|
bool probing_good = !ISNAN(t);
|
||||||
|
|
||||||
if (probing_good) {
|
if (probing_good) {
|
||||||
randomSeed(millis());
|
randomSeed(millis());
|
||||||
@ -219,7 +219,7 @@ void GcodeSuite::M48() {
|
|||||||
const float pz = probe.probe_at_point(test_position, raise_after, 0);
|
const float pz = probe.probe_at_point(test_position, raise_after, 0);
|
||||||
|
|
||||||
// Break the loop if the probe fails
|
// Break the loop if the probe fails
|
||||||
probing_good = !isnan(pz);
|
probing_good = !ISNAN(pz);
|
||||||
if (!probing_good) break;
|
if (!probing_good) break;
|
||||||
|
|
||||||
// Store the new sample
|
// Store the new sample
|
||||||
|
@ -52,7 +52,7 @@ void GcodeSuite::G30() {
|
|||||||
|
|
||||||
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
|
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
|
||||||
const float measured_z = probe.probe_at_point(pos, raise_after, 1);
|
const float measured_z = probe.probe_at_point(pos, raise_after, 1);
|
||||||
if (!isnan(measured_z))
|
if (!ISNAN(measured_z))
|
||||||
SERIAL_ECHOLNPAIR("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z);
|
SERIAL_ECHOLNPAIR("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z);
|
||||||
|
|
||||||
restore_feedrate_and_scaling();
|
restore_feedrate_and_scaling();
|
||||||
|
@ -1457,7 +1457,7 @@ void MarlinUI::draw_status_screen() {
|
|||||||
* Print Z values
|
* Print Z values
|
||||||
*/
|
*/
|
||||||
_ZLABEL(_LCD_W_POS, 1);
|
_ZLABEL(_LCD_W_POS, 1);
|
||||||
if (!isnan(ubl.z_values[x_plot][y_plot]))
|
if (!ISNAN(ubl.z_values[x_plot][y_plot]))
|
||||||
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||||
else
|
else
|
||||||
lcd_put_u8str_P(PSTR(" -----"));
|
lcd_put_u8str_P(PSTR(" -----"));
|
||||||
@ -1476,7 +1476,7 @@ void MarlinUI::draw_status_screen() {
|
|||||||
* Show the location value
|
* Show the location value
|
||||||
*/
|
*/
|
||||||
_ZLABEL(_LCD_W_POS, 3);
|
_ZLABEL(_LCD_W_POS, 3);
|
||||||
if (!isnan(ubl.z_values[x_plot][y_plot]))
|
if (!ISNAN(ubl.z_values[x_plot][y_plot]))
|
||||||
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||||
else
|
else
|
||||||
lcd_put_u8str_P(PSTR(" -----"));
|
lcd_put_u8str_P(PSTR(" -----"));
|
||||||
|
@ -941,7 +941,7 @@ void MarlinUI::draw_status_screen() {
|
|||||||
// Show the location value
|
// Show the location value
|
||||||
lcd.setCursor(_LCD_W_POS, 3); lcd_put_u8str_P(PSTR("Z:"));
|
lcd.setCursor(_LCD_W_POS, 3); lcd_put_u8str_P(PSTR("Z:"));
|
||||||
|
|
||||||
if (!isnan(ubl.z_values[x_plot][y_plot]))
|
if (!ISNAN(ubl.z_values[x_plot][y_plot]))
|
||||||
lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||||
else
|
else
|
||||||
lcd_put_u8str_P(PSTR(" -----"));
|
lcd_put_u8str_P(PSTR(" -----"));
|
||||||
|
@ -569,7 +569,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
|||||||
|
|
||||||
// Show the location value
|
// Show the location value
|
||||||
lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL);
|
lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL);
|
||||||
if (!isnan(ubl.z_values[x_plot][y_plot]))
|
if (!ISNAN(ubl.z_values[x_plot][y_plot]))
|
||||||
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||||
else
|
else
|
||||||
lcd_put_u8str_P(PSTR(" -----"));
|
lcd_put_u8str_P(PSTR(" -----"));
|
||||||
|
@ -835,13 +835,17 @@ void MarlinUI::draw_status_screen() {
|
|||||||
mix_label = PSTR("Mx");
|
mix_label = PSTR("Mx");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if GCC_VERSION <= 50000
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wformat-overflow"
|
#pragma GCC diagnostic ignored "-Wformat-overflow"
|
||||||
|
#endif
|
||||||
|
|
||||||
sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
|
sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
|
||||||
lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages);
|
lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages);
|
||||||
|
|
||||||
|
#if GCC_VERSION <= 50000
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
namespace FTDI {
|
namespace FTDI {
|
||||||
void draw_adjuster_value(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, float value, progmem_str units, int8_t width, uint8_t precision) {
|
void draw_adjuster_value(CommandProcessor& cmd, int16_t x, int16_t y, int16_t w, int16_t h, float value, progmem_str units, int8_t width, uint8_t precision) {
|
||||||
char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)];
|
char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)];
|
||||||
if (isnan(value))
|
if (ISNAN(value))
|
||||||
strcpy_P(str, PSTR("-"));
|
strcpy_P(str, PSTR("-"));
|
||||||
else
|
else
|
||||||
dtostrf(value, width, precision, str);
|
dtostrf(value, width, precision, str);
|
||||||
|
@ -31,7 +31,7 @@ void BedMeshBase::_drawMesh(CommandProcessor &cmd, int16_t x, int16_t y, int16_t
|
|||||||
constexpr uint8_t cols = GRID_MAX_POINTS_X;
|
constexpr uint8_t cols = GRID_MAX_POINTS_X;
|
||||||
|
|
||||||
#define VALUE(X,Y) (func ? func(X,Y,data) : 0)
|
#define VALUE(X,Y) (func ? func(X,Y,data) : 0)
|
||||||
#define ISVAL(X,Y) (func ? !isnan(VALUE(X,Y)) : true)
|
#define ISVAL(X,Y) (func ? !ISNAN(VALUE(X,Y)) : true)
|
||||||
#define HEIGHT(X,Y) (ISVAL(X,Y) ? (VALUE(X,Y) - val_min) * scale_z : 0)
|
#define HEIGHT(X,Y) (ISVAL(X,Y) ? (VALUE(X,Y) - val_min) * scale_z : 0)
|
||||||
|
|
||||||
// Compute the mean, min and max for the points
|
// Compute the mean, min and max for the points
|
||||||
|
@ -70,7 +70,7 @@ void BedMeshEditScreen::onEntry() {
|
|||||||
|
|
||||||
float BedMeshEditScreen::getHighlightedValue() {
|
float BedMeshEditScreen::getHighlightedValue() {
|
||||||
const float val = ExtUI::getMeshPoint(mydata.highlight);
|
const float val = ExtUI::getMeshPoint(mydata.highlight);
|
||||||
return (isnan(val) ? 0 : val) + mydata.zAdjustment;
|
return (ISNAN(val) ? 0 : val) + mydata.zAdjustment;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BedMeshEditScreen::setHighlightedValue(float value) {
|
void BedMeshEditScreen::setHighlightedValue(float value) {
|
||||||
|
@ -421,7 +421,7 @@ namespace ExtUI {
|
|||||||
#if AXIS_IS_TMC(Z2)
|
#if AXIS_IS_TMC(Z2)
|
||||||
case Z2: return stepperZ2.getMilliamps();
|
case Z2: return stepperZ2.getMilliamps();
|
||||||
#endif
|
#endif
|
||||||
default: return NAN;
|
default: return MFNAN;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,7 +451,7 @@ namespace ExtUI {
|
|||||||
#if AXIS_IS_TMC(E7)
|
#if AXIS_IS_TMC(E7)
|
||||||
case E7: return stepperE7.getMilliamps();
|
case E7: return stepperE7.getMilliamps();
|
||||||
#endif
|
#endif
|
||||||
default: return NAN;
|
default: return MFNAN;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ static bool probe_single_point() {
|
|||||||
z_measured[tram_index] = z_probed_height;
|
z_measured[tram_index] = z_probed_height;
|
||||||
move_to_tramming_wait_pos();
|
move_to_tramming_wait_pos();
|
||||||
|
|
||||||
return !isnan(z_probed_height);
|
return !ISNAN(z_probed_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _menu_single_probe(const uint8_t point) {
|
static void _menu_single_probe(const uint8_t point) {
|
||||||
|
@ -505,7 +505,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
|
|||||||
tft.set_background(COLOR_BACKGROUND);
|
tft.set_background(COLOR_BACKGROUND);
|
||||||
tft_string.set(Z_LBL);
|
tft_string.set(Z_LBL);
|
||||||
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||||
tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||||
tft_string.trim();
|
tft_string.trim();
|
||||||
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
|
|||||||
tft.set_background(COLOR_BACKGROUND);
|
tft.set_background(COLOR_BACKGROUND);
|
||||||
tft_string.set(Z_LBL);
|
tft_string.set(Z_LBL);
|
||||||
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||||
tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||||
tft_string.trim();
|
tft_string.trim();
|
||||||
tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
|
|||||||
tft.set_background(COLOR_BACKGROUND);
|
tft.set_background(COLOR_BACKGROUND);
|
||||||
tft_string.set(Z_LBL);
|
tft_string.set(Z_LBL);
|
||||||
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||||
tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||||
tft_string.trim();
|
tft_string.trim();
|
||||||
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||||
|
|
||||||
|
@ -583,7 +583,7 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
|
|||||||
* @details Used by probe_at_point to get the bed Z height at the current XY.
|
* @details Used by probe_at_point to get the bed Z height at the current XY.
|
||||||
* Leaves current_position.z at the height where the probe triggered.
|
* Leaves current_position.z at the height where the probe triggered.
|
||||||
*
|
*
|
||||||
* @return The Z position of the bed at the current XY or NAN on error.
|
* @return The Z position of the bed at the current XY or MFNAN on error.
|
||||||
*/
|
*/
|
||||||
float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
||||||
DEBUG_SECTION(log_probe, "Probe::run_z_probe", DEBUGGING(LEVELING));
|
DEBUG_SECTION(log_probe, "Probe::run_z_probe", DEBUGGING(LEVELING));
|
||||||
@ -617,11 +617,11 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
|||||||
#if TOTAL_PROBING == 2
|
#if TOTAL_PROBING == 2
|
||||||
|
|
||||||
// Attempt to tare the probe
|
// Attempt to tare the probe
|
||||||
if (TERN0(PROBE_TARE, tare())) return NAN;
|
if (TERN0(PROBE_TARE, tare())) return MFNAN;
|
||||||
|
|
||||||
// Do a first probe at the fast speed
|
// Do a first probe at the fast speed
|
||||||
if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s,
|
if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s,
|
||||||
sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN;
|
sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return MFNAN;
|
||||||
|
|
||||||
const float first_probe_z = current_position.z;
|
const float first_probe_z = current_position.z;
|
||||||
|
|
||||||
@ -662,7 +662,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
|||||||
|
|
||||||
// Probe downward slowly to find the bed
|
// Probe downward slowly to find the bed
|
||||||
if (try_to_probe(PSTR("SLOW"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW),
|
if (try_to_probe(PSTR("SLOW"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW),
|
||||||
sanity_check, Z_CLEARANCE_MULTI_PROBE) ) return NAN;
|
sanity_check, Z_CLEARANCE_MULTI_PROBE) ) return MFNAN;
|
||||||
|
|
||||||
TERN_(MEASURE_BACKLASH_WHEN_PROBING, backlash.measure_with_probe());
|
TERN_(MEASURE_BACKLASH_WHEN_PROBING, backlash.measure_with_probe());
|
||||||
|
|
||||||
@ -765,29 +765,29 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
|
|||||||
if (probe_relative) { // The given position is in terms of the probe
|
if (probe_relative) { // The given position is in terms of the probe
|
||||||
if (!can_reach(npos)) {
|
if (!can_reach(npos)) {
|
||||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable");
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable");
|
||||||
return NAN;
|
return MFNAN;
|
||||||
}
|
}
|
||||||
npos -= offset_xy; // Get the nozzle position
|
npos -= offset_xy; // Get the nozzle position
|
||||||
}
|
}
|
||||||
else if (!position_is_reachable(npos)) return NAN; // The given position is in terms of the nozzle
|
else if (!position_is_reachable(npos)) return MFNAN; // The given position is in terms of the nozzle
|
||||||
|
|
||||||
// Move the probe to the starting XYZ
|
// Move the probe to the starting XYZ
|
||||||
do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S));
|
do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S));
|
||||||
|
|
||||||
float measured_z = NAN;
|
float measured_z = MFNAN;
|
||||||
if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z;
|
if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z;
|
||||||
if (!isnan(measured_z)) {
|
if (!ISNAN(measured_z)) {
|
||||||
const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
|
const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
|
||||||
if (big_raise || raise_after == PROBE_PT_RAISE)
|
if (big_raise || raise_after == PROBE_PT_RAISE)
|
||||||
do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), z_probe_fast_mm_s);
|
do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), z_probe_fast_mm_s);
|
||||||
else if (raise_after == PROBE_PT_STOW)
|
else if (raise_after == PROBE_PT_STOW)
|
||||||
if (stow()) measured_z = NAN; // Error on stow?
|
if (stow()) measured_z = MFNAN; // Error on stow?
|
||||||
|
|
||||||
if (verbose_level > 2)
|
if (verbose_level > 2)
|
||||||
SERIAL_ECHOLNPAIR("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z);
|
SERIAL_ECHOLNPAIR("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isnan(measured_z)) {
|
if (ISNAN(measured_z)) {
|
||||||
stow();
|
stow();
|
||||||
LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
|
LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
|
||||||
#if DISABLED(G29_RETRY_AND_RECOVER)
|
#if DISABLED(G29_RETRY_AND_RECOVER)
|
||||||
|
@ -185,10 +185,10 @@ public:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float min_x() { return _min_x() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x)); }
|
static float min_x() { return _min_x() TERN_(NOZZLE_AS_PROBE, TERN_(HAS_HOME_OFFSET, - home_offset.x)); }
|
||||||
static float max_x() { return _max_x() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x)); }
|
static float max_x() { return _max_x() TERN_(NOZZLE_AS_PROBE, TERN_(HAS_HOME_OFFSET, - home_offset.x)); }
|
||||||
static float min_y() { return _min_y() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y)); }
|
static float min_y() { return _min_y() TERN_(NOZZLE_AS_PROBE, TERN_(HAS_HOME_OFFSET, - home_offset.y)); }
|
||||||
static float max_y() { return _max_y() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y)); }
|
static float max_y() { return _max_y() TERN_(NOZZLE_AS_PROBE, TERN_(HAS_HOME_OFFSET, - home_offset.y)); }
|
||||||
|
|
||||||
// constexpr helpers used in build-time static_asserts, relying on default probe offsets.
|
// constexpr helpers used in build-time static_asserts, relying on default probe offsets.
|
||||||
class build_time {
|
class build_time {
|
||||||
|
@ -900,8 +900,8 @@ void MarlinSettings::postprocess() {
|
|||||||
HOTEND_LOOP() {
|
HOTEND_LOOP() {
|
||||||
PIDCF_t pidcf = {
|
PIDCF_t pidcf = {
|
||||||
#if DISABLED(PIDTEMP)
|
#if DISABLED(PIDTEMP)
|
||||||
NAN, NAN, NAN,
|
MFNAN, MFNAN, MFNAN,
|
||||||
NAN, NAN
|
MFNAN, MFNAN
|
||||||
#else
|
#else
|
||||||
PID_PARAM(Kp, e),
|
PID_PARAM(Kp, e),
|
||||||
unscalePID_i(PID_PARAM(Ki, e)),
|
unscalePID_i(PID_PARAM(Ki, e)),
|
||||||
@ -928,7 +928,7 @@ void MarlinSettings::postprocess() {
|
|||||||
|
|
||||||
const PID_t bed_pid = {
|
const PID_t bed_pid = {
|
||||||
#if DISABLED(PIDTEMPBED)
|
#if DISABLED(PIDTEMPBED)
|
||||||
NAN, NAN, NAN
|
MFNAN, MFNAN, MFNAN
|
||||||
#else
|
#else
|
||||||
// Store the unscaled PID values
|
// Store the unscaled PID values
|
||||||
thermalManager.temp_bed.pid.Kp,
|
thermalManager.temp_bed.pid.Kp,
|
||||||
@ -947,7 +947,7 @@ void MarlinSettings::postprocess() {
|
|||||||
|
|
||||||
const PID_t chamber_pid = {
|
const PID_t chamber_pid = {
|
||||||
#if DISABLED(PIDTEMPCHAMBER)
|
#if DISABLED(PIDTEMPCHAMBER)
|
||||||
NAN, NAN, NAN
|
MFNAN, MFNAN, MFNAN
|
||||||
#else
|
#else
|
||||||
// Store the unscaled PID values
|
// Store the unscaled PID values
|
||||||
thermalManager.temp_chamber.pid.Kp,
|
thermalManager.temp_chamber.pid.Kp,
|
||||||
@ -1786,7 +1786,7 @@ void MarlinSettings::postprocess() {
|
|||||||
PIDCF_t pidcf;
|
PIDCF_t pidcf;
|
||||||
EEPROM_READ(pidcf);
|
EEPROM_READ(pidcf);
|
||||||
#if ENABLED(PIDTEMP)
|
#if ENABLED(PIDTEMP)
|
||||||
if (!validating && !isnan(pidcf.Kp)) {
|
if (!validating && !ISNAN(pidcf.Kp)) {
|
||||||
// Scale PID values since EEPROM values are unscaled
|
// Scale PID values since EEPROM values are unscaled
|
||||||
PID_PARAM(Kp, e) = pidcf.Kp;
|
PID_PARAM(Kp, e) = pidcf.Kp;
|
||||||
PID_PARAM(Ki, e) = scalePID_i(pidcf.Ki);
|
PID_PARAM(Ki, e) = scalePID_i(pidcf.Ki);
|
||||||
@ -1818,7 +1818,7 @@ void MarlinSettings::postprocess() {
|
|||||||
PID_t pid;
|
PID_t pid;
|
||||||
EEPROM_READ(pid);
|
EEPROM_READ(pid);
|
||||||
#if ENABLED(PIDTEMPBED)
|
#if ENABLED(PIDTEMPBED)
|
||||||
if (!validating && !isnan(pid.Kp)) {
|
if (!validating && !ISNAN(pid.Kp)) {
|
||||||
// Scale PID values since EEPROM values are unscaled
|
// Scale PID values since EEPROM values are unscaled
|
||||||
thermalManager.temp_bed.pid.Kp = pid.Kp;
|
thermalManager.temp_bed.pid.Kp = pid.Kp;
|
||||||
thermalManager.temp_bed.pid.Ki = scalePID_i(pid.Ki);
|
thermalManager.temp_bed.pid.Ki = scalePID_i(pid.Ki);
|
||||||
@ -1834,7 +1834,7 @@ void MarlinSettings::postprocess() {
|
|||||||
PID_t pid;
|
PID_t pid;
|
||||||
EEPROM_READ(pid);
|
EEPROM_READ(pid);
|
||||||
#if ENABLED(PIDTEMPCHAMBER)
|
#if ENABLED(PIDTEMPCHAMBER)
|
||||||
if (!validating && !isnan(pid.Kp)) {
|
if (!validating && !ISNAN(pid.Kp)) {
|
||||||
// Scale PID values since EEPROM values are unscaled
|
// Scale PID values since EEPROM values are unscaled
|
||||||
thermalManager.temp_chamber.pid.Kp = pid.Kp;
|
thermalManager.temp_chamber.pid.Kp = pid.Kp;
|
||||||
thermalManager.temp_chamber.pid.Ki = scalePID_i(pid.Ki);
|
thermalManager.temp_chamber.pid.Ki = scalePID_i(pid.Ki);
|
||||||
|
@ -74,9 +74,9 @@ hotend_pid_t;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PID_PARAM(F,H) _PID_##F(TERN(PID_PARAMS_PER_HOTEND, H, 0 & H)) // Always use 'H' to suppress warning
|
#define PID_PARAM(F,H) _PID_##F(TERN(PID_PARAMS_PER_HOTEND, H, 0 & H)) // Always use 'H' to suppress warning
|
||||||
#define _PID_Kp(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kp, NAN)
|
#define _PID_Kp(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kp, MFNAN)
|
||||||
#define _PID_Ki(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Ki, NAN)
|
#define _PID_Ki(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Ki, MFNAN)
|
||||||
#define _PID_Kd(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kd, NAN)
|
#define _PID_Kd(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kd, MFNAN)
|
||||||
#if ENABLED(PIDTEMP)
|
#if ENABLED(PIDTEMP)
|
||||||
#define _PID_Kc(H) TERN(PID_EXTRUSION_SCALING, Temperature::temp_hotend[H].pid.Kc, 1)
|
#define _PID_Kc(H) TERN(PID_EXTRUSION_SCALING, Temperature::temp_hotend[H].pid.Kc, 1)
|
||||||
#define _PID_Kf(H) TERN(PID_FAN_SCALING, Temperature::temp_hotend[H].pid.Kf, 0)
|
#define _PID_Kf(H) TERN(PID_FAN_SCALING, Temperature::temp_hotend[H].pid.Kf, 0)
|
||||||
|
@ -565,7 +565,7 @@ void announceOpen(const uint8_t doing, const char * const path) {
|
|||||||
// - 1 : (no file open) Opening a macro (M98).
|
// - 1 : (no file open) Opening a macro (M98).
|
||||||
// - 2 : Resuming from a sub-procedure
|
// - 2 : Resuming from a sub-procedure
|
||||||
//
|
//
|
||||||
void CardReader::openFileRead(char * const path, const uint8_t subcall_type/*=0*/) {
|
void CardReader::openFileRead(const char * const path, const uint8_t subcall_type/*=0*/) {
|
||||||
if (!isMounted()) return;
|
if (!isMounted()) return;
|
||||||
|
|
||||||
switch (subcall_type) {
|
switch (subcall_type) {
|
||||||
|
@ -102,7 +102,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Basic file ops
|
// Basic file ops
|
||||||
static void openFileRead(char * const path, const uint8_t subcall=0);
|
static void openFileRead(const char * const path, const uint8_t subcall=0);
|
||||||
static void openFileWrite(const char * const path);
|
static void openFileWrite(const char * const path);
|
||||||
static void closefile(const bool store_location=false);
|
static void closefile(const bool store_location=false);
|
||||||
static bool fileExists(const char * const name);
|
static bool fileExists(const char * const name);
|
||||||
|
@ -38,6 +38,13 @@ extra_configs =
|
|||||||
# The 'common' values are used for most Marlin builds
|
# The 'common' values are used for most Marlin builds
|
||||||
#
|
#
|
||||||
[common]
|
[common]
|
||||||
|
build_flags = -fmax-errors=5 -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants -fno-signed-zeros -ffinite-math-only
|
||||||
|
extra_scripts =
|
||||||
|
pre:buildroot/share/PlatformIO/scripts/common-dependencies.py
|
||||||
|
pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py
|
||||||
|
pre:buildroot/share/PlatformIO/scripts/preflight-checks.py
|
||||||
|
post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py
|
||||||
|
lib_deps =
|
||||||
default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
|
default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
|
||||||
-<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dwin> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
|
-<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dwin> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
|
||||||
-<src/HAL/STM32/tft> -<src/HAL/STM32F1/tft>
|
-<src/HAL/STM32/tft> -<src/HAL/STM32F1/tft>
|
||||||
@ -227,13 +234,6 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
|
|||||||
-<src/module/scara.cpp> -<src/gcode/calibrate/M665.cpp>
|
-<src/module/scara.cpp> -<src/gcode/calibrate/M665.cpp>
|
||||||
-<src/module/servo.cpp> -<src/gcode/control/M280.cpp>
|
-<src/module/servo.cpp> -<src/gcode/control/M280.cpp>
|
||||||
-<src/module/stepper/TMC26X.cpp>
|
-<src/module/stepper/TMC26X.cpp>
|
||||||
extra_scripts =
|
|
||||||
pre:buildroot/share/PlatformIO/scripts/common-dependencies.py
|
|
||||||
pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py
|
|
||||||
pre:buildroot/share/PlatformIO/scripts/preflight-checks.py
|
|
||||||
post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py
|
|
||||||
build_flags = -fmax-errors=5 -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants
|
|
||||||
lib_deps =
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Default values apply to all 'env:' prefixed environments
|
# Default values apply to all 'env:' prefixed environments
|
||||||
|
Loading…
Reference in New Issue
Block a user