|
|
|
@ -85,29 +85,29 @@ static volatile bool endstop_z_hit = false;
|
|
|
|
|
int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(X_MIN_PIN) && X_MIN_PIN >= 0
|
|
|
|
|
#if HAS_X_MIN
|
|
|
|
|
static bool old_x_min_endstop = false;
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(X_MAX_PIN) && X_MAX_PIN >= 0
|
|
|
|
|
#if HAS_X_MAX
|
|
|
|
|
static bool old_x_max_endstop = false;
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Y_MIN_PIN) && Y_MIN_PIN >= 0
|
|
|
|
|
#if HAS_Y_MIN
|
|
|
|
|
static bool old_y_min_endstop = false;
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Y_MAX_PIN) && Y_MAX_PIN >= 0
|
|
|
|
|
#if HAS_Y_MAX
|
|
|
|
|
static bool old_y_max_endstop = false;
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Z_MIN_PIN) && Z_MIN_PIN >= 0
|
|
|
|
|
#if HAS_Z_MIN
|
|
|
|
|
static bool old_z_min_endstop = false;
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Z_MAX_PIN) && Z_MAX_PIN >= 0
|
|
|
|
|
#if HAS_Z_MAX
|
|
|
|
|
static bool old_z_max_endstop = false;
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef Z_DUAL_ENDSTOPS
|
|
|
|
|
#if defined(Z2_MIN_PIN) && Z2_MIN_PIN >= 0
|
|
|
|
|
#if HAS_Z2_MIN
|
|
|
|
|
static bool old_z2_min_endstop = false;
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Z2_MAX_PIN) && Z2_MAX_PIN >= 0
|
|
|
|
|
#if HAS_Z2_MAX
|
|
|
|
|
static bool old_z2_max_endstop = false;
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
@ -472,7 +472,7 @@ ISR(TIMER1_COMPA_vect) {
|
|
|
|
|
if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
#if defined(X_MIN_PIN) && X_MIN_PIN >= 0
|
|
|
|
|
#if HAS_X_MIN
|
|
|
|
|
UPDATE_ENDSTOP(x, X, min, MIN);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@ -483,7 +483,7 @@ ISR(TIMER1_COMPA_vect) {
|
|
|
|
|
if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1))
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
#if defined(X_MAX_PIN) && X_MAX_PIN >= 0
|
|
|
|
|
#if HAS_X_MAX
|
|
|
|
|
UPDATE_ENDSTOP(x, X, max, MAX);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@ -498,12 +498,12 @@ ISR(TIMER1_COMPA_vect) {
|
|
|
|
|
if (TEST(out_bits, Y_AXIS)) // -direction
|
|
|
|
|
#endif
|
|
|
|
|
{ // -direction
|
|
|
|
|
#if defined(Y_MIN_PIN) && Y_MIN_PIN >= 0
|
|
|
|
|
#if HAS_Y_MIN
|
|
|
|
|
UPDATE_ENDSTOP(y, Y, min, MIN);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else { // +direction
|
|
|
|
|
#if defined(Y_MAX_PIN) && Y_MAX_PIN >= 0
|
|
|
|
|
#if HAS_Y_MAX
|
|
|
|
|
UPDATE_ENDSTOP(y, Y, max, MAX);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@ -519,13 +519,13 @@ ISR(TIMER1_COMPA_vect) {
|
|
|
|
|
|
|
|
|
|
if (check_endstops) {
|
|
|
|
|
|
|
|
|
|
#if defined(Z_MIN_PIN) && Z_MIN_PIN >= 0
|
|
|
|
|
#if HAS_Z_MIN
|
|
|
|
|
|
|
|
|
|
#ifdef Z_DUAL_ENDSTOPS
|
|
|
|
|
|
|
|
|
|
bool z_min_endstop = READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING,
|
|
|
|
|
z2_min_endstop =
|
|
|
|
|
#if defined(Z2_MIN_PIN) && Z2_MIN_PIN >= 0
|
|
|
|
|
#if HAS_Z2_MIN
|
|
|
|
|
READ(Z2_MIN_PIN) != Z2_MIN_ENDSTOP_INVERTING
|
|
|
|
|
#else
|
|
|
|
|
z_min_endstop
|
|
|
|
@ -561,13 +561,13 @@ ISR(TIMER1_COMPA_vect) {
|
|
|
|
|
|
|
|
|
|
if (check_endstops) {
|
|
|
|
|
|
|
|
|
|
#if defined(Z_MAX_PIN) && Z_MAX_PIN >= 0
|
|
|
|
|
#if HAS_Z_MAX
|
|
|
|
|
|
|
|
|
|
#ifdef Z_DUAL_ENDSTOPS
|
|
|
|
|
|
|
|
|
|
bool z_max_endstop = READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING,
|
|
|
|
|
z2_max_endstop =
|
|
|
|
|
#if defined(Z2_MAX_PIN) && Z2_MAX_PIN >= 0
|
|
|
|
|
#if HAS_Z2_MAX
|
|
|
|
|
READ(Z2_MAX_PIN) != Z2_MAX_ENDSTOP_INVERTING
|
|
|
|
|
#else
|
|
|
|
|
z_max_endstop
|
|
|
|
@ -835,127 +835,127 @@ void st_init() {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Initialize Dir Pins
|
|
|
|
|
#if defined(X_DIR_PIN) && X_DIR_PIN >= 0
|
|
|
|
|
#if HAS_X_DIR
|
|
|
|
|
X_DIR_INIT;
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(X2_DIR_PIN) && X2_DIR_PIN >= 0
|
|
|
|
|
#if HAS_X2_DIR
|
|
|
|
|
X2_DIR_INIT;
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Y_DIR_PIN) && Y_DIR_PIN >= 0
|
|
|
|
|
#if HAS_Y_DIR
|
|
|
|
|
Y_DIR_INIT;
|
|
|
|
|
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && Y2_DIR_PIN >= 0
|
|
|
|
|
#if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_DIR
|
|
|
|
|
Y2_DIR_INIT;
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Z_DIR_PIN) && Z_DIR_PIN >= 0
|
|
|
|
|
#if HAS_Z_DIR
|
|
|
|
|
Z_DIR_INIT;
|
|
|
|
|
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_DIR_PIN) && Z2_DIR_PIN >= 0
|
|
|
|
|
#if defined(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_DIR
|
|
|
|
|
Z2_DIR_INIT;
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(E0_DIR_PIN) && E0_DIR_PIN >= 0
|
|
|
|
|
#if HAS_E0_DIR
|
|
|
|
|
E0_DIR_INIT;
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(E1_DIR_PIN) && E1_DIR_PIN >= 0
|
|
|
|
|
#if HAS_E1_DIR
|
|
|
|
|
E1_DIR_INIT;
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(E2_DIR_PIN) && E2_DIR_PIN >= 0
|
|
|
|
|
#if HAS_E2_DIR
|
|
|
|
|
E2_DIR_INIT;
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(E3_DIR_PIN) && E3_DIR_PIN >= 0
|
|
|
|
|
#if HAS_E3_DIR
|
|
|
|
|
E3_DIR_INIT;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//Initialize Enable Pins - steppers default to disabled.
|
|
|
|
|
|
|
|
|
|
#if defined(X_ENABLE_PIN) && X_ENABLE_PIN >= 0
|
|
|
|
|
#if HAS_X_ENABLE
|
|
|
|
|
X_ENABLE_INIT;
|
|
|
|
|
if (!X_ENABLE_ON) X_ENABLE_WRITE(HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN >= 0
|
|
|
|
|
#if HAS_X2_ENABLE
|
|
|
|
|
X2_ENABLE_INIT;
|
|
|
|
|
if (!X_ENABLE_ON) X2_ENABLE_WRITE(HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN >= 0
|
|
|
|
|
#if HAS_Y_ENABLE
|
|
|
|
|
Y_ENABLE_INIT;
|
|
|
|
|
if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH);
|
|
|
|
|
|
|
|
|
|
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && Y2_ENABLE_PIN >= 0
|
|
|
|
|
#if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_ENABLE
|
|
|
|
|
Y2_ENABLE_INIT;
|
|
|
|
|
if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN >= 0
|
|
|
|
|
#if HAS_Z_ENABLE
|
|
|
|
|
Z_ENABLE_INIT;
|
|
|
|
|
if (!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH);
|
|
|
|
|
|
|
|
|
|
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_ENABLE_PIN) && Z2_ENABLE_PIN >= 0
|
|
|
|
|
#if defined(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_ENABLE
|
|
|
|
|
Z2_ENABLE_INIT;
|
|
|
|
|
if (!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(E0_ENABLE_PIN) && E0_ENABLE_PIN >= 0
|
|
|
|
|
#if HAS_E0_ENABLE
|
|
|
|
|
E0_ENABLE_INIT;
|
|
|
|
|
if (!E_ENABLE_ON) E0_ENABLE_WRITE(HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(E1_ENABLE_PIN) && E1_ENABLE_PIN >= 0
|
|
|
|
|
#if HAS_E1_ENABLE
|
|
|
|
|
E1_ENABLE_INIT;
|
|
|
|
|
if (!E_ENABLE_ON) E1_ENABLE_WRITE(HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(E2_ENABLE_PIN) && E2_ENABLE_PIN >= 0
|
|
|
|
|
#if HAS_E2_ENABLE
|
|
|
|
|
E2_ENABLE_INIT;
|
|
|
|
|
if (!E_ENABLE_ON) E2_ENABLE_WRITE(HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(E3_ENABLE_PIN) && E3_ENABLE_PIN >= 0
|
|
|
|
|
#if HAS_E3_ENABLE
|
|
|
|
|
E3_ENABLE_INIT;
|
|
|
|
|
if (!E_ENABLE_ON) E3_ENABLE_WRITE(HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//endstops and pullups
|
|
|
|
|
|
|
|
|
|
#if defined(X_MIN_PIN) && X_MIN_PIN >= 0
|
|
|
|
|
#if HAS_X_MIN
|
|
|
|
|
SET_INPUT(X_MIN_PIN);
|
|
|
|
|
#ifdef ENDSTOPPULLUP_XMIN
|
|
|
|
|
WRITE(X_MIN_PIN,HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(Y_MIN_PIN) && Y_MIN_PIN >= 0
|
|
|
|
|
#if HAS_Y_MIN
|
|
|
|
|
SET_INPUT(Y_MIN_PIN);
|
|
|
|
|
#ifdef ENDSTOPPULLUP_YMIN
|
|
|
|
|
WRITE(Y_MIN_PIN,HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(Z_MIN_PIN) && Z_MIN_PIN >= 0
|
|
|
|
|
#if HAS_Z_MIN
|
|
|
|
|
SET_INPUT(Z_MIN_PIN);
|
|
|
|
|
#ifdef ENDSTOPPULLUP_ZMIN
|
|
|
|
|
WRITE(Z_MIN_PIN,HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(X_MAX_PIN) && X_MAX_PIN >= 0
|
|
|
|
|
#if HAS_X_MAX
|
|
|
|
|
SET_INPUT(X_MAX_PIN);
|
|
|
|
|
#ifdef ENDSTOPPULLUP_XMAX
|
|
|
|
|
WRITE(X_MAX_PIN,HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(Y_MAX_PIN) && Y_MAX_PIN >= 0
|
|
|
|
|
#if HAS_Y_MAX
|
|
|
|
|
SET_INPUT(Y_MAX_PIN);
|
|
|
|
|
#ifdef ENDSTOPPULLUP_YMAX
|
|
|
|
|
WRITE(Y_MAX_PIN,HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(Z_MAX_PIN) && Z_MAX_PIN >= 0
|
|
|
|
|
#if HAS_Z_MAX
|
|
|
|
|
SET_INPUT(Z_MAX_PIN);
|
|
|
|
|
#ifdef ENDSTOPPULLUP_ZMAX
|
|
|
|
|
WRITE(Z_MAX_PIN,HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(Z2_MAX_PIN) && Z2_MAX_PIN >= 0
|
|
|
|
|
#if HAS_Z2_MAX
|
|
|
|
|
SET_INPUT(Z2_MAX_PIN);
|
|
|
|
|
#ifdef ENDSTOPPULLUP_ZMAX
|
|
|
|
|
WRITE(Z2_MAX_PIN,HIGH);
|
|
|
|
@ -970,36 +970,36 @@ void st_init() {
|
|
|
|
|
#define E_AXIS_INIT(NUM) AXIS_INIT(e## NUM, E## NUM, E)
|
|
|
|
|
|
|
|
|
|
// Initialize Step Pins
|
|
|
|
|
#if defined(X_STEP_PIN) && X_STEP_PIN >= 0
|
|
|
|
|
#if HAS_X_STEP
|
|
|
|
|
AXIS_INIT(x, X, X);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(X2_STEP_PIN) && X2_STEP_PIN >= 0
|
|
|
|
|
#if HAS_X2_STEP
|
|
|
|
|
AXIS_INIT(x, X2, X);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Y_STEP_PIN) && Y_STEP_PIN >= 0
|
|
|
|
|
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && Y2_STEP_PIN >= 0
|
|
|
|
|
#if HAS_Y_STEP
|
|
|
|
|
#if defined(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_STEP
|
|
|
|
|
Y2_STEP_INIT;
|
|
|
|
|
Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
|
|
|
|
|
#endif
|
|
|
|
|
AXIS_INIT(y, Y, Y);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(Z_STEP_PIN) && Z_STEP_PIN >= 0
|
|
|
|
|
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_STEP_PIN) && Z2_STEP_PIN >= 0
|
|
|
|
|
#if HAS_Z_STEP
|
|
|
|
|
#if defined(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_STEP
|
|
|
|
|
Z2_STEP_INIT;
|
|
|
|
|
Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
|
|
|
|
|
#endif
|
|
|
|
|
AXIS_INIT(z, Z, Z);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(E0_STEP_PIN) && E0_STEP_PIN >= 0
|
|
|
|
|
#if HAS_E0_STEP
|
|
|
|
|
E_AXIS_INIT(0);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(E1_STEP_PIN) && E1_STEP_PIN >= 0
|
|
|
|
|
#if HAS_E1_STEP
|
|
|
|
|
E_AXIS_INIT(1);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(E2_STEP_PIN) && E2_STEP_PIN >= 0
|
|
|
|
|
#if HAS_E2_STEP
|
|
|
|
|
E_AXIS_INIT(2);
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(E3_STEP_PIN) && E3_STEP_PIN >= 0
|
|
|
|
|
#if HAS_E3_STEP
|
|
|
|
|
E_AXIS_INIT(3);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -1220,12 +1220,12 @@ void digipot_current(uint8_t driver, int current) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void microstep_init() {
|
|
|
|
|
#if defined(E1_MS1_PIN) && E1_MS1_PIN >= 0
|
|
|
|
|
#if HAS_MICROSTEPS_E1
|
|
|
|
|
pinMode(E1_MS1_PIN,OUTPUT);
|
|
|
|
|
pinMode(E1_MS2_PIN,OUTPUT);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(X_MS1_PIN) && X_MS1_PIN >= 0
|
|
|
|
|
#if HAS_MICROSTEPS
|
|
|
|
|
pinMode(X_MS1_PIN,OUTPUT);
|
|
|
|
|
pinMode(X_MS2_PIN,OUTPUT);
|
|
|
|
|
pinMode(Y_MS1_PIN,OUTPUT);
|
|
|
|
@ -1246,7 +1246,7 @@ void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2) {
|
|
|
|
|
case 1: digitalWrite(Y_MS1_PIN, ms1); break;
|
|
|
|
|
case 2: digitalWrite(Z_MS1_PIN, ms1); break;
|
|
|
|
|
case 3: digitalWrite(E0_MS1_PIN, ms1); break;
|
|
|
|
|
#if defined(E1_MS1_PIN) && E1_MS1_PIN >= 0
|
|
|
|
|
#if HAS_MICROSTEPS_E1
|
|
|
|
|
case 4: digitalWrite(E1_MS1_PIN, ms1); break;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@ -1285,7 +1285,7 @@ void microstep_readings() {
|
|
|
|
|
SERIAL_PROTOCOLPGM("E0: ");
|
|
|
|
|
SERIAL_PROTOCOL(digitalRead(E0_MS1_PIN));
|
|
|
|
|
SERIAL_PROTOCOLLN(digitalRead(E0_MS2_PIN));
|
|
|
|
|
#if defined(E1_MS1_PIN) && E1_MS1_PIN >= 0
|
|
|
|
|
#if HAS_MICROSTEPS_E1
|
|
|
|
|
SERIAL_PROTOCOLPGM("E1: ");
|
|
|
|
|
SERIAL_PROTOCOL(digitalRead(E1_MS1_PIN));
|
|
|
|
|
SERIAL_PROTOCOLLN(digitalRead(E1_MS2_PIN));
|
|
|
|
|