|
@@ -49,7 +49,7 @@ block_t *current_block; // A pointer to the block currently being traced
|
49
|
49
|
static unsigned char out_bits = 0; // The next stepping-bits to be output
|
50
|
50
|
static unsigned int cleaning_buffer_counter;
|
51
|
51
|
|
52
|
|
-#ifdef Z_DUAL_ENDSTOPS
|
|
52
|
+#if ENABLED(Z_DUAL_ENDSTOPS)
|
53
|
53
|
static bool performing_homing = false,
|
54
|
54
|
locked_z_motor = false,
|
55
|
55
|
locked_z2_motor = false;
|
|
@@ -59,7 +59,7 @@ static unsigned int cleaning_buffer_counter;
|
59
|
59
|
static long counter_x, counter_y, counter_z, counter_e;
|
60
|
60
|
volatile static unsigned long step_events_completed; // The number of step events executed in the current block
|
61
|
61
|
|
62
|
|
-#ifdef ADVANCE
|
|
62
|
+#if ENABLED(ADVANCE)
|
63
|
63
|
static long advance_rate, advance, final_advance = 0;
|
64
|
64
|
static long old_advance = 0;
|
65
|
65
|
static long e_steps[4];
|
|
@@ -76,18 +76,18 @@ volatile long endstops_trigsteps[3] = { 0 };
|
76
|
76
|
volatile long endstops_stepsTotal, endstops_stepsDone;
|
77
|
77
|
static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROBE as BIT value
|
78
|
78
|
|
79
|
|
-#ifndef Z_DUAL_ENDSTOPS
|
|
79
|
+#if DISABLED(Z_DUAL_ENDSTOPS)
|
80
|
80
|
static byte
|
81
|
81
|
#else
|
82
|
82
|
static uint16_t
|
83
|
83
|
#endif
|
84
|
84
|
old_endstop_bits = 0; // use X_MIN, X_MAX... Z_MAX, Z_PROBE, Z2_MIN, Z2_MAX
|
85
|
85
|
|
86
|
|
-#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
|
|
86
|
+#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
|
87
|
87
|
bool abort_on_endstop_hit = false;
|
88
|
88
|
#endif
|
89
|
89
|
|
90
|
|
-#ifdef MOTOR_CURRENT_PWM_XY_PIN
|
|
90
|
+#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
|
91
|
91
|
int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT;
|
92
|
92
|
#endif
|
93
|
93
|
|
|
@@ -101,7 +101,7 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
|
101
|
101
|
//================================ functions ================================
|
102
|
102
|
//===========================================================================
|
103
|
103
|
|
104
|
|
-#ifdef DUAL_X_CARRIAGE
|
|
104
|
+#if ENABLED(DUAL_X_CARRIAGE)
|
105
|
105
|
#define X_APPLY_DIR(v,ALWAYS) \
|
106
|
106
|
if (extruder_duplication_enabled || ALWAYS) { \
|
107
|
107
|
X_DIR_WRITE(v); \
|
|
@@ -123,7 +123,7 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
|
123
|
123
|
#define X_APPLY_STEP(v,Q) X_STEP_WRITE(v)
|
124
|
124
|
#endif
|
125
|
125
|
|
126
|
|
-#ifdef Y_DUAL_STEPPER_DRIVERS
|
|
126
|
+#if ENABLED(Y_DUAL_STEPPER_DRIVERS)
|
127
|
127
|
#define Y_APPLY_DIR(v,Q) { Y_DIR_WRITE(v); Y2_DIR_WRITE((v) != INVERT_Y2_VS_Y_DIR); }
|
128
|
128
|
#define Y_APPLY_STEP(v,Q) { Y_STEP_WRITE(v); Y2_STEP_WRITE(v); }
|
129
|
129
|
#else
|
|
@@ -131,9 +131,9 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
|
131
|
131
|
#define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v)
|
132
|
132
|
#endif
|
133
|
133
|
|
134
|
|
-#ifdef Z_DUAL_STEPPER_DRIVERS
|
|
134
|
+#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
|
135
|
135
|
#define Z_APPLY_DIR(v,Q) { Z_DIR_WRITE(v); Z2_DIR_WRITE(v); }
|
136
|
|
- #ifdef Z_DUAL_ENDSTOPS
|
|
136
|
+ #if ENABLED(Z_DUAL_ENDSTOPS)
|
137
|
137
|
#define Z_APPLY_STEP(v,Q) \
|
138
|
138
|
if (performing_homing) { \
|
139
|
139
|
if (Z_HOME_DIR > 0) {\
|
|
@@ -263,17 +263,17 @@ void checkHitEndstops() {
|
263
|
263
|
SERIAL_ECHOPAIR(" Z:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
|
264
|
264
|
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z");
|
265
|
265
|
}
|
266
|
|
- #ifdef Z_PROBE_ENDSTOP
|
267
|
|
- if (endstop_hit_bits & BIT(Z_PROBE)) {
|
268
|
|
- SERIAL_ECHOPAIR(" Z_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
|
269
|
|
- LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP");
|
270
|
|
- }
|
|
266
|
+ #if ENABLED(Z_PROBE_ENDSTOP)
|
|
267
|
+ if (endstop_hit_bits & BIT(Z_PROBE)) {
|
|
268
|
+ SERIAL_ECHOPAIR(" Z_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
|
|
269
|
+ LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP");
|
|
270
|
+ }
|
271
|
271
|
#endif
|
272
|
272
|
SERIAL_EOL;
|
273
|
273
|
|
274
|
274
|
endstops_hit_on_purpose();
|
275
|
275
|
|
276
|
|
- #if defined(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && defined(SDSUPPORT)
|
|
276
|
+ #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && ENABLED(SDSUPPORT)
|
277
|
277
|
if (abort_on_endstop_hit) {
|
278
|
278
|
card.sdprinting = false;
|
279
|
279
|
card.closefile();
|
|
@@ -556,7 +556,7 @@ void set_stepper_direction() {
|
556
|
556
|
count_direction[Z_AXIS] = 1;
|
557
|
557
|
}
|
558
|
558
|
|
559
|
|
- #ifndef ADVANCE
|
|
559
|
+ #if DISABLED(ADVANCE)
|
560
|
560
|
if (TEST(out_bits, E_AXIS)) {
|
561
|
561
|
REV_E_DIR();
|
562
|
562
|
count_direction[E_AXIS] = -1;
|
|
@@ -577,7 +577,7 @@ FORCE_INLINE void trapezoid_generator_reset() {
|
577
|
577
|
set_stepper_direction();
|
578
|
578
|
}
|
579
|
579
|
|
580
|
|
- #ifdef ADVANCE
|
|
580
|
+ #if ENABLED(ADVANCE)
|
581
|
581
|
advance = current_block->initial_advance;
|
582
|
582
|
final_advance = current_block->final_advance;
|
583
|
583
|
// Do E steps + advance steps
|
|
@@ -630,7 +630,7 @@ ISR(TIMER1_COMPA_vect) {
|
630
|
630
|
counter_y = counter_z = counter_e = counter_x;
|
631
|
631
|
step_events_completed = 0;
|
632
|
632
|
|
633
|
|
- #ifdef Z_LATE_ENABLE
|
|
633
|
+ #if ENABLED(Z_LATE_ENABLE)
|
634
|
634
|
if (current_block->steps[Z_AXIS] > 0) {
|
635
|
635
|
enable_z();
|
636
|
636
|
OCR1A = 2000; //1ms wait
|
|
@@ -638,7 +638,7 @@ ISR(TIMER1_COMPA_vect) {
|
638
|
638
|
}
|
639
|
639
|
#endif
|
640
|
640
|
|
641
|
|
- // #ifdef ADVANCE
|
|
641
|
+ // #if ENABLED(ADVANCE)
|
642
|
642
|
// e_steps[current_block->active_extruder] = 0;
|
643
|
643
|
// #endif
|
644
|
644
|
}
|
|
@@ -658,7 +658,7 @@ ISR(TIMER1_COMPA_vect) {
|
658
|
658
|
MSerial.checkRx(); // Check for serial chars.
|
659
|
659
|
#endif
|
660
|
660
|
|
661
|
|
- #ifdef ADVANCE
|
|
661
|
+ #if ENABLED(ADVANCE)
|
662
|
662
|
counter_e += current_block->steps[E_AXIS];
|
663
|
663
|
if (counter_e > 0) {
|
664
|
664
|
counter_e -= current_block->step_event_count;
|
|
@@ -677,7 +677,7 @@ ISR(TIMER1_COMPA_vect) {
|
677
|
677
|
STEP_ADD(x,X);
|
678
|
678
|
STEP_ADD(y,Y);
|
679
|
679
|
STEP_ADD(z,Z);
|
680
|
|
- #ifndef ADVANCE
|
|
680
|
+ #if DISABLED(ADVANCE)
|
681
|
681
|
STEP_ADD(e,E);
|
682
|
682
|
#endif
|
683
|
683
|
|
|
@@ -691,7 +691,7 @@ ISR(TIMER1_COMPA_vect) {
|
691
|
691
|
STEP_IF_COUNTER(x, X);
|
692
|
692
|
STEP_IF_COUNTER(y, Y);
|
693
|
693
|
STEP_IF_COUNTER(z, Z);
|
694
|
|
- #ifndef ADVANCE
|
|
694
|
+ #if DISABLED(ADVANCE)
|
695
|
695
|
STEP_IF_COUNTER(e, E);
|
696
|
696
|
#endif
|
697
|
697
|
|
|
@@ -714,7 +714,7 @@ ISR(TIMER1_COMPA_vect) {
|
714
|
714
|
timer = calc_timer(acc_step_rate);
|
715
|
715
|
OCR1A = timer;
|
716
|
716
|
acceleration_time += timer;
|
717
|
|
- #ifdef ADVANCE
|
|
717
|
+ #if ENABLED(ADVANCE)
|
718
|
718
|
for(int8_t i=0; i < step_loops; i++) {
|
719
|
719
|
advance += advance_rate;
|
720
|
720
|
}
|
|
@@ -743,7 +743,7 @@ ISR(TIMER1_COMPA_vect) {
|
743
|
743
|
timer = calc_timer(step_rate);
|
744
|
744
|
OCR1A = timer;
|
745
|
745
|
deceleration_time += timer;
|
746
|
|
- #ifdef ADVANCE
|
|
746
|
+ #if ENABLED(ADVANCE)
|
747
|
747
|
for(int8_t i=0; i < step_loops; i++) {
|
748
|
748
|
advance -= advance_rate;
|
749
|
749
|
}
|
|
@@ -767,7 +767,7 @@ ISR(TIMER1_COMPA_vect) {
|
767
|
767
|
}
|
768
|
768
|
}
|
769
|
769
|
|
770
|
|
-#ifdef ADVANCE
|
|
770
|
+#if ENABLED(ADVANCE)
|
771
|
771
|
unsigned char old_OCR0A;
|
772
|
772
|
// Timer interrupt for E. e_steps is set in the main routine;
|
773
|
773
|
// Timer 0 is shared with millies
|
|
@@ -845,11 +845,11 @@ void st_init() {
|
845
|
845
|
microstep_init(); //Initialize Microstepping Pins
|
846
|
846
|
|
847
|
847
|
// initialise TMC Steppers
|
848
|
|
- #ifdef HAVE_TMCDRIVER
|
|
848
|
+ #if ENABLED(HAVE_TMCDRIVER)
|
849
|
849
|
tmc_init();
|
850
|
850
|
#endif
|
851
|
851
|
// initialise L6470 Steppers
|
852
|
|
- #ifdef HAVE_L6470DRIVER
|
|
852
|
+ #if ENABLED(HAVE_L6470DRIVER)
|
853
|
853
|
L6470_init();
|
854
|
854
|
#endif
|
855
|
855
|
|
|
@@ -862,13 +862,13 @@ void st_init() {
|
862
|
862
|
#endif
|
863
|
863
|
#if HAS_Y_DIR
|
864
|
864
|
Y_DIR_INIT;
|
865
|
|
- #if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_DIR
|
|
865
|
+ #if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_DIR
|
866
|
866
|
Y2_DIR_INIT;
|
867
|
867
|
#endif
|
868
|
868
|
#endif
|
869
|
869
|
#if HAS_Z_DIR
|
870
|
870
|
Z_DIR_INIT;
|
871
|
|
- #if defined(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_DIR
|
|
871
|
+ #if ENABLED(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_DIR
|
872
|
872
|
Z2_DIR_INIT;
|
873
|
873
|
#endif
|
874
|
874
|
#endif
|
|
@@ -899,7 +899,7 @@ void st_init() {
|
899
|
899
|
Y_ENABLE_INIT;
|
900
|
900
|
if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH);
|
901
|
901
|
|
902
|
|
- #if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_ENABLE
|
|
902
|
+ #if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_ENABLE
|
903
|
903
|
Y2_ENABLE_INIT;
|
904
|
904
|
if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
|
905
|
905
|
#endif
|
|
@@ -908,7 +908,7 @@ void st_init() {
|
908
|
908
|
Z_ENABLE_INIT;
|
909
|
909
|
if (!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH);
|
910
|
910
|
|
911
|
|
- #if defined(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_ENABLE
|
|
911
|
+ #if ENABLED(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_ENABLE
|
912
|
912
|
Z2_ENABLE_INIT;
|
913
|
913
|
if (!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH);
|
914
|
914
|
#endif
|
|
@@ -934,56 +934,56 @@ void st_init() {
|
934
|
934
|
|
935
|
935
|
#if HAS_X_MIN
|
936
|
936
|
SET_INPUT(X_MIN_PIN);
|
937
|
|
- #ifdef ENDSTOPPULLUP_XMIN
|
|
937
|
+ #if ENABLED(ENDSTOPPULLUP_XMIN)
|
938
|
938
|
WRITE(X_MIN_PIN,HIGH);
|
939
|
939
|
#endif
|
940
|
940
|
#endif
|
941
|
941
|
|
942
|
942
|
#if HAS_Y_MIN
|
943
|
943
|
SET_INPUT(Y_MIN_PIN);
|
944
|
|
- #ifdef ENDSTOPPULLUP_YMIN
|
|
944
|
+ #if ENABLED(ENDSTOPPULLUP_YMIN)
|
945
|
945
|
WRITE(Y_MIN_PIN,HIGH);
|
946
|
946
|
#endif
|
947
|
947
|
#endif
|
948
|
948
|
|
949
|
949
|
#if HAS_Z_MIN
|
950
|
950
|
SET_INPUT(Z_MIN_PIN);
|
951
|
|
- #ifdef ENDSTOPPULLUP_ZMIN
|
|
951
|
+ #if ENABLED(ENDSTOPPULLUP_ZMIN)
|
952
|
952
|
WRITE(Z_MIN_PIN,HIGH);
|
953
|
953
|
#endif
|
954
|
954
|
#endif
|
955
|
955
|
|
956
|
956
|
#if HAS_X_MAX
|
957
|
957
|
SET_INPUT(X_MAX_PIN);
|
958
|
|
- #ifdef ENDSTOPPULLUP_XMAX
|
|
958
|
+ #if ENABLED(ENDSTOPPULLUP_XMAX)
|
959
|
959
|
WRITE(X_MAX_PIN,HIGH);
|
960
|
960
|
#endif
|
961
|
961
|
#endif
|
962
|
962
|
|
963
|
963
|
#if HAS_Y_MAX
|
964
|
964
|
SET_INPUT(Y_MAX_PIN);
|
965
|
|
- #ifdef ENDSTOPPULLUP_YMAX
|
|
965
|
+ #if ENABLED(ENDSTOPPULLUP_YMAX)
|
966
|
966
|
WRITE(Y_MAX_PIN,HIGH);
|
967
|
967
|
#endif
|
968
|
968
|
#endif
|
969
|
969
|
|
970
|
970
|
#if HAS_Z_MAX
|
971
|
971
|
SET_INPUT(Z_MAX_PIN);
|
972
|
|
- #ifdef ENDSTOPPULLUP_ZMAX
|
|
972
|
+ #if ENABLED(ENDSTOPPULLUP_ZMAX)
|
973
|
973
|
WRITE(Z_MAX_PIN,HIGH);
|
974
|
974
|
#endif
|
975
|
975
|
#endif
|
976
|
976
|
|
977
|
977
|
#if HAS_Z2_MAX
|
978
|
978
|
SET_INPUT(Z2_MAX_PIN);
|
979
|
|
- #ifdef ENDSTOPPULLUP_ZMAX
|
|
979
|
+ #if ENABLED(ENDSTOPPULLUP_ZMAX)
|
980
|
980
|
WRITE(Z2_MAX_PIN,HIGH);
|
981
|
981
|
#endif
|
982
|
982
|
#endif
|
983
|
983
|
|
984
|
|
- #if (defined(Z_PROBE_PIN) && Z_PROBE_PIN >= 0) && defined(Z_PROBE_ENDSTOP) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used.
|
|
984
|
+ #if HAS_Z_PROBE && ENABLED(Z_PROBE_ENDSTOP) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used.
|
985
|
985
|
SET_INPUT(Z_PROBE_PIN);
|
986
|
|
- #ifdef ENDSTOPPULLUP_ZPROBE
|
|
986
|
+ #if ENABLED(ENDSTOPPULLUP_ZPROBE)
|
987
|
987
|
WRITE(Z_PROBE_PIN,HIGH);
|
988
|
988
|
#endif
|
989
|
989
|
#endif
|
|
@@ -1007,14 +1007,14 @@ void st_init() {
|
1007
|
1007
|
AXIS_INIT(x, X2, X);
|
1008
|
1008
|
#endif
|
1009
|
1009
|
#if HAS_Y_STEP
|
1010
|
|
- #if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_STEP
|
|
1010
|
+ #if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_STEP
|
1011
|
1011
|
Y2_STEP_INIT;
|
1012
|
1012
|
Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
|
1013
|
1013
|
#endif
|
1014
|
1014
|
AXIS_INIT(y, Y, Y);
|
1015
|
1015
|
#endif
|
1016
|
1016
|
#if HAS_Z_STEP
|
1017
|
|
- #if defined(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_STEP
|
|
1017
|
+ #if ENABLED(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_STEP
|
1018
|
1018
|
Z2_STEP_INIT;
|
1019
|
1019
|
Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
|
1020
|
1020
|
#endif
|
|
@@ -1054,7 +1054,7 @@ void st_init() {
|
1054
|
1054
|
TCNT1 = 0;
|
1055
|
1055
|
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
1056
|
1056
|
|
1057
|
|
- #ifdef ADVANCE
|
|
1057
|
+ #if ENABLED(ADVANCE)
|
1058
|
1058
|
#if defined(TCCR0A) && defined(WGM01)
|
1059
|
1059
|
TCCR0A &= ~BIT(WGM01);
|
1060
|
1060
|
TCCR0A &= ~BIT(WGM00);
|
|
@@ -1113,7 +1113,7 @@ void quickStop() {
|
1113
|
1113
|
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
1114
|
1114
|
}
|
1115
|
1115
|
|
1116
|
|
-#ifdef BABYSTEPPING
|
|
1116
|
+#if ENABLED(BABYSTEPPING)
|
1117
|
1117
|
|
1118
|
1118
|
// MUST ONLY BE CALLED BY AN ISR,
|
1119
|
1119
|
// No other ISR should ever interrupt this!
|
|
@@ -1146,7 +1146,7 @@ void quickStop() {
|
1146
|
1146
|
|
1147
|
1147
|
case Z_AXIS: {
|
1148
|
1148
|
|
1149
|
|
- #ifndef DELTA
|
|
1149
|
+ #if DISABLED(DELTA)
|
1150
|
1150
|
|
1151
|
1151
|
BABYSTEP_AXIS(z, Z, BABYSTEP_INVERT_Z);
|
1152
|
1152
|
|
|
@@ -1272,7 +1272,7 @@ void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2) {
|
1272
|
1272
|
case 1: digitalWrite(Y_MS2_PIN, ms2); break;
|
1273
|
1273
|
case 2: digitalWrite(Z_MS2_PIN, ms2); break;
|
1274
|
1274
|
case 3: digitalWrite(E0_MS2_PIN, ms2); break;
|
1275
|
|
- #if defined(E1_MS2_PIN) && E1_MS2_PIN >= 0
|
|
1275
|
+ #if PIN_EXISTS(E1_MS2)
|
1276
|
1276
|
case 4: digitalWrite(E1_MS2_PIN, ms2); break;
|
1277
|
1277
|
#endif
|
1278
|
1278
|
}
|
|
@@ -1309,7 +1309,7 @@ void microstep_readings() {
|
1309
|
1309
|
#endif
|
1310
|
1310
|
}
|
1311
|
1311
|
|
1312
|
|
-#ifdef Z_DUAL_ENDSTOPS
|
|
1312
|
+#if ENABLED(Z_DUAL_ENDSTOPS)
|
1313
|
1313
|
void In_Homing_Process(bool state) { performing_homing = state; }
|
1314
|
1314
|
void Lock_z_motor(bool state) { locked_z_motor = state; }
|
1315
|
1315
|
void Lock_z2_motor(bool state) { locked_z2_motor = state; }
|