Browse Source

Add float suffix in G33

Scott Lahteine 6 years ago
parent
commit
b71a755a30
1 changed files with 50 additions and 50 deletions
  1. 50
    50
      Marlin/src/gcode/calibrate/G33.cpp

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

179
         S2 += sq(z_pt[rad]);
179
         S2 += sq(z_pt[rad]);
180
         N++;
180
         N++;
181
       }
181
       }
182
-      return LROUND(SQRT(S2 / N) * 1000.0) / 1000.0 + 0.00001;
182
+      return LROUND(SQRT(S2 / N) * 1000.0f) / 1000.0f + 0.00001f;
183
     }
183
     }
184
   }
184
   }
185
-  return 0.00001;
185
+  return 0.00001f;
186
 }
186
 }
187
 
187
 
188
 /**
188
 /**
218
              _7p_6_center         = probe_points >= 5 && probe_points <= 7,
218
              _7p_6_center         = probe_points >= 5 && probe_points <= 7,
219
              _7p_9_center         = probe_points >= 8;
219
              _7p_9_center         = probe_points >= 8;
220
 
220
 
221
-  LOOP_CAL_ALL(rad) z_pt[rad] = 0.0;
221
+  LOOP_CAL_ALL(rad) z_pt[rad] = 0.0f;
222
 
222
 
223
   if (!_0p_calibration) {
223
   if (!_0p_calibration) {
224
 
224
 
228
     }
228
     }
229
 
229
 
230
     if (_7p_calibration) { // probe extra center points
230
     if (_7p_calibration) { // probe extra center points
231
-      const float start  = _7p_9_center ? float(_CA) + _7P_STEP / 3.0 : _7p_6_center ? float(_CA) : float(__C),
232
-                  steps  = _7p_9_center ? _4P_STEP / 3.0 : _7p_6_center ? _7P_STEP : _4P_STEP;
231
+      const float start  = _7p_9_center ? float(_CA) + _7P_STEP / 3.0f : _7p_6_center ? float(_CA) : float(__C),
232
+                  steps  = _7p_9_center ? _4P_STEP / 3.0f : _7p_6_center ? _7P_STEP : _4P_STEP;
233
       I_LOOP_CAL_PT(rad, start, steps) {
233
       I_LOOP_CAL_PT(rad, start, steps) {
234
         const float a = RADIANS(210 + (360 / NPP) *  (rad - 1)),
234
         const float a = RADIANS(210 + (360 / NPP) *  (rad - 1)),
235
                     r = delta_calibration_radius * 0.1;
235
                     r = delta_calibration_radius * 0.1;
241
 
241
 
242
     if (!_1p_calibration) {  // probe the radius
242
     if (!_1p_calibration) {  // probe the radius
243
       const CalEnum start  = _4p_opposite_points ? _AB : __A;
243
       const CalEnum start  = _4p_opposite_points ? _AB : __A;
244
-      const float   steps  = _7p_14_intermediates ? _7P_STEP / 15.0 : // 15r * 6 + 10c = 100
245
-                             _7p_11_intermediates ? _7P_STEP / 12.0 : // 12r * 6 +  9c = 81
246
-                             _7p_8_intermediates  ? _7P_STEP /  9.0 : //  9r * 6 + 10c = 64
247
-                             _7p_6_intermediates  ? _7P_STEP /  7.0 : //  7r * 6 +  7c = 49
248
-                             _7p_4_intermediates  ? _7P_STEP /  5.0 : //  5r * 6 +  6c = 36
249
-                             _7p_2_intermediates  ? _7P_STEP /  3.0 : //  3r * 6 +  7c = 25
250
-                             _7p_1_intermediates  ? _7P_STEP /  2.0 : //  2r * 6 +  4c = 16
244
+      const float   steps  = _7p_14_intermediates ? _7P_STEP / 15.0f : // 15r * 6 + 10c = 100
245
+                             _7p_11_intermediates ? _7P_STEP / 12.0f : // 12r * 6 +  9c = 81
246
+                             _7p_8_intermediates  ? _7P_STEP /  9.0f : //  9r * 6 + 10c = 64
247
+                             _7p_6_intermediates  ? _7P_STEP /  7.0f : //  7r * 6 +  7c = 49
248
+                             _7p_4_intermediates  ? _7P_STEP /  5.0f : //  5r * 6 +  6c = 36
249
+                             _7p_2_intermediates  ? _7P_STEP /  3.0f : //  3r * 6 +  7c = 25
250
+                             _7p_1_intermediates  ? _7P_STEP /  2.0f : //  2r * 6 +  4c = 16
251
                              _7p_no_intermediates ? _7P_STEP :        //  1r * 6 +  3c = 9
251
                              _7p_no_intermediates ? _7P_STEP :        //  1r * 6 +  3c = 9
252
                              _4P_STEP;                                // .5r * 6 +  1c = 4
252
                              _4P_STEP;                                // .5r * 6 +  1c = 4
253
       bool zig_zag = true;
253
       bool zig_zag = true;
269
         LOOP_CAL_RAD(rad)
269
         LOOP_CAL_RAD(rad)
270
           z_pt[rad] /= _7P_STEP / steps;
270
           z_pt[rad] /= _7P_STEP / steps;
271
 
271
 
272
-      do_blocking_move_to_xy(0.0, 0.0);
272
+      do_blocking_move_to_xy(0.0f, 0.0f);
273
     }
273
     }
274
   }
274
   }
275
   return true;
275
   return true;
286
 
286
 
287
   LOOP_CAL_ALL(rad) {
287
   LOOP_CAL_ALL(rad) {
288
     const float a = RADIANS(210 + (360 / NPP) *  (rad - 1)),
288
     const float a = RADIANS(210 + (360 / NPP) *  (rad - 1)),
289
-                r = (rad == CEN ? 0.0 : delta_calibration_radius);
289
+                r = (rad == CEN ? 0.0f : delta_calibration_radius);
290
     pos[X_AXIS] = cos(a) * r;
290
     pos[X_AXIS] = cos(a) * r;
291
     pos[Y_AXIS] = sin(a) * r;
291
     pos[Y_AXIS] = sin(a) * r;
292
     pos[Z_AXIS] = z_pt[rad];
292
     pos[Z_AXIS] = z_pt[rad];
298
 static void forward_kinematics_probe_points(float mm_at_pt_axis[NPP + 1][ABC], float z_pt[NPP + 1]) {
298
 static void forward_kinematics_probe_points(float mm_at_pt_axis[NPP + 1][ABC], float z_pt[NPP + 1]) {
299
   const float r_quot = delta_calibration_radius / delta_radius;
299
   const float r_quot = delta_calibration_radius / delta_radius;
300
 
300
 
301
-  #define ZPP(N,I,A) ((1 / 3.0 + r_quot * (N) / 3.0 ) * mm_at_pt_axis[I][A])
301
+  #define ZPP(N,I,A) ((1 / 3.0f + r_quot * (N) / 3.0f ) * mm_at_pt_axis[I][A])
302
   #define Z00(I, A) ZPP( 0, I, A)
302
   #define Z00(I, A) ZPP( 0, I, A)
303
   #define Zp1(I, A) ZPP(+1, I, A)
303
   #define Zp1(I, A) ZPP(+1, I, A)
304
   #define Zm1(I, A) ZPP(-1, I, A)
304
   #define Zm1(I, A) ZPP(-1, I, A)
339
 
339
 
340
 static float auto_tune_h() {
340
 static float auto_tune_h() {
341
   const float r_quot = delta_calibration_radius / delta_radius;
341
   const float r_quot = delta_calibration_radius / delta_radius;
342
-  float h_fac = 0.0;
342
+  float h_fac = 0.0f;
343
 
343
 
344
-  h_fac = r_quot / (2.0 / 3.0);
344
+  h_fac = r_quot / (2.0f / 3.0f);
345
   h_fac = 1.0f / h_fac; // (2/3)/CR
345
   h_fac = 1.0f / h_fac; // (2/3)/CR
346
   return h_fac;
346
   return h_fac;
347
 }
347
 }
348
 
348
 
349
 static float auto_tune_r() {
349
 static float auto_tune_r() {
350
-  const float diff = 0.01;
351
-  float r_fac = 0.0,
352
-        z_pt[NPP + 1] = { 0.0 },
353
-        delta_e[ABC] = {0.0},
354
-        delta_r = {0.0},
355
-        delta_t[ABC] = {0.0};
350
+  const float diff = 0.01f;
351
+  float r_fac = 0.0f,
352
+        z_pt[NPP + 1] = { 0.0f },
353
+        delta_e[ABC] = { 0.0f },
354
+        delta_r = { 0.0f },
355
+        delta_t[ABC] = { 0.0f };
356
 
356
 
357
   delta_r = diff;
357
   delta_r = diff;
358
   calc_kinematics_diff_probe_points(z_pt, delta_e, delta_r, delta_t);
358
   calc_kinematics_diff_probe_points(z_pt, delta_e, delta_r, delta_t);
359
-  r_fac = -(z_pt[__A] + z_pt[__B] + z_pt[__C] + z_pt[_BC] + z_pt[_CA] + z_pt[_AB]) / 6.0;
360
-  r_fac = diff / r_fac / 3.0; // 1/(3*delta_Z)
359
+  r_fac = -(z_pt[__A] + z_pt[__B] + z_pt[__C] + z_pt[_BC] + z_pt[_CA] + z_pt[_AB]) / 6.0f;
360
+  r_fac = diff / r_fac / 3.0f; // 1/(3*delta_Z)
361
   return r_fac;
361
   return r_fac;
362
 }
362
 }
363
 
363
 
364
 static float auto_tune_a() {
364
 static float auto_tune_a() {
365
-  const float diff = 0.01;
366
-  float a_fac = 0.0,
367
-        z_pt[NPP + 1] = { 0.0 },
368
-        delta_e[ABC] = {0.0},
369
-        delta_r = {0.0},
370
-        delta_t[ABC] = {0.0};
365
+  const float diff = 0.01f;
366
+  float a_fac = 0.0f,
367
+        z_pt[NPP + 1] = { 0.0f },
368
+        delta_e[ABC] = { 0.0f },
369
+        delta_r = { 0.0f },
370
+        delta_t[ABC] = { 0.0f };
371
 
371
 
372
   ZERO(delta_t);
372
   ZERO(delta_t);
373
   LOOP_XYZ(axis) {
373
   LOOP_XYZ(axis) {
374
     delta_t[axis] = diff;
374
     delta_t[axis] = diff;
375
     calc_kinematics_diff_probe_points(z_pt, delta_e, delta_r, delta_t);
375
     calc_kinematics_diff_probe_points(z_pt, delta_e, delta_r, delta_t);
376
     delta_t[axis] = 0;
376
     delta_t[axis] = 0;
377
-    a_fac += z_pt[uint8_t((axis * _4P_STEP) - _7P_STEP + NPP) % NPP + 1] / 6.0;
378
-    a_fac -= z_pt[uint8_t((axis * _4P_STEP) + 1 + _7P_STEP)] / 6.0;
377
+    a_fac += z_pt[uint8_t((axis * _4P_STEP) - _7P_STEP + NPP) % NPP + 1] / 6.0f;
378
+    a_fac -= z_pt[uint8_t((axis * _4P_STEP) + 1 + _7P_STEP)] / 6.0f;
379
   }
379
   }
380
-  a_fac = diff / a_fac / 3.0; // 1/(3*delta_Z)
380
+  a_fac = diff / a_fac / 3.0f; // 1/(3*delta_Z)
381
   return a_fac;
381
   return a_fac;
382
 }
382
 }
383
 
383
 
418
 
418
 
419
   const bool towers_set = !parser.seen('T');
419
   const bool towers_set = !parser.seen('T');
420
 
420
 
421
-  const float calibration_precision = parser.floatval('C', 0.0);
421
+  const float calibration_precision = parser.floatval('C', 0.0f);
422
   if (calibration_precision < 0) {
422
   if (calibration_precision < 0) {
423
     SERIAL_ECHOLNPGM("?(C)alibration precision implausible (>=0).");
423
     SERIAL_ECHOLNPGM("?(C)alibration precision implausible (>=0).");
424
     return;
424
     return;
450
   static const char save_message[] PROGMEM = "Save with M500 and/or copy to Configuration.h";
450
   static const char save_message[] PROGMEM = "Save with M500 and/or copy to Configuration.h";
451
   int8_t iterations = 0;
451
   int8_t iterations = 0;
452
   float test_precision,
452
   float test_precision,
453
-        zero_std_dev = (verbose_level ? 999.0 : 0.0), // 0.0 in dry-run mode : forced end
453
+        zero_std_dev = (verbose_level ? 999.0f : 0.0f), // 0.0 in dry-run mode : forced end
454
         zero_std_dev_min = zero_std_dev,
454
         zero_std_dev_min = zero_std_dev,
455
         zero_std_dev_old = zero_std_dev,
455
         zero_std_dev_old = zero_std_dev,
456
         h_factor,
456
         h_factor,
497
 
497
 
498
   do { // start iterations
498
   do { // start iterations
499
 
499
 
500
-    float z_at_pt[NPP + 1] = { 0.0 };
500
+    float z_at_pt[NPP + 1] = { 0.0f };
501
 
501
 
502
-    test_precision = zero_std_dev_old != 999.0 ? (zero_std_dev + zero_std_dev_old) / 2 : zero_std_dev;
502
+    test_precision = zero_std_dev_old != 999.0f ? (zero_std_dev + zero_std_dev_old) / 2.0f : zero_std_dev;
503
     iterations++;
503
     iterations++;
504
 
504
 
505
     // Probe the points
505
     // Probe the points
515
     if ((zero_std_dev < test_precision || iterations <= force_iterations) && zero_std_dev > calibration_precision) {
515
     if ((zero_std_dev < test_precision || iterations <= force_iterations) && zero_std_dev > calibration_precision) {
516
 
516
 
517
       #if !HAS_BED_PROBE
517
       #if !HAS_BED_PROBE
518
-        test_precision = 0.00; // forced end
518
+        test_precision = 0.0f; // forced end
519
       #endif
519
       #endif
520
 
520
 
521
       if (zero_std_dev < zero_std_dev_min) {
521
       if (zero_std_dev < zero_std_dev_min) {
526
         COPY(a_old, delta_tower_angle_trim);
526
         COPY(a_old, delta_tower_angle_trim);
527
       }
527
       }
528
 
528
 
529
-      float e_delta[ABC] = { 0.0 },
530
-            r_delta = 0.0,
531
-            t_delta[ABC] = { 0.0 };
529
+      float e_delta[ABC] = { 0.0f },
530
+            r_delta = 0.0f,
531
+            t_delta[ABC] = { 0.0f };
532
 
532
 
533
       /**
533
       /**
534
        * convergence matrices:
534
        * convergence matrices:
536
        *  - definition of the matrix scaling parameters
536
        *  - definition of the matrix scaling parameters
537
        *  - matrices for 4 and 7 point calibration
537
        *  - matrices for 4 and 7 point calibration
538
        */
