Browse Source

Merge pull request #6552 from thinkyhead/rc_more_ubl_cleanup

Further cleanup of UBL
Scott Lahteine 7 years ago
parent
commit
628391304f

+ 10
- 10
Marlin/G26_Mesh_Validation_Tool.cpp View File

258
         : find_closest_circle_to_print(x_pos, y_pos); // Find the closest Mesh Intersection to where we are now.
258
         : find_closest_circle_to_print(x_pos, y_pos); // Find the closest Mesh Intersection to where we are now.
259
 
259
 
260
       if (location.x_index >= 0 && location.y_index >= 0) {
260
       if (location.x_index >= 0 && location.y_index >= 0) {
261
-        const float circle_x = pgm_read_float(&(ubl.mesh_index_to_xpos[location.x_index])),
262
-                    circle_y = pgm_read_float(&(ubl.mesh_index_to_ypos[location.y_index]));
261
+        const float circle_x = pgm_read_float(&ubl.mesh_index_to_xpos[location.x_index]),
262
+                    circle_y = pgm_read_float(&ubl.mesh_index_to_ypos[location.y_index]);
263
 
263
 
264
         // Let's do a couple of quick sanity checks.  We can pull this code out later if we never see it catch a problem
264
         // Let's do a couple of quick sanity checks.  We can pull this code out later if we never see it catch a problem
265
         #ifdef DELTA
265
         #ifdef DELTA
401
     for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
401
     for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
402
       for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
402
       for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
403
         if (!is_bit_set(circle_flags, i, j)) {
403
         if (!is_bit_set(circle_flags, i, j)) {
404
-          const float mx = pgm_read_float(&(ubl.mesh_index_to_xpos[i])),  // We found a circle that needs to be printed
405
-                      my = pgm_read_float(&(ubl.mesh_index_to_ypos[j]));
404
+          const float mx = pgm_read_float(&ubl.mesh_index_to_xpos[i]),  // We found a circle that needs to be printed
405
+                      my = pgm_read_float(&ubl.mesh_index_to_ypos[j]);
406
 
406
 
407
           // Get the distance to this intersection
407
           // Get the distance to this intersection
408
           float f = HYPOT(X - mx, Y - my);
408
           float f = HYPOT(X - mx, Y - my);
446
               // We found two circles that need a horizontal line to connect them
446
               // We found two circles that need a horizontal line to connect them
447
               // Print it!
447
               // Print it!
448
               //
448
               //
449
-              sx = pgm_read_float(&(ubl.mesh_index_to_xpos[  i  ])) + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // right edge
450
-              ex = pgm_read_float(&(ubl.mesh_index_to_xpos[i + 1])) - (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // left edge
449
+              sx = pgm_read_float(&ubl.mesh_index_to_xpos[  i  ]) + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // right edge
450
+              ex = pgm_read_float(&ubl.mesh_index_to_xpos[i + 1]) - (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // left edge
451
 
451
 
452
               sx = constrain(sx, X_MIN_POS + 1, X_MAX_POS - 1);
452
               sx = constrain(sx, X_MIN_POS + 1, X_MAX_POS - 1);
453
-              sy = ey = constrain(pgm_read_float(&(ubl.mesh_index_to_ypos[j])), Y_MIN_POS + 1, Y_MAX_POS - 1);
453
+              sy = ey = constrain(pgm_read_float(&ubl.mesh_index_to_ypos[j]), Y_MIN_POS + 1, Y_MAX_POS - 1);
454
               ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
454
               ex = constrain(ex, X_MIN_POS + 1, X_MAX_POS - 1);
455
 
455
 
456
               if (ubl.g26_debug_flag) {
456
               if (ubl.g26_debug_flag) {
477
                 // We found two circles that need a vertical line to connect them
477
                 // We found two circles that need a vertical line to connect them
478
                 // Print it!
478
                 // Print it!
479
                 //
479
                 //
480
-                sy = pgm_read_float(&(ubl.mesh_index_to_ypos[  j  ])) + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // top edge
481
-                ey = pgm_read_float(&(ubl.mesh_index_to_ypos[j + 1])) - (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // bottom edge
480
+                sy = pgm_read_float(&ubl.mesh_index_to_ypos[  j  ]) + (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // top edge
481
+                ey = pgm_read_float(&ubl.mesh_index_to_ypos[j + 1]) - (SIZE_OF_INTERSECTION_CIRCLES - (SIZE_OF_CROSSHAIRS)); // bottom edge
482
 
482
 
483
-                sx = ex = constrain(pgm_read_float(&(ubl.mesh_index_to_xpos[i])), X_MIN_POS + 1, X_MAX_POS - 1);
483
+                sx = ex = constrain(pgm_read_float(&ubl.mesh_index_to_xpos[i]), X_MIN_POS + 1, X_MAX_POS - 1);
484
                 sy = constrain(sy, Y_MIN_POS + 1, Y_MAX_POS - 1);
484
                 sy = constrain(sy, Y_MIN_POS + 1, Y_MAX_POS - 1);
485
                 ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
485
                 ey = constrain(ey, Y_MIN_POS + 1, Y_MAX_POS - 1);
486
 
486
 

+ 7
- 7
Marlin/Marlin_main.cpp View File

4919
       // For LINEAR and 3POINT leveling correct the current position
4919
       // For LINEAR and 3POINT leveling correct the current position
4920
 
4920
 
4921
       if (verbose_level > 0)
4921
       if (verbose_level > 0)
4922
-        planner.bed_level_matrix.debug("\n\nBed Level Correction Matrix:");
4922
+        planner.bed_level_matrix.debug(PSTR("\n\nBed Level Correction Matrix:"));
4923
 
4923
 
4924
       if (!dryrun) {
4924
       if (!dryrun) {
4925
         //
4925
         //
6965
     for (uint8_t i = 0; i < COUNT(debug_strings); i++) {
6965
     for (uint8_t i = 0; i < COUNT(debug_strings); i++) {
6966
       if (TEST(marlin_debug_flags, i)) {
6966
       if (TEST(marlin_debug_flags, i)) {
6967
         if (comma++) SERIAL_CHAR(',');
6967
         if (comma++) SERIAL_CHAR(',');
6968
-        serialprintPGM((char*)pgm_read_word(&(debug_strings[i])));
6968
+        serialprintPGM((char*)pgm_read_word(&debug_strings[i]));
6969
       }
6969
       }
6970
     }
6970
     }
6971
   }
6971
   }
8360
     // V to print the matrix or mesh
8360
     // V to print the matrix or mesh
8361
     if (code_seen('V')) {
8361
     if (code_seen('V')) {
8362
       #if ABL_PLANAR
8362
       #if ABL_PLANAR
8363
-        planner.bed_level_matrix.debug("Bed Level Correction Matrix:");
8363
+        planner.bed_level_matrix.debug(PSTR("Bed Level Correction Matrix:"));
8364
       #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
8364
       #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
8365
         if (bilinear_grid_spacing[X_AXIS]) {
8365
         if (bilinear_grid_spacing[X_AXIS]) {
8366
           print_bilinear_leveling_grid();
8366
           print_bilinear_leveling_grid();
9545
 
9545
 
9546
             #if ENABLED(DEBUG_LEVELING_FEATURE)
9546
             #if ENABLED(DEBUG_LEVELING_FEATURE)
9547
               if (DEBUGGING(LEVELING)) {
9547
               if (DEBUGGING(LEVELING)) {
9548
-                tmp_offset_vec.debug("tmp_offset_vec");
9549
-                act_offset_vec.debug("act_offset_vec");
9550
-                offset_vec.debug("offset_vec (BEFORE)");
9548
+                tmp_offset_vec.debug(PSTR("tmp_offset_vec"));
9549
+                act_offset_vec.debug(PSTR("act_offset_vec"));
9550
+                offset_vec.debug(PSTR("offset_vec (BEFORE)"));
9551
               }
9551
               }
9552
             #endif
9552
             #endif
9553
 
9553
 
9554
             offset_vec.apply_rotation(planner.bed_level_matrix.transpose(planner.bed_level_matrix));
9554
             offset_vec.apply_rotation(planner.bed_level_matrix.transpose(planner.bed_level_matrix));
9555
 
9555
 
9556
             #if ENABLED(DEBUG_LEVELING_FEATURE)
9556
             #if ENABLED(DEBUG_LEVELING_FEATURE)
9557
-              if (DEBUGGING(LEVELING)) offset_vec.debug("offset_vec (AFTER)");
9557
+              if (DEBUGGING(LEVELING)) offset_vec.debug(PSTR("offset_vec (AFTER)"));
9558
             #endif
9558
             #endif
9559
 
9559
 
9560
             // Adjustments to the current position
9560
             // Adjustments to the current position

+ 1
- 1
Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration.h View File

452
 
452
 
453
   // set the radius for the calibration probe points - max 0.8 * DELTA_PRINTABLE_RADIUS if DELTA_AUTO_CALIBRATION enabled
453
   // set the radius for the calibration probe points - max 0.8 * DELTA_PRINTABLE_RADIUS if DELTA_AUTO_CALIBRATION enabled
454
   #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - 17) // mm
454
   #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - 17) // mm
455
-  
455
+
456
   // G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results)
456
   // G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results)
457
   #define DELTA_AUTO_CALIBRATION
457
   #define DELTA_AUTO_CALIBRATION
458
   #if ENABLED(DELTA_AUTO_CALIBRATION)
458
   #if ENABLED(DELTA_AUTO_CALIBRATION)

+ 1
- 1
Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration.h View File

459
 
459
 
460
   // set the radius for the calibration probe points - max 0.8 * DELTA_PRINTABLE_RADIUS if DELTA_AUTO_CALIBRATION enabled
460
   // set the radius for the calibration probe points - max 0.8 * DELTA_PRINTABLE_RADIUS if DELTA_AUTO_CALIBRATION enabled
461
   #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - 17) // mm
461
   #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - 17) // mm
462
-  
462
+
463
   // G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results)
463
   // G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results)
464
   //#define DELTA_AUTO_CALIBRATION
464
   //#define DELTA_AUTO_CALIBRATION
465
   #if ENABLED(DELTA_AUTO_CALIBRATION)
465
   #if ENABLED(DELTA_AUTO_CALIBRATION)

+ 1
- 1
Marlin/example_configurations/delta/generic/Configuration.h View File

448
 
448
 
449
   // set the radius for the calibration probe points - max 0.8 * DELTA_PRINTABLE_RADIUS if DELTA_AUTO_CALIBRATION enabled
449
   // set the radius for the calibration probe points - max 0.8 * DELTA_PRINTABLE_RADIUS if DELTA_AUTO_CALIBRATION enabled
450
   #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - 28) // mm
450
   #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - 28) // mm
451
-  
451
+
452
   // G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results)
452
   // G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results)
453
   //#define DELTA_AUTO_CALIBRATION
453
   //#define DELTA_AUTO_CALIBRATION
454
   #if ENABLED(DELTA_AUTO_CALIBRATION)
454
   #if ENABLED(DELTA_AUTO_CALIBRATION)

+ 1
- 1
Marlin/example_configurations/delta/kossel_mini/Configuration.h View File

448
 
448
 
449
   // set the radius for the calibration probe points - max 0.8 * DELTA_PRINTABLE_RADIUS if DELTA_AUTO_CALIBRATION enabled
449
   // set the radius for the calibration probe points - max 0.8 * DELTA_PRINTABLE_RADIUS if DELTA_AUTO_CALIBRATION enabled
450
   #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - 18) // mm
450
   #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - 18) // mm
451
-  
451
+
452
   // G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results)
452
   // G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results)
453
   //#define DELTA_AUTO_CALIBRATION
453
   //#define DELTA_AUTO_CALIBRATION
454
   #if ENABLED(DELTA_AUTO_CALIBRATION)
454
   #if ENABLED(DELTA_AUTO_CALIBRATION)

+ 1
- 1
Marlin/example_configurations/delta/kossel_pro/Configuration.h View File

435
 
435
 
436
   // set the radius for the calibration probe points - max 0.8 * DELTA_PRINTABLE_RADIUS if DELTA_AUTO_CALIBRATION enabled
436
   // set the radius for the calibration probe points - max 0.8 * DELTA_PRINTABLE_RADIUS if DELTA_AUTO_CALIBRATION enabled
437
   #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - 25.4) // mm
437
   #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - 25.4) // mm
438
-  
438
+
439
   // G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results)
439
   // G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results)
440
   //#define DELTA_AUTO_CALIBRATION
440
   //#define DELTA_AUTO_CALIBRATION
441
   #if ENABLED(DELTA_AUTO_CALIBRATION)
441
   #if ENABLED(DELTA_AUTO_CALIBRATION)

+ 1
- 1
Marlin/example_configurations/delta/kossel_xl/Configuration.h View File

453
 
453
 
454
   // set the radius for the calibration probe points - max 0.8 * DELTA_PRINTABLE_RADIUS if DELTA_AUTO_CALIBRATION enabled
454
   // set the radius for the calibration probe points - max 0.8 * DELTA_PRINTABLE_RADIUS if DELTA_AUTO_CALIBRATION enabled
455
   #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - 28) // mm
455
   #define DELTA_CALIBRATION_RADIUS (DELTA_PRINTABLE_RADIUS - 28) // mm
456
-  
456
+
457
   // G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results)
457
   // G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results)
458
   //#define DELTA_AUTO_CALIBRATION
458
   //#define DELTA_AUTO_CALIBRATION
459
   #if ENABLED(DELTA_AUTO_CALIBRATION)
459
   #if ENABLED(DELTA_AUTO_CALIBRATION)

+ 6
- 6
Marlin/least_squares_fit.cpp View File

66
   lsf->xbar /= N;
66
   lsf->xbar /= N;
67
   lsf->ybar /= N;
67
   lsf->ybar /= N;
68
   lsf->zbar /= N;
68
   lsf->zbar /= N;
69
-  lsf->x2bar = lsf->x2bar / N - lsf->xbar * lsf->xbar;
70
-  lsf->y2bar = lsf->y2bar / N - lsf->ybar * lsf->ybar;
71
-  lsf->z2bar = lsf->z2bar / N - lsf->zbar * lsf->zbar;
72
-  lsf->xybar = lsf->xybar / N - lsf->xbar * lsf->ybar;
73
-  lsf->yzbar = lsf->yzbar / N - lsf->ybar * lsf->zbar;
74
-  lsf->xzbar = lsf->xzbar / N - lsf->xbar * lsf->zbar;
69
+  lsf->x2bar = lsf->x2bar / N - sq(lsf->xbar);
70
+  lsf->y2bar = lsf->y2bar / N - sq(lsf->ybar);
71
+  lsf->z2bar = lsf->z2bar / N - sq(lsf->zbar);
72
+  lsf->xybar = lsf->xybar / N - sq(lsf->xbar);
73
+  lsf->yzbar = lsf->yzbar / N - sq(lsf->ybar);
74
+  lsf->xzbar = lsf->xzbar / N - sq(lsf->xbar);
75
 
75
 
76
   const float DD = lsf->x2bar * lsf->y2bar - sq(lsf->xybar);
76
   const float DD = lsf->x2bar * lsf->y2bar - sq(lsf->xybar);
77
   if (fabs(DD) <= 1e-10 * (lsf->max_absx + lsf->max_absy))
77
   if (fabs(DD) <= 1e-10 * (lsf->max_absx + lsf->max_absy))

+ 394
- 422
Marlin/ubl_G29.cpp
File diff suppressed because it is too large
View File


+ 14
- 14
Marlin/ubl_motion.cpp View File

154
        * to create a 1-over number for us. That will allow us to do a floating point multiply instead of a floating point divide.
154
        * to create a 1-over number for us. That will allow us to do a floating point multiply instead of a floating point divide.
155
        */
155
        */
156
 
156
 
157
-      const float xratio = (RAW_X_POSITION(end[X_AXIS]) - pgm_read_float(&(ubl.mesh_index_to_xpos[cell_dest_xi]))) * (1.0 / (MESH_X_DIST)),
157
+      const float xratio = (RAW_X_POSITION(end[X_AXIS]) - pgm_read_float(&ubl.mesh_index_to_xpos[cell_dest_xi])) * (1.0 / (MESH_X_DIST)),
158
                   z1 = ubl.z_values[cell_dest_xi    ][cell_dest_yi    ] + xratio *
158
                   z1 = ubl.z_values[cell_dest_xi    ][cell_dest_yi    ] + xratio *
159
                       (ubl.z_values[cell_dest_xi + 1][cell_dest_yi    ] - ubl.z_values[cell_dest_xi][cell_dest_yi    ]),
159
                       (ubl.z_values[cell_dest_xi + 1][cell_dest_yi    ] - ubl.z_values[cell_dest_xi][cell_dest_yi    ]),
160
                   z2 = ubl.z_values[cell_dest_xi    ][cell_dest_yi + 1] + xratio *
160
                   z2 = ubl.z_values[cell_dest_xi    ][cell_dest_yi + 1] + xratio *
163
       // we are done with the fractional X distance into the cell. Now with the two Z-Heights we have calculated, we
163
       // we are done with the fractional X distance into the cell. Now with the two Z-Heights we have calculated, we
164
       // are going to apply the Y-Distance into the cell to interpolate the final Z correction.
164
       // are going to apply the Y-Distance into the cell to interpolate the final Z correction.
165
 
165
 
166
-      const float yratio = (RAW_Y_POSITION(end[Y_AXIS]) - pgm_read_float(&(ubl.mesh_index_to_ypos[cell_dest_yi]))) * (1.0 / (MESH_Y_DIST));
166
+      const float yratio = (RAW_Y_POSITION(end[Y_AXIS]) - pgm_read_float(&ubl.mesh_index_to_ypos[cell_dest_yi])) * (1.0 / (MESH_Y_DIST));
167
 
167
 
168
       float z0 = z1 + (z2 - z1) * yratio;
168
       float z0 = z1 + (z2 - z1) * yratio;
169
 
169
 
198
     const float dx = end[X_AXIS] - start[X_AXIS],
198
     const float dx = end[X_AXIS] - start[X_AXIS],
199
                 dy = end[Y_AXIS] - start[Y_AXIS];
199
                 dy = end[Y_AXIS] - start[Y_AXIS];
200
 
200
 
201
-    const int left_flag = dx < 0.0 ? 1.0 : 0.0,
202
-              down_flag = dy < 0.0 ? 1.0 : 0.0;
201
+    const int left_flag = dx < 0.0 ? 1 : 0,
202
+              down_flag = dy < 0.0 ? 1 : 0;
203
 
203
 
204
     const float adx = left_flag ? -dx : dx,
204
     const float adx = left_flag ? -dx : dx,
205
                 ady = down_flag ? -dy : dy;
205
                 ady = down_flag ? -dy : dy;
230
     const float m = dy / dx,
230
     const float m = dy / dx,
231
                 c = start[Y_AXIS] - m * start[X_AXIS];
231
                 c = start[Y_AXIS] - m * start[X_AXIS];
232
 
232
 
233
-    const bool inf_normalized_flag=isinf(e_normalized_dist),
234
-               inf_m_flag=isinf(m);
233
+    const bool inf_normalized_flag = isinf(e_normalized_dist),
234
+               inf_m_flag = isinf(m);
235
     /**
235
     /**
236
      * This block handles vertical lines. These are lines that stay within the same
236
      * This block handles vertical lines. These are lines that stay within the same
237
      * X Cell column. They do not need to be perfectly vertical. They just can
237
      * X Cell column. They do not need to be perfectly vertical. They just can
241
       current_yi += down_flag;  // Line is heading down, we just want to go to the bottom
241
       current_yi += down_flag;  // Line is heading down, we just want to go to the bottom
242
       while (current_yi != cell_dest_yi + down_flag) {
242
       while (current_yi != cell_dest_yi + down_flag) {
243
         current_yi += dyi;
243
         current_yi += dyi;
244
-        const float next_mesh_line_y = LOGICAL_Y_POSITION(pgm_read_float(&(ubl.mesh_index_to_ypos[current_yi])));
244
+        const float next_mesh_line_y = LOGICAL_Y_POSITION(pgm_read_float(&ubl.mesh_index_to_ypos[current_yi]));
245
 
245
 
246
         /**
246
         /**
247
          * if the slope of the line is infinite, we won't do the calculations
247
          * if the slope of the line is infinite, we won't do the calculations
263
          */
263
          */
264
         if (isnan(z0)) z0 = 0.0;
264
         if (isnan(z0)) z0 = 0.0;
265
 
265
 
266
-        const float y = LOGICAL_Y_POSITION(pgm_read_float(&(ubl.mesh_index_to_ypos[current_yi])));
266
+        const float y = LOGICAL_Y_POSITION(pgm_read_float(&ubl.mesh_index_to_ypos[current_yi]));
267
 
267
 
268
         /**
268
         /**
269
          * Without this check, it is possible for the algorithm to generate a zero length move in the case
269
          * Without this check, it is possible for the algorithm to generate a zero length move in the case
274
         if (y != start[Y_AXIS]) {
274
         if (y != start[Y_AXIS]) {
275
           if (!inf_normalized_flag) {
275
           if (!inf_normalized_flag) {
276
 
276
 
277
-            //on_axis_distance = y - start[Y_AXIS];                               
277
+            //on_axis_distance = y - start[Y_AXIS];
278
             on_axis_distance = use_x_dist ? x - start[X_AXIS] : y - start[Y_AXIS];
278
             on_axis_distance = use_x_dist ? x - start[X_AXIS] : y - start[Y_AXIS];
279
 
279
 
280
             //on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : y - start[Y_AXIS];
280
             //on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : y - start[Y_AXIS];
283
             //on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : y - start[Y_AXIS];
283
             //on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : y - start[Y_AXIS];
284
             //on_axis_distance = use_x_dist ? x - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
284
             //on_axis_distance = use_x_dist ? x - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
285
 
285
 
286
-            e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;  
286
+            e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;
287
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
287
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
288
           }
288
           }
289
           else {
289
           else {
321
                                 // edge of this cell for the first move.
321
                                 // edge of this cell for the first move.
322
       while (current_xi != cell_dest_xi + left_flag) {
322
       while (current_xi != cell_dest_xi + left_flag) {
323
         current_xi += dxi;
323
         current_xi += dxi;
324
-        const float next_mesh_line_x = LOGICAL_X_POSITION(pgm_read_float(&(ubl.mesh_index_to_xpos[current_xi]))),
324
+        const float next_mesh_line_x = LOGICAL_X_POSITION(pgm_read_float(&ubl.mesh_index_to_xpos[current_xi])),
325
                     y = m * next_mesh_line_x + c;   // Calculate Y at the next X mesh line
325
                     y = m * next_mesh_line_x + c;   // Calculate Y at the next X mesh line
326
 
326
 
327
         float z0 = ubl.z_correction_for_y_on_vertical_mesh_line(y, current_xi, current_yi);
327
         float z0 = ubl.z_correction_for_y_on_vertical_mesh_line(y, current_xi, current_yi);
337
          */
337
          */
338
         if (isnan(z0)) z0 = 0.0;
338
         if (isnan(z0)) z0 = 0.0;
339
 
339
 
340
-        const float x = LOGICAL_X_POSITION(pgm_read_float(&(ubl.mesh_index_to_xpos[current_xi])));
340
+        const float x = LOGICAL_X_POSITION(pgm_read_float(&ubl.mesh_index_to_xpos[current_xi]));
341
 
341
 
342
         /**
342
         /**
343
          * Without this check, it is possible for the algorithm to generate a zero length move in the case
343
          * Without this check, it is possible for the algorithm to generate a zero length move in the case
393
 
393
 
394
     while (xi_cnt > 0 || yi_cnt > 0) {
394
     while (xi_cnt > 0 || yi_cnt > 0) {
395
 
395
 
396
-      const float next_mesh_line_x = LOGICAL_X_POSITION(pgm_read_float(&(ubl.mesh_index_to_xpos[current_xi + dxi]))),
397
-                  next_mesh_line_y = LOGICAL_Y_POSITION(pgm_read_float(&(ubl.mesh_index_to_ypos[current_yi + dyi]))),
396
+      const float next_mesh_line_x = LOGICAL_X_POSITION(pgm_read_float(&ubl.mesh_index_to_xpos[current_xi + dxi])),
397
+                  next_mesh_line_y = LOGICAL_Y_POSITION(pgm_read_float(&ubl.mesh_index_to_ypos[current_yi + dyi])),
398
                   y = m * next_mesh_line_x + c,   // Calculate Y at the next X mesh line
398
                   y = m * next_mesh_line_x + c,   // Calculate Y at the next X mesh line
399
                   x = (next_mesh_line_y - c) / m; // Calculate X at the next Y mesh line
399
                   x = (next_mesh_line_y - c) / m; // Calculate X at the next Y mesh line
400
                                                   // (No need to worry about m being zero.
400
                                                   // (No need to worry about m being zero.

+ 13
- 13
Marlin/vector_3.cpp View File

63
   return normalized;
63
   return normalized;
64
 }
64
 }
65
 
65
 
66
-float vector_3::get_length() { return sqrt((x * x) + (y * y) + (z * z)); }
66
+float vector_3::get_length() { return sqrt(sq(x) + sq(y) + sq(z)); }
67
 
67
 
68
 void vector_3::normalize() {
68
 void vector_3::normalize() {
69
   const float inv_length = 1.0 / get_length();
69
   const float inv_length = 1.0 / get_length();
81
   z = resultZ;
81
   z = resultZ;
82
 }
82
 }
83
 
83
 
84
-void vector_3::debug(const char title[]) {
85
-  SERIAL_PROTOCOL(title);
84
+void vector_3::debug(const char * const title) {
85
+  serialprintPGM(title);
86
   SERIAL_PROTOCOLPGM(" x: ");
86
   SERIAL_PROTOCOLPGM(" x: ");
87
   SERIAL_PROTOCOL_F(x, 6);
87
   SERIAL_PROTOCOL_F(x, 6);
88
   SERIAL_PROTOCOLPGM(" y: ");
88
   SERIAL_PROTOCOLPGM(" y: ");
101
 }
101
 }
102
 
102
 
103
 matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 row_2) {
103
 matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 row_2) {
104
-  //row_0.debug("row_0");
105
-  //row_1.debug("row_1");
106
-  //row_2.debug("row_2");
104
+  //row_0.debug(PSTR("row_0"));
105
+  //row_1.debug(PSTR("row_1"));
106
+  //row_2.debug(PSTR("row_2"));
107
   matrix_3x3 new_matrix;
107
   matrix_3x3 new_matrix;
108
   new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z;
108
   new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z;
109
   new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z;
109
   new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z;
110
   new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z;
110
   new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z;
111
-  //new_matrix.debug("new_matrix");
111
+  //new_matrix.debug(PSTR("new_matrix"));
112
   return new_matrix;
112
   return new_matrix;
113
 }
113
 }
114
 
114
 
123
   vector_3 x_row = vector_3(1, 0, -target.x / target.z).get_normal();
123
   vector_3 x_row = vector_3(1, 0, -target.x / target.z).get_normal();
124
   vector_3 y_row = vector_3::cross(z_row, x_row).get_normal();
124
   vector_3 y_row = vector_3::cross(z_row, x_row).get_normal();
125
 
125
 
126
-  // x_row.debug("x_row");
127
-  // y_row.debug("y_row");
128
-  // z_row.debug("z_row");
126
+  // x_row.debug(PSTR("x_row"));
127
+  // y_row.debug(PSTR("y_row"));
128
+  // z_row.debug(PSTR("z_row"));
129
 
129
 
130
   // create the matrix already correctly transposed
130
   // create the matrix already correctly transposed
131
   matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row);
131
   matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row);
132
 
132
 
133
-  // rot.debug("rot");
133
+  // rot.debug(PSTR("rot"));
134
   return rot;
134
   return rot;
135
 }
135
 }
136
 
136
 
142
   return new_matrix;
142
   return new_matrix;
143
 }
143
 }
144
 
144
 
145
-void matrix_3x3::debug(const char title[]) {
146
-  SERIAL_PROTOCOLLN(title);
145
+void matrix_3x3::debug(const char * const title) {
146
+  serialprintPGM(title);
147
   uint8_t count = 0;
147
   uint8_t count = 0;
148
   for (uint8_t i = 0; i < 3; i++) {
148
   for (uint8_t i = 0; i < 3; i++) {
149
     for (uint8_t j = 0; j < 3; j++) {
149
     for (uint8_t j = 0; j < 3; j++) {

+ 4
- 3
Marlin/vector_3.h View File

42
 #define VECTOR_3_H
42
 #define VECTOR_3_H
43
 
43
 
44
 #if HAS_ABL
44
 #if HAS_ABL
45
+
45
 class matrix_3x3;
46
 class matrix_3x3;
46
 
47
 
47
 struct vector_3 {
48
 struct vector_3 {
58
   float get_length();
59
   float get_length();
59
   vector_3 get_normal();
60
   vector_3 get_normal();
60
 
61
 
61
-  void debug(const char title[]);
62
+  void debug(const char * const title);
62
 
63
 
63
   void apply_rotation(matrix_3x3 matrix);
64
   void apply_rotation(matrix_3x3 matrix);
64
 };
65
 };
72
 
73
 
73
   void set_to_identity();
74
   void set_to_identity();
74
 
75
 
75
-  void debug(const char title[]);
76
+  void debug(const char * const title);
76
 };
77
 };
77
 
78
 
78
 
79
 
79
 void apply_rotation_xyz(matrix_3x3 rotationMatrix, float& x, float& y, float& z);
80
 void apply_rotation_xyz(matrix_3x3 rotationMatrix, float& x, float& y, float& z);
80
-#endif // HAS_ABL
81
 
81
 
82
+#endif // HAS_ABL
82
 #endif // VECTOR_3_H
83
 #endif // VECTOR_3_H

Loading…
Cancel
Save