浏览代码

Patch up LCD Bed Leveling menu

Scott Lahteine 8 年前
父节点
当前提交
9677f3f2f5
共有 2 个文件被更改,包括 77 次插入47 次删除
  1. 1
    1
      Marlin/Marlin_main.cpp
  2. 76
    46
      Marlin/ultralcd.cpp

+ 1
- 1
Marlin/Marlin_main.cpp 查看文件

@@ -4460,7 +4460,7 @@ void home_all_axes() { gcode_G28(true); }
4460 4460
       if (verbose_level || seenQ) {
4461 4461
         SERIAL_PROTOCOLPGM("Manual G29 ");
4462 4462
         if (g29_in_progress) {
4463
-          SERIAL_PROTOCOLPAIR("point ", abl_probe_index + 1);
4463
+          SERIAL_PROTOCOLPAIR("point ", min(abl_probe_index + 1, abl2));
4464 4464
           SERIAL_PROTOCOLLNPAIR(" of ", abl2);
4465 4465
         }
4466 4466
         else

+ 76
- 46
Marlin/ultralcd.cpp 查看文件

@@ -484,6 +484,11 @@ uint16_t max_display_update_time = 0;
484 484
   static const char moving[] PROGMEM = MSG_MOVING;
485 485
   static const char *sync_message = moving;
486 486
 
487
+  //
488
+  // Display the synchronize screen until moves are
489
+  // finished, and don't return to the caller until
490
+  // done. ** This blocks the command queue! **
491
+  //
487 492
   void _lcd_synchronize() {
488 493
     static bool no_reentry = false;
489 494
     if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
@@ -498,6 +503,8 @@ uint16_t max_display_update_time = 0;
498 503
     lcd_goto_screen(old_screen);
499 504
   }
500 505
 
506
+  // Display the synchronize screen with a custom message
507
+  // ** This blocks the command queue! **
501 508
   void lcd_synchronize(const char * const msg=NULL) {
502 509
     sync_message = msg ? msg : moving;
503 510
     _lcd_synchronize();
@@ -1427,6 +1434,26 @@ void kill_screen(const char* lcd_msg) {
1427 1434
       #endif
1428 1435
     );
1429 1436
 
1437
+    //
1438
+    // Raise Z to the "manual probe height"
1439
+    // Don't return until done.
1440
+    // ** This blocks the command queue! **
1441
+    //
1442
+    void _lcd_after_probing() {
1443
+      #if MANUAL_PROBE_HEIGHT > 0
1444
+        current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT;
1445
+        line_to_current(Z_AXIS);
1446
+      #endif
1447
+      // Display "Done" screen and wait for moves to complete
1448
+      #if MANUAL_PROBE_HEIGHT > 0 || ENABLED(MESH_BED_LEVELING)
1449
+        lcd_synchronize(PSTR(MSG_LEVEL_BED_DONE));
1450
+      #endif
1451
+      lcd_goto_previous_menu();
1452
+      lcd_completion_feedback();
1453
+      defer_return_to_status = false;
1454
+      //LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
1455
+    }
1456
+
1430 1457
     #if ENABLED(MESH_BED_LEVELING)
1431 1458
 
1432 1459
       // Utility to go to the next mesh point
@@ -1445,12 +1472,22 @@ void kill_screen(const char* lcd_msg) {
1445 1472
         lcd_synchronize();
1446 1473
       }
1447 1474
 
1448
-    #endif // MESH_BED_LEVELING
1475
+    #elif ENABLED(PROBE_MANUALLY)
1449 1476
 
1450
-    void _lcd_level_bed_done() {
1451
-      if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_DONE));
1452
-      lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
1453
-    }
1477
+      bool lcd_wait_for_move;
1478
+
1479
+      //
1480
+      // Bed leveling is done. Wait for G29 to complete.
1481
+      // A flag is used so that this can release control
1482
+      // and allow the command queue to be processed.
1483
+      //
1484
+      void _lcd_level_bed_done() {
1485
+        if (!lcd_wait_for_move) _lcd_after_probing();
1486
+        if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_DONE));
1487
+        lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
1488
+      }
1489
+
1490
+    #endif
1454 1491
 
1455 1492
     void _lcd_level_goto_next_point();
1456 1493
 
