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
 #define SIGN(a) ({__typeof__(a) _a = (a); (_a>0)-(_a<0);})
112
 #define SIGN(a) ({__typeof__(a) _a = (a); (_a>0)-(_a<0);})
113
 #define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))
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
 // Macros to constrain values
118
 // Macros to constrain values
116
 #ifdef __cplusplus
119
 #ifdef __cplusplus
117
 
120
 

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

43
  * Extrapolate a single point from its neighbors
43
  * Extrapolate a single point from its neighbors
44
  */
44
  */
45
 static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) {
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
   if (DEBUGGING(LEVELING)) {
47
   if (DEBUGGING(LEVELING)) {
48
     DEBUG_ECHOPGM("Extrapolate [");
48
     DEBUG_ECHOPGM("Extrapolate [");
49
     if (x < 10) DEBUG_CHAR(' ');
49
     if (x < 10) DEBUG_CHAR(' ');
63
         c1 = z_values[x1][y1], c2 = z_values[x2][y2];
63
         c1 = z_values[x1][y1], c2 = z_values[x2][y2];
64
 
64
 
65
   // Treat far unprobed points as zero, near as equal to far
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
   const float a = 2 * a1 - a2, b = 2 * b1 - b2, c = 2 * c1 - c2;
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
       bilinear_start.reset();
132
       bilinear_start.reset();
133
       bilinear_grid_spacing.reset();
133
       bilinear_grid_spacing.reset();
134
       GRID_LOOP(x, y) {
134
       GRID_LOOP(x, y) {
135
-        z_values[x][y] = NAN;
135
+        z_values[x][y] = MFNAN;
136
         TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, 0));
136
         TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, 0));
137
       }
137
       }
138
     #elif ABL_PLANAR
138
     #elif ABL_PLANAR
177
       LOOP_L_N(x, sx) {
177
       LOOP_L_N(x, sx) {
178
         SERIAL_CHAR(' ');
178
         SERIAL_CHAR(' ');
179
         const float offset = fn(x, y);
179
         const float offset = fn(x, y);
180
-        if (!isnan(offset)) {
180
+        if (!ISNAN(offset)) {
181
           if (offset >= 0) SERIAL_CHAR('+');
181
           if (offset >= 0) SERIAL_CHAR('+');
182
           SERIAL_ECHO_F(offset, int(precision));
182
           SERIAL_ECHO_F(offset, int(precision));
183
         }
183
         }

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

97
   static inline xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); }
97
   static inline xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); }
98
 
