Browse Source

Apply const float & more

Scott Lahteine 7 years ago
parent
commit
c99bd69889
3 changed files with 11 additions and 11 deletions
  1. 1
    1
      Marlin/Marlin_main.cpp
  2. 4
    4
      Marlin/least_squares_fit.h
  3. 6
    6
      Marlin/ubl_G29.cpp

+ 1
- 1
Marlin/Marlin_main.cpp View File

2355
    *   - Raise to the BETWEEN height
2355
    *   - Raise to the BETWEEN height
2356
    * - Return the probed Z position
2356
    * - Return the probed Z position
2357
    */
2357
    */
2358
-  float probe_pt(const float x, const float y, const bool stow/*=true*/, const int verbose_level/*=1*/) {
2358
+  float probe_pt(const float &x, const float &y, const bool stow/*=true*/, const int verbose_level/*=1*/) {
2359
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2359
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2360
       if (DEBUGGING(LEVELING)) {
2360
       if (DEBUGGING(LEVELING)) {
2361
         SERIAL_ECHOPAIR(">>> probe_pt(", x);
2361
         SERIAL_ECHOPAIR(">>> probe_pt(", x);

+ 4
- 4
Marlin/least_squares_fit.h View File

52
   memset(lsf, 0, sizeof(linear_fit_data));
52
   memset(lsf, 0, sizeof(linear_fit_data));
53
 }
53
 }
54
 
54
 
55
-void inline incremental_WLSF(struct linear_fit_data *lsf, float x, float y, float z, float w) {
55
+void inline incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w) {
56
   // weight each accumulator by factor w, including the "number" of samples
56
   // weight each accumulator by factor w, including the "number" of samples
57
   // (analagous to calling inc_LSF twice with same values to weight it by 2X)
57
   // (analagous to calling inc_LSF twice with same values to weight it by 2X)
58
   lsf->xbar  += w * x;
58
   lsf->xbar  += w * x;
65
   lsf->xzbar += w * x * z;
65
   lsf->xzbar += w * x * z;
66
   lsf->yzbar += w * y * z;
66
   lsf->yzbar += w * y * z;
67
   lsf->N     += w;
67
   lsf->N     += w;
68
-  lsf->max_absx = max(fabs( w * x ), lsf->max_absx);
69
-  lsf->max_absy = max(fabs( w * y ), lsf->max_absy);
68
+  lsf->max_absx = max(fabs(w * x), lsf->max_absx);
69
+  lsf->max_absy = max(fabs(w * y), lsf->max_absy);
70
 }
70
 }
71
 
71
 
72
-void inline incremental_LSF(struct linear_fit_data *lsf, float x, float y, float z) {
72
+void inline incremental_LSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z) {
73
   lsf->xbar += x;
73
   lsf->xbar += x;
74
   lsf->ybar += y;
74
   lsf->ybar += y;
75
   lsf->zbar += z;
75
   lsf->zbar += z;

+ 6
- 6
Marlin/ubl_G29.cpp View File

51
   extern uint8_t code_value_byte();
51
   extern uint8_t code_value_byte();
52
   extern bool code_value_bool();
52
   extern bool code_value_bool();
53
   extern bool code_has_value();
53
   extern bool code_has_value();
54
-  extern float probe_pt(float x, float y, bool, int);
54
+  extern float probe_pt(const float &x, const float &y, bool, int);
55
   extern bool set_probe_deployed(bool);
55
   extern bool set_probe_deployed(bool);
56
   void smart_fill_mesh();
56
   void smart_fill_mesh();
57
-  void smart_fill_wlsf(float);
57
+  void smart_fill_wlsf(const float &);
58
   float measure_business_card_thickness(float &in_height);
58
   float measure_business_card_thickness(float &in_height);
59
   void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
59
   void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
60
 
60
 
531
             }
531
             }
532
           } else {
532
           } else {
533
             const float cvf = code_value_float();
533
             const float cvf = code_value_float();
534
-            switch( (int)truncf( cvf * 10.0 ) - 30 ) {   // 3.1 -> 1
534
+            switch((int)truncf(cvf * 10.0) - 30) {   // 3.1 -> 1
535
               #if ENABLED(UBL_G29_P31)
535
               #if ENABLED(UBL_G29_P31)
536
                 case 1: {
536
                 case 1: {
537
 
537
 
541
                   // P3.12 100X distance weighting
541
                   // P3.12 100X distance weighting
542
                   // P3.13 1000X distance weighting, approaches simple average of nearest points
542
                   // P3.13 1000X distance weighting, approaches simple average of nearest points
543
 
543
 
544
-                  const float weight_power  = (cvf - 3.10) * 100.0;  // 3.12345 -> 2.345
545
-                  const float weight_factor = weight_power ? pow( 10.0, weight_power ) : 0;
546
-                  smart_fill_wlsf( weight_factor );
544
+                  const float weight_power  = (cvf - 3.10) * 100.0,  // 3.12345 -> 2.345
545
+                              weight_factor = weight_power ? pow(10.0, weight_power) : 0;
546
+                  smart_fill_wlsf(weight_factor);
547
                 }
547
                 }
548
                 break;
548
                 break;
549
               #endif
549
               #endif

Loading…
Cancel
Save