Browse Source

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

Scott Lahteine 3 years ago
parent
commit
24a095c5c1
No account linked to committer's email address
35 changed files with 141 additions and 145 deletions
  1. 3
    0
      Marlin/src/core/macros.h
  2. 7
    7
      Marlin/src/feature/bedlevel/abl/abl.cpp
  3. 2
    2
      Marlin/src/feature/bedlevel/bedlevel.cpp
  4. 5
    2
      Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h
  5. 5
    5
      Marlin/src/feature/bedlevel/ubl/ubl.cpp
  6. 14
    28
      Marlin/src/feature/bedlevel/ubl/ubl.h
  7. 20
    20
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  8. 9
    9
      Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp
  9. 1
    1
      Marlin/src/gcode/bedlevel/G35.cpp
  10. 11
    11
      Marlin/src/gcode/bedlevel/abl/G29.cpp
  11. 1
    1
      Marlin/src/gcode/bedlevel/ubl/M421.cpp
  12. 3
    3
      Marlin/src/gcode/calibrate/G33.cpp
  13. 1
    1
      Marlin/src/gcode/calibrate/G34_M422.cpp
  14. 3
    3
      Marlin/src/gcode/calibrate/G76_M192_M871.cpp
  15. 2
    2
      Marlin/src/gcode/calibrate/M48.cpp
  16. 1
    1
      Marlin/src/gcode/probe/G30.cpp
  17. 2
    2
      Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
  18. 1
    1
      Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
  19. 1
    1
      Marlin/src/lcd/dogm/marlinui_DOGM.cpp
  20. 7
    3
      Marlin/src/lcd/dogm/status_screen_DOGM.cpp
  21. 1
    1
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp
  22. 1
    1
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp
  23. 1
    1
      Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp
  24. 2
    2
      Marlin/src/lcd/extui/ui_api.cpp
  25. 1
    1
      Marlin/src/lcd/menu/menu_tramming.cpp
  26. 1
    1
      Marlin/src/lcd/tft/ui_1024x600.cpp
  27. 1
    1
      Marlin/src/lcd/tft/ui_320x240.cpp
  28. 1
    1
      Marlin/src/lcd/tft/ui_480x320.cpp
  29. 10
    10
      Marlin/src/module/probe.cpp
  30. 4
    4
      Marlin/src/module/probe.h
  31. 7
    7
      Marlin/src/module/settings.cpp
  32. 3
    3
      Marlin/src/module/temperature.h
  33. 1
    1
      Marlin/src/sd/cardreader.cpp
  34. 1
    1
      Marlin/src/sd/cardreader.h
  35. 7
    7
      platformio.ini

+ 3
- 0
Marlin/src/core/macros.h View File

@@ -112,6 +112,9 @@
112 112
 #define SIGN(a) ({__typeof__(a) _a = (a); (_a>0)-(_a<0);})
113 113
 #define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))
114 114
 
115
+#define MFNAN 999999.0f
116
+#define ISNAN(V) ((V) == MFNAN)
117
+
115 118
 // Macros to constrain values
116 119
 #ifdef __cplusplus
117 120
 

+ 7
- 7
Marlin/src/feature/bedlevel/abl/abl.cpp View File

@@ -43,7 +43,7 @@ bed_mesh_t z_values;
43 43
  * Extrapolate a single point from its neighbors
44 44
  */
