Browse Source

Merge pull request #6858 from thinkyhead/bf_leveling_patch

Fixes for PROBE_MANUALLY and LCD_BED_LEVELING
Scott Lahteine 8 years ago
parent
commit
73ed0c63b4
4 changed files with 468 additions and 492 deletions
  1. 1
    0
      .gitignore
  2. 47
    25
      Marlin/Marlin_main.cpp
  3. 4
    4
      Marlin/configuration_store.cpp
  4. 416
    463
      Marlin/ultralcd.cpp

+ 1
- 0
.gitignore View File

52
 *.lo
52
 *.lo
53
 *.o
53
 *.o
54
 *.obj
54
 *.obj
55
+*.ino.cpp
55
 
56
 
56
 # Precompiled Headers
57
 # Precompiled Headers
57
 *.gch
58
 *.gch

+ 47
- 25
Marlin/Marlin_main.cpp View File

3800
 
3800
 
3801
 #if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
3801
 #if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
3802
 
3802
 
3803
+  #if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
3804
+    extern bool lcd_wait_for_move;
3805
+  #endif
3806
+
3803
   inline void _manual_goto_xy(const float &x, const float &y) {
3807
   inline void _manual_goto_xy(const float &x, const float &y) {
3804
     const float old_feedrate_mm_s = feedrate_mm_s;
3808
     const float old_feedrate_mm_s = feedrate_mm_s;
3805
 
3809
 
3822
 
3826
 
3823
     feedrate_mm_s = old_feedrate_mm_s;
3827
     feedrate_mm_s = old_feedrate_mm_s;
3824
     stepper.synchronize();
3828
     stepper.synchronize();
3829
+
3830
+    #if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
3831
+      lcd_wait_for_move = false;
3832
+    #endif
3825
   }
3833
   }
3826
 
3834
 
3827
 #endif
3835
 #endif
