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
         S2 += sq(z_pt[rad]);
185
         S2 += sq(z_pt[rad]);
186
         N++;
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
   return 0.00001;
191
   return 0.00001;
277
           const float z_temp = calibration_probe(cos(a) * r, sin(a) * r, stow_after_each, set_up);
277
           const float z_temp = calibration_probe(cos(a) * r, sin(a) * r, stow_after_each, set_up);
278
           if (isnan(z_temp)) return false;
278
           if (isnan(z_temp)) return false;
279
           // split probe point to neighbouring calibration points
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
         zig_zag = !zig_zag;
283
         zig_zag = !zig_zag;
284
       }
284
       }
680
         char mess[21];
680
         char mess[21];
681
         strcpy_P(mess, PSTR("Calibration sd:"));
681
         strcpy_P(mess, PSTR("Calibration sd:"));
682
         if (zero_std_dev_min < 1)
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
         else
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
         lcd_setstatus(mess);
686
         lcd_setstatus(mess);
687
         print_calibration_settings(_endstop_results, _angle_results);
687
         print_calibration_settings(_endstop_results, _angle_results);
688
         serialprintPGM(save_message);
688
         serialprintPGM(save_message);
716
       strcpy_P(mess, enddryrun);
716
       strcpy_P(mess, enddryrun);
717
       strcpy_P(&mess[11], PSTR(" sd:"));
717
       strcpy_P(&mess[11], PSTR(" sd:"));
718
       if (zero_std_dev < 1)
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
       else
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
       lcd_setstatus(mess);
722
       lcd_setstatus(mess);
723
     }
723
     }
724
     ac_home();
724
     ac_home();

Loading…
Cancel
Save