Fix Babystepping loop (again)
This commit is contained in:
@ -35,17 +35,17 @@
|
||||
|
||||
Babystep babystep;
|
||||
|
||||
volatile int16_t Babystep::steps[BS_TODO_AXIS(Z_AXIS) + 1];
|
||||
volatile int16_t Babystep::steps[BS_AXIS_IND(Z_AXIS) + 1];
|
||||
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
|
||||
int16_t Babystep::axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1];
|
||||
#endif
|
||||
int16_t Babystep::accum;
|
||||
|
||||
void Babystep::step_axis(const AxisEnum axis) {
|
||||
const int16_t curTodo = steps[BS_TODO_AXIS(axis)]; // get rid of volatile for performance
|
||||
const int16_t curTodo = steps[BS_AXIS_IND(axis)]; // get rid of volatile for performance
|
||||
if (curTodo) {
|
||||
stepper.do_babystep((AxisEnum)axis, curTodo > 0);
|
||||
if (curTodo > 0) steps[BS_TODO_AXIS(axis)]--; else steps[BS_TODO_AXIS(axis)]++;
|
||||
if (curTodo > 0) steps[BS_AXIS_IND(axis)]--; else steps[BS_AXIS_IND(axis)]++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
|
||||
#else
|
||||
BSA_ENABLE(Z_AXIS);
|
||||
#endif
|
||||
steps[BS_TODO_AXIS(axis)] += distance;
|
||||
steps[BS_AXIS_IND(axis)] += distance;
|
||||
#endif
|
||||
#if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
|
||||
gcode.reset_stepper_timeout();
|
||||
|
@ -32,9 +32,11 @@
|
||||
#endif
|
||||
|
||||
#if IS_CORE || EITHER(BABYSTEP_XY, I2C_POSITION_ENCODERS)
|
||||
#define BS_TODO_AXIS(A) A
|
||||
#define BS_AXIS_IND(A) A
|
||||
#define BS_AXIS(I) AxisEnum(I)
|
||||
#else
|
||||
#define BS_TODO_AXIS(A) 0
|
||||
#define BS_AXIS_IND(A) 0
|
||||
#define BS_AXIS(I) Z_AXIS
|
||||
#endif
|
||||
|
||||
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
|
||||
@ -47,7 +49,7 @@
|
||||
|
||||
class Babystep {
|
||||
public:
|
||||
static volatile int16_t steps[BS_TODO_AXIS(Z_AXIS) + 1];
|
||||
static volatile int16_t steps[BS_AXIS_IND(Z_AXIS) + 1];
|
||||
static int16_t accum; // Total babysteps in current edit
|
||||
|
||||
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
|
||||
@ -65,7 +67,7 @@ public:
|
||||
static void add_mm(const AxisEnum axis, const float &mm);
|
||||
|
||||
static inline bool has_steps() {
|
||||
return steps[BS_TODO_AXIS(X_AXIS)] || steps[BS_TODO_AXIS(Y_AXIS)] || steps[BS_TODO_AXIS(Z_AXIS)];
|
||||
return steps[BS_AXIS_IND(X_AXIS)] || steps[BS_AXIS_IND(Y_AXIS)] || steps[BS_AXIS_IND(Z_AXIS)];
|
||||
}
|
||||
|
||||
//
|
||||
@ -73,7 +75,7 @@ public:
|
||||
// apply accumulated babysteps to the axes.
|
||||
//
|
||||
static inline void task() {
|
||||
LOOP_LE_N(axis, BS_TODO_AXIS(Z_AXIS)) step_axis((AxisEnum)axis);
|
||||
LOOP_LE_N(i, BS_AXIS_IND(Z_AXIS)) step_axis(BS_AXIS(i));
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1097,7 +1097,7 @@
|
||||
|
||||
bool tmc_enable_stallguard(TMC2209Stepper &st) {
|
||||
const bool stealthchop_was_enabled = !st.en_spreadCycle();
|
||||
|
||||
|
||||
st.TCOOLTHRS(0xFFFFF);
|
||||
st.en_spreadCycle(false);
|
||||
return stealthchop_was_enabled;
|
||||
|
Reference in New Issue
Block a user