98
 
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) {
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
     const float delta_z = (z2 - z1) / (a2 - a1),
101
     const float delta_z = (z2 - z1) / (a2 - a1),
101
                 delta_a = a0 - a1;
102
                 delta_a = a0 - a1;
102
     return z1 + delta_a * delta_z;
103
     return z1 + delta_a * delta_z;
114
     const float x1 = index_to_xpos[ind.x], x2 = index_to_xpos[ind.x+1],
115
     const float x1 = index_to_xpos[ind.x], x2 = index_to_xpos[ind.x+1],
115
                 y1 = index_to_xpos[ind.y], y2 = index_to_xpos[ind.y+1],
116
                 y1 = index_to_xpos[ind.y], y2 = index_to_xpos[ind.y+1],
116
                 z1 = calc_z0(pos.x, x1, z_values[ind.x][ind.y  ], x2, z_values[ind.x+1][ind.y  ]),
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
   #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)
125
   #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)

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

48
   if (!leveling_is_valid()) return;
48
   if (!leveling_is_valid()) return;
49
   SERIAL_ECHO_MSG("  G29 I999");
49
   SERIAL_ECHO_MSG("  G29 I999");
50
   GRID_LOOP(x, y)
50
   GRID_LOOP(x, y)
51
-    if (!isnan(z_values[x][y])) {
51
+    if (!ISNAN(z_values[x][y])) {
52
       SERIAL_ECHO_START();
52
       SERIAL_ECHO_START();
53
       SERIAL_ECHOPAIR("  M421 I", x, " J", y);
53
       SERIAL_ECHOPAIR("  M421 I", x, " J", y);
54
       SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z_values[x][y], 4);
54
       SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z_values[x][y], 4);
99
 
99
 
100
 void unified_bed_leveling::invalidate() {
100
 void unified_bed_leveling::invalidate() {
101
   set_bed_leveling_enabled(false);
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
 void unified_bed_leveling::set_all_mesh_points_to_value(const_float_t value) {
105
 void unified_bed_leveling::set_all_mesh_points_to_value(const_float_t value) {
116
 
116
 
117
   void unified_bed_leveling::set_store_from_mesh(const bed_mesh_t &in_values, mesh_store_t &stored_values) {
117
   void unified_bed_leveling::set_store_from_mesh(const bed_mesh_t &in_values, mesh_store_t &stored_values) {
118
     auto z_to_store = [](const_float_t z) {
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
       const int32_t z_scaled = TRUNC(z * mesh_store_scaling);
120
       const int32_t z_scaled = TRUNC(z * mesh_store_scaling);
121
       if (z_scaled == Z_STEPS_NAN || !WITHIN(z_scaled, INT16_MIN, INT16_MAX))
121
       if (z_scaled == Z_STEPS_NAN || !WITHIN(z_scaled, INT16_MIN, INT16_MAX))
122
         return Z_STEPS_NAN; // If Z is out of range, return our custom 'NaN'
122
         return Z_STEPS_NAN; // If Z is out of range, return our custom 'NaN'
127
 
127
 
128
   void unified_bed_leveling::set_mesh_from_store(const mesh_store_t &stored_values, bed_mesh_t &out_values) {
128
   void unified_bed_leveling::set_mesh_from_store(const mesh_store_t &stored_values, bed_mesh_t &out_values) {
129
     auto store_to_z = [](const int16_t z_scaled) {
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
     GRID_LOOP(x, y) out_values[x][y] = store_to_z(stored_values[x][y]);
132
     GRID_LOOP(x, y) out_values[x][y] = store_to_z(stored_values[x][y]);
133
   }
133
   }
211
       if (lcd) {
211
       if (lcd) {
212
         // TODO: Display on Graphical LCD
212
         // TODO: Display on Graphical LCD
213
       }
213
       }
214
-      else if (isnan(f))
214
+      else if (ISNAN(f))
215
         SERIAL_ECHOPGM_P(human ? PSTR("  .   ") : PSTR("NAN"));
215
         SERIAL_ECHOPGM_P(human ? PSTR("  .   ") : PSTR("NAN"));
216
       else if (human || csv) {
216
       else if (human || csv) {
217
         if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' ');  // Display sign also for positive numbers (' ' for 0)
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
   #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
196
   #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
197
     #define _UBL_OUTER_Z_RAISE UBL_Z_RAISE_WHEN_OFF_MESH
197
     #define _UBL_OUTER_Z_RAISE UBL_Z_RAISE_WHEN_OFF_MESH
198
   #else
198
   #else
199
-    #define _UBL_OUTER_Z_RAISE NAN
199
+    #define _UBL_OUTER_Z_RAISE MFNAN
200
   #endif
200
   #endif
201
 
201
 
202
   /**
202
   /**
264
         return UBL_Z_RAISE_WHEN_OFF_MESH;
264
         return UBL_Z_RAISE_WHEN_OFF_MESH;
265
     #endif
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
       z0 = 0.0;      // in ubl.z_values[][] and propagate through the
273
       z0 = 0.0;      // in ubl.z_values[][] and propagate through the
288
                      // calculations. If our correction is NAN, we throw it out
274
                      // calculations. If our correction is NAN, we throw it out
289
                      // because part of the Mesh is undefined and we don't have the
275
                      // because part of the Mesh is undefined and we don't have the
290
                      // information we need to complete the height correction.
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
     return z0;
286
     return z0;
301
   }
287
   }
302
   static inline float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); }
288
   static inline float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); }
315
   #endif
301
   #endif
316
 
302
 
317
   static inline bool mesh_is_valid() {
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
     return true;
305
     return true;
320
   }
306
   }
321
 
307
 

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

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

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

85
 
85
 
86
       // Undefined parts of the Mesh in z_values[][] are NAN.
86
       // Undefined parts of the Mesh in z_values[][] are NAN.
87
       // Replace NAN corrections with 0.0 to prevent NAN propagation.
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
       planner.buffer_segment(end, scaled_fr_mm_s, extruder);
89
       planner.buffer_segment(end, scaled_fr_mm_s, extruder);
90
       current_position = destination;
90
       current_position = destination;
91
       return;
91
       return;
150
 
150
 
151
         // Undefined parts of the Mesh in z_values[][] are NAN.
151
         // Undefined parts of the Mesh in z_values[][] are NAN.
152
         // Replace NAN corrections with 0.0 to prevent NAN propagation.
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
         const float ry = mesh_index_to_ypos(icell.y);
155
         const float ry = mesh_index_to_ypos(icell.y);
156
 
156
 
198
 
198
 
199
         // Undefined parts of the Mesh in z_values[][] are NAN.
199
         // Undefined parts of the Mesh in z_values[][] are NAN.
200
         // Replace NAN corrections with 0.0 to prevent NAN propagation.
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
          * Without this check, it's possible to generate a zero length move, as in the case where
204
          * Without this check, it's possible to generate a zero length move, as in the case where
253
 
253
 
254
         // Undefined parts of the Mesh in z_values[][] are NAN.
254
         // Undefined parts of the Mesh in z_values[][] are NAN.
255
         // Replace NAN corrections with 0.0 to prevent NAN propagation.
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
         if (!inf_normalized_flag) {
258
         if (!inf_normalized_flag) {
259
           on_axis_distance = use_x_dist ? rx - start.x : next_mesh_line_y - start.y;
259
           on_axis_distance = use_x_dist ? rx - start.x : next_mesh_line_y - start.y;
276
 
276
 
277
         // Undefined parts of the Mesh in z_values[][] are NAN.
277
         // Undefined parts of the Mesh in z_values[][] are NAN.
278
         // Replace NAN corrections with 0.0 to prevent NAN propagation.
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
         if (!inf_normalized_flag) {
281
         if (!inf_normalized_flag) {
282
           on_axis_distance = use_x_dist ? next_mesh_line_x - start.x : ry - start.y;
282
           on_axis_distance = use_x_dist ? next_mesh_line_x - start.x : ry - start.y;
405
             z_x0y1 = z_values[icell.x  ][icell.y+1],  // z at lower right corner
405
             z_x0y1 = z_values[icell.x  ][icell.y+1],  // z at lower right corner
406
             z_x1y1 = z_values[icell.x+1][icell.y+1];  // z at upper right corner
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
       const xy_pos_t pos = { mesh_index_to_xpos(icell.x), mesh_index_to_ypos(icell.y) };
413
       const xy_pos_t pos = { mesh_index_to_xpos(icell.x), mesh_index_to_ypos(icell.y) };
414
       xy_pos_t cell = raw - pos;
414
       xy_pos_t cell = raw - pos;

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

105
     do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, Z_CLEARANCE_BETWEEN_PROBES, 7));
105
     do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, Z_CLEARANCE_BETWEEN_PROBES, 7));
106
     const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[i], PROBE_PT_RAISE, 0, true);
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
       SERIAL_ECHOPAIR("G35 failed at point ", i, " (");
109
       SERIAL_ECHOPAIR("G35 failed at point ", i, " (");
110
       SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i]));
110
       SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i]));
111
       SERIAL_CHAR(')');
111
       SERIAL_CHAR(')');

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

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

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

62
     SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
62
     SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
63
   else {
63
   else {
64
     float &zval = ubl.z_values[ij.x][ij.y];
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
     TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval));
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
     if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center
212
     if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center
213
       const xy_pos_t center{0};
213
       const xy_pos_t center{0};
214
       z_pt[CEN] += calibration_probe(center, stow_after_each);
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
     if (_7p_calibration) { // probe extra center points
218
     if (_7p_calibration) { // probe extra center points
223
                     r = dcr * 0.1;
223
                     r = dcr * 0.1;
224
         const xy_pos_t vec = { cos(a), sin(a) };
224
         const xy_pos_t vec = { cos(a), sin(a) };
225
         z_pt[CEN] += calibration_probe(vec * r, stow_after_each);
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
       z_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points);
228
       z_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points);
229
     }
229
     }
248
                       interpol = FMOD(rad, 1);
248
                       interpol = FMOD(rad, 1);
249
           const xy_pos_t vec = { cos(a), sin(a) };
249
           const xy_pos_t vec = { cos(a), sin(a) };
250
           const float z_temp = calibration_probe(vec * r, stow_after_each);
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
           // split probe point to neighbouring calibration points
252
           // split probe point to neighbouring calibration points
253
           z_pt[uint8_t(LROUND(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
253
           z_pt[uint8_t(LROUND(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
254
           z_pt[uint8_t(LROUND(rad - interpol))           % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
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
           // Probing sanity check is disabled, as it would trigger even in normal cases because
229
           // Probing sanity check is disabled, as it would trigger even in normal cases because
230
           // current_position.z has been manually altered in the "dirty trick" above.
230
           // current_position.z has been manually altered in the "dirty trick" above.
231
           const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true, false);
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
             SERIAL_ECHOLNPGM("Probing failed");
233
             SERIAL_ECHOLNPGM("Probing failed");
234
             LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
234
             LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
235
             err_break = true;
235
             err_break = true;

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

113
   auto g76_probe = [](const TempSensorID sid, uint16_t &targ, const xy_pos_t &nozpos) {
113
   auto g76_probe = [](const TempSensorID sid, uint16_t &targ, const xy_pos_t &nozpos) {
114
     do_z_clearance(5.0); // Raise nozzle before probing
114
     do_z_clearance(5.0); // Raise nozzle before probing
115
     const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false);  // verbose=0, probe_relative=false
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
       SERIAL_ECHOLNPGM("!Received NAN. Aborting.");
117
       SERIAL_ECHOLNPGM("!Received NAN. Aborting.");
118
     else {
118
     else {
119
       SERIAL_ECHOLNPAIR_F("Measured: ", measured_z);
119
       SERIAL_ECHOLNPAIR_F("Measured: ", measured_z);
208
         report_temps(next_temp_report);
208
         report_temps(next_temp_report);
209
 
209
 
210
       const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz);
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
     SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
214
     SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
267
       if (timeout) break;
267
       if (timeout) break;
268
 
268
 
269
       const float measured_z = g76_probe(TSI_PROBE, target_probe, noz_pos_xyz);
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
     SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
273
     SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());

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

134
 
134
 
135
   // Move to the first point, deploy, and probe
135
   // Move to the first point, deploy, and probe
136
   const float t = probe.probe_at_point(test_position, raise_after, verbose_level);
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
   if (probing_good) {
139
   if (probing_good) {
140
     randomSeed(millis());
140
     randomSeed(millis());
219
       const float pz = probe.probe_at_point(test_position, raise_after, 0);
219
       const float pz = probe.probe_at_point(test_position, raise_after, 0);
220
 
220
 
221
       // Break the loop if the probe fails
221
       // Break the loop if the probe fails
222
-      probing_good = !isnan(pz);
222
+      probing_good = !ISNAN(pz);
223
       if (!probing_good) break;
223
       if (!probing_good) break;
224
 
224
 
225
       // Store the new sample
225
       // Store the new sample

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

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

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

1457
          * Print Z values
1457
          * Print Z values
1458
          */
1458
          */
1459
         _ZLABEL(_LCD_W_POS, 1);
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
           lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1461
           lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1462
         else
1462
         else
1463
           lcd_put_u8str_P(PSTR(" -----"));
1463
           lcd_put_u8str_P(PSTR(" -----"));
1476
          * Show the location value
1476
          * Show the location value
1477
          */
1477
          */
1478
         _ZLABEL(_LCD_W_POS, 3);
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
           lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1480
           lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
1481
         else
1481
         else
1482
           lcd_put_u8str_P(PSTR(" -----"));
1482
           lcd_put_u8str_P(PSTR(" -----"));

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

941
       // Show the location value
941
       // Show the location value
942
       lcd.setCursor(_LCD_W_POS, 3); lcd_put_u8str_P(PSTR("Z:"));
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
         lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
945
         lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
946
       else
946
       else
947
         lcd_put_u8str_P(PSTR(" -----"));
947
         lcd_put_u8str_P(PSTR(" -----"));

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

569
 
569
 
570
         // Show the location value
570
         // Show the location value
571
         lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL);
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
           lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
573
           lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
574
         else
574
         else
575
           lcd_put_u8str_P(PSTR(" -----"));
575
           lcd_put_u8str_P(PSTR(" -----"));

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

835
             mix_label = PSTR("Mx");
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
         sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
843
         sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
842
         lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages);
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
       #else
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
 namespace FTDI {
32
 namespace FTDI {
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) {
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
     char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)];
34
     char str[width + precision + 10 + (units ? strlen_P((const char*) units) : 0)];
35
-    if (isnan(value))
35
+    if (ISNAN(value))
36
       strcpy_P(str, PSTR("-"));
36
       strcpy_P(str, PSTR("-"));
37
     else
37
     else
38
       dtostrf(value, width, precision, str);
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
   constexpr uint8_t cols = GRID_MAX_POINTS_X;
31
   constexpr uint8_t cols = GRID_MAX_POINTS_X;
32
 
32
 
33
   #define VALUE(X,Y)  (func ? func(X,Y,data) : 0)
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
   #define HEIGHT(X,Y) (ISVAL(X,Y) ? (VALUE(X,Y) - val_min) * scale_z : 0)
35
   #define HEIGHT(X,Y) (ISVAL(X,Y) ? (VALUE(X,Y) - val_min) * scale_z : 0)
36
 
36
 
37
   // Compute the mean, min and max for the points
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
 
70
 
71
 float BedMeshEditScreen::getHighlightedValue() {
71
 float BedMeshEditScreen::getHighlightedValue() {
72
   const float val = ExtUI::getMeshPoint(mydata.highlight);
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
 void BedMeshEditScreen::setHighlightedValue(float value) {
76
 void BedMeshEditScreen::setHighlightedValue(float value) {

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

421
         #if AXIS_IS_TMC(Z2)
421
         #if AXIS_IS_TMC(Z2)
422
           case Z2: return stepperZ2.getMilliamps();
422
           case Z2: return stepperZ2.getMilliamps();
423
         #endif
423
         #endif
424
-        default: return NAN;
424
+        default: return MFNAN;
425
       };
425
       };
426
     }
426
     }
427
 
427
 
451
         #if AXIS_IS_TMC(E7)
451
         #if AXIS_IS_TMC(E7)
452
           case E7: return stepperE7.getMilliamps();
452
           case E7: return stepperE7.getMilliamps();
453
         #endif
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
   z_measured[tram_index] = z_probed_height;
54
   z_measured[tram_index] = z_probed_height;
55
   move_to_tramming_wait_pos();
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
 static void _menu_single_probe(const uint8_t point) {
60
 static void _menu_single_probe(const uint8_t point) {

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

505
     tft.set_background(COLOR_BACKGROUND);
505
     tft.set_background(COLOR_BACKGROUND);
506
     tft_string.set(Z_LBL);
506
     tft_string.set(Z_LBL);
507
     tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
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
     tft_string.trim();
509
     tft_string.trim();
510
     tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
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
     tft.set_background(COLOR_BACKGROUND);
492
     tft.set_background(COLOR_BACKGROUND);
493
     tft_string.set(Z_LBL);
493
     tft_string.set(Z_LBL);
494
     tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
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
     tft_string.trim();
496
     tft_string.trim();
497
     tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
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
     tft.set_background(COLOR_BACKGROUND);
492
     tft.set_background(COLOR_BACKGROUND);
493
     tft_string.set(Z_LBL);
493
     tft_string.set(Z_LBL);
494
     tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
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
     tft_string.trim();
496
     tft_string.trim();
497
     tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
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
  * @details Used by probe_at_point to get the bed Z height at the current XY.
583
  * @details Used by probe_at_point to get the bed Z height at the current XY.
584
  *          Leaves current_position.z at the height where the probe triggered.
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
 float Probe::run_z_probe(const bool sanity_check/*=true*/) {
588
 float Probe::run_z_probe(const bool sanity_check/*=true*/) {
589
   DEBUG_SECTION(log_probe, "Probe::run_z_probe", DEBUGGING(LEVELING));
589
   DEBUG_SECTION(log_probe, "Probe::run_z_probe", DEBUGGING(LEVELING));
617
   #if TOTAL_PROBING == 2
617
   #if TOTAL_PROBING == 2
618
 
618
 
619
     // Attempt to tare the probe
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
     // Do a first probe at the fast speed
622
     // Do a first probe at the fast speed
623
     if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s,
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
     const float first_probe_z = current_position.z;
626
     const float first_probe_z = current_position.z;
627
 
627
 
662
 
662
 
663
       // Probe downward slowly to find the bed
663
       // Probe downward slowly to find the bed
664
       if (try_to_probe(PSTR("SLOW"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW),
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
       TERN_(MEASURE_BACKLASH_WHEN_PROBING, backlash.measure_with_probe());
667
       TERN_(MEASURE_BACKLASH_WHEN_PROBING, backlash.measure_with_probe());
668
 
668
 
765
   if (probe_relative) {                                     // The given position is in terms of the probe
765
   if (probe_relative) {                                     // The given position is in terms of the probe
766
     if (!can_reach(npos)) {
766
     if (!can_reach(npos)) {
767
       if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable");
767
       if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable");
768
-      return NAN;
768
+      return MFNAN;
769
     }
769
     }
770
     npos -= offset_xy;                                      // Get the nozzle position
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
   // Move the probe to the starting XYZ
774
   // Move the probe to the starting XYZ
775
   do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S));
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
   if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z;
778
   if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z;
779
-  if (!isnan(measured_z)) {
779
+  if (!ISNAN(measured_z)) {
780
     const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
780
     const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
781
     if (big_raise || raise_after == PROBE_PT_RAISE)
781
     if (big_raise || raise_after == PROBE_PT_RAISE)
782
       do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), z_probe_fast_mm_s);
782
       do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), z_probe_fast_mm_s);
783
     else if (raise_after == PROBE_PT_STOW)
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
     if (verbose_level > 2)
786
     if (verbose_level > 2)
787
       SERIAL_ECHOLNPAIR("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z);
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
     stow();
791
     stow();
792
     LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
792
     LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
793
     #if DISABLED(G29_RETRY_AND_RECOVER)
793
     #if DISABLED(G29_RETRY_AND_RECOVER)

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

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
     // constexpr helpers used in build-time static_asserts, relying on default probe offsets.
193
     // constexpr helpers used in build-time static_asserts, relying on default probe offsets.
194
     class build_time {
194
     class build_time {

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

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

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

74
 #endif
74
 #endif
75
 
75
 
76
 #define PID_PARAM(F,H) _PID_##F(TERN(PID_PARAMS_PER_HOTEND, H, 0 & H)) // Always use 'H' to suppress warning
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
 #if ENABLED(PIDTEMP)
80
 #if ENABLED(PIDTEMP)
81
   #define _PID_Kc(H) TERN(PID_EXTRUSION_SCALING, Temperature::temp_hotend[H].pid.Kc, 1)
81
   #define _PID_Kc(H) TERN(PID_EXTRUSION_SCALING, Temperature::temp_hotend[H].pid.Kc, 1)
82
   #define _PID_Kf(H) TERN(PID_FAN_SCALING,       Temperature::temp_hotend[H].pid.Kf, 0)
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
 //   - 1 : (no file open) Opening a macro (M98).
565
 //   - 1 : (no file open) Opening a macro (M98).
566
 //   - 2 : Resuming from a sub-procedure
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
   if (!isMounted()) return;
569
   if (!isMounted()) return;
570
 
570
 
571
   switch (subcall_type) {
571
   switch (subcall_type) {

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

102
   #endif
102
   #endif
103
 
103
 
104
   // Basic file ops
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
   static void openFileWrite(const char * const path);
106
   static void openFileWrite(const char * const path);
107
   static void closefile(const bool store_location=false);
107
   static void closefile(const bool store_location=false);
108
   static bool fileExists(const char * const name);
108
   static bool fileExists(const char * const name);

+ 7
- 7
platformio.ini View File

38
 # The 'common' values are used for most Marlin builds
38
 # The 'common' values are used for most Marlin builds
39
 #
39
 #
40
 [common]
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
 default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
48
 default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
42
   -<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dwin> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
49
   -<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dwin> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
43
   -<src/HAL/STM32/tft> -<src/HAL/STM32F1/tft>
50
   -<src/HAL/STM32/tft> -<src/HAL/STM32F1/tft>
227
   -<src/module/scara.cpp> -<src/gcode/calibrate/M665.cpp>
234
   -<src/module/scara.cpp> -<src/gcode/calibrate/M665.cpp>
228
   -<src/module/servo.cpp> -<src/gcode/control/M280.cpp>
235
   -<src/module/servo.cpp> -<src/gcode/control/M280.cpp>
229
   -<src/module/stepper/TMC26X.cpp>
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
 # Default values apply to all 'env:' prefixed environments
239
 # Default values apply to all 'env:' prefixed environments

Loading…
Cancel
Save