Minor cleanup of multi-stepping logic

This commit is contained in:
Scott Lahteine 2018-05-28 17:39:23 -05:00
parent 16da5c62d0
commit 6919e87656
2 changed files with 14 additions and 26 deletions

View file

@ -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
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);
// Now all extrusion positions are resumed and ready to be confirmed

View file

@ -267,41 +267,28 @@ class Stepper {
// Set direction bits for all steppers
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) {
uint32_t timer;
NOMORE(step_rate, uint32_t(MAX_STEP_FREQUENCY));
// TODO: HAL: tidy this up, use Conditionals_post.h
#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
step_rate >>= 2;
step_loops = 4;
}
else if (step_rate > STEP_DOUBLER_FREQUENCY) { // If steprate > STEP_DOUBLER_FREQUENCY kHz >> step 2 times
step_rate >>= 1;
step_loops = 2;
}
else {
step_loops = 1;
}
#endif
#else
if (step_rate > 20000) { // If steprate > 20kHz >> step 4 times
#if DISABLED(DISABLE_MULTI_STEPPING)
if (step_rate > STEP_DOUBLER_FREQUENCY * 2) { // If steprate > (STEP_DOUBLER_FREQUENCY * 2) kHz >> step 4 times
step_rate >>= 2;
step_loops = 4;
}
else if (step_rate > 10000) { // If steprate > 10kHz >> step 2 times
else if (step_rate > STEP_DOUBLER_FREQUENCY) { // If steprate > STEP_DOUBLER_FREQUENCY kHz >> step 2 times
step_rate >>= 1;
step_loops = 2;
}
else {
step_loops = 1;
}
else
#endif
step_loops = 1;
#ifdef CPU_32_BIT
// 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;
NOLESS(timer, min_time_per_step); // (STEP_DOUBLER_FREQUENCY * 2 kHz - this should never happen)
#else
NOLESS(step_rate, uint32_t(F_CPU / 500000U));
step_rate -= F_CPU / 500000; // Correct for minimal speed
constexpr uint32_t min_step_rate = F_CPU / 500000U;
NOLESS(step_rate, min_step_rate);
step_rate -= min_step_rate; // Correct for minimal speed
if (step_rate >= (8 * 256)) { // higher step rate
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],