Просмотр исходного кода

UBL-related cleanup, spacing, standards

Reference: #6804
Scott Lahteine 8 лет назад
Родитель
Сommit
02f15f6775
3 измененных файлов: 60 добавлений и 68 удалений
  1. 22
    29
      Marlin/Marlin.h
  2. 9
    8
      Marlin/Marlin_main.cpp
  3. 29
    31
      Marlin/ubl_G29.cpp

+ 22
- 29
Marlin/Marlin.h Просмотреть файл

438
 
438
 
439
 #if IS_KINEMATIC // (DELTA or SCARA)
439
 #if IS_KINEMATIC // (DELTA or SCARA)
440
 
440
 
441
-  #if ENABLED(DELTA)
442
-    #define DELTA_PRINTABLE_RADIUS_SQUARED ((float)DELTA_PRINTABLE_RADIUS * (float)DELTA_PRINTABLE_RADIUS )
443
-  #endif
444
-
445
   #if IS_SCARA
441
   #if IS_SCARA
446
     extern const float L1, L2;
442
     extern const float L1, L2;
447
   #endif
443
   #endif
448
 
444
 
449
-  inline bool position_is_reachable_raw_xy( float raw_x, float raw_y ) {
445
+  inline bool position_is_reachable_raw_xy(const float &rx, const float &ry) {
450
     #if ENABLED(DELTA)
446
     #if ENABLED(DELTA)
451
-      return ( HYPOT2( raw_x, raw_y ) <= DELTA_PRINTABLE_RADIUS_SQUARED );
447
+      return HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS);
452
     #elif IS_SCARA
448
     #elif IS_SCARA
453
       #if MIDDLE_DEAD_ZONE_R > 0
449
       #if MIDDLE_DEAD_ZONE_R > 0
454
-        const float R2 = HYPOT2(raw_x - SCARA_OFFSET_X, raw_y - SCARA_OFFSET_Y);
450
+        const float R2 = HYPOT2(rx - SCARA_OFFSET_X, ry - SCARA_OFFSET_Y);
455
         return R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) && R2 <= sq(L1 + L2);
451
         return R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) && R2 <= sq(L1 + L2);
456
       #else
452
       #else
457
-        return HYPOT2(raw_x - SCARA_OFFSET_X, raw_y - SCARA_OFFSET_Y) <= sq(L1 + L2);
453
+        return HYPOT2(rx - SCARA_OFFSET_X, ry - SCARA_OFFSET_Y) <= sq(L1 + L2);
458
       #endif
454
       #endif
459
     #else // CARTESIAN
455
     #else // CARTESIAN
460
-      #error
456
+      // To be migrated from MakerArm branch in future
461
     #endif
457
     #endif
462
   }
458
   }
463
 
459
 
464
-  inline bool position_is_reachable_by_probe_raw_xy( float raw_x, float raw_y ) {
460
+  inline bool position_is_reachable_by_probe_raw_xy(const float &rx, const float &ry) {
465
 
461
 
466
-    // both the nozzle and the probe must be able to reach the point
462
+    // Both the nozzle and the probe must be able to reach the point.
463
+    // This won't work on SCARA since the probe offset rotates with the arm.
467
 
464
 
468
-    return ( position_is_reachable_raw_xy( raw_x, raw_y ) &&
469
-             position_is_reachable_raw_xy(
470
-                raw_x - X_PROBE_OFFSET_FROM_EXTRUDER,
471
-                raw_y - Y_PROBE_OFFSET_FROM_EXTRUDER ));
465
+    return position_is_reachable_raw_xy(rx, ry)
466
+        && position_is_reachable_raw_xy(rx - X_PROBE_OFFSET_FROM_EXTRUDER, ry - Y_PROBE_OFFSET_FROM_EXTRUDER);
472
   }
467
   }
473
 
468
 
474
 #else // CARTESIAN
469
 #else // CARTESIAN
475
 
470
 