4190
     if (!g29_in_progress) {
4198
     if (!g29_in_progress) {
4191
 
4199
 
4192
       #if ENABLED(PROBE_MANUALLY) || ENABLED(AUTO_BED_LEVELING_LINEAR)
4200
       #if ENABLED(PROBE_MANUALLY) || ENABLED(AUTO_BED_LEVELING_LINEAR)
4193
-        abl_probe_index = 0;
4201
+        abl_probe_index = -1;
4194
       #endif
4202
       #endif
4195
 
4203
 
4196
       abl_should_enable = planner.abl_enabled;
4204
       abl_should_enable = planner.abl_enabled;
4397
 
4405
 
4398
     #if ENABLED(PROBE_MANUALLY)
4406
     #if ENABLED(PROBE_MANUALLY)
4399
 
4407
 
4408
+      const bool seenA = parser.seen('A'), seenQ = parser.seen('Q');
4409
+
4410
+      // For manual probing, get the next index to probe now.
4411
+      // On the first probe this will be incremented to 0.
4412
+      if (!seenA && !seenQ) {
4413
+        ++abl_probe_index;
4414
+        g29_in_progress = true;
4415
+      }
4416
+
4400
       // Abort current G29 procedure, go back to ABLStart
4417
       // Abort current G29 procedure, go back to ABLStart
4401
-      if (parser.seen('A') && g29_in_progress) {
4418
+      if (seenA && g29_in_progress) {
4402
         SERIAL_PROTOCOLLNPGM("Manual G29 aborted");
4419
         SERIAL_PROTOCOLLNPGM("Manual G29 aborted");
4403
         #if HAS_SOFTWARE_ENDSTOPS
4420
         #if HAS_SOFTWARE_ENDSTOPS
4404
           soft_endstops_enabled = enable_soft_endstops;
4421
           soft_endstops_enabled = enable_soft_endstops;
4405
         #endif
4422
         #endif
4406
         planner.abl_enabled = abl_should_enable;
4423
         planner.abl_enabled = abl_should_enable;
4407
         g29_in_progress = false;
4424
         g29_in_progress = false;
4425
+        #if ENABLED(LCD_BED_LEVELING)
4426
+          lcd_wait_for_move = false;
4427
+        #endif
4408
       }
4428
       }
4409
 
4429
 
4410
       // Query G29 status
4430
       // Query G29 status
4411
-      if (parser.seen('Q')) {
4412
-        if (!g29_in_progress)
4413
-          SERIAL_PROTOCOLLNPGM("Manual G29 idle");
4414
-        else {
4415
-          SERIAL_PROTOCOLPAIR("Manual G29 point ", abl_probe_index + 1);
4431
+      if (verbose_level || seenQ) {
4432
+        SERIAL_PROTOCOLPGM("Manual G29 ");
4433
+        if (g29_in_progress) {
4434
+          SERIAL_PROTOCOLPAIR("point ", abl_probe_index + 1);
4416
           SERIAL_PROTOCOLLNPAIR(" of ", abl2);
4435
           SERIAL_PROTOCOLLNPAIR(" of ", abl2);
4417
         }
4436
         }
4437
+        else
4438
+          SERIAL_PROTOCOLLNPGM("idle");
4418
       }
4439
       }
4419
 
4440
 
4420
-      if (parser.seen('A') || parser.seen('Q')) return;
4421
-
4422
-      // Fall through to probe the first point
4423
-      g29_in_progress = true;
4441
+      if (seenA || seenQ) return;
4424
 
4442
 
4425
       if (abl_probe_index == 0) {
4443
       if (abl_probe_index == 0) {
4426
         // For the initial G29 save software endstop state
4444
         // For the initial G29 save software endstop state
4458
 
4476
 
4459
       #if ABL_GRID
4477
       #if ABL_GRID
4460
 
4478
 
4461
-        // Find a next point to probe
4462
-        // On the first G29 this will be the first probe point
4479
+        // Skip any unreachable points
4463
         while (abl_probe_index < abl2) {
4480
         while (abl_probe_index < abl2) {
4464
 
4481
 
4465
           // Set xCount, yCount based on abl_probe_index, with zig-zag
4482
           // Set xCount, yCount based on abl_probe_index, with zig-zag
4466
           PR_OUTER_VAR = abl_probe_index / PR_INNER_END;
4483
           PR_OUTER_VAR = abl_probe_index / PR_INNER_END;
4467
           PR_INNER_VAR = abl_probe_index - (PR_OUTER_VAR * PR_INNER_END);
4484
           PR_INNER_VAR = abl_probe_index - (PR_OUTER_VAR * PR_INNER_END);
4468
 
4485
 
4469
-          bool zig = (PR_OUTER_VAR & 1) != ((PR_OUTER_END) & 1);
4486
+          // Probe in reverse order for every other row/column
4487
+          bool zig = (PR_OUTER_VAR & 1); // != ((PR_OUTER_END) & 1);
4470
 
4488
 
4471
           if (zig) PR_INNER_VAR = (PR_INNER_END - 1) - PR_INNER_VAR;
4489
           if (zig) PR_INNER_VAR = (PR_INNER_END - 1) - PR_INNER_VAR;
4472
 
4490
 
4473
-          const float xBase = left_probe_bed_position + xGridSpacing * xCount,
4474
-                      yBase = front_probe_bed_position + yGridSpacing * yCount;
4491
+          const float xBase = xCount * xGridSpacing + left_probe_bed_position,
4492
+                      yBase = yCount * yGridSpacing + front_probe_bed_position;
4475
 
4493
 
4476
           xProbe = floor(xBase + (xBase < 0 ? 0 : 0.5));
4494
           xProbe = floor(xBase + (xBase < 0 ? 0 : 0.5));
4477
           yProbe = floor(yBase + (yBase < 0 ? 0 : 0.5));
4495
           yProbe = floor(yBase + (yBase < 0 ? 0 : 0.5));
4488
         // Is there a next point to move to?
4506
         // Is there a next point to move to?
4489
         if (abl_probe_index < abl2) {
4507
         if (abl_probe_index < abl2) {
4490
           _manual_goto_xy(xProbe, yProbe); // Can be used here too!
4508
           _manual_goto_xy(xProbe, yProbe); // Can be used here too!
4491
-          ++abl_probe_index;
4492
           #if HAS_SOFTWARE_ENDSTOPS
4509
           #if HAS_SOFTWARE_ENDSTOPS
4493
             // Disable software endstops to allow manual adjustment
4510
             // Disable software endstops to allow manual adjustment
4494
             // If G29 is not completed, they will not be re-enabled
4511
             // If G29 is not completed, they will not be re-enabled
4497
           return;
4514
           return;
4498
         }
4515
         }
4499
         else {
4516
         else {
4500
-          // Then leveling is done!
4501
-          // G29 finishing code goes here
4502
 
4517
 
4503
-          // After recording the last point, activate abl
4518
+          // Leveling done! Fall through to G29 finishing code below
4519
+
4504
           SERIAL_PROTOCOLLNPGM("Grid probing done.");
4520
           SERIAL_PROTOCOLLNPGM("Grid probing done.");
4505
           g29_in_progress = false;
4521
           g29_in_progress = false;
4506
 
4522
 
4514
 
4530
 
4515
         // Probe at 3 arbitrary points
4531
         // Probe at 3 arbitrary points
4516
         if (abl_probe_index < 3) {
4532
         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;
4533
+          xProbe = LOGICAL_X_POSITION(points[abl_probe_index].x);
4534
+          yProbe = LOGICAL_Y_POSITION(points[abl_probe_index].y);
4520
           #if HAS_SOFTWARE_ENDSTOPS
4535
           #if HAS_SOFTWARE_ENDSTOPS
4521
             // Disable software endstops to allow manual adjustment
4536
             // Disable software endstops to allow manual adjustment
4522
             // If G29 is not completed, they will not be re-enabled
4537
             // If G29 is not completed, they will not be re-enabled
4587
             yProbe = floor(yBase + (yBase < 0 ? 0 : 0.5));
4602
             yProbe = floor(yBase + (yBase < 0 ? 0 : 0.5));
4588
 
4603
 
4589
             #if ENABLED(AUTO_BED_LEVELING_LINEAR)
4604
             #if ENABLED(AUTO_BED_LEVELING_LINEAR)
4590
-              indexIntoAB[xCount][yCount] = ++abl_probe_index;
4605
+              indexIntoAB[xCount][yCount] = ++abl_probe_index; // 0...
4591
             #endif
4606
             #endif
4592
 
4607
 
4593
             #if IS_KINEMATIC
4608
             #if IS_KINEMATIC
4665
     // G29 Finishing Code
4680
     // G29 Finishing Code
4666
     //
4681
     //
4667
     // Unless this is a dry run, auto bed leveling will
4682
     // Unless this is a dry run, auto bed leveling will
4668
-    // definitely be enabled after this point
4683
+    // definitely be enabled after this point.
4684
+    //
4685
+    // If code above wants to continue leveling, it should
4686
+    // return or loop before this point.
4669
     //
4687
     //
4670
 
4688
 
4671
     // Restore state after probing
4689
     // Restore state after probing
4675
       if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
4693
       if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
4676
     #endif
4694
     #endif
4677
 
4695
 
4696
+    #if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
4697
+      lcd_wait_for_move = false;
4698
+    #endif
4699
+
4678
     // Calculate leveling, print reports, correct the position
4700
     // Calculate leveling, print reports, correct the position
4679
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
4701
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
4680
 
4702
 

+ 4
- 4
Marlin/configuration_store.cpp View File

1344
     #else
1344
     #else
1345
       #define LINEAR_UNIT(N) N
1345
       #define LINEAR_UNIT(N) N
1346
       #define VOLUMETRIC_UNIT(N) N
1346
       #define VOLUMETRIC_UNIT(N) N
1347
-      SERIAL_ECHOLNPGM("  G21 ; Units in mm\n");
1347
+      SERIAL_ECHOLNPGM("  G21    ; Units in mm");
1348
     #endif
1348
     #endif
1349
-    SERIAL_EOL;
1350
 
1349
 
1351
     #if ENABLED(ULTIPANEL)
1350
     #if ENABLED(ULTIPANEL)
1352
 
1351
 
1361
         serialprintPGM(parser.temp_units_name());
1360
         serialprintPGM(parser.temp_units_name());
1362
       #else
1361
       #else
1363
         #define TEMP_UNIT(N) N
1362
         #define TEMP_UNIT(N) N
1364
-        SERIAL_ECHOLNPGM("  M149 C ; Units in Celsius\n");
1363
+        SERIAL_ECHOLNPGM("  M149 C ; Units in Celsius");
1365
       #endif
1364
       #endif
1366
-      SERIAL_EOL;
1367
 
1365
 
1368
     #endif
1366
     #endif
1369
 
1367
 
1368
+    SERIAL_EOL;
1369
+
1370
     /**
1370
     /**
1371
      * Volumetric extrusion M200
1371
      * Volumetric extrusion M200
1372
      */
1372
      */

+ 416
- 463
Marlin/ultralcd.cpp
File diff suppressed because it is too large
View File


Loading…
Cancel
Save