浏览代码

UBL Cleanup/Bugfix

- Fix bug in ubl_line_to_destination
- Improve/fix output of some ubl.h functions
Brian 8 年前
父节点
当前提交
4da14b14f4
共有 2 个文件被更改,包括 12 次插入11 次删除
  1. 8
    5
      Marlin/ubl.h
  2. 4
    6
      Marlin/ubl_motion.cpp

+ 8
- 5
Marlin/ubl.h 查看文件

160
       unified_bed_leveling();
160
       unified_bed_leveling();
161
 
161
 
162
       FORCE_INLINE void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
162
       FORCE_INLINE void set_z(const int8_t px, const int8_t py, const float &z) { z_values[px][py] = z; }
163
-        int8_t get_cell_index_x(const float &x) {
163
+
164
+      int8_t get_cell_index_x(const float &x) {
164
         const int8_t cx = (x - (UBL_MESH_MIN_X)) * (1.0 / (MESH_X_DIST));
165
         const int8_t cx = (x - (UBL_MESH_MIN_X)) * (1.0 / (MESH_X_DIST));
165
         return constrain(cx, 0, (GRID_MAX_POINTS_X) - 1);   // -1 is appropriate if we want all movement to the X_MAX
166
         return constrain(cx, 0, (GRID_MAX_POINTS_X) - 1);   // -1 is appropriate if we want all movement to the X_MAX
166
       }                                                     // position. But with this defined this way, it is possible
167
       }                                                     // position. But with this defined this way, it is possible
210
        */
211
        */
211
       inline float z_correction_for_x_on_horizontal_mesh_line(const float &lx0, const int x1_i, const int yi) {
212
       inline float z_correction_for_x_on_horizontal_mesh_line(const float &lx0, const int x1_i, const int yi) {
212
         if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
213
         if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
213
-          SERIAL_ECHOPAIR("? in z_correction_for_x_on_horizontal_mesh_line(lx0=", lx0);
214
+          serialprintPGM( !WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) ? PSTR("x1l_i") : PSTR("yi") );
215
+          SERIAL_ECHOPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(lx0=", lx0);
214
           SERIAL_ECHOPAIR(",x1_i=", x1_i);
216
           SERIAL_ECHOPAIR(",x1_i=", x1_i);
215
           SERIAL_ECHOPAIR(",yi=", yi);
217
           SERIAL_ECHOPAIR(",yi=", yi);
216
           SERIAL_CHAR(')');
218
           SERIAL_CHAR(')');
229
       //
231
       //
230
       inline float z_correction_for_y_on_vertical_mesh_line(const float &ly0, const int xi, const int y1_i) {
232
       inline float z_correction_for_y_on_vertical_mesh_line(const float &ly0, const int xi, const int y1_i) {
231
         if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
233
         if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
232
-          SERIAL_ECHOPAIR("? in get_z_correction_along_vertical_mesh_line_at_specific_x(ly0=", ly0);
233
-          SERIAL_ECHOPAIR(", x1_i=", xi);
234
-          SERIAL_ECHOPAIR(", yi=", y1_i);
234
+          serialprintPGM( !WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) ? PSTR("xi") : PSTR("yl_i") );
235
+          SERIAL_ECHOPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ly0=", ly0);
236
+          SERIAL_ECHOPAIR(", xi=", xi);
237
+          SERIAL_ECHOPAIR(", y1_i=", y1_i);
235
           SERIAL_CHAR(')');
238
           SERIAL_CHAR(')');
236
           SERIAL_EOL;
239
           SERIAL_EOL;
237
           return NAN;
240
           return NAN;

+ 4
- 6
Marlin/ubl_motion.cpp 查看文件

231
     const float m = dy / dx,
231
     const float m = dy / dx,
232
                 c = start[Y_AXIS] - m * start[X_AXIS];
232
                 c = start[Y_AXIS] - m * start[X_AXIS];
233
 
233
 
234
-    const bool inf_normalized_flag = isinf(e_normalized_dist),
235
-               inf_m_flag = isinf(m);
234
+    const bool inf_normalized_flag = (isinf(e_normalized_dist) != 0),
235
+               inf_m_flag = (isinf(m) != 0);
236
     /**
236
     /**
237
      * This block handles vertical lines. These are lines that stay within the same
237
      * This block handles vertical lines. These are lines that stay within the same
238
      * X Cell column. They do not need to be perfectly vertical. They just can
238
      * X Cell column. They do not need to be perfectly vertical. They just can
403
                                                   //  as a vertical line move above.)
403
                                                   //  as a vertical line move above.)
404
 
404
 
405
       if (left_flag == (x > next_mesh_line_x)) { // Check if we hit the Y line first
405
       if (left_flag == (x > next_mesh_line_x)) { // Check if we hit the Y line first
406
-        //
407
         // Yes!  Crossing a Y Mesh Line next
406
         // Yes!  Crossing a Y Mesh Line next
408
-        //
409
         float z0 = ubl.z_correction_for_x_on_horizontal_mesh_line(x, current_xi - left_flag, current_yi + dyi);
407
         float z0 = ubl.z_correction_for_x_on_horizontal_mesh_line(x, current_xi - left_flag, current_yi + dyi);
410
 
408
 
411
         z0 *= ubl.fade_scaling_factor_for_z(end[Z_AXIS]);
409
         z0 *= ubl.fade_scaling_factor_for_z(end[Z_AXIS]);
433
         yi_cnt--;
431
         yi_cnt--;
434
       }
432
       }
435
       else {
433
       else {
436
-        //
437
         // Yes!  Crossing a X Mesh Line next
434
         // Yes!  Crossing a X Mesh Line next
438
-        //
439
         float z0 = ubl.z_correction_for_y_on_vertical_mesh_line(y, current_xi + dxi, current_yi - down_flag);
435
         float z0 = ubl.z_correction_for_y_on_vertical_mesh_line(y, current_xi + dxi, current_yi - down_flag);
440
 
436
 
441
         z0 *= ubl.fade_scaling_factor_for_z(end[Z_AXIS]);
437
         z0 *= ubl.fade_scaling_factor_for_z(end[Z_AXIS]);
463
         current_xi += dxi;
459
         current_xi += dxi;
464
         xi_cnt--;
460
         xi_cnt--;
465
       }
461
       }
462
+
463
+      if (xi_cnt < 0 || yi_cnt < 0) break; // we've gone too far, so exit the loop and move on to FINAL_MOVE
466
     }
464
     }
467
 
465
 
468
     if (ubl.g26_debug_flag)
466
     if (ubl.g26_debug_flag)

正在加载...
取消
保存