476
-  inline bool position_is_reachable_raw_xy( float raw_x, float raw_y ) {
477
-      // note to reviewer: this +/-0.0001 logic is copied from original postion_is_reachable
478
-      return WITHIN(raw_x, X_MIN_POS - 0.0001, X_MAX_POS + 0.0001)
479
-          && WITHIN(raw_y, Y_MIN_POS - 0.0001, Y_MAX_POS + 0.0001);
471
+  inline bool position_is_reachable_raw_xy(const float &rx, const float &ry) {
472
+      // Add 0.001 margin to deal with float imprecision
473
+      return WITHIN(rx, X_MIN_POS - 0.001, X_MAX_POS + 0.001)
474
+          && WITHIN(ry, Y_MIN_POS - 0.001, Y_MAX_POS + 0.001);
480
   }
475
   }
481
 
476
 
482
-  inline bool position_is_reachable_by_probe_raw_xy( float raw_x, float raw_y ) {
483
-      // note to reviewer: this logic is copied from UBL_G29.cpp and does not contain the +/-0.0001 above
484
-      return WITHIN(raw_x, MIN_PROBE_X, MAX_PROBE_X)
485
-          && WITHIN(raw_y, MIN_PROBE_Y, MAX_PROBE_Y);
477
+  inline bool position_is_reachable_by_probe_raw_xy(const float &rx, const float &ry) {
478
+      // Add 0.001 margin to deal with float imprecision
479
+      return WITHIN(rx, MIN_PROBE_X - 0.001, MAX_PROBE_X + 0.001)
480
+          && WITHIN(ry, MIN_PROBE_Y - 0.001, MAX_PROBE_Y + 0.001);
486
   }
481
   }
487
 
482
 
488
 #endif // CARTESIAN
483
 #endif // CARTESIAN
489
 
484
 
490
-inline bool position_is_reachable_by_probe_xy( float target_x, float target_y ) {
491
-  return position_is_reachable_by_probe_raw_xy(
492
-            RAW_X_POSITION( target_x ),
493
-            RAW_Y_POSITION( target_y ));
485
+FORCE_INLINE bool position_is_reachable_by_probe_xy(const float &lx, const float &ly) {
486
+  return position_is_reachable_by_probe_raw_xy(RAW_X_POSITION(lx), RAW_Y_POSITION(ly));
494
 }
487
 }
495
 
488
 
496
-inline bool position_is_reachable_xy( float target_x, float target_y ) {
497
-  return position_is_reachable_raw_xy( RAW_X_POSITION( target_x ), RAW_Y_POSITION( target_y ));
489
+FORCE_INLINE bool position_is_reachable_xy(const float &lx, const float &ly) {
490
+  return position_is_reachable_raw_xy(RAW_X_POSITION(lx), RAW_Y_POSITION(ly));
498
 }
491
 }
499
 
492
 
500
 #endif //MARLIN_H
493
 #endif //MARLIN_H

+ 9
- 8
Marlin/Marlin_main.cpp Просмотреть файл

1684
 
1684
 
1685
   #if ENABLED(DELTA)
1685
   #if ENABLED(DELTA)
1686
 
1686
 
1687
-    if ( ! position_is_reachable_xy( x, y )) return;
1687
+    if (!position_is_reachable_xy(x, y)) return;
1688
 
1688
 
1689
     feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
1689
     feedrate_mm_s = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
1690
 
1690
 
1740
 
1740
 
1741
   #elif IS_SCARA
1741
   #elif IS_SCARA
1742
 
1742
 
1743
-    if ( ! position_is_reachable_xy( x, y )) return;
1743
+    if (!position_is_reachable_xy(x, y)) return;
1744
 
1744
 
1745
     set_destination_to_current();
1745
     set_destination_to_current();
1746
 
1746
 
2366
       }
2366
       }
2367
     #endif
2367
     #endif
2368
 
2368
 
2369
-    if ( ! position_is_reachable_by_probe_xy( x, y )) return NAN;
2369
+    if (!position_is_reachable_by_probe_xy(x, y)) return NAN;
2370
 
2370
 
2371
     const float old_feedrate_mm_s = feedrate_mm_s;
2371
     const float old_feedrate_mm_s = feedrate_mm_s;
2372
 
2372
 
3713
       destination[Y_AXIS] -= Y_PROBE_OFFSET_FROM_EXTRUDER;
3713
       destination[Y_AXIS] -= Y_PROBE_OFFSET_FROM_EXTRUDER;
3714
     #endif
3714
     #endif
3715
 
3715
 
