Browse Source

Followup to float maths patch

Scott Lahteine 7 years ago
parent
commit
63f4c9bdb9

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

82
   }
82
   }
83
 
83
 
84
   static int8_t probe_index_x(const float &x) {
84
   static int8_t probe_index_x(const float &x) {
85
-    int8_t px = (x - (MESH_MIN_X) + 0.5 * (MESH_X_DIST)) * (1.0f / (MESH_X_DIST));
85
+    int8_t px = (x - (MESH_MIN_X) + 0.5f * (MESH_X_DIST)) * (1.0f / (MESH_X_DIST));
86
     return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
86
     return WITHIN(px, 0, GRID_MAX_POINTS_X - 1) ? px : -1;
87
   }
87
   }
88
 
88
 
89
   static int8_t probe_index_y(const float &y) {
89
   static int8_t probe_index_y(const float &y) {
90
-    int8_t py = (y - (MESH_MIN_Y) + 0.5 * (MESH_Y_DIST)) * (1.0f / (MESH_Y_DIST));
90
+    int8_t py = (y - (MESH_MIN_Y) + 0.5f * (MESH_Y_DIST)) * (1.0f / (MESH_Y_DIST));
91
     return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
91
     return WITHIN(py, 0, GRID_MAX_POINTS_Y - 1) ? py : -1;
92
   }
92
   }
93
 
93
 

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

65
          unified_bed_leveling::g29_y_flag;
65
          unified_bed_leveling::g29_y_flag;
66
   float  unified_bed_leveling::g29_x_pos,
66
   float  unified_bed_leveling::g29_x_pos,
67
          unified_bed_leveling::g29_y_pos,
67
          unified_bed_leveling::g29_y_pos,
68
-         unified_bed_leveling::g29_card_thickness = 0.0,
69
-         unified_bed_leveling::g29_constant = 0.0;
68
+         unified_bed_leveling::g29_card_thickness = 0,
69
+         unified_bed_leveling::g29_constant = 0;
70
 
70
 
71
   #if HAS_BED_PROBE
71
   #if HAS_BED_PROBE
72
     int  unified_bed_leveling::g29_grid_size;
72
     int  unified_bed_leveling::g29_grid_size;
346
         case 0:
346
         case 0:
347
           for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {   // Create a bowl shape - similar to
347
           for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {   // Create a bowl shape - similar to
348
             for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { // a poorly calibrated Delta.
348
             for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { // a poorly calibrated Delta.
349
-              const float p1 = 0.5 * (GRID_MAX_POINTS_X) - x,
350
-                          p2 = 0.5 * (GRID_MAX_POINTS_Y) - y;
351
-              z_values[x][y] += 2.0 * HYPOT(p1, p2);
349
+              const float p1 = 0.5f * (GRID_MAX_POINTS_X) - x,
350
+                          p2 = 0.5f * (GRID_MAX_POINTS_Y) - y;
351
+              z_values[x][y] += 2.0f * HYPOT(p1, p2);
352
             }
352
             }
353
           }
353
           }
354
           break;
354
           break;
355
         case 1:
355
         case 1:
356
           for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {  // Create a diagonal line several Mesh cells thick that is raised
356
           for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {  // Create a diagonal line several Mesh cells thick that is raised
357
-            z_values[x][x] += 9.999;
358
-            z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1] += 9.999; // We want the altered line several mesh points thick
357
+            z_values[x][x] += 9.999f;
358
+            z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1] += 9.999f; // We want the altered line several mesh points thick
359
           }
359
           }
360
           break;
360
           break;
361
         case 2:
361
         case 2:
362
           // Allow the user to specify the height because 10mm is a little extreme in some cases.
362
           // Allow the user to specify the height because 10mm is a little extreme in some cases.
363
           for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++)   // Create a rectangular raised area in
363
           for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++)   // Create a rectangular raised area in
364
             for (uint8_t y = (GRID_MAX_POINTS_Y) / 3; y < 2 * (GRID_MAX_POINTS_Y) / 3; y++) // the center of the bed
364
             for (uint8_t y = (GRID_MAX_POINTS_Y) / 3; y < 2 * (GRID_MAX_POINTS_Y) / 3; y++) // the center of the bed
