enumerate for axis endstop
This commit is contained in:
parent
ccbcbc5ab4
commit
3b13eb342f
13
dda.c
13
dda.c
|
|
@ -21,6 +21,7 @@
|
||||||
#include "sersendf.h"
|
#include "sersendf.h"
|
||||||
#include "pinio.h"
|
#include "pinio.h"
|
||||||
#include "memory_barrier.h"
|
#include "memory_barrier.h"
|
||||||
|
#include "home.h"
|
||||||
//#include "graycode.c"
|
//#include "graycode.c"
|
||||||
|
|
||||||
#ifdef DC_EXTRUDER
|
#ifdef DC_EXTRUDER
|
||||||
|
|
@ -767,7 +768,7 @@ void dda_clock() {
|
||||||
// endstop search, but as part of normal operations.
|
// endstop search, but as part of normal operations.
|
||||||
if (dda->endstop_check && ! move_state.endstop_stop) {
|
if (dda->endstop_check && ! move_state.endstop_stop) {
|
||||||
#ifdef X_MIN_PIN
|
#ifdef X_MIN_PIN
|
||||||
if (dda->endstop_check & 0x01) {
|
if (dda->endstop_check & X_MIN_ENDSTOP) {
|
||||||
if (x_min() == dda->endstop_stop_cond)
|
if (x_min() == dda->endstop_stop_cond)
|
||||||
move_state.debounce_count_x++;
|
move_state.debounce_count_x++;
|
||||||
else
|
else
|
||||||
|
|
@ -776,7 +777,7 @@ void dda_clock() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef X_MAX_PIN
|
#ifdef X_MAX_PIN
|
||||||
if (dda->endstop_check & 0x02) {
|
if (dda->endstop_check & X_MAX_ENDSTOP) {
|
||||||
if (x_max() == dda->endstop_stop_cond)
|
if (x_max() == dda->endstop_stop_cond)
|
||||||
move_state.debounce_count_x++;
|
move_state.debounce_count_x++;
|
||||||
else
|
else
|
||||||
|
|
@ -786,7 +787,7 @@ void dda_clock() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Y_MIN_PIN
|
#ifdef Y_MIN_PIN
|
||||||
if (dda->endstop_check & 0x04) {
|
if (dda->endstop_check & Y_MIN_ENDSTOP) {
|
||||||
if (y_min() == dda->endstop_stop_cond)
|
if (y_min() == dda->endstop_stop_cond)
|
||||||
move_state.debounce_count_y++;
|
move_state.debounce_count_y++;
|
||||||
else
|
else
|
||||||
|
|
@ -795,7 +796,7 @@ void dda_clock() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef Y_MAX_PIN
|
#ifdef Y_MAX_PIN
|
||||||
if (dda->endstop_check & 0x08) {
|
if (dda->endstop_check & Y_MAX_ENDSTOP) {
|
||||||
if (y_max() == dda->endstop_stop_cond)
|
if (y_max() == dda->endstop_stop_cond)
|
||||||
move_state.debounce_count_y++;
|
move_state.debounce_count_y++;
|
||||||
else
|
else
|
||||||
|
|
@ -805,7 +806,7 @@ void dda_clock() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Z_MIN_PIN
|
#ifdef Z_MIN_PIN
|
||||||
if (dda->endstop_check & 0x10) {
|
if (dda->endstop_check & Z_MIN_ENDSTOP) {
|
||||||
if (z_min() == dda->endstop_stop_cond)
|
if (z_min() == dda->endstop_stop_cond)
|
||||||
move_state.debounce_count_z++;
|
move_state.debounce_count_z++;
|
||||||
else
|
else
|
||||||
|
|
@ -814,7 +815,7 @@ void dda_clock() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef Z_MAX_PIN
|
#ifdef Z_MAX_PIN
|
||||||
if (dda->endstop_check & 0x20) {
|
if (dda->endstop_check & Z_MAX_ENDSTOP) {
|
||||||
if (z_max() == dda->endstop_stop_cond)
|
if (z_max() == dda->endstop_stop_cond)
|
||||||
move_state.debounce_count_z++;
|
move_state.debounce_count_z++;
|
||||||
else
|
else
|
||||||
|
|
|
||||||
26
home.c
26
home.c
|
|
@ -66,7 +66,7 @@ static const uint32_t PROGMEM search_feedrate_P[3] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t get_endstop_check(enum axis_e n, int8_t dir);
|
uint8_t get_endstop_check(enum axis_e n, int8_t dir);
|
||||||
void home_axis(enum axis_e n, int8_t dir);
|
void home_axis(enum axis_e n, int8_t dir, enum axis_endstop_e endstop_check);
|
||||||
void set_axis_home_position(enum axis_e n, int8_t dir);
|
void set_axis_home_position(enum axis_e n, int8_t dir);
|
||||||
|
|
||||||
/// home all 3 axes
|
/// home all 3 axes
|
||||||
|
|
@ -97,7 +97,7 @@ void home() {
|
||||||
/// find X MIN endstop
|
/// find X MIN endstop
|
||||||
void home_x_negative() {
|
void home_x_negative() {
|
||||||
#if defined X_MIN_PIN
|
#if defined X_MIN_PIN
|
||||||
home_axis(X, -1);
|
home_axis(X, -1, X_MIN_ENDSTOP);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,14 +107,14 @@ void home_x_positive() {
|
||||||
#warning X_MAX_PIN defined, but not X_MAX. home_x_positive() disabled.
|
#warning X_MAX_PIN defined, but not X_MAX. home_x_positive() disabled.
|
||||||
#endif
|
#endif
|
||||||
#if defined X_MAX_PIN && defined X_MAX
|
#if defined X_MAX_PIN && defined X_MAX
|
||||||
home_axis(X, 1);
|
home_axis(X, 1, X_MAX_ENDSTOP);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// fund Y MIN endstop
|
/// fund Y MIN endstop
|
||||||
void home_y_negative() {
|
void home_y_negative() {
|
||||||
#if defined Y_MIN_PIN
|
#if defined Y_MIN_PIN
|
||||||
home_axis(Y, -1);
|
home_axis(Y, -1, Y_MIN_ENDSTOP);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,14 +124,14 @@ void home_y_positive() {
|
||||||
#warning Y_MAX_PIN defined, but not Y_MAX. home_y_positive() disabled.
|
#warning Y_MAX_PIN defined, but not Y_MAX. home_y_positive() disabled.
|
||||||
#endif
|
#endif
|
||||||
#if defined Y_MAX_PIN && defined Y_MAX
|
#if defined Y_MAX_PIN && defined Y_MAX
|
||||||
home_axis(Y, 1);
|
home_axis(Y, 1, Y_MAX_ENDSTOP);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// find Z MIN endstop
|
/// find Z MIN endstop
|
||||||
void home_z_negative() {
|
void home_z_negative() {
|
||||||
#if defined Z_MIN_PIN
|
#if defined Z_MIN_PIN
|
||||||
home_axis(Z, -1);
|
home_axis(Z, -1, Z_MIN_ENDSTOP);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,23 +141,13 @@ void home_z_positive() {
|
||||||
#warning Z_MAX_PIN defined, but not Z_MAX. home_z_positive() disabled.
|
#warning Z_MAX_PIN defined, but not Z_MAX. home_z_positive() disabled.
|
||||||
#endif
|
#endif
|
||||||
#if defined Z_MAX_PIN && defined Z_MAX
|
#if defined Z_MAX_PIN && defined Z_MAX
|
||||||
home_axis(Z, 1);
|
home_axis(Z, 1, Z_MAX_ENDSTOP);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t get_endstop_check(enum axis_e n, int8_t dir) {
|
void home_axis(enum axis_e n, int8_t dir, enum axis_endstop_e endstop_check) {
|
||||||
uint8_t endstop_check;
|
|
||||||
if (dir < 0)
|
|
||||||
endstop_check = 1 << (n * 2);
|
|
||||||
else
|
|
||||||
endstop_check = 1 << (n * 2 + 1);
|
|
||||||
return endstop_check;
|
|
||||||
}
|
|
||||||
|
|
||||||
void home_axis(enum axis_e n, int8_t dir) {
|
|
||||||
TARGET t = startpoint;
|
TARGET t = startpoint;
|
||||||
startpoint.axis[n] = 0;
|
startpoint.axis[n] = 0;
|
||||||
uint8_t endstop_check = get_endstop_check(n, dir);
|
|
||||||
|
|
||||||
t.axis[n] = dir * MAX_DELTA_UM;
|
t.axis[n] = dir * MAX_DELTA_UM;
|
||||||
t.F = pgm_read_dword(&fast_feedrate_P[n]);
|
t.F = pgm_read_dword(&fast_feedrate_P[n]);
|
||||||
|
|
|
||||||
9
home.h
9
home.h
|
|
@ -3,6 +3,15 @@
|
||||||
|
|
||||||
void home(void);
|
void home(void);
|
||||||
|
|
||||||
|
enum axis_endstop_e {
|
||||||
|
X_MIN_ENDSTOP = 0x01,
|
||||||
|
X_MAX_ENDSTOP = 0x02,
|
||||||
|
Y_MIN_ENDSTOP = 0x04,
|
||||||
|
Y_MAX_ENDSTOP = 0x08,
|
||||||
|
Z_MIN_ENDSTOP = 0x10,
|
||||||
|
Z_MAX_ENDSTOP = 0x20,
|
||||||
|
};
|
||||||
|
|
||||||
void home_x_negative(void);
|
void home_x_negative(void);
|
||||||
void home_x_positive(void);
|
void home_x_positive(void);
|
||||||
void home_y_negative(void);
|
void home_y_negative(void);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue