Browse Source

Apply leveling for DELTA,

- Fix `prepare_move` function not calling `adjust_delta`
- Add more shorthand for plan_buffer_line.
- Fix wrong `federate` usage, assuming they are all mm/m
- Minor `stepper.cpp` cleanup
Scott Lahteine 10 years ago
parent
commit
d73b169de3
2 changed files with 571 additions and 513 deletions
  1. 501
    467
      Marlin/Marlin_main.cpp
  2. 70
    46
      Marlin/stepper.cpp

+ 501
- 467
Marlin/Marlin_main.cpp
File diff suppressed because it is too large
View File


+ 70
- 46
Marlin/stepper.cpp View File

507
     }
507
     }
508
 
508
 
509
     if (TEST(out_bits, Z_AXIS)) {   // -direction
509
     if (TEST(out_bits, Z_AXIS)) {   // -direction
510
+
510
       Z_APPLY_DIR(INVERT_Z_DIR,0);
511
       Z_APPLY_DIR(INVERT_Z_DIR,0);
511
       count_direction[Z_AXIS] = -1;
512
       count_direction[Z_AXIS] = -1;
512
-      if (check_endstops) 
513
-      {
514
-        #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
515
-          #ifndef Z_DUAL_ENDSTOPS
516
-            UPDATE_ENDSTOP(z, Z, min, MIN);
517
-          #else
518
-            bool z_min_endstop=(READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
519
-            #if defined(Z2_MIN_PIN) && Z2_MIN_PIN > -1
520
-              bool z2_min_endstop=(READ(Z2_MIN_PIN) != Z2_MIN_ENDSTOP_INVERTING);
521
-            #else
522
-              bool z2_min_endstop=z_min_endstop;
523
-            #endif
524
-            if(((z_min_endstop && old_z_min_endstop) || (z2_min_endstop && old_z2_min_endstop)) && (current_block->steps[Z_AXIS] > 0))
525
-            {
513
+
514
+      if (check_endstops) {
515
+
516
+        #if defined(Z_MIN_PIN) && Z_MIN_PIN >= 0
517
+
518
+          #ifdef Z_DUAL_ENDSTOPS
519
+
520
+            bool z_min_endstop = READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING,
521
+                z2_min_endstop =
522
+                  #if defined(Z2_MIN_PIN) && Z2_MIN_PIN >= 0
523
+                    READ(Z2_MIN_PIN) != Z2_MIN_ENDSTOP_INVERTING
524
+                  #else
525
+                    z_min_endstop
526
+                  #endif
527
+                ;
528
+
529
+            bool z_min_both = z_min_endstop && old_z_min_endstop,
530
+                z2_min_both = z2_min_endstop && old_z2_min_endstop;
531
+            if ((z_min_both || z2_min_both) && current_block->steps[Z_AXIS] > 0) {
526
               endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
532
               endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
527
-              endstop_z_hit=true;
528
-              if (!(performing_homing) || ((performing_homing)&&(z_min_endstop && old_z_min_endstop)&&(z2_min_endstop && old_z2_min_endstop))) //if not performing home or if both endstops were trigged during homing...
529
-              {
533
+              endstop_z_hit = true;
534
+              if (!performing_homing || (performing_homing && z_min_both && z2_min_both)) //if not performing home or if both endstops were trigged during homing...
530
                 step_events_completed = current_block->step_event_count;
535
                 step_events_completed = current_block->step_event_count;
531
-              } 
532
             }
536
             }
533
             old_z_min_endstop = z_min_endstop;
537
             old_z_min_endstop = z_min_endstop;
534
             old_z2_min_endstop = z2_min_endstop;
538
             old_z2_min_endstop = z2_min_endstop;
535
-          #endif
536
-        #endif
537
-      }
539
+
540
+          #else // !Z_DUAL_ENDSTOPS
541
+
542
+            UPDATE_ENDSTOP(z, Z, min, MIN);
543
+
544
+          #endif // !Z_DUAL_ENDSTOPS
545
+
546
+        #endif // Z_MIN_PIN
547
+
548
+      } // check_endstops
549
+
538
     }
550
     }
539
     else { // +direction
551
     else { // +direction
552
+
540
       Z_APPLY_DIR(!INVERT_Z_DIR,0);
553
       Z_APPLY_DIR(!INVERT_Z_DIR,0);
541
       count_direction[Z_AXIS] = 1;
554
       count_direction[Z_AXIS] = 1;
555
+
542
       if (check_endstops) {
556
       if (check_endstops) {
557
+
543
         #if defined(Z_MAX_PIN) && Z_MAX_PIN >= 0
558
         #if defined(Z_MAX_PIN) && Z_MAX_PIN >= 0
544
-          #ifndef Z_DUAL_ENDSTOPS
545
-            UPDATE_ENDSTOP(z, Z, max, MAX);
546
-          #else
547
-            bool z_max_endstop=(READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING);
548
-            #if defined(Z2_MAX_PIN) && Z2_MAX_PIN > -1
549
-              bool z2_max_endstop=(READ(Z2_MAX_PIN) != Z2_MAX_ENDSTOP_INVERTING);
550
-            #else
551
-              bool z2_max_endstop=z_max_endstop;
552
-            #endif
553
-            if(((z_max_endstop && old_z_max_endstop) || (z2_max_endstop && old_z2_max_endstop)) && (current_block->steps[Z_AXIS] > 0))
554
-            {
559
+
560
+          #ifdef Z_DUAL_ENDSTOPS
561
+
562
+            bool z_max_endstop = READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING,
563
+                z2_max_endstop =
564
+                  #if defined(Z2_MAX_PIN) && Z2_MAX_PIN >= 0
565
+                    READ(Z2_MAX_PIN) != Z2_MAX_ENDSTOP_INVERTING
566
+                  #else
567
+                    z_max_endstop
568
+                  #endif
569
+                ;
570
+
571
+            bool z_max_both = z_max_endstop && old_z_max_endstop,
572
+                z2_max_both = z2_max_endstop && old_z2_max_endstop;
573
+            if ((z_max_both || z2_max_both) && current_block->steps[Z_AXIS] > 0) {
555
               endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
574
               endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
556
-              endstop_z_hit=true;
575
+              endstop_z_hit = true;
557
 
576
 
558
-//              if (z_max_endstop && old_z_max_endstop) SERIAL_ECHOLN("z_max_endstop = true");
559
-//              if (z2_max_endstop && old_z2_max_endstop) SERIAL_ECHOLN("z2_max_endstop = true");
577
+             // if (z_max_both) SERIAL_ECHOLN("z_max_endstop = true");
578
+             // if (z2_max_both) SERIAL_ECHOLN("z2_max_endstop = true");
560
 
579
 
561
-            
562
-              if (!(performing_homing) || ((performing_homing)&&(z_max_endstop && old_z_max_endstop)&&(z2_max_endstop && old_z2_max_endstop))) //if not performing home or if both endstops were trigged during homing...
563
-              {
580
+              if (!performing_homing || (performing_homing && z_max_both && z2_max_both)) //if not performing home or if both endstops were trigged during homing...
564
                 step_events_completed = current_block->step_event_count;
581
                 step_events_completed = current_block->step_event_count;
565
-              } 
566
             }
582
             }
567
             old_z_max_endstop = z_max_endstop;
583
             old_z_max_endstop = z_max_endstop;
568
             old_z2_max_endstop = z2_max_endstop;
584
             old_z2_max_endstop = z2_max_endstop;
569
-          #endif
570
-        #endif
571
-      }
572
-    }
585
+
586
+          #else // !Z_DUAL_ENDSTOPS
587
+
588
+            UPDATE_ENDSTOP(z, Z, max, MAX);
589
+
590
+          #endif // !Z_DUAL_ENDSTOPS
591
+
592
+        #endif // Z_MAX_PIN
593
+
594
+      } // check_endstops
595
+
596
+    } // +direction
573
 
597
 
574
     #ifndef ADVANCE
598
     #ifndef ADVANCE
575
       if (TEST(out_bits, E_AXIS)) {  // -direction
599
       if (TEST(out_bits, E_AXIS)) {  // -direction
576
         REV_E_DIR();
600
         REV_E_DIR();
577
-        count_direction[E_AXIS]=-1;
601
+        count_direction[E_AXIS] = -1;
578
       }
602
       }
579
       else { // +direction
603
       else { // +direction
580
         NORM_E_DIR();
604
         NORM_E_DIR();
581
-        count_direction[E_AXIS]=1;
605
+        count_direction[E_AXIS] = 1;
582
       }
606
       }
583
     #endif //!ADVANCE
607
     #endif //!ADVANCE
584
 
608
 
585
     // Take multiple steps per interrupt (For high speed moves)
609
     // Take multiple steps per interrupt (For high speed moves)
586
-    for (int8_t i=0; i < step_loops; i++) {
610
+    for (int8_t i = 0; i < step_loops; i++) {
587
       #ifndef AT90USB
611
       #ifndef AT90USB
588
         MSerial.checkRx(); // Check for serial chars.
612
         MSerial.checkRx(); // Check for serial chars.
589
       #endif
613
       #endif

Loading…
Cancel
Save