Ver código fonte

Merge branch 'Marlin_v1' into typofixes_1

Cylindric 11 anos atrás
pai
commit
08263ae66e
1 arquivos alterados com 32 adições e 63 exclusões
  1. 32
    63
      Marlin/Marlin_main.cpp

+ 32
- 63
Marlin/Marlin_main.cpp Ver arquivo

978
     #endif
978
     #endif
979
 }
979
 }
980
 
980
 
981
+/// Probe bed height at position (x,y), returns the measured z value
982
+static float probe_pt(float x, float y, float z_before) {
983
+  // move to right place
984
+  do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before);
985
+  do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
986
+
987
+  engage_z_probe();   // Engage Z Servo endstop if available
988
+  run_z_probe();
989
+  float measured_z = current_position[Z_AXIS];
990
+  retract_z_probe();
991
+
992
+  SERIAL_PROTOCOLPGM(MSG_BED);
993
+  SERIAL_PROTOCOLPGM(" x: ");
994
+  SERIAL_PROTOCOL(x);
995
+  SERIAL_PROTOCOLPGM(" y: ");
996
+  SERIAL_PROTOCOL(y);
997
+  SERIAL_PROTOCOLPGM(" z: ");
998
+  SERIAL_PROTOCOL(measured_z);
999
+  SERIAL_PROTOCOLPGM("\n");
1000
+  return measured_z;
1001
+}
1002
+
981
 #endif // #ifdef ENABLE_AUTO_BED_LEVELING
1003
 #endif // #ifdef ENABLE_AUTO_BED_LEVELING
982
 
1004
 