365
-              z_values[x][y] += parser.seen('C') ? g29_constant : 9.99;
365
+              z_values[x][y] += parser.seen('C') ? g29_constant : 9.99f;
366
           break;
366
           break;
367
       }
367
       }
368
     }
368
     }
381
           tilt_mesh_based_on_probed_grid(true /* true says to do 3-Point leveling */ );
381
           tilt_mesh_based_on_probed_grid(true /* true says to do 3-Point leveling */ );
382
           restore_ubl_active_state_and_leave();
382
           restore_ubl_active_state_and_leave();
383
         }
383
         }
384
-        do_blocking_move_to_xy(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)));
384
+        do_blocking_move_to_xy(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)));
385
         report_current_position();
385
         report_current_position();
386
       }
386
       }
387
 
387
 
453
 
453
 
454
             if (parser.seen('B')) {
454
             if (parser.seen('B')) {
455
               g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness((float) Z_CLEARANCE_BETWEEN_PROBES);
455
               g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness((float) Z_CLEARANCE_BETWEEN_PROBES);
456
-              if (ABS(g29_card_thickness) > 1.5) {
456
+              if (ABS(g29_card_thickness) > 1.5f) {
457
                 SERIAL_PROTOCOLLNPGM("?Error in Business Card measurement.");
457
                 SERIAL_PROTOCOLLNPGM("?Error in Business Card measurement.");
458
                 return;
458
                 return;
459
               }
459
               }
509
           }
509
           }
