Browse Source

Merge pull request #6533 from thinkyhead/rc_autocal_patches

General cleanup of G33
Scott Lahteine 8 years ago
parent
commit
0803c9d997
6 changed files with 118 additions and 108 deletions
  1. 87
    83
      Marlin/Marlin_main.cpp
  2. 2
    2
      Marlin/configuration_store.cpp
  3. 1
    1
      Marlin/ubl.cpp
  4. 19
    11
      Marlin/ubl.h
  5. 1
    1
      Marlin/ubl_G29.cpp
  6. 8
    10
      Marlin/ubl_motion.cpp

+ 87
- 83
Marlin/Marlin_main.cpp View File

61
  * G30 - Single Z probe, probes bed at X Y location (defaults to current XY location)
61
  * G30 - Single Z probe, probes bed at X Y location (defaults to current XY location)
62
  * G31 - Dock sled (Z_PROBE_SLED only)
62
  * G31 - Dock sled (Z_PROBE_SLED only)
63
  * G32 - Undock sled (Z_PROBE_SLED only)
63
  * G32 - Undock sled (Z_PROBE_SLED only)
64
- * G33 - Delta '1-4-7-point' auto calibration : "G33 V<verbose> P<points> <A> <O> <T>" (Requires DELTA)
64
+ * G33 - Delta Auto-Calibration (Requires DELTA_AUTO_CALIBRATION)
65
  * G38 - Probe target - similar to G28 except it uses the Z_MIN_PROBE for all three axes
65
  * G38 - Probe target - similar to G28 except it uses the Z_MIN_PROBE for all three axes
66
  * G90 - Use Absolute Coordinates
66
  * G90 - Use Absolute Coordinates
67
  * G91 - Use Relative Coordinates
67
  * G91 - Use Relative Coordinates
3904
   #if ENABLED(DEBUG_LEVELING_FEATURE)
3904
   #if ENABLED(DEBUG_LEVELING_FEATURE)
3905
     if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G28");
3905
     if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G28");
3906
   #endif
3906
   #endif
3907
-}
3907
+} // G28
3908
 
3908
 
3909
 void home_all_axes() { gcode_G28(); }
3909
 void home_all_axes() { gcode_G28(); }
3910
 
3910
 
5057
 
5057
 
5058
   #if ENABLED(DELTA_AUTO_CALIBRATION)
5058
   #if ENABLED(DELTA_AUTO_CALIBRATION)
5059
     /**
5059
     /**
5060
-     * G33 - Delta '1-4-7-point' auto calibration (Requires DELTA)
5061
-     * 
5062
-     * Usage:
5063
-     *   G33 <Vn> <Pn> <A> <O> <T>
5064
-     *   
5065
-     *     Vn = verbose level (n=0-2 default 1)
5066
-     *          n=0 dry-run mode: setting + probe results / no calibration
5067
-     *          n=1 settings 
5068
-     *          n=2 setting + probe results 
5069
-     *     Pn = n=-7 -> +7 : n*n probe points
5070
-     *          calibrates height ('1 point'), endstops, and delta radius ('4 points') 
5071
-     *          and tower angles with n > 2 ('7+ points')
5072
-     *          n=1  probes center / sets height only
5073
-     *          n=2  probes center and towers / sets height, endstops and delta radius
5074
-     *          n=3  probes all points: center, towers and opposite towers / sets all
5075
-     *          n>3  probes all points multiple times and averages
5076
-     *     A  = abort 1 point delta height calibration after 1 probe
5077
-     *     O  = use oposite tower points instead of tower points with 4 point calibration
5078
-     *     T  = do not calibrate tower angles with 7+ point calibration
5060
+     * G33 - Delta '1-4-7-point' Auto-Calibration
5061
+     *       Calibrate height, endstops, delta radius, and tower angles.
5062
+     *
5063
+     * Parameters:
5064
+     *
5065
+     *   P  Number of probe points:
5066
+     *
5067
+     *      P1     Probe center and set height only.
5068
+     *      P2     Probe center and towers. Set height, endstops, and delta radius.
5069
+     *      P3     Probe all positions: center, towers and opposite towers. Set all.
5070
+     *      P4-P7  Probe all positions at different locations and average them.
5071
+     *
5072
+     *   A  Abort delta height calibration after 1 probe (only P1)
5073
+     *
5074
+     *   O  Use opposite tower points instead of tower points (only P2)
5075
+     *
5076
+     *   T  Don't calibrate tower angle corrections (P3-P7)
5077
+     *
5078
+     *   V  Verbose level:
5079
+     *
5080
+     *      V0  Dry-run mode. Report settings and probe results. No calibration.
5081
+     *      V1  Report settings
5082
+     *      V2  Report settings and probe results
5079
      */
