Browse Source

Merge pull request #6716 from thinkyhead/bf_ubl_prepare_move

Fix prepare_move... for UBL
Scott Lahteine 8 years ago
parent
commit
2da4398fb5
6 changed files with 60 additions and 62 deletions
  1. 2
    5
      Marlin/G26_Mesh_Validation_Tool.cpp
  2. 39
    34
      Marlin/Marlin_main.cpp
  3. 2
    2
      Marlin/planner.cpp
  4. 1
    3
      Marlin/ubl.h
  5. 8
    10
      Marlin/ubl_G29.cpp
  6. 8
    8
      Marlin/ultralcd.cpp

+ 2
- 5
Marlin/G26_Mesh_Validation_Tool.cpp View File

@@ -69,7 +69,7 @@
69 69
    *   B #  Bed         Set the Bed Temperature.  If not specified, a default of 60 C. will be assumed.
70 70
    *
71 71
    *   C    Current     When searching for Mesh Intersection points to draw, use the current nozzle location
72
-                        as the base for any distance comparison.
72
+   *                    as the base for any distance comparison.
73 73
    *
74 74
    *   D    Disable     Disable the Unified Bed Leveling System.  In the normal case the user is invoking this
75 75
    *                    command to see how well a Mesh as been adjusted to match a print surface.  In order to do
@@ -748,10 +748,7 @@
748 748
     }
749 749
 
750 750
     /**
751
-     * We save the question of what to do with the Unified Bed Leveling System's Activation until the very
752
-     * end.  The reason is, if one of the parameters specified up above is incorrect, we don't want to
753
-     * alter the system's status.  We wait until we know everything is correct before altering the state
754
-     * of the system.
751
+     * Wait until all parameters are verified before altering the state!
755 752
      */
756 753
     ubl.state.active = !code_seen('D');
757 754
 

+ 39
- 34
Marlin/Marlin_main.cpp View File

