Minor cleanup of multi-stepping logic
This commit is contained in:
parent
16da5c62d0
commit
6919e87656
@ -533,7 +533,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
|
|||||||
// Move XY to starting position, then Z
|
// Move XY to starting position, then Z
|
||||||
do_blocking_move_to_xy(resume_position[X_AXIS], resume_position[Y_AXIS], NOZZLE_PARK_XY_FEEDRATE);
|
do_blocking_move_to_xy(resume_position[X_AXIS], resume_position[Y_AXIS], NOZZLE_PARK_XY_FEEDRATE);
|
||||||
|
|
||||||
// Set Z_AXIS to saved position
|
// Move Z_AXIS to saved position
|
||||||
do_blocking_move_to_z(resume_position[Z_AXIS], NOZZLE_PARK_Z_FEEDRATE);
|
do_blocking_move_to_z(resume_position[Z_AXIS], NOZZLE_PARK_Z_FEEDRATE);
|
||||||
|
|
||||||
// Now all extrusion positions are resumed and ready to be confirmed
|
// Now all extrusion positions are resumed and ready to be confirmed
|
||||||
|
@ -267,16 +267,17 @@ class Stepper {
|
|||||||
// Set direction bits for all steppers
|
// Set direction bits for all steppers
|
||||||
static void set_directions();
|
static void set_directions();
|
||||||
|
|
||||||
|
// Limit the speed to 10KHz for AVR
|
||||||
|
#ifndef STEP_DOUBLER_FREQUENCY
|
||||||
|
#define STEP_DOUBLER_FREQUENCY 10000
|
||||||
|
#endif
|
||||||
|
|
||||||
FORCE_INLINE static uint32_t calc_timer_interval(uint32_t step_rate) {
|
FORCE_INLINE static uint32_t calc_timer_interval(uint32_t step_rate) {
|
||||||
uint32_t timer;
|
uint32_t timer;
|
||||||
|
|
||||||
NOMORE(step_rate, uint32_t(MAX_STEP_FREQUENCY));
|
NOMORE(step_rate, uint32_t(MAX_STEP_FREQUENCY));
|
||||||
|
|
||||||
// TODO: HAL: tidy this up, use Conditionals_post.h
|
#if DISABLED(DISABLE_MULTI_STEPPING)
|
||||||
#ifdef CPU_32_BIT
|
|
||||||
#if ENABLED(DISABLE_MULTI_STEPPING)
|
|
||||||
step_loops = 1;
|
|
||||||
#else
|
|
||||||
if (step_rate > STEP_DOUBLER_FREQUENCY * 2) { // If steprate > (STEP_DOUBLER_FREQUENCY * 2) kHz >> step 4 times
|
if (step_rate > STEP_DOUBLER_FREQUENCY * 2) { // If steprate > (STEP_DOUBLER_FREQUENCY * 2) kHz >> step 4 times
|
||||||
step_rate >>= 2;
|
step_rate >>= 2;
|
||||||
step_loops = 4;
|
step_loops = 4;
|
||||||
@ -285,23 +286,9 @@ class Stepper {
|
|||||||
step_rate >>= 1;
|
step_rate >>= 1;
|
||||||
step_loops = 2;
|
step_loops = 2;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
step_loops = 1;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
if (step_rate > 20000) { // If steprate > 20kHz >> step 4 times
|
|
||||||
step_rate >>= 2;
|
|
||||||
step_loops = 4;
|
|
||||||
}
|
|
||||||
else if (step_rate > 10000) { // If steprate > 10kHz >> step 2 times
|
|
||||||
step_rate >>= 1;
|
|
||||||
step_loops = 2;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
step_loops = 1;
|
step_loops = 1;
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CPU_32_BIT
|
#ifdef CPU_32_BIT
|
||||||
// In case of high-performance processor, it is able to calculate in real-time
|
// In case of high-performance processor, it is able to calculate in real-time
|
||||||
@ -309,8 +296,9 @@ class Stepper {
|
|||||||
timer = uint32_t(HAL_STEPPER_TIMER_RATE) / step_rate;
|
timer = uint32_t(HAL_STEPPER_TIMER_RATE) / step_rate;
|
||||||
NOLESS(timer, min_time_per_step); // (STEP_DOUBLER_FREQUENCY * 2 kHz - this should never happen)
|
NOLESS(timer, min_time_per_step); // (STEP_DOUBLER_FREQUENCY * 2 kHz - this should never happen)
|
||||||
#else
|
#else
|
||||||
NOLESS(step_rate, uint32_t(F_CPU / 500000U));
|
constexpr uint32_t min_step_rate = F_CPU / 500000U;
|
||||||
step_rate -= F_CPU / 500000; // Correct for minimal speed
|
NOLESS(step_rate, min_step_rate);
|
||||||
|
step_rate -= min_step_rate; // Correct for minimal speed
|
||||||
if (step_rate >= (8 * 256)) { // higher step rate
|
if (step_rate >= (8 * 256)) { // higher step rate
|
||||||
const uint8_t tmp_step_rate = (step_rate & 0x00FF);
|
const uint8_t tmp_step_rate = (step_rate & 0x00FF);
|
||||||
const uint16_t table_address = (uint16_t)&speed_lookuptable_fast[(uint8_t)(step_rate >> 8)][0],
|
const uint16_t table_address = (uint16_t)&speed_lookuptable_fast[(uint8_t)(step_rate >> 8)][0],
|
||||||
|
Loading…
Reference in New Issue
Block a user