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