Browse Source

Optimize calculations with LROUND

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

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

@@ -185,7 +185,7 @@ static float std_dev_points(float z_pt[NPP + 1], const bool _0p_cal, const bool
185 185
         S2 += sq(z_pt[rad]);
186 186
         N++;
187 187
       }
188
-      return round(SQRT(S2 / N) * 1000.0) / 1000.0 + 0.00001;
188
+      return LROUND(SQRT(S2 / N) * 1000.0) / 1000.0 + 0.00001;
189 189
     }
190 190
   }
191 191
   return 0.00001;
@@ -277,8 +277,8 @@ static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_poi
277 277
           const float z_temp = calibration_probe(cos(a) * r, sin(a) * r, stow_after_each, set_up);
278 278
           if (isnan(z_temp)) return false;
279 279
           // split probe point to neighbouring calibration points
280
-          z_pt[uint8_t(round(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
281
-          z_pt[uint8_t(round(rad - interpol))           % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
280
+          z_pt[uint8_t(LROUND(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
281
+          z_pt[uint8_t(LROUND(rad - interpol))           % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
282 282
         }
283 283
         zig_zag = !zig_zag;
284 284
       }
@@ -680,9 +680,9 @@ void GcodeSuite::G33() {
680 680
         char mess[21];
681 681
         strcpy_P(mess, PSTR("Calibration sd:"));
682 682
         if (zero_std_dev_min < 1)
683
-          sprintf_P(&mess[15], PSTR("0.%03i"), (int)round(zero_std_dev_min * 1000.0));
683
+          sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev_min * 1000.0));
684 684
         else
685
-          sprintf_P(&mess[15], PSTR("%03i.x"), (int)round(zero_std_dev_min));
685
+          sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev_min));
686 686
         lcd_setstatus(mess);
687 687
         print_calibration_settings(_endstop_results, _angle_results);
688 688
         serialprintPGM(save_message);
@@ -716,9 +716,9 @@ void GcodeSuite::G33() {
716 716
       strcpy_P(mess, enddryrun);
717 717
       strcpy_P(&mess[11], PSTR(" sd:"));
718 718
       if (zero_std_dev < 1)
719
-        sprintf_P(&mess[15], PSTR("0.%03i"), (int)round(zero_std_dev * 1000.0));
719
+        sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev * 1000.0));
720 720
       else
721
-        sprintf_P(&mess[15], PSTR("%03i.x"), (int)round(zero_std_dev));
721
+        sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev));
722 722
       lcd_setstatus(mess);
723 723
     }
724 724
     ac_home();

Loading…
Cancel
Save