瀏覽代碼

Fix PROBE_MANUALLY via G-code

Scott Lahteine 8 年之前
父節點
當前提交
78af2b1444
共有 1 個檔案被更改,包括 27 行新增21 行删除
  1. 27
    21
      Marlin/Marlin_main.cpp

+ 27
- 21
Marlin/Marlin_main.cpp 查看文件

4190
     if (!g29_in_progress) {
4190
     if (!g29_in_progress) {
4191
 
4191
 
4192
       #if ENABLED(PROBE_MANUALLY) || ENABLED(AUTO_BED_LEVELING_LINEAR)
4192
       #if ENABLED(PROBE_MANUALLY) || ENABLED(AUTO_BED_LEVELING_LINEAR)
4193
-        abl_probe_index = 0;
4193
+        abl_probe_index = -1;
4194
       #endif
4194
       #endif
4195
 
4195
 
4196
       abl_should_enable = planner.abl_enabled;
4196
       abl_should_enable = planner.abl_enabled;
4397
 
4397
 
4398
     #if ENABLED(PROBE_MANUALLY)
4398
     #if ENABLED(PROBE_MANUALLY)
4399
 
4399
 
4400
+      const bool seenA = parser.seen('A'), seenQ = parser.seen('Q');
4401
+
4402
+      // For manual probing, get the next index to probe now.
4403
+      // On the first probe this will be incremented to 0.
4404
+      if (!seenA && !seenQ) {
4405
+        ++abl_probe_index;
4406
+        g29_in_progress = true;
4407
+      }
4408
+
4400
       // Abort current G29 procedure, go back to ABLStart
4409
       // Abort current G29 procedure, go back to ABLStart
4401
-      if (parser.seen('A') && g29_in_progress) {
4410
+      if (seenA && g29_in_progress) {
4402
         SERIAL_PROTOCOLLNPGM("Manual G29 aborted");
4411
         SERIAL_PROTOCOLLNPGM("Manual G29 aborted");
4403
         #if HAS_SOFTWARE_ENDSTOPS
4412
         #if HAS_SOFTWARE_ENDSTOPS
4404
           soft_endstops_enabled = enable_soft_endstops;
4413
           soft_endstops_enabled = enable_soft_endstops;
4408
       }
4417
       }
4409
 
4418
 
4410
       // Query G29 status
4419
       // Query G29 status
4411
-      if (parser.seen('Q')) {
4420
+      if (verbose_level || seenQ) {
4412
         if (!g29_in_progress)
4421
         if (!g29_in_progress)
4413
           SERIAL_PROTOCOLLNPGM("Manual G29 idle");
4422
           SERIAL_PROTOCOLLNPGM("Manual G29 idle");
4414
         else {
4423
         else {
4417
         }
4426
         }
4418
       }
4427
       }
4419
 
4428
 
4420
-      if (parser.seen('A') || parser.seen('Q')) return;
4421
-
4422
-      // Fall through to probe the first point
4423
-      g29_in_progress = true;
4429
+      if (seenA || seenQ) return;
4424
 
4430
 
4425
       if (abl_probe_index == 0) {
4431
       if (abl_probe_index == 0) {
4426
         // For the initial G29 save software endstop state
4432
         // For the initial G29 save software endstop state
4458
 
4464
 
4459
       #if ABL_GRID
4465
       #if ABL_GRID
4460
 
4466
 
4461
-        // Find a next point to probe
4462
-        // On the first G29 this will be the first probe point
4467
+        // Skip any unreachable points
4463
         while (abl_probe_index < abl2) {
4468
         while (abl_probe_index < abl2) {
4464
 
4469
 
4465
           // Set xCount, yCount based on abl_probe_index, with zig-zag
4470
           // Set xCount, yCount based on abl_probe_index, with zig-zag
4466
           PR_OUTER_VAR = abl_probe_index / PR_INNER_END;
4471
           PR_OUTER_VAR = abl_probe_index / PR_INNER_END;
4467
           PR_INNER_VAR = abl_probe_index - (PR_OUTER_VAR * PR_INNER_END);
4472
           PR_INNER_VAR = abl_probe_index - (PR_OUTER_VAR * PR_INNER_END);
4468
 
4473
 
4469
-          bool zig = (PR_OUTER_VAR & 1) != ((PR_OUTER_END) & 1);
4474
+          // Probe in reverse order for every other row/column
4475
+          bool zig = (PR_OUTER_VAR & 1); // != ((PR_OUTER_END) & 1);
4470
 
4476
 
4471
           if (zig) PR_INNER_VAR = (PR_INNER_END - 1) - PR_INNER_VAR;
4477
           if (zig) PR_INNER_VAR = (PR_INNER_END - 1) - PR_INNER_VAR;
4472
 
4478
 
4473
-          const float xBase = left_probe_bed_position + xGridSpacing * xCount,
4474
-                      yBase = front_probe_bed_position + yGridSpacing * yCount;
4479
+          const float xBase = xCount * xGridSpacing + left_probe_bed_position,
4480
+                      yBase = yCount * yGridSpacing + front_probe_bed_position;
4475
 
4481
 
4476
           xProbe = floor(xBase + (xBase < 0 ? 0 : 0.5));
4482
           xProbe = floor(xBase + (xBase < 0 ? 0 : 0.5));
4477
           yProbe = floor(yBase + (yBase < 0 ? 0 : 0.5));
4483
           yProbe = floor(yBase + (yBase < 0 ? 0 : 0.5));
4488
         // Is there a next point to move to?
4494
         // Is there a next point to move to?
4489
         if (abl_probe_index < abl2) {
4495
         if (abl_probe_index < abl2) {
4490
           _manual_goto_xy(xProbe, yProbe); // Can be used here too!
4496
           _manual_goto_xy(xProbe, yProbe); // Can be used here too!
4491
-          ++abl_probe_index;
4492
           #if HAS_SOFTWARE_ENDSTOPS
4497
           #if HAS_SOFTWARE_ENDSTOPS
4493
             // Disable software endstops to allow manual adjustment
4498
             // Disable software endstops to allow manual adjustment
4494
             // If G29 is not completed, they will not be re-enabled
4499
             // If G29 is not completed, they will not be re-enabled
4497
           return;
4502
           return;
4498
         }
4503
         }
4499
         else {
4504
         else {
4500
-          // Then leveling is done!
4501
-          // G29 finishing code goes here
4502
 
4505
 
4503
-          // After recording the last point, activate abl
4506
+          // Leveling done! Fall through to G29 finishing code below
4507
+
4504
           SERIAL_PROTOCOLLNPGM("Grid probing done.");
4508
           SERIAL_PROTOCOLLNPGM("Grid probing done.");
4505
           g29_in_progress = false;
4509
           g29_in_progress = false;
4506
 
4510
 
4514
 
4518
 
4515
         // Probe at 3 arbitrary points
4519
         // Probe at 3 arbitrary points
4516
         if (abl_probe_index < 3) {
4520
         if (abl_probe_index < 3) {
4517
-          xProbe = LOGICAL_X_POSITION(points[i].x);
4518
-          yProbe = LOGICAL_Y_POSITION(points[i].y);
4519
-          ++abl_probe_index;
4521
+          xProbe = LOGICAL_X_POSITION(points[abl_probe_index].x);
4522
+          yProbe = LOGICAL_Y_POSITION(points[abl_probe_index].y);
4520
           #if HAS_SOFTWARE_ENDSTOPS
4523
           #if HAS_SOFTWARE_ENDSTOPS
4521
             // Disable software endstops to allow manual adjustment
4524
             // Disable software endstops to allow manual adjustment
4522
             // If G29 is not completed, they will not be re-enabled
4525
             // If G29 is not completed, they will not be re-enabled
4587
             yProbe = floor(yBase + (yBase < 0 ? 0 : 0.5));
4590
             yProbe = floor(yBase + (yBase < 0 ? 0 : 0.5));
4588
 
4591
 
4589
             #if ENABLED(AUTO_BED_LEVELING_LINEAR)
4592
             #if ENABLED(AUTO_BED_LEVELING_LINEAR)
4590
-              indexIntoAB[xCount][yCount] = ++abl_probe_index;
4593
+              indexIntoAB[xCount][yCount] = ++abl_probe_index; // 0...
4591
             #endif
4594
             #endif
4592
 
4595
 
4593
             #if IS_KINEMATIC
4596
             #if IS_KINEMATIC
4665
     // G29 Finishing Code
4668
     // G29 Finishing Code
4666
     //
4669
     //
4667
     // Unless this is a dry run, auto bed leveling will
4670
     // Unless this is a dry run, auto bed leveling will
4668
-    // definitely be enabled after this point
4671
+    // definitely be enabled after this point.
4672
+    //
4673
+    // If code above wants to continue leveling, it should
4674
+    // return or loop before this point.
4669
     //
4675
     //
4670
 
4676
 
4671
     // Restore state after probing
4677
     // Restore state after probing

Loading…
取消
儲存