@@ -7610,13 +7610,14 @@ inline void gcode_M205() {
7610 7610
   /**
7611 7611
    * M665: Set delta configurations
7612 7612
    *
7613
-   *    H = diagonal rod // AC-version
7613
+   *    H = delta height
7614 7614
    *    L = diagonal rod
7615 7615
    *    R = delta radius
7616 7616
    *    S = segments per second
7617
-   *    A = Alpha (Tower 1) diagonal rod trim
7618
-   *    B = Beta (Tower 2) diagonal rod trim
7619
-   *    C = Gamma (Tower 3) diagonal rod trim
7617
+   *    B = delta calibration radius
7618
+   *    X = Alpha (Tower 1) angle trim
7619
+   *    Y = Beta (Tower 2) angle trim
7620
+   *    Z = Rotate A and B by this angle
7620 7621
    */
7621 7622
   inline void gcode_M665() {
7622 7623
     if (code_seen('H')) {
@@ -7628,11 +7629,11 @@ inline void gcode_M205() {
7628 7629
     if (code_seen('R')) delta_radius = code_value_linear_units();
7629 7630
     if (code_seen('S')) delta_segments_per_second = code_value_float();
7630 7631
     if (code_seen('B')) delta_calibration_radius = code_value_float();
7631
-    if (code_seen('X')) delta_tower_angle_trim[A_AXIS] = code_value_linear_units();
7632
-    if (code_seen('Y')) delta_tower_angle_trim[B_AXIS] = code_value_linear_units();
7632
+    if (code_seen('X')) delta_tower_angle_trim[A_AXIS] = code_value_float();
7633
+    if (code_seen('Y')) delta_tower_angle_trim[B_AXIS] = code_value_float();
7633 7634
     if (code_seen('Z')) { // rotate all 3 axis for Z = 0
7634
-      delta_tower_angle_trim[A_AXIS] -= code_value_linear_units();
7635
-      delta_tower_angle_trim[B_AXIS] -= code_value_linear_units();
7635
+      delta_tower_angle_trim[A_AXIS] -= code_value_float();
7636
+      delta_tower_angle_trim[B_AXIS] -= code_value_float();
7636 7637
     }
7637 7638
     recalc_delta_settings(delta_radius, delta_diagonal_rod);
7638 7639
   }
@@ -11235,32 +11236,36 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
11235 11236
    * Returns true if the caller didn't update current_position.
11236 11237
    */
11237 11238
   inline bool prepare_move_to_destination_cartesian() {
11238
-    // Do not use feedrate_percentage for E or Z only moves
11239
-    if (current_position[X_AXIS] == destination[X_AXIS] && current_position[Y_AXIS] == destination[Y_AXIS]) {
11240
-      line_to_destination();
11241
-    }
11242
-    else {
11243
-      #if ENABLED(MESH_BED_LEVELING)
11244
-        if (mbl.active()) {
11245
-          mesh_line_to_destination(MMS_SCALED(feedrate_mm_s));
11246
-          return true;
11247
-        }
11248
-        else
11249
-      #elif ENABLED(AUTO_BED_LEVELING_UBL)
11250
-        if (ubl.state.active) {
11251
-          ubl_line_to_destination_cartesian(MMS_SCALED(feedrate_mm_s), active_extruder);
11252
-          return true;
11253
-        }
11254
-        else
11255
-      #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
11256
-        if (planner.abl_enabled) {
11257
-          bilinear_line_to_destination(MMS_SCALED(feedrate_mm_s));
11258
-          return true;
11259
-        }
11260
-        else
11261
-      #endif
11262
-          line_to_destination(MMS_SCALED(feedrate_mm_s));
11263
-    }
11239
+    #if ENABLED(AUTO_BED_LEVELING_UBL)
11240
+      const float fr_scaled = MMS_SCALED(feedrate_mm_s);
11241
+      if (ubl.state.active) {
11242
+        ubl_line_to_destination_cartesian(fr_scaled, active_extruder);
11243
+        return true;
11244
+      }
11245
+      else
11246
+        line_to_destination(fr_scaled);
11247
+    #else
11248
+      // Do not use feedrate_percentage for E or Z only moves
11249
+      if (current_position[X_AXIS] == destination[X_AXIS] && current_position[Y_AXIS] == destination[Y_AXIS])
11250
+        line_to_destination();
11251
+      else {
11252
+        const float fr_scaled = MMS_SCALED(feedrate_mm_s);
11253
+        #if ENABLED(MESH_BED_LEVELING)
11254
+          if (mbl.active()) {
11255
+            mesh_line_to_destination(fr_scaled);
11256
+            return true;
11257
+          }
11258
+          else
11259
+        #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
11260
+          if (planner.abl_enabled) {
11261
+            bilinear_line_to_destination(fr_scaled);
11262
+            return true;
11263
+          }
11264
+          else
11265
+        #endif
11266
+            line_to_destination(fr_scaled);
11267
+      }
11268
+    #endif
11264 11269
     return false;
11265 11270
   }
11266 11271
 

+ 2
- 2
Marlin/planner.cpp View File

@@ -539,7 +539,7 @@ void Planner::check_axes_activity() {
539 539
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
540 540
         // if z_fade_height enabled (nonzero) and raw_z above it, no leveling required
541 541
         if ((planner.z_fade_height) && (planner.z_fade_height <= RAW_Z_POSITION(lz))) return;
542
-        lz += ubl.state.z_offset + ubl.get_z_correction(lx,ly) * ubl.fade_scaling_factor_for_z(lz);
542
+        lz += ubl.state.z_offset + ubl.get_z_correction(lx, ly) * ubl.fade_scaling_factor_for_z(lz);
543 543
       #else // no fade
544 544
         lz += ubl.state.z_offset + ubl.get_z_correction(lx,ly);
545 545
       #endif // FADE
@@ -617,7 +617,7 @@ void Planner::check_axes_activity() {
617 617
           //    so U==(L-O-M)/(1-M/H) for U<H
618 618
 
619 619
           if (planner.z_fade_height) {
620
-            float z_unfaded = z_unlevel / (1.0 - z_ublmesh * planner.inverse_z_fade_height);
620
+            const float z_unfaded = z_unlevel / (1.0 - z_ublmesh * planner.inverse_z_fade_height);
621 621
             if (z_unfaded < planner.z_fade_height)  // don't know until after compute
622 622
               z_unlevel = z_unfaded;
623 623
           }

+ 1
- 3
Marlin/ubl.h View File

@@ -61,8 +61,7 @@
61 61
 
62 62
   void dump(char * const str, const float &f);
63 63
   void probe_entire_mesh(const float&, const float&, const bool, const bool, const bool);
64
-  void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
65
-  float measure_business_card_thickness(const float&);
64
+  float measure_business_card_thickness(float&);
66 65
   mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, unsigned int[16], bool);
67 66
   void shift_mesh_height();
68 67
   void fine_tune_mesh(const float&, const float&, const bool);
@@ -108,7 +107,6 @@
108 107
       void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);
109 108
       void tilt_mesh_based_on_3pts(const float &z1, const float &z2, const float &z3);
110 109
       void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
111
-      void manually_probe_remaining_mesh(const float &lx, const float &ly, const float &z_clearance, const float &card_thickness, const bool do_ubl_mesh_map);
112 110
       void save_ubl_active_state_and_disable();
113 111
       void restore_ubl_active_state_and_leave();
114 112
       void g29_what_command();

+ 8
- 10
Marlin/ubl_G29.cpp View File

@@ -56,7 +56,7 @@
56 56
   extern bool set_probe_deployed(bool);
57 57
   void smart_fill_mesh();
58 58
   float measure_business_card_thickness(float &in_height);
59
-  void manually_probe_remaining_mesh(const float &lx, const float &ly, float &z_clearance, const float &card_thickness, const bool do_ubl_mesh_map);
59
+  void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
60 60
 
61 61
   bool ProbeStay = true;
62 62
 
@@ -482,7 +482,7 @@
482 482
            */
483 483
           if (c_flag) {
484 484
 
485
-            if ( repetition_cnt >= ( GRID_MAX_POINTS_X * GRID_MAX_POINTS_Y )) {
485
+            if (repetition_cnt >= GRID_MAX_POINTS) {
486 486
               for ( uint8_t x = 0; x < GRID_MAX_POINTS_X; x++ ) {
487 487
                 for ( uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++ ) {
488 488
                   ubl.z_values[x][y] = ubl_constant;
@@ -735,7 +735,7 @@
735 735
     ubl.save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
736 736
     DEPLOY_PROBE();
737 737
 
738
-    uint16_t max_iterations = ( GRID_MAX_POINTS_X * GRID_MAX_POINTS_Y );
738
+    uint16_t max_iterations = GRID_MAX_POINTS;
739 739
 
740 740
     do {
741 741
       if (ubl_lcd_clicked()) {
@@ -941,7 +941,7 @@
941 941
     return thickness;
942 942
   }
943 943
 
944
-  void manually_probe_remaining_mesh(const float &lx, const float &ly, float &z_clearance, const float &card_thickness, const bool do_ubl_mesh_map) {
944
+  void manually_probe_remaining_mesh(const float &lx, const float &ly, const float &z_clearance, const float &card_thickness, const bool do_ubl_mesh_map) {
945 945
 
946 946
     ubl.has_control_of_lcd_panel = true;
947 947
     ubl.save_ubl_active_state_and_disable();   // we don't do bed level correction because we want the raw data when we probe
@@ -956,14 +956,11 @@
956 956
       if (location.x_index < 0 && location.y_index < 0) continue;
957 957
 
958 958
       const float rawx = pgm_read_float(&ubl.mesh_index_to_xpos[location.x_index]),
959
-                  rawy = pgm_read_float(&ubl.mesh_index_to_ypos[location.y_index]);
960
-
961
-      const float xProbe = LOGICAL_X_POSITION(rawx),
959
+                  rawy = pgm_read_float(&ubl.mesh_index_to_ypos[location.y_index]),
960
+                  xProbe = LOGICAL_X_POSITION(rawx),
962 961
                   yProbe = LOGICAL_Y_POSITION(rawy);
963 962
 
964
-      if ( ! position_is_reachable_raw_xy( rawx, rawy )) {    // SHOULD NOT OCCUR (find_closest_mesh_point only returns reachable points)
965
-        break;
966
-      }
963
+      if (!position_is_reachable_raw_xy(rawx, rawy)) break; // SHOULD NOT OCCUR (find_closest_mesh_point only returns reachable points)
967 964
 
968 965
       do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
969 966
 
@@ -1129,6 +1126,7 @@
1129 1126
       SERIAL_PROTOCOLLNPGM("Invalid map type.\n");
1130 1127
       return UBL_ERR;
1131 1128
     }
1129
+
1132 1130
     // Check if a map type was specified
1133 1131
     if (code_seen('M')) { // Warning! Use of 'M' flouts established standards.
1134 1132
       map_type = code_has_value() ? code_value_int() : 0;

+ 8
- 8
Marlin/ultralcd.cpp View File

@@ -1674,13 +1674,13 @@ void kill_screen(const char* lcd_msg) {
1674 1674
 
1675 1675
     void _lcd_ubl_level_bed();
1676 1676
 
1677
-    int UBL_STORAGE_SLOT = 0;
1678
-    int CUSTOM_BED_TEMP = 50;
1679
-    int CUSTOM_HOTEND_TEMP = 190;
1680
-    int SIDE_POINTS = 3;
1681
-    int UBL_FILLIN_AMOUNT = 5;
1682
-    int UBL_HEIGHT_AMOUNT;
1683
-    int map_type;
1677
+    int UBL_STORAGE_SLOT = 0,
1678
+        CUSTOM_BED_TEMP = 50,
1679
+        CUSTOM_HOTEND_TEMP = 190,
1680
+        SIDE_POINTS = 3,
1681
+        UBL_FILLIN_AMOUNT = 5,
1682
+        UBL_HEIGHT_AMOUNT,
1683
+        map_type;
1684 1684
 
1685 1685
     char UBL_LCD_GCODE [30];
1686 1686
 
@@ -1858,7 +1858,7 @@ void kill_screen(const char* lcd_msg) {
1858 1858
      * UBL Build Mesh submenu
1859 1859
      */
1860 1860
     void _lcd_ubl_build_mesh() {
1861
-      int GRID_NUM_POINTS = GRID_MAX_POINTS_X * GRID_MAX_POINTS_Y ;
1861
+      int GRID_NUM_POINTS = GRID_MAX_POINTS;
1862 1862
       START_MENU();
1863 1863
       MENU_BACK(MSG_UBL_TOOLS);
1864 1864
       #if (WATCH_THE_BED)

Loading…
Cancel
Save