Browse Source

Patch up LCD Bed Leveling menu

Scott Lahteine 8 years ago
parent
commit
9677f3f2f5
2 changed files with 77 additions and 47 deletions
  1. 1
    1
      Marlin/Marlin_main.cpp
  2. 76
    46
      Marlin/ultralcd.cpp

+ 1
- 1
Marlin/Marlin_main.cpp View File

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

+ 76
- 46
Marlin/ultralcd.cpp View File

484
   static const char moving[] PROGMEM = MSG_MOVING;
484
   static const char moving[] PROGMEM = MSG_MOVING;
485
   static const char *sync_message = moving;
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
   void _lcd_synchronize() {
492
   void _lcd_synchronize() {
488
     static bool no_reentry = false;
493
     static bool no_reentry = false;
489
     if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
494
     if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
498
     lcd_goto_screen(old_screen);
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
   void lcd_synchronize(const char * const msg=NULL) {
508
   void lcd_synchronize(const char * const msg=NULL) {
502
     sync_message = msg ? msg : moving;
509
     sync_message = msg ? msg : moving;
503
     _lcd_synchronize();
510
     _lcd_synchronize();
1427
       #endif
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
     #if ENABLED(MESH_BED_LEVELING)
1457
     #if ENABLED(MESH_BED_LEVELING)
1431
 
1458
 
1432
       // Utility to go to the next mesh point
1459
       // Utility to go to the next mesh point
1445
         lcd_synchronize();
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() {
1477
+      bool lcd_wait_for_move;
1451
-      if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_DONE));
1478
+
1452
-      lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
1479
+      //
1453
-    }
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
     void _lcd_level_goto_next_point();
1492
     void _lcd_level_goto_next_point();
1456
 
1493
 
1462
 
1499
 
1463
       if (lcd_clicked) {
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
         #if ENABLED(MESH_BED_LEVELING)
1506
         #if ENABLED(MESH_BED_LEVELING)
1467
 
1507
 
1508
+          //
1468
           // MBL records the position but doesn't move to the next one
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]);
1510
+          //
1470
-
1471
-        #elif ENABLED(PROBE_MANUALLY)
1472
 
1511
 
1473
-          // The last G29 will record but not move
1512
+          mbl.set_zigzag_z(manual_probe_index, current_position[Z_AXIS]);
1474
-          if (manual_probe_index == total_probe_points - 1)
1475
-            enqueue_and_echo_commands_P(PSTR("G29 V1"));
1476
 
1513
 
1477
         #endif
1514
         #endif
1478
 
1515
 
1479
         // If done...
1516
         // If done...
1480
         if (++manual_probe_index >= total_probe_points) {
1517
         if (++manual_probe_index >= total_probe_points) {
1481
 
1518
 
1482
-          // Say "Done!"
1519
+          #if ENABLED(PROBE_MANUALLY)
1483
-          lcd_goto_screen(_lcd_level_bed_done);
1484
 
1520
 
1485
-          // Raise Z to the "manual probe height"
1521
+            //
1486
-          #if MANUAL_PROBE_HEIGHT > 0
1522
+            // The last G29 will record and enable but not move.
1487
-            current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT;
1523
+            // Since G29 is deferred, 
1488
-            line_to_current(Z_AXIS);
1524
+            //
1489
-          #endif
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)
1529
+          #elif ENABLED(MESH_BED_LEVELING)
1492
-            lcd_synchronize(PSTR(MSG_LEVEL_BED_DONE));
1493
-          #endif
1494
 
1530
 
1495
-          // Enable leveling, if needed
1531
+            _lcd_after_probing();
1496
-          #if ENABLED(MESH_BED_LEVELING)
1497
 
1532
 
1498
             mbl.set_has_mesh(true);
1533
             mbl.set_has_mesh(true);
1499
             mesh_probing_done();
1534
             mesh_probing_done();
1500
 
1535
 
1501
-          #elif ENABLED(PROBE_MANUALLY)
1502
-
1503
-            // ABL will be enabled due to "G29".
1504
-
1505
           #endif
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
           _lcd_level_goto_next_point();
1542
           _lcd_level_goto_next_point();
1543
+        }
1514
 
1544
 
1515
         return;
1545
         return;
1516
       }
1546
       }
1517
 
1547
 
1548
+      //
1518
       // Encoder knob or keypad buttons adjust the Z position
1549
       // Encoder knob or keypad buttons adjust the Z position
1550
+      //
1519
       if (encoderPosition) {
1551
       if (encoderPosition) {
1520
         refresh_cmd_timeout();
1552
         refresh_cmd_timeout();
1521
         current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
1553
         current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
1526
         encoderPosition = 0;
1558
         encoderPosition = 0;
1527
       }
1559
       }
1528
 
1560
 
1529
-      // Update on first display, then only on updates to Z position
1561
+      //
1530
-      // Show message above on clicks instead
1562
+      // Draw on first display, then only on Z change
1563
+      //
1531
       if (lcdDrawUpdate) {
1564
       if (lcdDrawUpdate) {
1532
         const float v = current_position[Z_AXIS];
1565
         const float v = current_position[Z_AXIS];
1533
         lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001 : 0.0001), '+'));
1566
         lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001 : 0.0001), '+'));
1538
      * Step 6: Display "Next point: 1 / 9" while waiting for move to finish
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
     void _lcd_level_bed_moving() {
1574
     void _lcd_level_bed_moving() {
1546
       if (lcdDrawUpdate) {
1575
       if (lcdDrawUpdate) {
1547
         char msg[10];
1576
         char msg[10];
1578
 
1607
 
1579
       #elif ENABLED(PROBE_MANUALLY)
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
         lcd_wait_for_move = true;
1611
         lcd_wait_for_move = true;
1583
         enqueue_and_echo_commands_P(PSTR("G29 V1"));
1612
         enqueue_and_echo_commands_P(PSTR("G29 V1"));
1584
 
1613
 
1628
     /**
1657
     /**
1629
      * Step 1: Bed Level entry-point
1658
      * Step 1: Bed Level entry-point
1630
      *  - Cancel
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
      *  - Level Bed >
1662
      *  - Level Bed >
1633
-     *  - Fade Height (Req: ENABLE_LEVELING_FADE_HEIGHT)
1663
+     *  - Fade Height     (Req: ENABLE_LEVELING_FADE_HEIGHT)
1634
-     *  - Mesh Z Offset (Req: MESH_BED_LEVELING)
1664
+     *  - Mesh Z Offset   (Req: MESH_BED_LEVELING)
1635
-     *  - Z Probe Offset (Req: HAS_BED_PROBE, Opt: BABYSTEP_ZPROBE_OFFSET)
1665
+     *  - Z Probe Offset  (Req: HAS_BED_PROBE, Opt: BABYSTEP_ZPROBE_OFFSET)
1636
-     *  - Load Settings (Req: EEPROM_SETTINGS)
1666
+     *  - Load Settings   (Req: EEPROM_SETTINGS)
1637
-     *  - Save Settings (Req: EEPROM_SETTINGS)
1667
+     *  - Save Settings   (Req: EEPROM_SETTINGS)
1638
      */
1668
      */
1639
     void lcd_bed_leveling() {
1669
     void lcd_bed_leveling() {
1640
       START_MENU();
1670
       START_MENU();

Loading…
Cancel
Save