45 45
 static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) {
46
-  if (!isnan(z_values[x][y])) return;
46
+  if (!ISNAN(z_values[x][y])) return;
47 47
   if (DEBUGGING(LEVELING)) {
48 48
     DEBUG_ECHOPGM("Extrapolate [");
49 49
     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
63 63
         c1 = z_values[x1][y1], c2 = z_values[x2][y2];
64 64
 
65 65
   // Treat far unprobed points as zero, near as equal to far
66
-  if (isnan(a2)) a2 = 0.0;
67
-  if (isnan(a1)) a1 = a2;
68
-  if (isnan(b2)) b2 = 0.0;
69
-  if (isnan(b1)) b1 = b2;
70
-  if (isnan(c2)) c2 = 0.0;
71
-  if (isnan(c1)) c1 = c2;
66
+  if (ISNAN(a2)) a2 = 0.0;
67
+  if (ISNAN(a1)) a1 = a2;
68
+  if (ISNAN(b2)) b2 = 0.0;
69
+  if (ISNAN(b1)) b1 = b2;
70
+  if (ISNAN(c2)) c2 = 0.0;
71
+  if (ISNAN(c1)) c1 = c2;
72 72
 
73 73
   const float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2;
74 74
 

+ 2
- 2
Marlin/src/feature/bedlevel/bedlevel.cpp View File

@@ -132,7 +132,7 @@ void reset_bed_level() {
132 132
       bilinear_start.reset();
133 133
       bilinear_grid_spacing.reset();
134 134
       GRID_LOOP(x, y) {
135
-        z_values[x][y] = NAN;
135
+        z_values[x][y] = MFNAN;
136 136
         TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, 0));
137 137
       }
138 138
     #elif ABL_PLANAR
@@ -177,7 +177,7 @@ void reset_bed_level() {
177 177
       LOOP_L_N(x, sx) {
178 178
         SERIAL_CHAR(' ');
179 179
         const float offset = fn(x, y);
180
-        if (!isnan(offset)) {
180
+        if (!ISNAN(offset)) {
181 181
           if (offset >= 0) SERIAL_CHAR('+');
182 182
           SERIAL_ECHO_F(offset, int(precision));
183 183
         }

+ 5
- 2
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h View File

@@ -97,6 +97,7 @@ public:
97 97
   static inline xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); }
98 98
 
99 99
   static float calc_z0(const_float_t a0, const_float_t a1, const_float_t z1, const_float_t a2, const_float_t z2) {
100
+    if (ISNAN(a0) || ISNAN(a1) || ISNAN(z1) || ISNAN(a2) || ISNAN(z2)) return MFNAN;
100 101
     const float delta_z = (z2 - z1) / (a2 - a1),
101 102
                 delta_a = a0 - a1;
102 103
     return z1 + delta_a * delta_z;
@@ -114,9 +115,11 @@ public:
114 115
     const float x1 = index_to_xpos[ind.x], x2 = index_to_xpos[ind.x+1],
115 116
                 y1 = index_to_xpos[ind.y], y2 = index_to_xpos[ind.y+1],
116 117
                 z1 = calc_z0(pos.x, x1, z_values[ind.x][ind.y  ], x2, z_values[ind.x+1][ind.y  ]),
117
-                z2 = calc_z0(pos.x, x1, z_values[ind.x][ind.y+1], x2, z_values[ind.x+1][ind.y+1]);
118
+                z2 = calc_z0(pos.x, x1, z_values[ind.x][ind.y+1], x2, z_values[ind.x+1][ind.y+1]),
119
+                zf = calc_z0(pos.y, y1, z1, y2, z2);
118 120
 
119
-    return z_offset + calc_z0(pos.y, y1, z1, y2, z2) * factor;
121
+
122
+    return ISNAN(zf) ? zf : z_offset + zf * factor;
120 123
   }
121 124
 
122 125
   #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)

+ 5
- 5
Marlin/src/feature/bedlevel/ubl/ubl.cpp View File

@@ -48,7 +48,7 @@ void unified_bed_leveling::report_current_mesh() {
48 48
   if (!leveling_is_valid()) return;
49 49
   SERIAL_ECHO_MSG("  G29 I999");
50 50
   GRID_LOOP(x, y)
51
-    if (!isnan(z_values[x][y])) {
51
+    if (!ISNAN(z_values[x][y])) {
52 52
       SERIAL_ECHO_START();
53 53
       SERIAL_ECHOPAIR("  M421 I", x, " J", y);
54 54
       SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z_values[x][y], 4);
@@ -99,7 +99,7 @@ void unified_bed_leveling::reset() {
99 99
 
100 100
 void unified_bed_leveling::invalidate() {
101 101
   set_bed_leveling_enabled(false);
102
-  set_all_mesh_points_to_value(NAN);
102
+  set_all_mesh_points_to_value(MFNAN);
103 103
 }
104 104
 
105 105
 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) {
116 116
 
117 117
   void unified_bed_leveling::set_store_from_mesh(const bed_mesh_t &in_values, mesh_store_t &stored_values) {
118 118
     auto z_to_store = [](const_float_t z) {
119
-      if (isnan(z)) return Z_STEPS_NAN;
119
+      if (ISNAN(z)) return Z_STEPS_NAN;
120 120
       const int32_t z_scaled = TRUNC(z * mesh_store_scaling);
121 121
       if (z_scaled == Z_STEPS_NAN || !WITHIN(z_scaled, INT16_MIN, INT16_MAX))
122 122
         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) {
127 127
 
128 128
   void unified_bed_leveling::set_mesh_from_store(const mesh_store_t &stored_values, bed_mesh_t &out_values) {
129 129
     auto store_to_z = [](const int16_t z_scaled) {
130
-      return z_scaled == Z_STEPS_NAN ? NAN : z_scaled / mesh_store_scaling;
130
+      return z_scaled == Z_STEPS_NAN ? MFNAN : z_scaled / mesh_store_scaling;
131 131
     };
132 132
     GRID_LOOP(x, y) out_values[x][y] = store_to_z(stored_values[x][y]);
133 133
   }
@@ -211,7 +211,7 @@ void unified_bed_leveling::display_map(const int map_type) {
211 211
       if (lcd) {
212 212
         // TODO: Display on Graphical LCD
213 213
       }
214
-      else if (isnan(f))
214
+      else if (ISNAN(f))
215 215
         SERIAL_ECHOPGM_P(human ? PSTR("  .   ") : PSTR("NAN"));
216 216
       else if (human || csv) {
217 217
         if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' ');  // Display sign also for positive numbers (' ' for 0)

+ 14
- 28
Marlin/src/feature/bedlevel/ubl/ubl.h View File

@@ -196,7 +196,7 @@ public:
196 196
   #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
197 197
     #define _UBL_OUTER_Z_RAISE UBL_Z_RAISE_WHEN_OFF_MESH
198 198
   #else
199
-    #define _UBL_OUTER_Z_RAISE NAN
199
+    #define _UBL_OUTER_Z_RAISE MFNAN
200 200
   #endif
201 201
 
202 202
   /**
@@ -264,39 +264,25 @@ public:
264 264
         return UBL_Z_RAISE_WHEN_OFF_MESH;
265 265
     #endif
266 266
 
267
-    const float z1 = calc_z0(rx0,
268
-                             mesh_index_to_xpos(cx), z_values[cx][cy],
269
-                             mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, (GRID_MAX_POINTS_X) - 2) + 1][cy]);
267
+    const uint8_t mx = _MIN(cx, (GRID_MAX_POINTS_X) - 2) + 1, my = _MIN(cy, (GRID_MAX_POINTS_Y) - 2) + 1;
268
+    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]);
269
+    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]);
270
+    float z0 = calc_z0(ry0, mesh_index_to_ypos(cy), z1, mesh_index_to_ypos(cy + 1), z2);
270 271
 
271
-    const float z2 = calc_z0(rx0,
272
-                             mesh_index_to_xpos(cx), z_values[cx][_MIN(cy, (GRID_MAX_POINTS_Y) - 2) + 1],
273
-                             mesh_index_to_xpos(cx + 1), z_values[_MIN(cx, (GRID_MAX_POINTS_X) - 2) + 1][_MIN(cy, (GRID_MAX_POINTS_Y) - 2) + 1]);
274
-
275
-    float z0 = calc_z0(ry0,
276
-                       mesh_index_to_ypos(cy), z1,
277
-                       mesh_index_to_ypos(cy + 1), z2);
278
-
279
-    if (DEBUGGING(MESH_ADJUST)) {
280
-      DEBUG_ECHOPAIR(" raw get_z_correction(", rx0);
281
-      DEBUG_CHAR(','); DEBUG_ECHO(ry0);
282
-      DEBUG_ECHOPAIR_F(") = ", z0, 6);
283
-      DEBUG_ECHOLNPAIR_F(" >>>---> ", z0, 6);
284
-    }
285
-
286
-    if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN
272
+    if (ISNAN(z0)) { // if part of the Mesh is undefined, it will show up as MFNAN
287 273
       z0 = 0.0;      // in ubl.z_values[][] and propagate through the
288 274
                      // calculations. If our correction is NAN, we throw it out
289 275
                      // because part of the Mesh is undefined and we don't have the
290 276
                      // information we need to complete the height correction.
291 277
 
292
-      if (DEBUGGING(MESH_ADJUST)) {
293
-        DEBUG_ECHOPAIR("??? Yikes!  NAN in get_z_correction(", rx0);
294
-        DEBUG_CHAR(',');
295
-        DEBUG_ECHO(ry0);
296
-        DEBUG_CHAR(')');
297
-        DEBUG_EOL();
298
-      }
278
+      if (DEBUGGING(MESH_ADJUST)) DEBUG_ECHOLNPAIR("??? Yikes! NAN in ");
299 279
     }
280
+
281
+    if (DEBUGGING(MESH_ADJUST)) {
282
+      DEBUG_ECHOPAIR("get_z_correction(", rx0, ", ", ry0);
283
+      DEBUG_ECHOLNPAIR_F(") => ", z0, 6);
284
+    }
285
+
300 286
     return z0;
301 287
   }
302 288
   static inline float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); }
@@ -315,7 +301,7 @@ public:
315 301
   #endif
316 302
 
317 303
   static inline bool mesh_is_valid() {
318
-    GRID_LOOP(x, y) if (isnan(z_values[x][y])) return false;
304
+    GRID_LOOP(x, y) if (ISNAN(z_values[x][y])) return false;
319 305
     return true;
320 306
   }
321 307
 

+ 20
- 20
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp View File

@@ -331,7 +331,7 @@ void unified_bed_leveling::G29() {
331 331
         // to invalidate the ENTIRE mesh, which can't be done with
332 332
         // find_closest_mesh_point (which only returns REAL points).
333 333
         if (closest.pos.x < 0) { invalidate_all = true; break; }
334
-        z_values[closest.pos.x][closest.pos.y] = NAN;
334
+        z_values[closest.pos.x][closest.pos.y] = MFNAN;
335 335
         TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(closest.pos, 0.0f));
336 336
       }
337 337
     }
@@ -516,7 +516,7 @@ void unified_bed_leveling::G29() {
516 516
               if (cpos.x < 0) {
517 517
                 // No more REAL INVALID mesh points to populate, so we ASSUME
518 518
                 // user meant to populate ALL INVALID mesh points to value
519
-                GRID_LOOP(x, y) if (isnan(z_values[x][y])) z_values[x][y] = param.C_constant;
519
+                GRID_LOOP(x, y) if (ISNAN(z_values[x][y])) z_values[x][y] = param.C_constant;
520 520
                 break; // No more invalid Mesh Points to populate
521 521
               }
522 522
               else {
@@ -675,7 +675,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o
675 675
   float sum = 0;
676 676
   int n = 0;
677 677
   GRID_LOOP(x, y)
678
-    if (!isnan(z_values[x][y])) {
678
+    if (!ISNAN(z_values[x][y])) {
679 679
       sum += z_values[x][y];
680 680
       n++;
681 681
     }
@@ -687,7 +687,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o
687 687
   //
688 688
   float sum_of_diff_squared = 0;
689 689
   GRID_LOOP(x, y)
690
-    if (!isnan(z_values[x][y]))
690
+    if (!ISNAN(z_values[x][y]))
691 691
       sum_of_diff_squared += sq(z_values[x][y] - mean);
692 692
 
693 693
   SERIAL_ECHOLNPAIR("# of samples: ", n);
@@ -698,7 +698,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o
698 698
 
699 699
   if (cflag)
700 700
     GRID_LOOP(x, y)
701
-      if (!isnan(z_values[x][y])) {
701
+      if (!ISNAN(z_values[x][y])) {
702 702
         z_values[x][y] -= mean + offset;
703 703
         TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
704 704
       }
@@ -709,7 +709,7 @@ void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t o
709 709
  */
710 710
 void unified_bed_leveling::shift_mesh_height() {
711 711
   GRID_LOOP(x, y)
712
-    if (!isnan(z_values[x][y])) {
712
+    if (!ISNAN(z_values[x][y])) {
713 713
       z_values[x][y] += param.C_constant;
714 714
       TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
715 715
     }
@@ -1017,7 +1017,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
1017 1017
       ui.refresh();
1018 1018
 
1019 1019
       float new_z = z_values[lpos.x][lpos.y];
1020
-      if (isnan(new_z)) new_z = 0;                        // Invalid points begin at 0
1020
+      if (ISNAN(new_z)) new_z = 0;                        // Invalid points begin at 0
1021 1021
       new_z = FLOOR(new_z * 1000) * 0.001f;               // Chop off digits after the 1000ths place
1022 1022
 
1023 1023
       ui.ubl_mesh_edit_start(new_z);
@@ -1227,7 +1227,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
1227 1227
   mesh_index_pair farthest { -1, -1, -99999.99 };
1228 1228
 
1229 1229
   GRID_LOOP(i, j) {
1230
-    if (!isnan(z_values[i][j])) continue;  // Skip valid mesh points
1230
+    if (!ISNAN(z_values[i][j])) continue;  // Skip valid mesh points
1231 1231
 
1232 1232
     // Skip unreachable points
1233 1233
     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() {
1238 1238
     xy_int8_t nearby { -1, -1 };
1239 1239
     float d1, d2 = 99999.9f;
1240 1240
     GRID_LOOP(k, l) {
1241
-      if (isnan(z_values[k][l])) continue;
1241
+      if (ISNAN(z_values[k][l])) continue;
1242 1242
 
1243 1243
       found_a_real = true;
1244 1244
 
@@ -1282,7 +1282,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
1282 1282
 
1283 1283
   static bool test_func(uint8_t i, uint8_t j, void *data) {
1284 1284
     find_closest_t *d = (find_closest_t*)data;
1285
-    if ( (d->type == (isnan(ubl.z_values[i][j]) ? INVALID : REAL))
1285
+    if ( (d->type == (ISNAN(ubl.z_values[i][j]) ? INVALID : REAL))
1286 1286
       || (d->type == SET_IN_BITMAP && !d->done_flags->marked(i, j))
1287 1287
     ) {
1288 1288
       // 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
1326 1326
     float best_so_far = 99999.99f;
1327 1327
 
1328 1328
     GRID_LOOP(i, j) {
1329
-      if ( (type == (isnan(z_values[i][j]) ? INVALID : REAL))
1329
+      if ( (type == (ISNAN(z_values[i][j]) ? INVALID : REAL))
1330 1330
         || (type == SET_IN_BITMAP && !done_flags->marked(i, j))
1331 1331
       ) {
1332 1332
         // 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
1367 1367
 
1368 1368
 bool unified_bed_leveling::smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) {
1369 1369
   const float v = z_values[x][y];
1370
-  if (isnan(v)) {                           // A NAN...
1370
+  if (ISNAN(v)) {                           // A NAN...
1371 1371
     const int8_t dx = x + xdir, dy = y + ydir;
1372 1372
     const float v1 = z_values[dx][dy];
1373
-    if (!isnan(v1)) {                       // ...next to a pair of real values?
1373
+    if (!ISNAN(v1)) {                       // ...next to a pair of real values?
1374 1374
       const float v2 = z_values[dx + xdir][dy + ydir];
1375
-      if (!isnan(v2)) {
1375
+      if (!ISNAN(v2)) {
1376 1376
         z_values[x][y] = v1 < v2 ? v1 : v1 + v1 - v2;
1377 1377
         TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
1378 1378
         return true;
@@ -1441,7 +1441,7 @@ void unified_bed_leveling::smart_fill_mesh() {
1441 1441
       TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
1442 1442
 
1443 1443
       measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, param.V_verbosity);
1444
-      if (isnan(measured_z))
1444
+      if (ISNAN(measured_z))
1445 1445
         abort_flag = true;
1446 1446
       else {
1447 1447
         measured_z -= get_z_correction(points[0]);
@@ -1463,7 +1463,7 @@ void unified_bed_leveling::smart_fill_mesh() {
1463 1463
         #ifdef VALIDATE_MESH_TILT
1464 1464
           z2 = measured_z;
1465 1465
         #endif
1466
-        if (isnan(measured_z))
1466
+        if (ISNAN(measured_z))
1467 1467
           abort_flag = true;
1468 1468
         else {
1469 1469
           measured_z -= get_z_correction(points[1]);
@@ -1483,7 +1483,7 @@ void unified_bed_leveling::smart_fill_mesh() {
1483 1483
         #ifdef VALIDATE_MESH_TILT
1484 1484
           z3 = measured_z;
1485 1485
         #endif
1486
-        if (isnan(measured_z))
1486
+        if (ISNAN(measured_z))
1487 1487
           abort_flag = true;
1488 1488
         else {
1489 1489
           measured_z -= get_z_correction(points[2]);
@@ -1522,7 +1522,7 @@ void unified_bed_leveling::smart_fill_mesh() {
1522 1522
 
1523 1523
             measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling
1524 1524
 
1525
-            abort_flag = isnan(measured_z);
1525
+            abort_flag = ISNAN(measured_z);
1526 1526
 
1527 1527
             #if ENABLED(DEBUG_LEVELING_FEATURE)
1528 1528
               if (DEBUGGING(LEVELING)) {
@@ -1673,14 +1673,14 @@ void unified_bed_leveling::smart_fill_mesh() {
1673 1673
 
1674 1674
     const float weight_scaled = weight_factor * _MAX(MESH_X_DIST, MESH_Y_DIST);
1675 1675
 
1676
-    GRID_LOOP(jx, jy) if (!isnan(z_values[jx][jy])) SBI(bitmap[jx], jy);
1676
+    GRID_LOOP(jx, jy) if (!ISNAN(z_values[jx][jy])) SBI(bitmap[jx], jy);
1677 1677
 
1678 1678
     xy_pos_t ppos;
1679 1679
     LOOP_L_N(ix, GRID_MAX_POINTS_X) {
1680 1680
       ppos.x = mesh_index_to_xpos(ix);
1681 1681
       LOOP_L_N(iy, GRID_MAX_POINTS_Y) {
1682 1682
         ppos.y = mesh_index_to_ypos(iy);
1683
-        if (isnan(z_values[ix][iy])) {
1683
+        if (ISNAN(z_values[ix][iy])) {
1684 1684
           // undefined mesh point at (ppos.x,ppos.y), compute weighted LSF from original valid mesh points.
1685 1685
           incremental_LSF_reset(&lsf_results);
1686 1686
           xy_pos_t rpos;

+ 9
- 9
Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp View File

@@ -85,7 +85,7 @@
85 85
 
86 86
       // Undefined parts of the Mesh in z_values[][] are NAN.
87 87
       // Replace NAN corrections with 0.0 to prevent NAN propagation.
88
-      if (!isnan(z0)) end.z += z0;
88
+      if (!ISNAN(z0)) end.z += z0;
89 89
       planner.buffer_segment(end, scaled_fr_mm_s, extruder);
90 90
       current_position = destination;
91 91
       return;
@@ -150,7 +150,7 @@
150 150
 
151 151
         // Undefined parts of the Mesh in z_values[][] are NAN.
152 152
         // Replace NAN corrections with 0.0 to prevent NAN propagation.
153
-        if (isnan(z0)) z0 = 0.0;
153
+        if (ISNAN(z0)) z0 = 0.0;
154 154
 
155 155
         const float ry = mesh_index_to_ypos(icell.y);
156 156
 
@@ -198,7 +198,7 @@
198 198
 
199 199
         // Undefined parts of the Mesh in z_values[][] are NAN.
200 200
         // Replace NAN corrections with 0.0 to prevent NAN propagation.
201
-        if (isnan(z0)) z0 = 0.0;
201
+        if (ISNAN(z0)) z0 = 0.0;
202 202
 
203 203
         /**
204 204
          * Without this check, it's possible to generate a zero length move, as in the case where
@@ -253,7 +253,7 @@
253 253
 
254 254
         // Undefined parts of the Mesh in z_values[][] are NAN.
255 255
         // Replace NAN corrections with 0.0 to prevent NAN propagation.
256
-        if (isnan(z0)) z0 = 0.0;
256
+        if (ISNAN(z0)) z0 = 0.0;
257 257
 
258 258
         if (!inf_normalized_flag) {
259 259
           on_axis_distance = use_x_dist ? rx - start.x : next_mesh_line_y - start.y;
@@ -276,7 +276,7 @@
276 276
 
277 277
         // Undefined parts of the Mesh in z_values[][] are NAN.
278 278
         // Replace NAN corrections with 0.0 to prevent NAN propagation.
279
-        if (isnan(z0)) z0 = 0.0;
279
+        if (ISNAN(z0)) z0 = 0.0;
280 280
 
281 281
         if (!inf_normalized_flag) {
282 282
           on_axis_distance = use_x_dist ? next_mesh_line_x - start.x : ry - start.y;
@@ -405,10 +405,10 @@
405 405
             z_x0y1 = z_values[icell.x  ][icell.y+1],  // z at lower right corner
406 406
             z_x1y1 = z_values[icell.x+1][icell.y+1];  // z at upper right corner
407 407
 
408
-      if (isnan(z_x0y0)) z_x0y0 = 0;              // ideally activating planner.leveling_active (G29 A)
409
-      if (isnan(z_x1y0)) z_x1y0 = 0;              //   should refuse if any invalid mesh points
410
-      if (isnan(z_x0y1)) z_x0y1 = 0;              //   in order to avoid isnan tests per cell,
411
-      if (isnan(z_x1y1)) z_x1y1 = 0;              //   thus guessing zero for undefined points
408
+      if (ISNAN(z_x0y0)) z_x0y0 = 0;              // ideally activating planner.leveling_active (G29 A)
409
+      if (ISNAN(z_x1y0)) z_x1y0 = 0;              //   should refuse if any invalid mesh points
410
+      if (ISNAN(z_x0y1)) z_x0y1 = 0;              //   in order to avoid ISNAN tests per cell,
411
+      if (ISNAN(z_x1y1)) z_x1y1 = 0;              //   thus guessing zero for undefined points
412 412
 
413 413
       const xy_pos_t pos = { mesh_index_to_xpos(icell.x), mesh_index_to_ypos(icell.y) };
414 414
       xy_pos_t cell = raw - pos;

+ 1
- 1
Marlin/src/gcode/bedlevel/G35.cpp View File

@@ -105,7 +105,7 @@ void GcodeSuite::G35() {
105 105
     do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, Z_CLEARANCE_BETWEEN_PROBES, 7));
106 106
     const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[i], PROBE_PT_RAISE, 0, true);
107 107
 
108
-    if (isnan(z_probed_height)) {
108
+    if (ISNAN(z_probed_height)) {
109 109
       SERIAL_ECHOPAIR("G35 failed at point ", i, " (");
110 110
       SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i]));
111 111
       SERIAL_CHAR(')');

+ 11
- 11
Marlin/src/gcode/bedlevel/abl/G29.cpp View File

@@ -287,11 +287,11 @@ G29_TYPE GcodeSuite::G29() {
287 287
           G29_RETURN(false);
288 288
         }
289 289
 
290
-        const float rx = RAW_X_POSITION(parser.linearval('X', NAN)),
291
-                    ry = RAW_Y_POSITION(parser.linearval('Y', NAN));
290
+        const float rx = RAW_X_POSITION(parser.linearval('X', MFNAN)),
291
+                    ry = RAW_Y_POSITION(parser.linearval('Y', MFNAN));
292 292
         int8_t i = parser.byteval('I', -1), j = parser.byteval('J', -1);
293 293
 
294
-        if (!isnan(rx) && !isnan(ry)) {
294
+        if (!ISNAN(rx) && !ISNAN(ry)) {
295 295
           // Get nearest i / j from rx / ry
296 296
           i = (rx - bilinear_start.x + 0.5 * abl.gridSpacing.x) / abl.gridSpacing.x;
297 297
           j = (ry - bilinear_start.y + 0.5 * abl.gridSpacing.y) / abl.gridSpacing.y;
@@ -608,7 +608,7 @@ G29_TYPE GcodeSuite::G29() {
608 608
 
609 609
       // Outer loop is X with PROBE_Y_FIRST enabled
610 610
       // Outer loop is Y with PROBE_Y_FIRST disabled
611
-      for (PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_SIZE && !isnan(abl.measured_z); PR_OUTER_VAR++) {
611
+      for (PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_SIZE && !ISNAN(abl.measured_z); PR_OUTER_VAR++) {
612 612
 
613 613
         int8_t inStart, inStop, inInc;
614 614
 
@@ -644,7 +644,7 @@ G29_TYPE GcodeSuite::G29() {
644 644
 
645 645
           abl.measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level);
646 646
 
647
-          if (isnan(abl.measured_z)) {
647
+          if (ISNAN(abl.measured_z)) {
648 648
             set_bed_leveling_enabled(abl.reenable);
649 649
             break; // Breaks out of both loops
650 650
           }
@@ -690,14 +690,14 @@ G29_TYPE GcodeSuite::G29() {
690 690
         // Retain the last probe position
691 691
         abl.probePos = points[i];
692 692
         abl.measured_z = faux ? 0.001 * random(-100, 101) : probe.probe_at_point(abl.probePos, raise_after, abl.verbose_level);
693
-        if (isnan(abl.measured_z)) {
693
+        if (ISNAN(abl.measured_z)) {
694 694
           set_bed_leveling_enabled(abl.reenable);
695 695
           break;
696 696
         }
697 697
         points[i].z = abl.measured_z;
698 698
       }
699 699
 
700
-      if (!abl.dryrun && !isnan(abl.measured_z)) {
700
+      if (!abl.dryrun && !ISNAN(abl.measured_z)) {
701 701
         vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal();
702 702
         if (planeNormal.z < 0) planeNormal *= -1;
703 703
         planner.bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
@@ -713,7 +713,7 @@ G29_TYPE GcodeSuite::G29() {
713 713
     // Stow the probe. No raise for FIX_MOUNTED_PROBE.
714 714
     if (probe.stow()) {
715 715
       set_bed_leveling_enabled(abl.reenable);
716
-      abl.measured_z = NAN;
716
+      abl.measured_z = MFNAN;
717 717
     }
718 718
   }
719 719
   #endif // !PROBE_MANUALLY
@@ -736,7 +736,7 @@ G29_TYPE GcodeSuite::G29() {
736 736
   #endif
737 737
 
738 738
   // Calculate leveling, print reports, correct the position
739
-  if (!isnan(abl.measured_z)) {
739
+  if (!ISNAN(abl.measured_z)) {
740 740
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
741 741
 
742 742
       if (!abl.dryrun) extrapolate_unprobed_bed_level();
@@ -873,7 +873,7 @@ G29_TYPE GcodeSuite::G29() {
873 873
 
874 874
     // Auto Bed Leveling is complete! Enable if possible.
875 875
     planner.leveling_active = !abl.dryrun || abl.reenable;
876
-  } // !isnan(abl.measured_z)
876
+  } // !ISNAN(abl.measured_z)
877 877
 
878 878
   // Restore state after probing
879 879
   if (!faux) restore_feedrate_and_scaling();
@@ -897,7 +897,7 @@ G29_TYPE GcodeSuite::G29() {
897 897
 
898 898
   report_current_position();
899 899
 
900
-  G29_RETURN(isnan(abl.measured_z));
900
+  G29_RETURN(ISNAN(abl.measured_z));
901 901
 }
902 902
 
903 903
 #endif // HAS_ABL_NOT_UBL

+ 1
- 1
Marlin/src/gcode/bedlevel/ubl/M421.cpp View File

@@ -62,7 +62,7 @@ void GcodeSuite::M421() {
62 62
     SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
63 63
   else {
64 64
     float &zval = ubl.z_values[ij.x][ij.y];
65
-    zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0);
65
+    zval = hasN ? MFNAN : parser.value_linear_units() + (hasQ ? zval : 0);
66 66
     TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval));
67 67
   }
68 68
 }

+ 3
- 3
Marlin/src/gcode/calibrate/G33.cpp View File

@@ -212,7 +212,7 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi
212 212
     if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center
213 213
       const xy_pos_t center{0};
214 214
       z_pt[CEN] += calibration_probe(center, stow_after_each);
215
-      if (isnan(z_pt[CEN])) return false;
215
+      if (ISNAN(z_pt[CEN])) return false;
216 216
     }
217 217
 
218 218
     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
223 223
                     r = dcr * 0.1;
224 224
         const xy_pos_t vec = { cos(a), sin(a) };
225 225
         z_pt[CEN] += calibration_probe(vec * r, stow_after_each);
226
-        if (isnan(z_pt[CEN])) return false;
226
+        if (ISNAN(z_pt[CEN])) return false;
227 227
      }
228 228
       z_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points);
229 229
     }
@@ -248,7 +248,7 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi
248 248
                       interpol = FMOD(rad, 1);
249 249
           const xy_pos_t vec = { cos(a), sin(a) };
250 250
           const float z_temp = calibration_probe(vec * r, stow_after_each);
251
-          if (isnan(z_temp)) return false;
251
+          if (ISNAN(z_temp)) return false;
252 252
           // split probe point to neighbouring calibration points
253 253
           z_pt[uint8_t(LROUND(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
254 254
           z_pt[uint8_t(LROUND(rad - interpol))           % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));

+ 1
- 1
Marlin/src/gcode/calibrate/G34_M422.cpp View File

@@ -229,7 +229,7 @@ void GcodeSuite::G34() {
229 229
           // Probing sanity check is disabled, as it would trigger even in normal cases because
230 230
           // current_position.z has been manually altered in the "dirty trick" above.
231 231
           const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true, false);
232
-          if (isnan(z_probed_height)) {
232
+          if (ISNAN(z_probed_height)) {
233 233
             SERIAL_ECHOLNPGM("Probing failed");
234 234
             LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
235 235
             err_break = true;

+ 3
- 3
Marlin/src/gcode/calibrate/G76_M192_M871.cpp View File

@@ -113,7 +113,7 @@ void GcodeSuite::G76() {
113 113
   auto g76_probe = [](const TempSensorID sid, uint16_t &targ, const xy_pos_t &nozpos) {
114 114
     do_z_clearance(5.0); // Raise nozzle before probing
115 115
     const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false);  // verbose=0, probe_relative=false
116
-    if (isnan(measured_z))
116
+    if (ISNAN(measured_z))
117 117
       SERIAL_ECHOLNPGM("!Received NAN. Aborting.");
118 118
     else {
119 119
       SERIAL_ECHOLNPAIR_F("Measured: ", measured_z);
@@ -208,7 +208,7 @@ void GcodeSuite::G76() {
208 208
         report_temps(next_temp_report);
209 209
 
210 210
       const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz);
211
-      if (isnan(measured_z) || target_bed > BED_MAX_TARGET) break;
211
+      if (ISNAN(measured_z) || target_bed > BED_MAX_TARGET) break;
212 212
     }
213 213
 
214 214
     SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
@@ -267,7 +267,7 @@ void GcodeSuite::G76() {
267 267
       if (timeout) break;
268 268
 
269 269
       const float measured_z = g76_probe(TSI_PROBE, target_probe, noz_pos_xyz);
270
-      if (isnan(measured_z) || target_probe > cali_info_init[TSI_PROBE].end_temp) break;
270
+      if (ISNAN(measured_z) || target_probe > cali_info_init[TSI_PROBE].end_temp) break;
271 271
     }
272 272
 
273 273
     SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());

+ 2
- 2
Marlin/src/gcode/calibrate/M48.cpp View File

@@ -134,7 +134,7 @@ void GcodeSuite::M48() {
134 134
 
135 135
   // Move to the first point, deploy, and probe
136 136
   const float t = probe.probe_at_point(test_position, raise_after, verbose_level);
137
-  bool probing_good = !isnan(t);
137
+  bool probing_good = !ISNAN(t);
138 138
 
139 139
   if (probing_good) {
140 140
     randomSeed(millis());
@@ -219,7 +219,7 @@ void GcodeSuite::M48() {
219 219
       const float pz = probe.probe_at_point(test_position, raise_after, 0);
220 220
 
221 221
       // Break the loop if the probe fails
222
-      probing_good = !isnan(pz);
222
+      probing_good = !ISNAN(pz);
223 223
       if (!probing_good) break;
224 224
 
225 225
       // Store the new sample

+ 1
- 1
Marlin/src/gcode/probe/G30.cpp View File

@@ -52,7 +52,7 @@ void GcodeSuite::G30() {
52 52
 
53 53
   const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
54 54
   const float measured_z = probe.probe_at_point(pos, raise_after, 1);
55
-  if (!isnan(measured_z))
55
+  if (!ISNAN(measured_z))
56 56
     SERIAL_ECHOLNPAIR("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z);
57 57
 
58 58
   restore_feedrate_and_scaling();

+ 2
- 2
Marlin/src/lcd/HD44780/marlinui_HD44780.cpp View File

@@ -1457,7 +1457,7 @@ void MarlinUI::draw_status_screen() {
1457 1457
          * Print Z values
1458 1458
          */
1459 1459
         _ZLABEL(_LCD_W_POS, 1);
1460
-        if (!isnan(ubl.z_values[x_plot][y_plot]))
1460
+        if (!ISNAN(ubl.z_values[x_plot][y_plot]))
1461 1461
           lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1462 1462
         else
1463 1463
           lcd_put_u8str_P(PSTR(" -----"));
@@ -1476,7 +1476,7 @@ void MarlinUI::draw_status_screen() {
1476 1476
          * Show the location value
1477 1477
          */
1478 1478
         _ZLABEL(_LCD_W_POS, 3);
1479
-        if (!isnan(ubl.z_values[x_plot][y_plot]))
1479
+        if (!ISNAN(ubl.z_values[x_plot][y_plot]))
1480 1480
           lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1481 1481
         else
1482 1482
           lcd_put_u8str_P(PSTR(" -----"));

+ 1
- 1
Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp View File

@@ -941,7 +941,7 @@ void MarlinUI::draw_status_screen() {
941 941
       // Show the location value
942 942
       lcd.setCursor(_LCD_W_POS, 3); lcd_put_u8str_P(PSTR("Z:"));
943 943
 
944
-      if (!isnan(ubl.z_values[x_plot][y_plot]))
944
+      if (!ISNAN(ubl.z_values[x_plot][y_plot]))
945 945
         lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
946 946
       else
947 947
         lcd_put_u8str_P(PSTR(" -----"));

+ 1
- 1
Marlin/src/lcd/dogm/marlinui_DOGM.cpp View File

@@ -569,7 +569,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
569 569
 
570 570
         // Show the location value
571 571
         lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL);
572
-        if (!isnan(ubl.z_values[x_plot][y_plot]))
572
+        if (!ISNAN(ubl.z_values[x_plot][y_plot]))
573 573
           lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
574 574
         else
575 575
           lcd_put_u8str_P(PSTR(" -----"));

+ 7
- 3
Marlin/src/lcd/dogm/status_screen_DOGM.cpp View File

@@ -835,13 +835,17 @@ void MarlinUI::draw_status_screen() {
835 835
             mix_label = PSTR("Mx");
836 836
           }
837 837
 
838
-        #pragma GCC diagnostic push
839
-        #pragma GCC diagnostic ignored "-Wformat-overflow"
838
+        #if GCC_VERSION <= 50000
839
+          #pragma GCC diagnostic push
840
+          #pragma GCC diagnostic ignored "-Wformat-overflow"
841
+        #endif
840 842
 
841 843
         sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
842 844
         lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages);
843 845
 
844
-        #pragma GCC diagnostic pop
846
+        #if GCC_VERSION <= 50000
847
+          #pragma GCC diagnostic pop
848
+        #endif
845 849
 
846 850
       #else
847 851
 

+ 1
- 1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extended/adjuster_widget.cpp View File

@@ -32,7 +32,7 @@
32 32
 namespace FTDI {
33 33
   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) {
34 34
     char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)];
35
-    if (isnan(value))
35
+    if (ISNAN(value))
36 36
       strcpy_P(str, PSTR("-"));
37 37
     else
38 38
       dtostrf(value, width, precision, str);

+ 1
- 1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_base.cpp View File

@@ -31,7 +31,7 @@ void BedMeshBase::_drawMesh(CommandProcessor &cmd, int16_t x, int16_t y, int16_t
31 31
   constexpr uint8_t cols = GRID_MAX_POINTS_X;
32 32
 
33 33
   #define VALUE(X,Y)  (func ? func(X,Y,data) : 0)
34
-  #define ISVAL(X,Y)  (func ? !isnan(VALUE(X,Y)) : true)
34
+  #define ISVAL(X,Y)  (func ? !ISNAN(VALUE(X,Y)) : true)
35 35
   #define HEIGHT(X,Y) (ISVAL(X,Y) ? (VALUE(X,Y) - val_min) * scale_z : 0)
36 36
 
37 37
   // Compute the mean, min and max for the points

+ 1
- 1
Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/bed_mesh_edit_screen.cpp View File

@@ -70,7 +70,7 @@ void BedMeshEditScreen::onEntry() {
70 70
 
71 71
 float BedMeshEditScreen::getHighlightedValue() {
72 72
   const float val = ExtUI::getMeshPoint(mydata.highlight);
73
-  return (isnan(val) ? 0 : val) + mydata.zAdjustment;
73
+  return (ISNAN(val) ? 0 : val) + mydata.zAdjustment;
74 74
 }
75 75
 
76 76
 void BedMeshEditScreen::setHighlightedValue(float value) {

+ 2
- 2
Marlin/src/lcd/extui/ui_api.cpp View File

@@ -421,7 +421,7 @@ namespace ExtUI {
421 421
         #if AXIS_IS_TMC(Z2)
422 422
           case Z2: return stepperZ2.getMilliamps();
423 423
         #endif
424
-        default: return NAN;
424
+        default: return MFNAN;
425 425
       };
426 426
     }
427 427
 
@@ -451,7 +451,7 @@ namespace ExtUI {
451 451
         #if AXIS_IS_TMC(E7)
452 452
           case E7: return stepperE7.getMilliamps();
453 453
         #endif
454
-        default: return NAN;
454
+        default: return MFNAN;
455 455
       };
456 456
     }
457 457
 

+ 1
- 1
Marlin/src/lcd/menu/menu_tramming.cpp View File

@@ -54,7 +54,7 @@ static bool probe_single_point() {
54 54
   z_measured[tram_index] = z_probed_height;
55 55
   move_to_tramming_wait_pos();
56 56
 
57
-  return !isnan(z_probed_height);
57
+  return !ISNAN(z_probed_height);
58 58
 }
59 59
 
60 60
 static void _menu_single_probe(const uint8_t point) {

+ 1
- 1
Marlin/src/lcd/tft/ui_1024x600.cpp View File

@@ -505,7 +505,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
505 505
     tft.set_background(COLOR_BACKGROUND);
506 506
     tft_string.set(Z_LBL);
507 507
     tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
508
-    tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
508
+    tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
509 509
     tft_string.trim();
510 510
     tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
511 511
 

+ 1
- 1
Marlin/src/lcd/tft/ui_320x240.cpp View File

@@ -492,7 +492,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
492 492
     tft.set_background(COLOR_BACKGROUND);
493 493
     tft_string.set(Z_LBL);
494 494
     tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
495
-    tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
495
+    tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
496 496
     tft_string.trim();
497 497
     tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
498 498
 

+ 1
- 1
Marlin/src/lcd/tft/ui_480x320.cpp View File

@@ -492,7 +492,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
492 492
     tft.set_background(COLOR_BACKGROUND);
493 493
     tft_string.set(Z_LBL);
494 494
     tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
495
-    tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
495
+    tft_string.set(ISNAN(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
496 496
     tft_string.trim();
497 497
     tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
498 498
 

+ 10
- 10
Marlin/src/module/probe.cpp View File

@@ -583,7 +583,7 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
583 583
  * @details Used by probe_at_point to get the bed Z height at the current XY.
584 584
  *          Leaves current_position.z at the height where the probe triggered.
585 585
  *
586
- * @return The Z position of the bed at the current XY or NAN on error.
586
+ * @return The Z position of the bed at the current XY or MFNAN on error.
587 587
  */
588 588
 float Probe::run_z_probe(const bool sanity_check/*=true*/) {
589 589
   DEBUG_SECTION(log_probe, "Probe::run_z_probe", DEBUGGING(LEVELING));
@@ -617,11 +617,11 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
617 617
   #if TOTAL_PROBING == 2
618 618
 
619 619
     // Attempt to tare the probe
620
-    if (TERN0(PROBE_TARE, tare())) return NAN;
620
+    if (TERN0(PROBE_TARE, tare())) return MFNAN;
621 621
 
622 622
     // Do a first probe at the fast speed
623 623
     if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s,
624
-                     sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN;
624
+                     sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return MFNAN;
625 625
 
626 626
     const float first_probe_z = current_position.z;
627 627
 
@@ -662,7 +662,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
662 662
 
663 663
       // Probe downward slowly to find the bed
664 664
       if (try_to_probe(PSTR("SLOW"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW),
665
-                       sanity_check, Z_CLEARANCE_MULTI_PROBE) ) return NAN;
665
+                       sanity_check, Z_CLEARANCE_MULTI_PROBE) ) return MFNAN;
666 666
 
667 667
       TERN_(MEASURE_BACKLASH_WHEN_PROBING, backlash.measure_with_probe());
668 668
 
@@ -765,29 +765,29 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
765 765
   if (probe_relative) {                                     // The given position is in terms of the probe
766 766
     if (!can_reach(npos)) {
767 767
       if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable");
768
-      return NAN;
768
+      return MFNAN;
769 769
     }
770 770
     npos -= offset_xy;                                      // Get the nozzle position
771 771
   }
772
-  else if (!position_is_reachable(npos)) return NAN;        // The given position is in terms of the nozzle
772
+  else if (!position_is_reachable(npos)) return MFNAN;      // The given position is in terms of the nozzle
773 773
 
774 774
   // Move the probe to the starting XYZ
775 775
   do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S));
776 776
 
777
-  float measured_z = NAN;
777
+  float measured_z = MFNAN;
778 778
   if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z;
779
-  if (!isnan(measured_z)) {
779
+  if (!ISNAN(measured_z)) {
780 780
     const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
781 781
     if (big_raise || raise_after == PROBE_PT_RAISE)
782 782
       do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), z_probe_fast_mm_s);
783 783
     else if (raise_after == PROBE_PT_STOW)
784
-      if (stow()) measured_z = NAN;   // Error on stow?
784
+      if (stow()) measured_z = MFNAN;   // Error on stow?
785 785
 
786 786
     if (verbose_level > 2)
787 787
       SERIAL_ECHOLNPAIR("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z);
788 788
   }
789 789
 
790
-  if (isnan(measured_z)) {
790
+  if (ISNAN(measured_z)) {
791 791
     stow();
792 792
     LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
793 793
     #if DISABLED(G29_RETRY_AND_RECOVER)

+ 4
- 4
Marlin/src/module/probe.h View File

@@ -185,10 +185,10 @@ public:
185 185
       );
186 186
     }
187 187
 
188
-    static float min_x() { return _min_x() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x)); }
189
-    static float max_x() { return _max_x() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.x)); }
190
-    static float min_y() { return _min_y() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y)); }
191
-    static float max_y() { return _max_y() - TERN0(NOZZLE_AS_PROBE, TERN0(HAS_HOME_OFFSET, home_offset.y)); }
188
+    static float min_x() { return _min_x() TERN_(NOZZLE_AS_PROBE, TERN_(HAS_HOME_OFFSET, - home_offset.x)); }
189
+    static float max_x() { return _max_x() TERN_(NOZZLE_AS_PROBE, TERN_(HAS_HOME_OFFSET, - home_offset.x)); }
190
+    static float min_y() { return _min_y() TERN_(NOZZLE_AS_PROBE, TERN_(HAS_HOME_OFFSET, - home_offset.y)); }
191
+    static float max_y() { return _max_y() TERN_(NOZZLE_AS_PROBE, TERN_(HAS_HOME_OFFSET, - home_offset.y)); }
192 192
 
193 193
     // constexpr helpers used in build-time static_asserts, relying on default probe offsets.
194 194
     class build_time {

+ 7
- 7
Marlin/src/module/settings.cpp View File

@@ -900,8 +900,8 @@ void MarlinSettings::postprocess() {
900 900
       HOTEND_LOOP() {
901 901
         PIDCF_t pidcf = {
902 902
           #if DISABLED(PIDTEMP)
903
-            NAN, NAN, NAN,
904
-            NAN, NAN
903
+            MFNAN, MFNAN, MFNAN,
904
+            MFNAN, MFNAN
905 905
           #else
906 906
                          PID_PARAM(Kp, e),
907 907
             unscalePID_i(PID_PARAM(Ki, e)),
@@ -928,7 +928,7 @@ void MarlinSettings::postprocess() {
928 928
 
929 929
       const PID_t bed_pid = {
930 930
         #if DISABLED(PIDTEMPBED)
931
-          NAN, NAN, NAN
931
+          MFNAN, MFNAN, MFNAN
932 932
         #else
933 933
           // Store the unscaled PID values
934 934
           thermalManager.temp_bed.pid.Kp,
@@ -947,7 +947,7 @@ void MarlinSettings::postprocess() {
947 947
 
948 948
       const PID_t chamber_pid = {
949 949
         #if DISABLED(PIDTEMPCHAMBER)
950
-          NAN, NAN, NAN
950
+          MFNAN, MFNAN, MFNAN
951 951
         #else
952 952
           // Store the unscaled PID values
953 953
           thermalManager.temp_chamber.pid.Kp,
@@ -1786,7 +1786,7 @@ void MarlinSettings::postprocess() {
1786 1786
           PIDCF_t pidcf;
1787 1787
           EEPROM_READ(pidcf);
1788 1788
           #if ENABLED(PIDTEMP)
1789
-            if (!validating && !isnan(pidcf.Kp)) {
1789
+            if (!validating && !ISNAN(pidcf.Kp)) {
1790 1790
               // Scale PID values since EEPROM values are unscaled
1791 1791
               PID_PARAM(Kp, e) = pidcf.Kp;
1792 1792
               PID_PARAM(Ki, e) = scalePID_i(pidcf.Ki);
@@ -1818,7 +1818,7 @@ void MarlinSettings::postprocess() {
1818 1818
         PID_t pid;
1819 1819
         EEPROM_READ(pid);
1820 1820
         #if ENABLED(PIDTEMPBED)
1821
-          if (!validating && !isnan(pid.Kp)) {
1821
+          if (!validating && !ISNAN(pid.Kp)) {
1822 1822
             // Scale PID values since EEPROM values are unscaled
1823 1823
             thermalManager.temp_bed.pid.Kp = pid.Kp;
1824 1824
             thermalManager.temp_bed.pid.Ki = scalePID_i(pid.Ki);
@@ -1834,7 +1834,7 @@ void MarlinSettings::postprocess() {
1834 1834
         PID_t pid;
1835 1835
         EEPROM_READ(pid);
1836 1836
         #if ENABLED(PIDTEMPCHAMBER)
1837
-          if (!validating && !isnan(pid.Kp)) {
1837
+          if (!validating && !ISNAN(pid.Kp)) {
1838 1838
             // Scale PID values since EEPROM values are unscaled
1839 1839
             thermalManager.temp_chamber.pid.Kp = pid.Kp;
1840 1840
             thermalManager.temp_chamber.pid.Ki = scalePID_i(pid.Ki);

+ 3
- 3
Marlin/src/module/temperature.h View File

@@ -74,9 +74,9 @@ hotend_pid_t;
74 74
 #endif
75 75
 
76 76
 #define PID_PARAM(F,H) _PID_##F(TERN(PID_PARAMS_PER_HOTEND, H, 0 & H)) // Always use 'H' to suppress warning
77
-#define _PID_Kp(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kp, NAN)
78
-#define _PID_Ki(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Ki, NAN)
79
-#define _PID_Kd(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kd, NAN)
77
+#define _PID_Kp(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kp, MFNAN)
78
+#define _PID_Ki(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Ki, MFNAN)
79
+#define _PID_Kd(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kd, MFNAN)
80 80
 #if ENABLED(PIDTEMP)
81 81
   #define _PID_Kc(H) TERN(PID_EXTRUSION_SCALING, Temperature::temp_hotend[H].pid.Kc, 1)
82 82
   #define _PID_Kf(H) TERN(PID_FAN_SCALING,       Temperature::temp_hotend[H].pid.Kf, 0)

+ 1
- 1
Marlin/src/sd/cardreader.cpp View File

@@ -565,7 +565,7 @@ void announceOpen(const uint8_t doing, const char * const path) {
565 565
 //   - 1 : (no file open) Opening a macro (M98).
566 566
 //   - 2 : Resuming from a sub-procedure
567 567
 //
568
-void CardReader::openFileRead(char * const path, const uint8_t subcall_type/*=0*/) {
568
+void CardReader::openFileRead(const char * const path, const uint8_t subcall_type/*=0*/) {
569 569
   if (!isMounted()) return;
570 570
 
571 571
   switch (subcall_type) {

+ 1
- 1
Marlin/src/sd/cardreader.h View File

@@ -102,7 +102,7 @@ public:
102 102
   #endif
103 103
 
104 104
   // Basic file ops
105
-  static void openFileRead(char * const path, const uint8_t subcall=0);
105
+  static void openFileRead(const char * const path, const uint8_t subcall=0);
106 106
   static void openFileWrite(const char * const path);
107 107
   static void closefile(const bool store_location=false);
108 108
   static bool fileExists(const char * const name);

+ 7
- 7
platformio.ini View File

@@ -38,6 +38,13 @@ extra_configs =
38 38
 # The 'common' values are used for most Marlin builds
39 39
 #
40 40
 [common]
41
+build_flags        = -fmax-errors=5 -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants -fno-signed-zeros -ffinite-math-only
42
+extra_scripts      =
43
+  pre:buildroot/share/PlatformIO/scripts/common-dependencies.py
44
+  pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py
45
+  pre:buildroot/share/PlatformIO/scripts/preflight-checks.py
46
+  post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py
47
+lib_deps           =
41 48
 default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
42 49
   -<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dwin> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
43 50
   -<src/HAL/STM32/tft> -<src/HAL/STM32F1/tft>
@@ -227,13 +234,6 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
227 234
   -<src/module/scara.cpp> -<src/gcode/calibrate/M665.cpp>
228 235
   -<src/module/servo.cpp> -<src/gcode/control/M280.cpp>
229 236
   -<src/module/stepper/TMC26X.cpp>
230
-extra_scripts      =
231
-  pre:buildroot/share/PlatformIO/scripts/common-dependencies.py
232
-  pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py
233
-  pre:buildroot/share/PlatformIO/scripts/preflight-checks.py
234
-  post:buildroot/share/PlatformIO/scripts/common-dependencies-post.py
235
-build_flags        = -fmax-errors=5 -g3 -D__MARLIN_FIRMWARE__ -fmerge-constants
236
-lib_deps           =
237 237
 
238 238
 #
239 239
 # Default values apply to all 'env:' prefixed environments

Loading…
Cancel
Save