983
 static void homeaxis(int axis) {
1005
 static void homeaxis(int axis) {
1415
 
1437
 
1416
               for (int xCount=0; xCount < ACCURATE_BED_LEVELING_POINTS; xCount++)
1438
               for (int xCount=0; xCount < ACCURATE_BED_LEVELING_POINTS; xCount++)
1417
               {
1439
               {
1440
+                float z_before;
1418
                 if (probePointCounter == 0)
1441
                 if (probePointCounter == 0)
1419
                 {
1442
                 {
1420
                   // raise before probing
1443
                   // raise before probing
1421
-                  do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_RAISE_BEFORE_PROBING);
1444
+                  z_before = Z_RAISE_BEFORE_PROBING;
1422
                 } else
1445
                 } else
1423
                 {
1446
                 {
1424
                   // raise extruder
1447
                   // raise extruder
1425
-                  do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
1448
+                  z_before = current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS;
1426
                 }
1449
                 }
1427
 
1450
 
1451
+                float measured_z = probe_pt(xProbe, yProbe, z_before);
1428
 
1452
 
1429
-                do_blocking_move_to(xProbe - X_PROBE_OFFSET_FROM_EXTRUDER, yProbe - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
1430
-
1431
-                engage_z_probe();   // Engage Z Servo endstop if available
1432
-                run_z_probe();
1433
-                eqnBVector[probePointCounter] = current_position[Z_AXIS];
1434
-                retract_z_probe();
1435
-
1436
-                SERIAL_PROTOCOLPGM("Bed x: ");
1437
-                SERIAL_PROTOCOL(xProbe);
1438
-                SERIAL_PROTOCOLPGM(" y: ");
1439
-                SERIAL_PROTOCOL(yProbe);
1440
-                SERIAL_PROTOCOLPGM(" z: ");
1441
-                SERIAL_PROTOCOL(current_position[Z_AXIS]);
1442
-                SERIAL_PROTOCOLPGM("\n");
1453
+                eqnBVector[probePointCounter] = measured_z;
1443
 
1454
 
1444
                 eqnAMatrix[probePointCounter + 0*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = xProbe;
1455
                 eqnAMatrix[probePointCounter + 0*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = xProbe;
1445
                 eqnAMatrix[probePointCounter + 1*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = yProbe;
1456
                 eqnAMatrix[probePointCounter + 1*ACCURATE_BED_LEVELING_POINTS*ACCURATE_BED_LEVELING_POINTS] = yProbe;
1469
 
1480
 
1470
 
1481
 
1471
             // prob 1
1482
             // prob 1
1472
-            do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_RAISE_BEFORE_PROBING);
1473
-            do_blocking_move_to(LEFT_PROBE_BED_POSITION - X_PROBE_OFFSET_FROM_EXTRUDER, BACK_PROBE_BED_POSITION - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
1474
-
1475
-            engage_z_probe();   // Engage Z Servo endstop if available
1476
-            run_z_probe();
1477
-            float z_at_xLeft_yBack = current_position[Z_AXIS];
1478
-            retract_z_probe();
1479
-
1480
-            SERIAL_PROTOCOLPGM("Bed x: ");
1481
-            SERIAL_PROTOCOL(LEFT_PROBE_BED_POSITION);
1482
-            SERIAL_PROTOCOLPGM(" y: ");
1483
-            SERIAL_PROTOCOL(BACK_PROBE_BED_POSITION);
1484
-            SERIAL_PROTOCOLPGM(" z: ");
1485
-            SERIAL_PROTOCOL(current_position[Z_AXIS]);
1486
-            SERIAL_PROTOCOLPGM("\n");
1483
+            float z_at_xLeft_yBack = probe_pt(LEFT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, Z_RAISE_BEFORE_PROBING);
1487
 
1484
 
1488
             // prob 2
1485
             // prob 2
1489
-            do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
1490
-            do_blocking_move_to(LEFT_PROBE_BED_POSITION - X_PROBE_OFFSET_FROM_EXTRUDER, FRONT_PROBE_BED_POSITION - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
1491
-
1492
-            engage_z_probe();   // Engage Z Servo endstop if available
1493
-            run_z_probe();
1494
-            float z_at_xLeft_yFront = current_position[Z_AXIS];
1495
-            retract_z_probe();
1496
-
1497
-            SERIAL_PROTOCOLPGM("Bed x: ");
1498
-            SERIAL_PROTOCOL(LEFT_PROBE_BED_POSITION);
1499
-            SERIAL_PROTOCOLPGM(" y: ");
1500
-            SERIAL_PROTOCOL(FRONT_PROBE_BED_POSITION);
1501
-            SERIAL_PROTOCOLPGM(" z: ");
1502
-            SERIAL_PROTOCOL(current_position[Z_AXIS]);
1503
-            SERIAL_PROTOCOLPGM("\n");
1486
+            float z_at_xLeft_yFront = probe_pt(LEFT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
1504
 
1487
 
1505
             // prob 3
1488
             // prob 3
1506
-            do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
1507
-            // the current position will be updated by the blocking move so the head will not lower on this next call.
1508
-            do_blocking_move_to(RIGHT_PROBE_BED_POSITION - X_PROBE_OFFSET_FROM_EXTRUDER, FRONT_PROBE_BED_POSITION - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
1509
-
1510
-            engage_z_probe();   // Engage Z Servo endstop if available
1511
-            run_z_probe();
1512
-            float z_at_xRight_yFront = current_position[Z_AXIS];
1513
-            retract_z_probe(); // Retract Z Servo endstop if available
1514
-
1515
-            SERIAL_PROTOCOLPGM("Bed x: ");
1516
-            SERIAL_PROTOCOL(RIGHT_PROBE_BED_POSITION);
1517
-            SERIAL_PROTOCOLPGM(" y: ");
1518
-            SERIAL_PROTOCOL(FRONT_PROBE_BED_POSITION);
1519
-            SERIAL_PROTOCOLPGM(" z: ");
1520
-            SERIAL_PROTOCOL(current_position[Z_AXIS]);
1521
-            SERIAL_PROTOCOLPGM("\n");
1489
+            float z_at_xRight_yFront = probe_pt(RIGHT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
1522
 
1490
 
1523
             clean_up_after_endstop_move();
1491
             clean_up_after_endstop_move();
1524
 
1492
 
1553
             feedrate = homing_feedrate[Z_AXIS];
1521
             feedrate = homing_feedrate[Z_AXIS];
1554
 
1522
 
1555
             run_z_probe();
1523
             run_z_probe();
1556
-            SERIAL_PROTOCOLPGM("Bed Position X: ");
1524
+            SERIAL_PROTOCOLPGM(MSG_BED);
1525
+            SERIAL_PROTOCOLPGM(" X: ");
1557
             SERIAL_PROTOCOL(current_position[X_AXIS]);
1526
             SERIAL_PROTOCOL(current_position[X_AXIS]);
1558
             SERIAL_PROTOCOLPGM(" Y: ");
1527
             SERIAL_PROTOCOLPGM(" Y: ");
1559
             SERIAL_PROTOCOL(current_position[Y_AXIS]);
1528
             SERIAL_PROTOCOL(current_position[Y_AXIS]);

Carregando…
Cancelar
Salvar