5083
      */
5080
     inline void gcode_G33() {
5084
     inline void gcode_G33() {
5081
 
5085
 
5082
-      stepper.synchronize();
5086
+      const int8_t probe_points = code_seen('P') ? code_value_int() : DELTA_CALIBRATION_DEFAULT_POINTS;
5087
+      if (!WITHIN(probe_points, 1, 7)) {
5088
+        SERIAL_PROTOCOLLNPGM("?(P)oints is implausible (1 to 7).");
5089
+        return;
5090
+      }
5083
 
5091
 
5084
-      #if HAS_LEVELING
5085
-        set_bed_leveling_enabled(false);
5086
-      #endif
5092
+      const int8_t verbose_level = code_seen('V') ? code_value_byte() : 1;
5093
+      if (!WITHIN(verbose_level, 0, 2)) {
5094
+        SERIAL_PROTOCOLLNPGM("?(V)erbose Level is implausible (0-2).");
5095
+        return;
5096
+      }
5087
 
5097
 
5088
-      int8_t pp = (code_seen('P') ? code_value_int() : DELTA_CALIBRATION_DEFAULT_POINTS),
5089
-             probe_mode = (WITHIN(pp, 1, 7) ? pp : DELTA_CALIBRATION_DEFAULT_POINTS);
5098
+      const bool do_height_only       = probe_points == 1,
5099
+                 do_center_and_towers = probe_points == 2,
5100
+                 do_all_positions     = probe_points == 3,
5101
+                 do_circle_x2         = probe_points == 5,
5102
+                 do_circle_x3         = probe_points == 6,
5103
+                 do_circle_x4         = probe_points == 7,
5104
+                 probe_center_plus_3  = probe_points >= 3,
5105
+                 point_averaging      = probe_points >= 4,
5106
+                 probe_center_plus_6  = probe_points >= 5;
5090
 
5107
 
5091
-      probe_mode = (code_seen('A') && probe_mode == 1 ? -probe_mode : probe_mode);
5092
-      probe_mode = (code_seen('O') && probe_mode == 2 ? -probe_mode : probe_mode);
5093
-      probe_mode = (code_seen('T') && probe_mode > 2 ? -probe_mode : probe_mode);
5094
-      
5095
-      int8_t verbose_level = (code_seen('V') ? code_value_byte() : 1);
5108
+      const char negating_parameter = do_height_only ? 'A' : do_center_and_towers ? 'O' : 'T';
5109
+      int8_t probe_mode = code_seen(negating_parameter) && code_value_bool() ? -probe_points : probe_points;
5110
+
5111
+      SERIAL_PROTOCOLLNPGM("G33 Auto Calibrate");
5096
 
5112
 
5097
-      if (!WITHIN(verbose_level, 0, 2)) verbose_level = 1;
5113
+      #if HAS_LEVELING
5114
+        set_bed_leveling_enabled(false);
5115
+      #endif
5098
 
5116
 
5099
-      gcode_G28();
5117
+      home_all_axes();
5100
 
5118
 
5101
       const static char save_message[] PROGMEM = "Save with M500 and/or copy to Configuration.h";
5119
       const static char save_message[] PROGMEM = "Save with M500 and/or copy to Configuration.h";
5102
       float test_precision,
5120
       float test_precision,
5109
             dr_old = delta_radius,
5127
             dr_old = delta_radius,
5110
             zh_old = home_offset[Z_AXIS],
5128
             zh_old = home_offset[Z_AXIS],
5111
             alpha_old = delta_tower_angle_trim[A_AXIS],
5129
             alpha_old = delta_tower_angle_trim[A_AXIS],
5112
-            beta_old = delta_tower_angle_trim[B_AXIS]; 
5113
-      int8_t iterations = 0,
5114
-             probe_points = abs(probe_mode);
5115
-      const bool pp_equals_1 = (probe_points == 1),
5116
-                 pp_equals_2 = (probe_points == 2),
5117
-                 pp_equals_3 = (probe_points == 3),
5118
-                 pp_equals_4 = (probe_points == 4),
5119
-                 pp_equals_5 = (probe_points == 5),
5120
-                 pp_equals_6 = (probe_points == 6),
5121
-                 pp_equals_7 = (probe_points == 7),
5122
-                 pp_greather_2 = (probe_points > 2),
5123
-                 pp_greather_3 = (probe_points > 3),
5124
-                 pp_greather_4 = (probe_points > 4),
5125
-                 pp_greather_5 = (probe_points > 5);
5126
- 
5130
+            beta_old = delta_tower_angle_trim[B_AXIS];
5131
+
5127
       // print settings
5132
       // print settings
5128
 
5133
 
5129
-      SERIAL_PROTOCOLLNPGM("G33 Auto Calibrate");
5130
       SERIAL_PROTOCOLPGM("Checking... AC");
5134
       SERIAL_PROTOCOLPGM("Checking... AC");
5131
       if (verbose_level == 0) SERIAL_PROTOCOLPGM(" (DRY-RUN)");
5135
       if (verbose_level == 0) SERIAL_PROTOCOLPGM(" (DRY-RUN)");
5132
       SERIAL_EOL;
5136
       SERIAL_EOL;
5133
       LCD_MESSAGEPGM("Checking... AC");
5137
       LCD_MESSAGEPGM("Checking... AC");
5134
 
5138
 
5135
       SERIAL_PROTOCOLPAIR(".Height:", DELTA_HEIGHT + home_offset[Z_AXIS]);
5139
       SERIAL_PROTOCOLPAIR(".Height:", DELTA_HEIGHT + home_offset[Z_AXIS]);
5136
-      if (!pp_equals_1) {
5140
+      if (!do_height_only) {
5137
         SERIAL_PROTOCOLPGM("    Ex:");
5141
         SERIAL_PROTOCOLPGM("    Ex:");
5138
         if (endstop_adj[A_AXIS] >= 0) SERIAL_CHAR('+');
5142
         if (endstop_adj[A_AXIS] >= 0) SERIAL_CHAR('+');
5139
         SERIAL_PROTOCOL_F(endstop_adj[A_AXIS], 2);
5143
         SERIAL_PROTOCOL_F(endstop_adj[A_AXIS], 2);
5161
         DEPLOY_PROBE();
5165
         DEPLOY_PROBE();
5162
       #endif
5166
       #endif
5163
 
5167
 
5168
+      int8_t iterations = 0;
5169
+
5164
       do {
5170
       do {
5165
 
5171
 
5166
         float z_at_pt[13] = { 0 },
5172
         float z_at_pt[13] = { 0 },
5171
         test_precision = zero_std_dev;
5177
         test_precision = zero_std_dev;
5172
         iterations++;
5178
         iterations++;
5173
 
5179
 
5174
-        // probe the points
5180
+        // Probe the points
5175
 
5181
 
5176
-        if (!pp_equals_3 && !pp_equals_6) { // probe the centre
5182
+        if (!do_all_positions && !do_circle_x3) { // probe the center
5177
           setup_for_endstop_or_probe_move();
5183
           setup_for_endstop_or_probe_move();
5178
           z_at_pt[0] += probe_pt(0.0, 0.0 , true, 1);
5184
           z_at_pt[0] += probe_pt(0.0, 0.0 , true, 1);
5179
           clean_up_after_endstop_or_probe_move();
5185
           clean_up_after_endstop_or_probe_move();
5180
         }
5186
         }
5181
-        if (pp_greather_2) { // probe extra centre points
5182
-          for (int8_t axis = (pp_greather_4 ? 11 : 9); axis > 0; axis -= (pp_greather_4 ? 2 : 4)) {              
5187
+        if (probe_center_plus_3) { // probe extra center points
5188
+          for (int8_t axis = probe_center_plus_6 ? 11 : 9; axis > 0; axis -= probe_center_plus_6 ? 2 : 4) {
5183
             setup_for_endstop_or_probe_move();
5189
             setup_for_endstop_or_probe_move();
5184
             z_at_pt[0] += probe_pt(
5190
             z_at_pt[0] += probe_pt(
5185
               cos(RADIANS(180 + 30 * axis)) * (0.1 * delta_calibration_radius),
5191
               cos(RADIANS(180 + 30 * axis)) * (0.1 * delta_calibration_radius),
5186
               sin(RADIANS(180 + 30 * axis)) * (0.1 * delta_calibration_radius), true, 1);
5192
               sin(RADIANS(180 + 30 * axis)) * (0.1 * delta_calibration_radius), true, 1);
5187
             clean_up_after_endstop_or_probe_move();
5193
             clean_up_after_endstop_or_probe_move();
5188
           }
5194
           }
5189
-          z_at_pt[0] /= (pp_equals_5 ? 7 : probe_points);
5195
+          z_at_pt[0] /= float(do_circle_x2 ? 7 : probe_points);
5190
         }
5196
         }
5191
-        if (!pp_equals_1) {  // probe the radius
5192
-          float start_circles = (pp_equals_7 ? -1.5 : pp_equals_6 || pp_equals_5 ? -1 : 0),
5193
-                end_circles = -start_circles;
5197
+        if (!do_height_only) {  // probe the radius
5194
           bool zig_zag = true;
5198
           bool zig_zag = true;
5195
-          for (uint8_t axis = (probe_mode == -2 ? 3 : 1); axis < 13; 
5196
-               axis += (pp_equals_2 ? 4 : pp_equals_3 || pp_equals_5 ? 2 : 1)) {
5197
-            for (float circles = start_circles ; circles <= end_circles; circles++) {
5199
+          for (uint8_t axis = (probe_mode == -2 ? 3 : 1); axis < 13;
5200
+                       axis += (do_center_and_towers ? 4 : do_all_positions ? 2 : 1)) {
5201
+            float offset_circles = (do_circle_x4 ? (zig_zag ? 1.5 : 1.0) :
5202
+                                    do_circle_x3 ? (zig_zag ? 1.0 : 0.5) :
5203
+                                    do_circle_x2 ? (zig_zag ? 0.5 : 0.0) : 0);
5204
+            for (float circles = -offset_circles ; circles <= offset_circles; circles++) {
5198
               setup_for_endstop_or_probe_move();
5205
               setup_for_endstop_or_probe_move();
5199
               z_at_pt[axis] += probe_pt(
5206
               z_at_pt[axis] += probe_pt(
5200
-                cos(RADIANS(180 + 30 * axis)) * 
5201
-                (1 + circles * 0.1 * (zig_zag ? 1 : -1)) * delta_calibration_radius, 
5202
-                sin(RADIANS(180 + 30 * axis)) * 
5203
-                (1 + circles * 0.1 * (zig_zag ? 1 : -1)) * delta_calibration_radius, true, 1);
5207
+                cos(RADIANS(180 + 30 * axis)) * delta_calibration_radius *
5208
+                (1 + circles * 0.1 * (zig_zag ? 1 : -1)),
5209
+                sin(RADIANS(180 + 30 * axis)) * delta_calibration_radius *
5210
+                (1 + circles * 0.1 * (zig_zag ? 1 : -1)), true, 1);
5204
               clean_up_after_endstop_or_probe_move();
5211
               clean_up_after_endstop_or_probe_move();
5205
             }
5212
             }
5206
-            start_circles += (pp_greather_5 ? (zig_zag ? 0.5 : -0.5) : 0);
5207
-            end_circles = -start_circles;
5208
             zig_zag = !zig_zag;
5213
             zig_zag = !zig_zag;
5209
-            z_at_pt[axis] /= (pp_equals_7 ? (zig_zag ? 4.0 : 3.0) :
5210
-                              pp_equals_6 ? (zig_zag ? 3.0 : 2.0) : pp_equals_5 ? 3 : 1);
5214
+            z_at_pt[axis] /= (2 * offset_circles + 1);
5211
           }
5215
           }
5212
         }
5216
         }
5213
-        if (pp_greather_3 && !pp_equals_5) // average intermediates to tower and opposites
5214
-          for (uint8_t axis = 1; axis < 13; axis += 2)
5217
+        if (point_averaging) // average intermediates to tower and opposites
5218
+          for (uint8_t axis = 1; axis <= 11; axis += 2)
5215
             z_at_pt[axis] = (z_at_pt[axis] + (z_at_pt[axis + 1] + z_at_pt[(axis + 10) % 12 + 1]) / 2.0) / 2.0;
5219
             z_at_pt[axis] = (z_at_pt[axis] + (z_at_pt[axis + 1] + z_at_pt[(axis + 10) % 12 + 1]) / 2.0) / 2.0;
5216
 
5220
 
5217
         S1 += z_at_pt[0];
5221
         S1 += z_at_pt[0];
5218
         S2 += sq(z_at_pt[0]);
5222
         S2 += sq(z_at_pt[0]);
5219
         N++;
5223
         N++;
5220
-        if (!pp_equals_1) // std dev from zero plane
5221
-          for (uint8_t axis = (probe_mode == -2 ? 3 : 1); axis < 13; axis += (pp_equals_2 ? 4 : 2)) {
5224
+        if (!do_height_only) // std dev from zero plane
5225
+          for (uint8_t axis = (probe_mode == -2 ? 3 : 1); axis < 13; axis += (do_center_and_towers ? 4 : 2)) {
5222
             S1 += z_at_pt[axis];
5226
             S1 += z_at_pt[axis];
5223
             S2 += sq(z_at_pt[axis]);
5227
             S2 += sq(z_at_pt[axis]);
5224
             N++;
5228
             N++;
5279
               e_delta[Y_AXIS] = Z1050(0) - Z0175(1) + Z0350(5) - Z0175(9) + Z0175(7) - Z0350(11) + Z0175(3);
5283
               e_delta[Y_AXIS] = Z1050(0) - Z0175(1) + Z0350(5) - Z0175(9) + Z0175(7) - Z0350(11) + Z0175(3);
5280
               e_delta[Z_AXIS] = Z1050(0) - Z0175(1) - Z0175(5) + Z0350(9) + Z0175(7) + Z0175(11) - Z0350(3);
5284
               e_delta[Z_AXIS] = Z1050(0) - Z0175(1) - Z0175(5) + Z0350(9) + Z0175(7) + Z0175(11) - Z0350(3);
5281
               r_delta         = Z2250(0) - Z0375(1) - Z0375(5) - Z0375(9) - Z0375(7) - Z0375(11) - Z0375(3);
5285
               r_delta         = Z2250(0) - Z0375(1) - Z0375(5) - Z0375(9) - Z0375(7) - Z0375(11) - Z0375(3);
5282
-              
5286
+
5283
               if (probe_mode > 0) {  // negative disables tower angles
5287
               if (probe_mode > 0) {  // negative disables tower angles
5284
                 t_alpha = + Z0444(1) - Z0888(5) + Z0444(9) + Z0444(7) - Z0888(11) + Z0444(3);
5288
                 t_alpha = + Z0444(1) - Z0888(5) + Z0444(9) + Z0444(7) - Z0888(11) + Z0444(3);
5285
                 t_beta  = - Z0888(1) + Z0444(5) + Z0444(9) - Z0888(7) + Z0444(11) + Z0444(3);
5289
                 t_beta  = - Z0888(1) + Z0444(5) + Z0444(9) - Z0888(7) + Z0444(11) + Z0444(3);
5315
           SERIAL_PROTOCOLPGM(".      c:");
5319
           SERIAL_PROTOCOLPGM(".      c:");
5316
           if (z_at_pt[0] > 0) SERIAL_CHAR('+');
5320
           if (z_at_pt[0] > 0) SERIAL_CHAR('+');
5317
           SERIAL_PROTOCOL_F(z_at_pt[0], 2);
5321
           SERIAL_PROTOCOL_F(z_at_pt[0], 2);
5318
-          if (probe_mode == 2 || pp_greather_2) {
5322
+          if (probe_mode == 2 || probe_center_plus_3) {
5319
             SERIAL_PROTOCOLPGM("     x:");
5323
             SERIAL_PROTOCOLPGM("     x:");
5320
             if (z_at_pt[1] >= 0) SERIAL_CHAR('+');
5324
             if (z_at_pt[1] >= 0) SERIAL_CHAR('+');
5321
             SERIAL_PROTOCOL_F(z_at_pt[1], 2);
5325
             SERIAL_PROTOCOL_F(z_at_pt[1], 2);
5327
             SERIAL_PROTOCOL_F(z_at_pt[9], 2);
5331
             SERIAL_PROTOCOL_F(z_at_pt[9], 2);
5328
           }
5332
           }
5329
           if (probe_mode != -2) SERIAL_EOL;
5333
           if (probe_mode != -2) SERIAL_EOL;
5330
-          if (probe_mode == -2 || pp_greather_2) {
5331
-            if (pp_greather_2) {
5334
+          if (probe_mode == -2 || probe_center_plus_3) {
5335
+            if (probe_center_plus_3) {
5332
               SERIAL_CHAR('.');
5336
               SERIAL_CHAR('.');
5333
               SERIAL_PROTOCOL_SP(13);
5337
               SERIAL_PROTOCOL_SP(13);
5334
             }
5338
             }
5364
             lcd_setstatus(mess);
5368
             lcd_setstatus(mess);
5365
           }
5369
           }
5366
           SERIAL_PROTOCOLPAIR(".Height:", DELTA_HEIGHT + home_offset[Z_AXIS]);
5370
           SERIAL_PROTOCOLPAIR(".Height:", DELTA_HEIGHT + home_offset[Z_AXIS]);
5367
-          if (!pp_equals_1) {
5371
+          if (!do_height_only) {
5368
             SERIAL_PROTOCOLPGM("    Ex:");
5372
             SERIAL_PROTOCOLPGM("    Ex:");
5369
             if (endstop_adj[A_AXIS] >= 0) SERIAL_CHAR('+');
5373
             if (endstop_adj[A_AXIS] >= 0) SERIAL_CHAR('+');
5370
             SERIAL_PROTOCOL_F(endstop_adj[A_AXIS], 2);
5374
             SERIAL_PROTOCOL_F(endstop_adj[A_AXIS], 2);
5411
 
5415
 
5412
         stepper.synchronize();
5416
         stepper.synchronize();
5413
 
5417
 
5414
-        gcode_G28();
5418
+        home_all_axes();
5415
 
5419
 
5416
       } while (zero_std_dev < test_precision && iterations < 31);
5420
       } while (zero_std_dev < test_precision && iterations < 31);
5417
 
5421
 
6416
     clean_up_after_endstop_or_probe_move();
6420
     clean_up_after_endstop_or_probe_move();
6417
 
6421
 
6418
     // Re-enable bed level correction if it had been on
6422
     // Re-enable bed level correction if it had been on
6419
-    #if HAS_ABL
6423
+    #if HAS_LEVELING
6420
       set_bed_leveling_enabled(was_enabled);
6424
       set_bed_leveling_enabled(was_enabled);
6421
     #endif
6425
     #endif
6422
 
6426
 
8602
       #else
8606
       #else
8603
         UNUSED(no_babystep);
8607
         UNUSED(no_babystep);
8604
       #endif
8608
       #endif
8605
- 
8609
+
8606
       #if ENABLED(DELTA) // correct the delta_height
8610
       #if ENABLED(DELTA) // correct the delta_height
8607
         home_offset[Z_AXIS] -= diff;
8611
         home_offset[Z_AXIS] -= diff;
8608
       #endif
8612
       #endif
9874
 
9878
 
9875
         #if ENABLED(DELTA_AUTO_CALIBRATION)
9879
         #if ENABLED(DELTA_AUTO_CALIBRATION)
9876
 
9880
 
9877
-          case 33: // G33: Delta Auto Calibrate
9881
+          case 33: // G33: Delta Auto-Calibration
9878
             gcode_G33();
9882
             gcode_G33();
9879
             break;
9883
             break;
9880
 
9884
 

+ 2
- 2
Marlin/configuration_store.cpp View File

36
  *
36
  *
37
  */
37
  */
38
 
38
 
39
-#define EEPROM_VERSION "V36"
39
+#define EEPROM_VERSION "V37"
40
 
40
 
41
 // Change EEPROM version if these are changed:
41
 // Change EEPROM version if these are changed:
42
 #define EEPROM_OFFSET 100
42
 #define EEPROM_OFFSET 100
43
 
43
 
44
 /**
44
 /**
45
- * V35 EEPROM Layout:
45
+ * V37 EEPROM Layout:
46
  *
46
  *
47
  *  100  Version                                    (char x4)
47
  *  100  Version                                    (char x4)
48
  *  104  EEPROM Checksum                            (uint16_t)
48
  *  104  EEPROM Checksum                            (uint16_t)

+ 1
- 1
Marlin/ubl.cpp View File

39
   void bit_set(uint16_t bits[16], uint8_t x, uint8_t y) { SBI(bits[y], x); }
39
   void bit_set(uint16_t bits[16], uint8_t x, uint8_t y) { SBI(bits[y], x); }
40
   bool is_bit_set(uint16_t bits[16], uint8_t x, uint8_t y) { return TEST(bits[y], x); }
40
   bool is_bit_set(uint16_t bits[16], uint8_t x, uint8_t y) { return TEST(bits[y], x); }
41
 
41
 
42
-  int ubl_cnt=0;
42
+  uint8_t ubl_cnt = 0;
43
 
43
 
44
   static void serial_echo_xy(const uint16_t x, const uint16_t y) {
44
   static void serial_echo_xy(const uint16_t x, const uint16_t y) {
45
     SERIAL_CHAR('(');
45
     SERIAL_CHAR('(');

+ 19
- 11
Marlin/ubl.h View File

40
     float distance; // When populated, the distance from the search location
40
     float distance; // When populated, the distance from the search location
41
   } mesh_index_pair;
41
   } mesh_index_pair;
42
 
42
 
43
+  // ubl.cpp
44
+
45
+  void bit_clear(uint16_t bits[16], uint8_t x, uint8_t y);
46
+  void bit_set(uint16_t bits[16], uint8_t x, uint8_t y);
47
+  bool is_bit_set(uint16_t bits[16], uint8_t x, uint8_t y);
48
+
49
+  // ubl_motion.cpp
50
+
51
+  void debug_current_and_destination(const char * const title);
52
+  void ubl_line_to_destination(const float&, uint8_t);
53
+
54
+  // ubl_G29.cpp
55
+
43
   enum MeshPointType { INVALID, REAL, SET_IN_BITMAP };
56
   enum MeshPointType { INVALID, REAL, SET_IN_BITMAP };
44
 
57
 
45
   void dump(char * const str, const float &f);
58
   void dump(char * const str, const float &f);
46
-  bool ubl_lcd_clicked();
47
   void probe_entire_mesh(const float&, const float&, const bool, const bool, const bool);
59
   void probe_entire_mesh(const float&, const float&, const bool, const bool, const bool);
48
-  void debug_current_and_destination(const char * const title);
49
-  void ubl_line_to_destination(const float&, uint8_t);
50
   void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
60
   void manually_probe_remaining_mesh(const float&, const float&, const float&, const float&, const bool);
51
   float measure_business_card_thickness(const float&);
61
   float measure_business_card_thickness(const float&);
52
   mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, unsigned int[16], bool);
62
   mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const float&, const float&, const bool, unsigned int[16], bool);
53
   void shift_mesh_height();
63
   void shift_mesh_height();
64
+  void fine_tune_mesh(const float&, const float&, const bool);
54
   bool g29_parameter_parsing();
65
   bool g29_parameter_parsing();
55
   void g29_what_command();
66
   void g29_what_command();
56
   void g29_eeprom_dump();
67
   void g29_eeprom_dump();
57
   void g29_compare_current_mesh_to_stored_mesh();
68
   void g29_compare_current_mesh_to_stored_mesh();
58
-  void fine_tune_mesh(const float&, const float&, const bool);
59
-  void bit_clear(uint16_t bits[16], uint8_t x, uint8_t y);
60
-  void bit_set(uint16_t bits[16], uint8_t x, uint8_t y);
61
-  bool is_bit_set(uint16_t bits[16], uint8_t x, uint8_t y);
62
-  char *ftostr43sign(const float&, char);
63
 
69
 
64
-  void home_all_axes();
70
+  // External references
65
 
71
 
72
+  char *ftostr43sign(const float&, char);
73
+  bool ubl_lcd_clicked();
74
+  void home_all_axes();
66
   void gcode_G26();
75
   void gcode_G26();
67
   void gcode_G29();
76
   void gcode_G29();
68
 
77
 
69
-  extern int ubl_cnt;
78
+  extern uint8_t ubl_cnt;
70
 
79
 
71
   ///////////////////////////////////////////////////////////////////////////////////////////////////////
80
   ///////////////////////////////////////////////////////////////////////////////////////////////////////
72
 
81
 
75
     void lcd_quick_feedback();
84
     void lcd_quick_feedback();
76
   #endif
85
   #endif
77
 
86
 
78
-
79
   #define MESH_X_DIST (float(UBL_MESH_MAX_X - (UBL_MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
87
   #define MESH_X_DIST (float(UBL_MESH_MAX_X - (UBL_MESH_MIN_X)) / float(GRID_MAX_POINTS_X - 1))
80
   #define MESH_Y_DIST (float(UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1))
88
   #define MESH_Y_DIST (float(UBL_MESH_MAX_Y - (UBL_MESH_MIN_Y)) / float(GRID_MAX_POINTS_Y - 1))
81
 
89
 

+ 1
- 1
Marlin/ubl_G29.cpp View File

1195
     SERIAL_EOL;
1195
     SERIAL_EOL;
1196
     safe_delay(50);
1196
     safe_delay(50);
1197
 
1197
 
1198
-    SERIAL_PROTOCOLLNPAIR("UBL object count: ", ubl_cnt);
1198
+    SERIAL_PROTOCOLLNPAIR("UBL object count: ", (int)ubl_cnt);
1199
 
1199
 
1200
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1200
     #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1201
       SERIAL_PROTOCOLLNPAIR("planner.z_fade_height : ", planner.z_fade_height);
1201
       SERIAL_PROTOCOLLNPAIR("planner.z_fade_height : ", planner.z_fade_height);

+ 8
- 10
Marlin/ubl_motion.cpp View File

1
-
2
 /**
1
 /**
3
  * Marlin 3D Printer Firmware
2
  * Marlin 3D Printer Firmware
4
  * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
3
  * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
275
         if (y != start[Y_AXIS]) {
274
         if (y != start[Y_AXIS]) {
276
           if (!inf_normalized_flag) {
275
           if (!inf_normalized_flag) {
277
 
276
 
278
-//          on_axis_distance = y - start[Y_AXIS];                               
277
+            //on_axis_distance = y - start[Y_AXIS];                               
279
             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];
280
 
279
 
281
-//          on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : y - start[Y_AXIS];
282
-//          on_axis_distance = use_x_dist ? x - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
283
-
284
-//          on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : y - start[Y_AXIS];
285
-//          on_axis_distance = use_x_dist ? x - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
280
+            //on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : y - start[Y_AXIS];
281
+            //on_axis_distance = use_x_dist ? x - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
286
 
282
 
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];
287
 
285
 
288
             e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;  
286
             e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;  
289
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
287
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
350
         if (x != start[X_AXIS]) {
348
         if (x != start[X_AXIS]) {
351
           if (!inf_normalized_flag) {
349
           if (!inf_normalized_flag) {
352
 
350
 
353
-//          on_axis_distance = x - start[X_AXIS];
351
+            //on_axis_distance = x - start[X_AXIS];
354
             on_axis_distance = use_x_dist ? x - start[X_AXIS] : y - start[Y_AXIS];
352
             on_axis_distance = use_x_dist ? x - start[X_AXIS] : y - start[Y_AXIS];
355
 
353
 
356
-//          on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : y - start[Y_AXIS];
357
-//          on_axis_distance = use_x_dist ? x - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
354
+            //on_axis_distance = use_x_dist ? next_mesh_line_x - start[X_AXIS] : y - start[Y_AXIS];
355
+            //on_axis_distance = use_x_dist ? x - start[X_AXIS] : next_mesh_line_y - start[Y_AXIS];
358
 
356
 
359
             e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;  // is based on X or Y because this is a horizontal move
357
             e_position = start[E_AXIS] + on_axis_distance * e_normalized_dist;  // is based on X or Y because this is a horizontal move
360
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;
358
             z_position = start[Z_AXIS] + on_axis_distance * z_normalized_dist;

Loading…
Cancel
Save