510
           else {
510
           else {
511
             const float cvf = parser.value_float();
511
             const float cvf = parser.value_float();
512
-            switch ((int)truncf(cvf * 10.0) - 30) {   // 3.1 -> 1
512
+            switch ((int)truncf(cvf * 10.0f) - 30) {   // 3.1 -> 1
513
               #if ENABLED(UBL_G29_P31)
513
               #if ENABLED(UBL_G29_P31)
514
                 case 1: {
514
                 case 1: {
515
 
515
 
519
                   // P3.12 100X distance weighting
519
                   // P3.12 100X distance weighting
520
                   // P3.13 1000X distance weighting, approaches simple average of nearest points
520
                   // P3.13 1000X distance weighting, approaches simple average of nearest points
521
 
521
 
522
-                  const float weight_power  = (cvf - 3.10) * 100.0,  // 3.12345 -> 2.345
523
-                              weight_factor = weight_power ? POW(10.0, weight_power) : 0;
522
+                  const float weight_power  = (cvf - 3.10f) * 100.0f,  // 3.12345 -> 2.345
523
+                              weight_factor = weight_power ? POW(10.0f, weight_power) : 0;
524
                   smart_fill_wlsf(weight_factor);
524
                   smart_fill_wlsf(weight_factor);
525
                 }
525
                 }
526
                 break;
526
                 break;
634
   }
634
   }
635
 
635
 
636
   void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float value) {
636
   void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float value) {
637
-    float sum = 0.0;
637
+    float sum = 0;
638
     int n = 0;
638
     int n = 0;
639
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
639
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
640
       for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
640
       for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
648
     //
648
     //
649
     // Sum the squares of difference from mean
649
     // Sum the squares of difference from mean
650
     //
650
     //
651
-    float sum_of_diff_squared = 0.0;
651
+    float sum_of_diff_squared = 0;
652
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
652
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
653
       for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
653
       for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
654
         if (!isnan(z_values[x][y]))
654
         if (!isnan(z_values[x][y]))
786
 
786
 
787
     float unified_bed_leveling::measure_point_with_encoder() {
787
     float unified_bed_leveling::measure_point_with_encoder() {
788
       KEEPALIVE_STATE(PAUSED_FOR_USER);
788
       KEEPALIVE_STATE(PAUSED_FOR_USER);
789
-      move_z_with_encoder(0.01);
789
+      move_z_with_encoder(0.01f);
790
       KEEPALIVE_STATE(IN_HANDLER);
790
       KEEPALIVE_STATE(IN_HANDLER);
791
       return current_position[Z_AXIS];
791
       return current_position[Z_AXIS];
792
     }
792
     }
797
       lcd_external_control = true;
797
       lcd_external_control = true;
798
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
798
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
799
 
799
 
800
-      do_blocking_move_to(0.5 * (MESH_MAX_X - (MESH_MIN_X)), 0.5 * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
801
-        //, MIN(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) / 2.0);
800
+      do_blocking_move_to(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
801
+        //, MIN(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]) * 0.5f);
802
       planner.synchronize();
802
       planner.synchronize();
803
 
803
 
804
       SERIAL_PROTOCOLPGM("Place shim under nozzle");
804
       SERIAL_PROTOCOLPGM("Place shim under nozzle");
874
 
874
 
875
         serialprintPGM(parser.seen('B') ? PSTR(MSG_UBL_BC_INSERT) : PSTR(MSG_UBL_BC_INSERT2));
875
         serialprintPGM(parser.seen('B') ? PSTR(MSG_UBL_BC_INSERT) : PSTR(MSG_UBL_BC_INSERT2));
876
 
876
 
877
-        const float z_step = 0.01;                          // existing behavior: 0.01mm per click, occasionally step
877
+        const float z_step = 0.01f;                         // existing behavior: 0.01mm per click, occasionally step
878
         //const float z_step = planner.steps_to_mm[Z_AXIS]; // approx one step each click
878
         //const float z_step = planner.steps_to_mm[Z_AXIS]; // approx one step each click
879
 
879
 
880
         move_z_with_encoder(z_step);
880
         move_z_with_encoder(z_step);
913
       lcd_quick_feedback(true);
913
       lcd_quick_feedback(true);
914
     #endif
914
     #endif
915
 
915
 
916
-    g29_constant = 0.0;
916
+    g29_constant = 0;
917
     g29_repetition_cnt = 0;
917
     g29_repetition_cnt = 0;
918
 
918
 
919
     g29_x_flag = parser.seenval('X');
919
     g29_x_flag = parser.seenval('X');
1004
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1004
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1005
       if (parser.seenval('F')) {
1005
       if (parser.seenval('F')) {
1006
         const float fh = parser.value_float();
1006
         const float fh = parser.value_float();
1007
-        if (!WITHIN(fh, 0.0, 100.0)) {
1007
+        if (!WITHIN(fh, 0, 100)) {
1008
           SERIAL_PROTOCOLLNPGM("?(F)ade height for Bed Level Correction not plausible.\n");
1008
           SERIAL_PROTOCOLLNPGM("?(F)ade height for Bed Level Correction not plausible.\n");
1009
           return UBL_ERR;
1009
           return UBL_ERR;
1010
         }
1010
         }
1226
 
1226
 
1227
     mesh_index_pair out_mesh;
1227
     mesh_index_pair out_mesh;
1228
     out_mesh.x_index = out_mesh.y_index = -1;
1228
     out_mesh.x_index = out_mesh.y_index = -1;
1229
-    out_mesh.distance = -99999.99;
1229
+    out_mesh.distance = -99999.99f;
1230
 
1230
 
1231
     for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1231
     for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1232
       for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
1232
       for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
1242
           found_a_NAN = true;
1242
           found_a_NAN = true;
1243
 
1243
 
1244
           int8_t closest_x = -1, closest_y = -1;
1244
           int8_t closest_x = -1, closest_y = -1;
1245
-          float d1, d2 = 99999.9;
1245
+          float d1, d2 = 99999.9f;
1246
           for (int8_t k = 0; k < GRID_MAX_POINTS_X; k++) {
1246
           for (int8_t k = 0; k < GRID_MAX_POINTS_X; k++) {
1247
             for (int8_t l = 0; l < GRID_MAX_POINTS_Y; l++) {
1247
             for (int8_t l = 0; l < GRID_MAX_POINTS_Y; l++) {
1248
               if (!isnan(z_values[k][l])) {
1248
               if (!isnan(z_values[k][l])) {
1279
     if (!found_a_real && found_a_NAN) {        // if the mesh is totally unpopulated, start the probing
1279
     if (!found_a_real && found_a_NAN) {        // if the mesh is totally unpopulated, start the probing
1280
       out_mesh.x_index = GRID_MAX_POINTS_X / 2;
1280
       out_mesh.x_index = GRID_MAX_POINTS_X / 2;
1281
       out_mesh.y_index = GRID_MAX_POINTS_Y / 2;
1281
       out_mesh.y_index = GRID_MAX_POINTS_Y / 2;
1282
-      out_mesh.distance = 1.0;
1282
+      out_mesh.distance = 1;
1283
     }
1283
     }
1284
     return out_mesh;
1284
     return out_mesh;
1285
   }
1285
   }
1287
   mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const MeshPointType type, const float &rx, const float &ry, const bool probe_as_reference, uint16_t bits[16]) {
1287
   mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const MeshPointType type, const float &rx, const float &ry, const bool probe_as_reference, uint16_t bits[16]) {
1288
     mesh_index_pair out_mesh;
1288
     mesh_index_pair out_mesh;
1289
     out_mesh.x_index = out_mesh.y_index = -1;
1289
     out_mesh.x_index = out_mesh.y_index = -1;
1290
-    out_mesh.distance = -99999.9;
1290
+    out_mesh.distance = -99999.9f;
1291
 
1291
 
1292
     // Get our reference position. Either the nozzle or probe location.
1292
     // Get our reference position. Either the nozzle or probe location.
1293
     const float px = rx - (probe_as_reference == USE_PROBE_AS_REFERENCE ? X_PROBE_OFFSET_FROM_EXTRUDER : 0),
1293
     const float px = rx - (probe_as_reference == USE_PROBE_AS_REFERENCE ? X_PROBE_OFFSET_FROM_EXTRUDER : 0),
1294
                 py = ry - (probe_as_reference == USE_PROBE_AS_REFERENCE ? Y_PROBE_OFFSET_FROM_EXTRUDER : 0);
1294
                 py = ry - (probe_as_reference == USE_PROBE_AS_REFERENCE ? Y_PROBE_OFFSET_FROM_EXTRUDER : 0);
1295
 
1295
 
1296
-    float best_so_far = 99999.99;
1296
+    float best_so_far = 99999.99f;
1297
 
1297
 
1298
     for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1298
     for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
1299
       for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
1299
       for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
1320
 
1320
 
1321
           // factor in the distance from the current location for the normal case
1321
           // factor in the distance from the current location for the normal case
1322
           // so the nozzle isn't running all over the bed.
1322
           // so the nozzle isn't running all over the bed.
1323
-          distance += HYPOT(current_position[X_AXIS] - mx, current_position[Y_AXIS] - my) * 0.1;
1323
+          distance += HYPOT(current_position[X_AXIS] - mx, current_position[Y_AXIS] - my) * 0.1f;
1324
           if (distance < best_so_far) {
1324
           if (distance < best_so_far) {
1325
             best_so_far = distance;   // We found a closer location with
1325
             best_so_far = distance;   // We found a closer location with
1326
             out_mesh.x_index = i;     // the specified type of mesh value.
1326
             out_mesh.x_index = i;     // the specified type of mesh value.
1401
         lcd_refresh();
1401
         lcd_refresh();
1402
 
1402
 
1403
         float new_z = z_values[location.x_index][location.y_index];
1403
         float new_z = z_values[location.x_index][location.y_index];
1404
-        if (isnan(new_z)) new_z = 0.0;                              // Invalid points begin at 0
1405
-        new_z = FLOOR(new_z * 1000.0) * 0.001;                      // Chop off digits after the 1000ths place
1404
+        if (isnan(new_z)) new_z = 0;                                // Invalid points begin at 0
1405
+        new_z = FLOOR(new_z * 1000) * 0.001f;                       // Chop off digits after the 1000ths place
1406
 
1406
 
1407
         lcd_mesh_edit_setup(new_z);
1407
         lcd_mesh_edit_setup(new_z);
1408
 
1408
 
1461
       if (z_values[x1][y1] < z_values[x2][y2])                  // Angled downward?
1461
       if (z_values[x1][y1] < z_values[x2][y2])                  // Angled downward?
1462
         z_values[x][y] = z_values[x1][y1];                      // Use nearest (maybe a little too high.)
1462
         z_values[x][y] = z_values[x1][y1];                      // Use nearest (maybe a little too high.)
1463
       else
1463
       else
1464
-        z_values[x][y] = 2.0 * z_values[x1][y1] - z_values[x2][y2];   // Angled upward...
1464
+        z_values[x][y] = 2.0f * z_values[x1][y1] - z_values[x2][y2];   // Angled upward...
1465
       return true;
1465
       return true;
1466
     }
1466
     }
1467
     return false;
1467
     return false;
1510
 
1510
 
1511
       float measured_z;
1511
       float measured_z;
1512
 
1512
 
1513
-      const float dx = float(x_max - x_min) / (g29_grid_size - 1.0),
1514
-                  dy = float(y_max - y_min) / (g29_grid_size - 1.0);
1513
+      const float dx = float(x_max - x_min) / (g29_grid_size - 1),
1514
+                  dy = float(y_max - y_min) / (g29_grid_size - 1);
1515
 
1515
 
1516
       struct linear_fit_data lsf_results;
1516
       struct linear_fit_data lsf_results;
1517
 
1517
 
1634
         return;
1634
         return;
1635
       }
1635
       }
1636
 
1636
 
1637
-      vector_3 normal = vector_3(lsf_results.A, lsf_results.B, 1.0000).get_normal();
1637
+      vector_3 normal = vector_3(lsf_results.A, lsf_results.B, 1).get_normal();
1638
 
1638
 
1639
       if (g29_verbose_level > 2) {
1639
       if (g29_verbose_level > 2) {
1640
         SERIAL_ECHOPGM("bed plane normal = [");
1640
         SERIAL_ECHOPGM("bed plane normal = [");
1713
            * The only difference is just 3 points are used in the calculations.   That fact guarantees
1713
            * The only difference is just 3 points are used in the calculations.   That fact guarantees
1714
            * each probed point should have an exact match when a get_z_correction() for that location
1714
            * each probed point should have an exact match when a get_z_correction() for that location
1715
            * is calculated.  The Z error between the probed point locations and the get_z_correction()
1715
            * is calculated.  The Z error between the probed point locations and the get_z_correction()
1716
-           * numbers for those locations should be 0.000
1716
+           * numbers for those locations should be 0.
1717
            */
1717
            */
1718
           #if 0
1718
           #if 0
1719
           float t, t1, d;
1719
           float t, t1, d;
1743
           SERIAL_EOL();
1743
           SERIAL_EOL();
1744
 
1744
 
1745
           t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
1745
           t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
1746
-          d = t + normal.z * 0.000;
1746
+          d = t + normal.z * 0;
1747
           SERIAL_ECHOPGM("D from home location with Z=0 : ");
1747
           SERIAL_ECHOPGM("D from home location with Z=0 : ");
1748
           SERIAL_ECHO_F(d, 6);
1748
           SERIAL_ECHO_F(d, 6);
1749
           SERIAL_EOL();
1749
           SERIAL_EOL();
1750
 
1750
 
1751
           t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
1751
           t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
1752
-          d = t + get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT); // normal.z * 0.000;
1752
+          d = t + get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT); // normal.z * 0;
1753
           SERIAL_ECHOPGM("D from home location using mesh value for Z: ");
1753
           SERIAL_ECHOPGM("D from home location using mesh value for Z: ");
1754
           SERIAL_ECHO_F(d, 6);
1754
           SERIAL_ECHO_F(d, 6);
1755
 
1755
 
1800
                 if (TEST(bitmap[jx], jy)) {
1800
                 if (TEST(bitmap[jx], jy)) {
1801
                   const float ry = mesh_index_to_ypos(jy),
1801
                   const float ry = mesh_index_to_ypos(jy),
1802
                               rz = z_values[jx][jy],
1802
                               rz = z_values[jx][jy],
1803
-                              w  = 1.0 + weight_scaled / HYPOT((rx - px), (ry - py));
1803
+                              w  = 1 + weight_scaled / HYPOT((rx - px), (ry - py));
1804
                   incremental_WLSF(&lsf_results, rx, ry, rz, w);
1804
                   incremental_WLSF(&lsf_results, rx, ry, rz, w);
1805
                 }
1805
                 }
1806
               }
1806
               }

+ 11
- 11
Marlin/src/module/configuration_store.cpp View File

384
    * M500 - Store Configuration
384
    * M500 - Store Configuration
385
    */
385
    */
386
   bool MarlinSettings::save(PORTARG_SOLO) {
386
   bool MarlinSettings::save(PORTARG_SOLO) {
387
-    float dummy = 0.0f;
387
+    float dummy = 0;
388
     char ver[4] = "ERR";
388
     char ver[4] = "ERR";
389
 
389
 
390
     uint16_t working_crc = 0;
390
     uint16_t working_crc = 0;
466
       EEPROM_WRITE(mesh_num_y);
466
       EEPROM_WRITE(mesh_num_y);
467
       EEPROM_WRITE(mbl.z_values);
467
       EEPROM_WRITE(mbl.z_values);
468
     #else // For disabled MBL write a default mesh
468
     #else // For disabled MBL write a default mesh
469
-      dummy = 0.0f;
469
+      dummy = 0;
470
       const uint8_t mesh_num_x = 3, mesh_num_y = 3;
470
       const uint8_t mesh_num_x = 3, mesh_num_y = 3;
471
       EEPROM_WRITE(dummy); // z_offset
471
       EEPROM_WRITE(dummy); // z_offset
472
       EEPROM_WRITE(mesh_num_x);
472
       EEPROM_WRITE(mesh_num_x);
488
     #if ABL_PLANAR
488
     #if ABL_PLANAR
489
       EEPROM_WRITE(planner.bed_level_matrix);
489
       EEPROM_WRITE(planner.bed_level_matrix);
490
     #else
490
     #else
491
-      dummy = 0.0f;
491
+      dummy = 0;
492
       for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
492
       for (uint8_t q = 9; q--;) EEPROM_WRITE(dummy);
493
     #endif
493
     #endif
494
 
494
 
512
       // For disabled Bilinear Grid write an empty 3x3 grid
512
       // For disabled Bilinear Grid write an empty 3x3 grid
513
       const uint8_t grid_max_x = 3, grid_max_y = 3;
513
       const uint8_t grid_max_x = 3, grid_max_y = 3;
514
       const int bilinear_start[2] = { 0 }, bilinear_grid_spacing[2] = { 0 };
514
       const int bilinear_start[2] = { 0 }, bilinear_grid_spacing[2] = { 0 };
515
-      dummy = 0.0f;
515
+      dummy = 0;
516
       EEPROM_WRITE(grid_max_x);
516
       EEPROM_WRITE(grid_max_x);
517
       EEPROM_WRITE(grid_max_y);
517
       EEPROM_WRITE(grid_max_y);
518
       EEPROM_WRITE(bilinear_grid_spacing);
518
       EEPROM_WRITE(bilinear_grid_spacing);
550
       _FIELD_TEST(x_endstop_adj);
550
       _FIELD_TEST(x_endstop_adj);
551
 
551
 
552
       // Write dual endstops in X, Y, Z order. Unused = 0.0
552
       // Write dual endstops in X, Y, Z order. Unused = 0.0
553
-      dummy = 0.0f;
553
+      dummy = 0;
554
       #if ENABLED(X_DUAL_ENDSTOPS)
554
       #if ENABLED(X_DUAL_ENDSTOPS)
555
         EEPROM_WRITE(endstops.x_endstop_adj);   // 1 float
555
         EEPROM_WRITE(endstops.x_endstop_adj);   // 1 float
556
       #else
556
       #else
602
         {
602
         {
603
           dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
603
           dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
604
           EEPROM_WRITE(dummy); // Kp
604
           EEPROM_WRITE(dummy); // Kp
605
-          dummy = 0.0f;
605
+          dummy = 0;
606
           for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy); // Ki, Kd, Kc
606
           for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy); // Ki, Kd, Kc
607
         }
607
         }
608
 
608
 
848
     #if ENABLED(LIN_ADVANCE)
848
     #if ENABLED(LIN_ADVANCE)
849
       EEPROM_WRITE(planner.extruder_advance_K);
849
       EEPROM_WRITE(planner.extruder_advance_K);
850
     #else
850
     #else
851
-      dummy = 0.0f;
851
+      dummy = 0;
852
       EEPROM_WRITE(dummy);
852
       EEPROM_WRITE(dummy);
853
     #endif
853
     #endif
854
 
854
 
870
     #if ENABLED(CNC_COORDINATE_SYSTEMS)
870
     #if ENABLED(CNC_COORDINATE_SYSTEMS)
871
       EEPROM_WRITE(gcode.coordinate_system); // 27 floats
871
       EEPROM_WRITE(gcode.coordinate_system); // 27 floats
872
     #else
872
     #else
873
-      dummy = 0.0f;
873
+      dummy = 0;
874
       for (uint8_t q = MAX_COORDINATE_SYSTEMS * XYZ; q--;) EEPROM_WRITE(dummy);
874
       for (uint8_t q = MAX_COORDINATE_SYSTEMS * XYZ; q--;) EEPROM_WRITE(dummy);
875
     #endif
875
     #endif
876
 
876
 
885
       EEPROM_WRITE(planner.xz_skew_factor);
885
       EEPROM_WRITE(planner.xz_skew_factor);
886
       EEPROM_WRITE(planner.yz_skew_factor);
886
       EEPROM_WRITE(planner.yz_skew_factor);
887
     #else
887
     #else
888
-      dummy = 0.0f;
888
+      dummy = 0;
889
       for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
889
       for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
890
     #endif
890
     #endif
891
 
891
 
905
         EEPROM_WRITE(dummy);
905
         EEPROM_WRITE(dummy);
906
       }
906
       }
907
     #else
907
     #else
908
-      dummy = 0.0f;
908
+      dummy = 0;
909
       for (uint8_t q = MAX_EXTRUDERS * 2; q--;) EEPROM_WRITE(dummy);
909
       for (uint8_t q = MAX_EXTRUDERS * 2; q--;) EEPROM_WRITE(dummy);
910
     #endif
910
     #endif
911
 
911
 
974
       eeprom_error = true;
974
       eeprom_error = true;
975
     }
975
     }
976
     else {
976
     else {
977
-      float dummy = 0.0f;
977
+      float dummy = 0;
978
       #if DISABLED(AUTO_BED_LEVELING_UBL) || DISABLED(FWRETRACT) || ENABLED(NO_VOLUMETRICS)
978
       #if DISABLED(AUTO_BED_LEVELING_UBL) || DISABLED(FWRETRACT) || ENABLED(NO_VOLUMETRICS)
979
         bool dummyb;
979
         bool dummyb;
980
       #endif
980
       #endif

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

157
  */
157
  */
158
 void forward_kinematics_DELTA(const float &z1, const float &z2, const float &z3) {
158
 void forward_kinematics_DELTA(const float &z1, const float &z2, const float &z3) {
159
   // Create a vector in old coordinates along x axis of new coordinate
159
   // Create a vector in old coordinates along x axis of new coordinate
160
-  const float p12[3] = { delta_tower[B_AXIS][X_AXIS] - delta_tower[A_AXIS][X_AXIS], delta_tower[B_AXIS][Y_AXIS] - delta_tower[A_AXIS][Y_AXIS], z2 - z1 };
160
+  const float p12[3] = { delta_tower[B_AXIS][X_AXIS] - delta_tower[A_AXIS][X_AXIS], delta_tower[B_AXIS][Y_AXIS] - delta_tower[A_AXIS][Y_AXIS], z2 - z1 },
161
 
161
 
162
   // Get the reciprocal of Magnitude of vector.
162
   // Get the reciprocal of Magnitude of vector.
163
-  const float d2 = sq(p12[0]) + sq(p12[1]) + sq(p12[2]), inv_d = RSQRT(d2);
163
+  d2 = sq(p12[0]) + sq(p12[1]) + sq(p12[2]), inv_d = RSQRT(d2),
164
 
164
 
165
   // Create unit vector by multiplying by the inverse of the magnitude.
165
   // Create unit vector by multiplying by the inverse of the magnitude.
166
-  const float ex[3] = { p12[0] * inv_d, p12[1] * inv_d, p12[2] * inv_d };
166
+  ex[3] = { p12[0] * inv_d, p12[1] * inv_d, p12[2] * inv_d },
167
 
167
 
168
   // Get the vector from the origin of the new system to the third point.
168
   // Get the vector from the origin of the new system to the third point.
169
-  const float p13[3] = { delta_tower[C_AXIS][X_AXIS] - delta_tower[A_AXIS][X_AXIS], delta_tower[C_AXIS][Y_AXIS] - delta_tower[A_AXIS][Y_AXIS], z3 - z1 };
169
+  p13[3] = { delta_tower[C_AXIS][X_AXIS] - delta_tower[A_AXIS][X_AXIS], delta_tower[C_AXIS][Y_AXIS] - delta_tower[A_AXIS][Y_AXIS], z3 - z1 },
170
 
170
 
171
   // Use the dot product to find the component of this vector on the X axis.
171
   // Use the dot product to find the component of this vector on the X axis.
172
-  const float i = ex[0] * p13[0] + ex[1] * p13[1] + ex[2] * p13[2];
172
+  i = ex[0] * p13[0] + ex[1] * p13[1] + ex[2] * p13[2],
173
 
173
 
174
   // Create a vector along the x axis that represents the x component of p13.
174
   // Create a vector along the x axis that represents the x component of p13.
175
-  const float iex[3] = { ex[0] * i, ex[1] * i, ex[2] * i };
175
+  iex[3] = { ex[0] * i, ex[1] * i, ex[2] * i };
176
 
176
 
177
   // Subtract the X component from the original vector leaving only Y. We use the
177
   // Subtract the X component from the original vector leaving only Y. We use the
178
   // variable that will be the unit vector after we scale it.
178
   // variable that will be the unit vector after we scale it.
190
     ex[1] * ey[2] - ex[2] * ey[1],
190
     ex[1] * ey[2] - ex[2] * ey[1],
191
     ex[2] * ey[0] - ex[0] * ey[2],
191
     ex[2] * ey[0] - ex[0] * ey[2],
192
     ex[0] * ey[1] - ex[1] * ey[0]
192
     ex[0] * ey[1] - ex[1] * ey[0]
193
-  };
193
+  },
194
 
194
 
195
   // We now have the d, i and j values defined in Wikipedia.
195
   // We now have the d, i and j values defined in Wikipedia.
196
   // Plug them into the equations defined in Wikipedia for Xnew, Ynew and Znew
196
   // Plug them into the equations defined in Wikipedia for Xnew, Ynew and Znew
197
-  const float Xnew = (delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[B_AXIS] + d2) * inv_d * 0.5,
198
-              Ynew = ((delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[C_AXIS] + sq(i) + j2) * 0.5 - i * Xnew) * inv_j,
199
-              Znew = SQRT(delta_diagonal_rod_2_tower[A_AXIS] - HYPOT2(Xnew, Ynew));
197
+  Xnew = (delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[B_AXIS] + d2) * inv_d * 0.5,
198
+  Ynew = ((delta_diagonal_rod_2_tower[A_AXIS] - delta_diagonal_rod_2_tower[C_AXIS] + sq(i) + j2) * 0.5 - i * Xnew) * inv_j,
199
+  Znew = SQRT(delta_diagonal_rod_2_tower[A_AXIS] - HYPOT2(Xnew, Ynew));
200
 
200
 
201
   // Start from the origin of the old coordinates and add vectors in the
201
   // Start from the origin of the old coordinates and add vectors in the
202
   // old coords that represent the Xnew, Ynew and Znew to find the point
202
   // old coords that represent the Xnew, Ynew and Znew to find the point

+ 1
- 1
Marlin/src/module/planner.cpp View File

1317
    * Return 1.0 with volumetric off or a diameter of 0.0.
1317
    * Return 1.0 with volumetric off or a diameter of 0.0.
1318
    */
1318
    */
1319
   inline float calculate_volumetric_multiplier(const float &diameter) {
1319
   inline float calculate_volumetric_multiplier(const float &diameter) {
1320
-    return (parser.volumetric_enabled && diameter) ? RECIPROCAL(CIRCLE_AREA(diameter * 0.5f)) : 1;
1320
+    return (parser.volumetric_enabled && diameter) ? 1.0f / CIRCLE_AREA(diameter * 0.5f) : 1;
1321
   }
1321
   }
1322
 
1322
 
1323
   /**
1323
   /**

Loading…
Cancel
Save