3716
-    if ( position_is_reachable_xy( destination[X_AXIS], destination[Y_AXIS] )) {
3716
+    if (position_is_reachable_xy(destination[X_AXIS], destination[Y_AXIS])) {
3717
 
3717
 
3718
       #if ENABLED(DEBUG_LEVELING_FEATURE)
3718
       #if ENABLED(DEBUG_LEVELING_FEATURE)
3719
         if (DEBUGGING(LEVELING)) DEBUG_POS("Z_SAFE_HOMING", destination);
3719
         if (DEBUGGING(LEVELING)) DEBUG_POS("Z_SAFE_HOMING", destination);
4639
             indexIntoAB[xCount][yCount] = abl_probe_index;
4639
             indexIntoAB[xCount][yCount] = abl_probe_index;
4640
           #endif
4640
           #endif
4641
 
4641
 
4642
-          if (position_is_reachable_xy( xProbe, yProbe )) break;
4642
+          // Keep looping till a reachable point is found
4643
+          if (position_is_reachable_xy(xProbe, yProbe)) break;
4643
           ++abl_probe_index;
4644
           ++abl_probe_index;
4644
         }
4645
         }
4645
 
4646
 
4750
 
4751
 
4751
             #if IS_KINEMATIC
4752
             #if IS_KINEMATIC
4752
               // Avoid probing outside the round or hexagonal area
4753
               // Avoid probing outside the round or hexagonal area
4753
-              if (!position_is_reachable_by_probe_xy( xProbe, yProbe )) continue;
4754
+              if (!position_is_reachable_by_probe_xy(xProbe, yProbe)) continue;
4754
             #endif
4755
             #endif
4755
 
4756
 
4756
             measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
4757
             measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
5055
     const float xpos = code_seen('X') ? code_value_linear_units() : current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
5056
     const float xpos = code_seen('X') ? code_value_linear_units() : current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
5056
                 ypos = code_seen('Y') ? code_value_linear_units() : current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
5057
                 ypos = code_seen('Y') ? code_value_linear_units() : current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER;
5057
 
5058
 
5058
-    if (!position_is_reachable_by_probe_xy( xpos, ypos )) return;
5059
+    if (!position_is_reachable_by_probe_xy(xpos, ypos)) return;
5059
 
5060
 
5060
     // Disable leveling so the planner won't mess with us
5061
     // Disable leveling so the planner won't mess with us
5061
     #if HAS_LEVELING
5062
     #if HAS_LEVELING
6513
           #else
6514
           #else
6514
             // If we have gone out too far, we can do a simple fix and scale the numbers
6515
             // If we have gone out too far, we can do a simple fix and scale the numbers
6515
             // back in closer to the origin.
6516
             // back in closer to the origin.