@@ -1462,60 +1499,55 @@ void kill_screen(const char* lcd_msg) {
1462 1499
 
1463 1500
       if (lcd_clicked) {
1464 1501
 
1465
-        // Use a hook to set the probe point z
1502
+        //
1503
+        // Save the current Z position
1504
+        //
1505
+
1466 1506
         #if ENABLED(MESH_BED_LEVELING)
1467 1507
 
1508
+          //
1468 1509
           // MBL records the position but doesn't move to the next one
1469
-          mbl.set_zigzag_z(manual_probe_index, current_position[Z_AXIS]);
1470
-
1471
-        #elif ENABLED(PROBE_MANUALLY)
1510
+          //
1472 1511
 
1473
-          // The last G29 will record but not move
1474
-          if (manual_probe_index == total_probe_points - 1)
1475
-            enqueue_and_echo_commands_P(PSTR("G29 V1"));
1512
+          mbl.set_zigzag_z(manual_probe_index, current_position[Z_AXIS]);
1476 1513
 
1477 1514
         #endif
1478 1515
 
1479 1516
         // If done...
1480 1517
         if (++manual_probe_index >= total_probe_points) {
1481 1518
 
1482
-          // Say "Done!"
1483
-          lcd_goto_screen(_lcd_level_bed_done);
1519
+          #if ENABLED(PROBE_MANUALLY)
1484 1520
 
1485
-          // Raise Z to the "manual probe height"
1486
-          #if MANUAL_PROBE_HEIGHT > 0
1487
-            current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT;
1488
-            line_to_current(Z_AXIS);
1489
-          #endif
1521
+            //
1522
+            // The last G29 will record and enable but not move.
1523
+            // Since G29 is deferred, 
1524
+            //
1525
+            lcd_wait_for_move = true;
1526
+            enqueue_and_echo_commands_P(PSTR("G29 V1"));
1527
+            lcd_goto_screen(_lcd_level_bed_done);
1490 1528
 
1491
-          #if MANUAL_PROBE_HEIGHT > 0 || ENABLED(MESH_BED_LEVELING)
1492
-            lcd_synchronize(PSTR(MSG_LEVEL_BED_DONE));
1493
-          #endif
1529
+          #elif ENABLED(MESH_BED_LEVELING)
1494 1530
 
1495
-          // Enable leveling, if needed
1496
-          #if ENABLED(MESH_BED_LEVELING)
1531
+            _lcd_after_probing();
1497 1532
 
1498 1533
             mbl.set_has_mesh(true);
1499 1534
             mesh_probing_done();
1500 1535
 
1501
-          #elif ENABLED(PROBE_MANUALLY)
1502
-
1503
-            // ABL will be enabled due to "G29".
1504
-
1505 1536
           #endif
1506 1537
 
1507
-          lcd_goto_previous_menu(); // Return to the last clicked item ("Level Bed")
1508
-
1509
-          //LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
1510
-          lcd_completion_feedback();
1511 1538
         }
1512
-        else
1539
+        else {
1540
+          // MESH_BED_LEVELING: Z already stored, just move
1541
+          //    PROBE_MANUALLY: Send G29 to record Z, then move
1513 1542
           _lcd_level_goto_next_point();
1543
+        }
1514 1544
 
1515 1545
         return;
1516 1546
       }
1517 1547
 
1548
+      //
1518 1549
       // Encoder knob or keypad buttons adjust the Z position
1550
+      //
1519 1551
       if (encoderPosition) {
1520 1552
         refresh_cmd_timeout();
1521 1553
         current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
@@ -1526,8 +1558,9 @@ void kill_screen(const char* lcd_msg) {
1526 1558
         encoderPosition = 0;
1527 1559
       }
1528 1560
 
1529
-      // Update on first display, then only on updates to Z position
1530
-      // Show message above on clicks instead
1561
+      //
1562
+      // Draw on first display, then only on Z change
1563
+      //
1531 1564
       if (lcdDrawUpdate) {
1532 1565
         const float v = current_position[Z_AXIS];
1533 1566
         lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001 : 0.0001), '+'));
@@ -1538,10 +1571,6 @@ void kill_screen(const char* lcd_msg) {
1538 1571
      * Step 6: Display "Next point: 1 / 9" while waiting for move to finish
1539 1572
      */
1540 1573
 
1541
-    #if ENABLED(PROBE_MANUALLY)
1542
-      bool lcd_wait_for_move;
1543
-    #endif
1544
-
1545 1574
     void _lcd_level_bed_moving() {
1546 1575
       if (lcdDrawUpdate) {
1547 1576
         char msg[10];
@@ -1578,7 +1607,7 @@ void kill_screen(const char* lcd_msg) {
1578 1607
 
1579 1608
       #elif ENABLED(PROBE_MANUALLY)
1580 1609
 
1581
-        // G29 will signal when it's done
1610
+        // G29 Records Z, moves, and signals when it pauses
1582 1611
         lcd_wait_for_move = true;
1583 1612
         enqueue_and_echo_commands_P(PSTR("G29 V1"));
1584 1613
 
@@ -1628,13 +1657,14 @@ void kill_screen(const char* lcd_msg) {
1628 1657
     /**
1629 1658
      * Step 1: Bed Level entry-point
1630 1659
      *  - Cancel
1631
-     *  - Leveling On/Off (if there is leveling data)
1660
+     *  - Auto Home       (if homing needed)
1661
+     *  - Leveling On/Off (if data exists, and homed)
1632 1662
      *  - Level Bed >
1633
-     *  - Fade Height (Req: ENABLE_LEVELING_FADE_HEIGHT)
1634
-     *  - Mesh Z Offset (Req: MESH_BED_LEVELING)
1635
-     *  - Z Probe Offset (Req: HAS_BED_PROBE, Opt: BABYSTEP_ZPROBE_OFFSET)
1636
-     *  - Load Settings (Req: EEPROM_SETTINGS)
1637
-     *  - Save Settings (Req: EEPROM_SETTINGS)
1663
+     *  - Fade Height     (Req: ENABLE_LEVELING_FADE_HEIGHT)
1664
+     *  - Mesh Z Offset   (Req: MESH_BED_LEVELING)
1665
+     *  - Z Probe Offset  (Req: HAS_BED_PROBE, Opt: BABYSTEP_ZPROBE_OFFSET)
1666
+     *  - Load Settings   (Req: EEPROM_SETTINGS)
1667
+     *  - Save Settings   (Req: EEPROM_SETTINGS)
1638 1668
      */
1639 1669
     void lcd_bed_leveling() {
1640 1670
       START_MENU();

正在加载...
取消
保存