Reduce math library code size by 3.4KB (#21575)

This commit is contained in:
Scott Lahteine
2021-04-12 16:49:53 -05:00
committed by GitHub
parent 1742fb8655
commit 24a095c5c1
35 changed files with 141 additions and 145 deletions

View File

@ -105,7 +105,7 @@ void GcodeSuite::G35() {
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);
if (isnan(z_probed_height)) {
if (ISNAN(z_probed_height)) {
SERIAL_ECHOPAIR("G35 failed at point ", i, " (");
SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i]));
SERIAL_CHAR(')');

View File

@ -287,11 +287,11 @@ G29_TYPE GcodeSuite::G29() {
G29_RETURN(false);
}
const float rx = RAW_X_POSITION(parser.linearval('X', NAN)),
ry = RAW_Y_POSITION(parser.linearval('Y', NAN));
const float rx = RAW_X_POSITION(parser.linearval('X', MFNAN)),
ry = RAW_Y_POSITION(parser.linearval('Y', MFNAN));
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
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;
@ -608,7 +608,7 @@ G29_TYPE GcodeSuite::G29() {
// Outer loop is X with PROBE_Y_FIRST enabled
// 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;
@ -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);
if (isnan(abl.measured_z)) {
if (ISNAN(abl.measured_z)) {
set_bed_leveling_enabled(abl.reenable);
break; // Breaks out of both loops
}
@ -690,14 +690,14 @@ G29_TYPE GcodeSuite::G29() {
// Retain the last probe position
abl.probePos = points[i];
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);
break;
}
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();
if (planeNormal.z < 0) planeNormal *= -1;
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.
if (probe.stow()) {
set_bed_leveling_enabled(abl.reenable);
abl.measured_z = NAN;
abl.measured_z = MFNAN;
}
}
#endif // !PROBE_MANUALLY
@ -736,7 +736,7 @@ G29_TYPE GcodeSuite::G29() {
#endif
// Calculate leveling, print reports, correct the position
if (!isnan(abl.measured_z)) {
if (!ISNAN(abl.measured_z)) {
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
if (!abl.dryrun) extrapolate_unprobed_bed_level();
@ -873,7 +873,7 @@ G29_TYPE GcodeSuite::G29() {
// Auto Bed Leveling is complete! Enable if possible.
planner.leveling_active = !abl.dryrun || abl.reenable;
} // !isnan(abl.measured_z)
} // !ISNAN(abl.measured_z)
// Restore state after probing
if (!faux) restore_feedrate_and_scaling();
@ -897,7 +897,7 @@ G29_TYPE GcodeSuite::G29() {
report_current_position();
G29_RETURN(isnan(abl.measured_z));
G29_RETURN(ISNAN(abl.measured_z));
}
#endif // HAS_ABL_NOT_UBL

View File

@ -62,7 +62,7 @@ void GcodeSuite::M421() {
SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
else {
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));
}
}