6516
-            while ( ! position_is_reachable_by_probe_xy( X_current, Y_current )) {
6517
+            while (!position_is_reachable_by_probe_xy(X_current, Y_current)) {
6517
               X_current *= 0.8;
6518
               X_current *= 0.8;
6518
               Y_current *= 0.8;
6519
               Y_current *= 0.8;
6519
               if (verbose_level > 3) {
6520
               if (verbose_level > 3) {

+ 29
- 31
Marlin/ubl_G29.cpp Просмотреть файл

135
    *                    a subsequent G or T leveling operation for backward compatibility.
135
    *                    a subsequent G or T leveling operation for backward compatibility.
136
    *
136
    *
137
    *   P1    Phase 1    Invalidate entire Mesh and continue with automatic generation of the Mesh data using
137
    *   P1    Phase 1    Invalidate entire Mesh and continue with automatic generation of the Mesh data using
138
-   *                    the Z-Probe. Usually the probe can not reach all areas that the nozzle can reach.
139
-   *                    In Cartesian printers, mesh points within the X_OFFSET_FROM_EXTRUDER and Y_OFFSET_FROM_EXTRUDER
140
-   *                    area can not be automatically probed.  For Delta printers the area in which DELTA_PROBEABLE_RADIUS
138
+   *                    the Z-Probe. Usually the probe can't reach all areas that the nozzle can reach. On
139
+   *                    Cartesian printers, points within the X_PROBE_OFFSET_FROM_EXTRUDER and Y_PROBE_OFFSET_FROM_EXTRUDER
140
+   *                    area cannot be automatically probed. For Delta printers the area in which DELTA_PROBEABLE_RADIUS
141
    *                    and DELTA_PRINTABLE_RADIUS do not overlap will not be automatically probed.
141
    *                    and DELTA_PRINTABLE_RADIUS do not overlap will not be automatically probed.
142
    *
142
    *
143
    *                    These points will be handled in Phase 2 and Phase 3. If the Phase 1 command is given the
143
    *                    These points will be handled in Phase 2 and Phase 3. If the Phase 1 command is given the
186
    *                    of the Mesh being built.
186
    *                    of the Mesh being built.
187
    *
187
    *
188
    *   P3    Phase 3    Fill the unpopulated regions of the Mesh with a fixed value. There are two different paths the
188
    *   P3    Phase 3    Fill the unpopulated regions of the Mesh with a fixed value. There are two different paths the
189
-   *                    user can go down.  If the user specifies the value using the C parameter, the closest invalid
190
-   *                    mesh points to the nozzle will be filled.   The user can specify a repeat count using the R
189
+   *                    user can go down. If the user specifies the value using the C parameter, the closest invalid
190
+   *                    mesh points to the nozzle will be filled. The user can specify a repeat count using the R
191
    *                    parameter with the C version of the command.
191
    *                    parameter with the C version of the command.
192
    *
192
    *
193
-   *                    A second version of the fill command is available if no C constant is specified.  Not
194
-   *                    specifying a C constant will invoke the 'Smart Fill' algorithm.  The G29 P3 command will search
195
-   *                    from the edges of the mesh inward looking for invalid mesh points.  It will look at the next
196
-   *                    several mesh points to determine if the print bed is sloped up or down.  If the bed is sloped
193
+   *                    A second version of the fill command is available if no C constant is specified. Not
194
+   *                    specifying a C constant will invoke the 'Smart Fill' algorithm. The G29 P3 command will search
195
+   *                    from the edges of the mesh inward looking for invalid mesh points. It will look at the next
196
+   *                    several mesh points to determine if the print bed is sloped up or down. If the bed is sloped
197
    *                    upward from the invalid mesh point, it will be replaced with the value of the nearest mesh point.
197
    *                    upward from the invalid mesh point, it will be replaced with the value of the nearest mesh point.
198
    *                    If the bed is sloped downward from the invalid mesh point, it will be replaced with a value that
198
    *                    If the bed is sloped downward from the invalid mesh point, it will be replaced with a value that
199
-   *                    puts all three points in a line.   The second version of the G29 P3 command is a quick, easy and
199
+   *                    puts all three points in a line. The second version of the G29 P3 command is a quick, easy and
200
    *                    usually safe way to populate the unprobed regions of your mesh so you can continue to the G26
200
    *                    usually safe way to populate the unprobed regions of your mesh so you can continue to the G26
201
-   *                    Mesh Validation Pattern phase.   Please note that you are populating your mesh with unverified
202
-   *                    numbers.  You should use some scrutiny and caution.
201
+   *                    Mesh Validation Pattern phase. Please note that you are populating your mesh with unverified
202
+   *                    numbers. You should use some scrutiny and caution.
203
    *
203
    *
204
    *   P4    Phase 4    Fine tune the Mesh. The Delta Mesh Compensation System assume the existence of
204
    *   P4    Phase 4    Fine tune the Mesh. The Delta Mesh Compensation System assume the existence of
205
    *                    an LCD Panel. It is possible to fine tune the mesh without the use of an LCD Panel.
205
    *                    an LCD Panel. It is possible to fine tune the mesh without the use of an LCD Panel.
242
    *                    command is not anticipated to be of much value to the typical user. It is intended
242
    *                    command is not anticipated to be of much value to the typical user. It is intended
243
    *                    for developers to help them verify correct operation of the Unified Bed Leveling System.
243
    *                    for developers to help them verify correct operation of the Unified Bed Leveling System.
244
    *
244
    *
245
-   *   R #   Repeat     Repeat this command the specified number of times.  If no number is specified the
245
+   *   R #   Repeat     Repeat this command the specified number of times. If no number is specified the
246
    *                    command will be repeated GRID_MAX_POINTS_X * GRID_MAX_POINTS_Y times.
246
    *                    command will be repeated GRID_MAX_POINTS_X * GRID_MAX_POINTS_Y times.
247
    *
247
    *
248
    *   S     Store      Store the current Mesh in the Activated area of the EEPROM. It will also store the
248
    *   S     Store      Store the current Mesh in the Activated area of the EEPROM. It will also store the
497
 
497
 
498
           if (code_seen('H') && code_has_value()) height = code_value_float();
498
           if (code_seen('H') && code_has_value()) height = code_value_float();
499
 
499
 
500
-          if ( !position_is_reachable_xy( x_pos, y_pos )) {
500
+          if (!position_is_reachable_xy(x_pos, y_pos)) {
501
             SERIAL_PROTOCOLLNPGM("(X,Y) outside printable radius.");
501
             SERIAL_PROTOCOLLNPGM("(X,Y) outside printable radius.");
502
             return;
502
             return;
503
           }
503
           }
635
       ubl.display_map(code_has_value() ? code_value_int() : 0);
635
       ubl.display_map(code_has_value() ? code_value_int() : 0);
636
 
636
 
637
     /*
637
     /*
638
-     * This code may not be needed...   Prepare for its removal...
638
+     * This code may not be needed...  Prepare for its removal...
639
      *
639
      *
640
     if (code_seen('Z')) {
640
     if (code_seen('Z')) {
641
       if (code_has_value())
641
       if (code_has_value())
660
           do_blocking_move_to_z(measured_z);
660
           do_blocking_move_to_z(measured_z);
661
         } while (!ubl_lcd_clicked());
661
         } while (!ubl_lcd_clicked());
662
 
662
 
663
-        ubl.has_control_of_lcd_panel = true;   // There is a race condition for the Encoder Wheel getting clicked.
663
+        ubl.has_control_of_lcd_panel = true;   // There is a race condition for the encoder click.
664
                                                // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
664
                                                // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
665
-                                               // or here. So, until we are done looking for a long Encoder Wheel Press,
665
+                                               // or here. So, until we are done looking for a long encoder press,
666
                                                // we need to take control of the panel
666
                                                // we need to take control of the panel
667
 
667
 
668
         KEEPALIVE_STATE(IN_HANDLER);
668
         KEEPALIVE_STATE(IN_HANDLER);
1346
                       my = pgm_read_float(&ubl.mesh_index_to_ypos[j]);
1346
                       my = pgm_read_float(&ubl.mesh_index_to_ypos[j]);
1347
 
1347
 
1348
           // If using the probe as the reference there are some unreachable locations.
1348
           // If using the probe as the reference there are some unreachable locations.
1349
-          // Also for round beds, there are grid points outside the bed that nozzle can't reach.
1349
+          // Also for round beds, there are grid points outside the bed the nozzle can't reach.
1350
           // Prune them from the list and ignore them till the next Phase (manual nozzle probing).
1350
           // Prune them from the list and ignore them till the next Phase (manual nozzle probing).
1351
 
1351
 
1352
-          if ( ! (probe_as_reference ? position_is_reachable_by_probe_raw_xy(mx, my) : position_is_reachable_raw_xy(mx, my)) )
1352
+          if (probe_as_reference ? !position_is_reachable_by_probe_raw_xy(mx, my) : !position_is_reachable_raw_xy(mx, my))
1353
             continue;
1353
             continue;
1354
 
1354
 
1355
           // Reachable. Check if it's the closest location to the nozzle.
1355
           // Reachable. Check if it's the closest location to the nozzle.
1390
   }
1390
   }
1391
 
1391
 
1392
   void fine_tune_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map) {
1392
   void fine_tune_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map) {
1393
-    if (!code_seen('R'))    // fine_tune_mesh() is special.  If no repetion count flag is specified
1394
-      repetition_cnt = 1;   // we know to do exactly one mesh location. Otherwise we use what the parser decided.
1393
+    if (!code_seen('R'))    // fine_tune_mesh() is special. If no repetition count flag is specified
1394
+      repetition_cnt = 1;   // do exactly one mesh location. Otherwise use what the parser decided.
1395
 
1395
 
1396
     mesh_index_pair location;
1396
     mesh_index_pair location;
1397
     uint16_t not_done[16];
1397
     uint16_t not_done[16];
1398
     int32_t round_off;
1398
     int32_t round_off;
1399
 
1399
 
1400
-    if ( ! position_is_reachable_xy( lx, ly )) {
1400
+    if (!position_is_reachable_xy(lx, ly)) {
1401
       SERIAL_PROTOCOLLNPGM("(X,Y) outside printable radius.");
1401
       SERIAL_PROTOCOLLNPGM("(X,Y) outside printable radius.");
1402
       return;
1402
       return;
1403
     }
1403
     }
1413
     do {
1413
     do {
1414
       location = find_closest_mesh_point_of_type(SET_IN_BITMAP, lx, ly, USE_NOZZLE_AS_REFERENCE, not_done, false);
1414
       location = find_closest_mesh_point_of_type(SET_IN_BITMAP, lx, ly, USE_NOZZLE_AS_REFERENCE, not_done, false);
1415
 
1415
 
1416
-      if (location.x_index < 0 ) break; // stop when we can't find any more reachable points.
1416
+      if (location.x_index < 0) break; // stop when we can't find any more reachable points.
1417
 
1417
 
1418
       bit_clear(not_done, location.x_index, location.y_index);  // Mark this location as 'adjusted' so we will find a
1418
       bit_clear(not_done, location.x_index, location.y_index);  // Mark this location as 'adjusted' so we will find a
1419
                                                                 // different location the next time through the loop
1419
                                                                 // different location the next time through the loop
1421
       const float rawx = pgm_read_float(&ubl.mesh_index_to_xpos[location.x_index]),
1421
       const float rawx = pgm_read_float(&ubl.mesh_index_to_xpos[location.x_index]),
1422
                   rawy = pgm_read_float(&ubl.mesh_index_to_ypos[location.y_index]);
1422
                   rawy = pgm_read_float(&ubl.mesh_index_to_ypos[location.y_index]);
1423
 
1423
 
1424
-      if ( ! position_is_reachable_raw_xy( rawx, rawy )) { // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
1424
+      if (!position_is_reachable_raw_xy(rawx, rawy)) // SHOULD NOT OCCUR because find_closest_mesh_point_of_type will only return reachable
1425
         break;
1425
         break;
1426
-      }
1427
 
1426
 
1428
       float new_z = ubl.z_values[location.x_index][location.y_index];
1427
       float new_z = ubl.z_values[location.x_index][location.y_index];
1429
 
1428
 
1432
         do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);    // Move the nozzle to where we are going to edit
1431
         do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);    // Move the nozzle to where we are going to edit
1433
         do_blocking_move_to_xy(LOGICAL_X_POSITION(rawx), LOGICAL_Y_POSITION(rawy));
1432
         do_blocking_move_to_xy(LOGICAL_X_POSITION(rawx), LOGICAL_Y_POSITION(rawy));
1434
 
1433
 
1435
-        round_off = (int32_t)(new_z * 1000.0);    // we chop off the last digits just to be clean. We are rounding to the
1436
-        new_z = float(round_off) / 1000.0;
1434
+        new_z = floor(new_z * 1000.0) * 0.001; // Chop off digits after the 1000ths place
1437
 
1435
 
1438
         KEEPALIVE_STATE(PAUSED_FOR_USER);
1436
         KEEPALIVE_STATE(PAUSED_FOR_USER);
1439
         ubl.has_control_of_lcd_panel = true;
1437
         ubl.has_control_of_lcd_panel = true;
1451
 
1449
 
1452
         lcd_return_to_status();
1450
         lcd_return_to_status();
1453
 
1451
 
1454
-        // There is a race condition for the Encoder Wheel getting clicked.
1455
-        // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
1456
-        // or here.
1452
+        // The technique used here generates a race condition for the encoder click.
1453
+        // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune) or here.
1454
+        // Let's work on specifying a proper API for the LCD ASAP, OK?
1457
         ubl.has_control_of_lcd_panel = true;
1455
         ubl.has_control_of_lcd_panel = true;
1458
       }
1456
       }
1459
 
1457
 
1478
 
1476
 
1479
       lcd_implementation_clear();
1477
       lcd_implementation_clear();
1480
 
1478
 
1481
-    } while (( location.x_index >= 0 ) && (--repetition_cnt>0));
1479
+    } while (location.x_index >= 0 && --repetition_cnt > 0);
1482
 
1480
 
1483
     FINE_TUNE_EXIT:
1481
     FINE_TUNE_EXIT:
1484
 
1482
 

Загрузка…
Отмена
Сохранить