538
        */
539
-      #define ZP(N,I) ((N) * z_at_pt[I] / 4.0) // 4.0 = divider to normalize to integers
539
+      #define ZP(N,I) ((N) * z_at_pt[I] / 4.0f) // 4.0 = divider to normalize to integers
540
       #define Z12(I) ZP(12, I)
540
       #define Z12(I) ZP(12, I)
541
       #define Z4(I) ZP(4, I)
541
       #define Z4(I) ZP(4, I)
542
       #define Z2(I) ZP(2, I)
542
       #define Z2(I) ZP(2, I)
545
 
545
 
546
       // calculate factors
546
       // calculate factors
547
       const float cr_old = delta_calibration_radius;
547
       const float cr_old = delta_calibration_radius;
548
-      if (_7p_9_center) delta_calibration_radius *= 0.9;
548
+      if (_7p_9_center) delta_calibration_radius *= 0.9f;
549
       h_factor = auto_tune_h();
549
       h_factor = auto_tune_h();
550
       r_factor = auto_tune_r();
550
       r_factor = auto_tune_r();
551
       a_factor = auto_tune_a();
551
       a_factor = auto_tune_a();
553
 
553
 
554
       switch (probe_points) {
554
       switch (probe_points) {
555
         case 0:
555
         case 0:
556
-          test_precision = 0.00; // forced end
556
+          test_precision = 0.0f; // forced end
557
           break;
557
           break;
558
 
558
 
559
         case 1:
559
         case 1:
560
-          test_precision = 0.00; // forced end
560
+          test_precision = 0.0f; // forced end
561
           LOOP_XYZ(axis) e_delta[axis] = +Z4(CEN);
561
           LOOP_XYZ(axis) e_delta[axis] = +Z4(CEN);
562
           break;
562
           break;
563
 
563
 
605
 
605
 
606
       // Normalize angles to least-squares
606
       // Normalize angles to least-squares
607
       if (_angle_results) {
607
       if (_angle_results) {
608
-        float a_sum = 0.0;
608
+        float a_sum = 0.0f;
609
         LOOP_XYZ(axis) a_sum += delta_tower_angle_trim[axis];
609
         LOOP_XYZ(axis) a_sum += delta_tower_angle_trim[axis];
610
-        LOOP_XYZ(axis) delta_tower_angle_trim[axis] -= a_sum / 3.0;
610
+        LOOP_XYZ(axis) delta_tower_angle_trim[axis] -= a_sum / 3.0f;
611
       }
611
       }
612
 
612
 
613
       // adjust delta_height and endstops by the max amount
613
       // adjust delta_height and endstops by the max amount
639
         char mess[21];
639
         char mess[21];
640
         strcpy_P(mess, PSTR("Calibration sd:"));
640
         strcpy_P(mess, PSTR("Calibration sd:"));
641
         if (zero_std_dev_min < 1)
641
         if (zero_std_dev_min < 1)
642
-          sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev_min * 1000.0));
642
+          sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev_min * 1000.0f));
643
         else
643
         else
644
           sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev_min));
644
           sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev_min));
645
         ui.set_status(mess);
645
         ui.set_status(mess);
671
       strcpy_P(mess, enddryrun);
671
       strcpy_P(mess, enddryrun);
672
       strcpy_P(&mess[11], PSTR(" sd:"));
672
       strcpy_P(&mess[11], PSTR(" sd:"));
673
       if (zero_std_dev < 1)
673
       if (zero_std_dev < 1)
674
-        sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev * 1000.0));
674
+        sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev * 1000.0f));
675
       else
675
       else
676
         sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev));
676
         sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev));
677
       ui.set_status(mess);
677
       ui.set_status(mess);

Loading…
Cancel
Save