Minor optimizations to planner code
- Prefetch values used more than once
This commit is contained in:
parent
13fbf42d95
commit
af14c684b5
|
@ -315,9 +315,8 @@ void planner_recalculate_trapezoids() {
|
||||||
// Recalculate if current block entry or exit junction speed has changed.
|
// Recalculate if current block entry or exit junction speed has changed.
|
||||||
if (current->recalculate_flag || next->recalculate_flag) {
|
if (current->recalculate_flag || next->recalculate_flag) {
|
||||||
// NOTE: Entry and exit factors always > 0 by all previous logic operations.
|
// NOTE: Entry and exit factors always > 0 by all previous logic operations.
|
||||||
calculate_trapezoid_for_block(current,
|
float nom = current->nominal_speed;
|
||||||
current->entry_speed / current->nominal_speed,
|
calculate_trapezoid_for_block(current, current->entry_speed / nom, next->entry_speed / nom);
|
||||||
next->entry_speed / current->nominal_speed);
|
|
||||||
current->recalculate_flag = false; // Reset current only to ensure next trapezoid is computed
|
current->recalculate_flag = false; // Reset current only to ensure next trapezoid is computed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -325,8 +324,8 @@ void planner_recalculate_trapezoids() {
|
||||||
}
|
}
|
||||||
// Last/newest block in buffer. Exit speed is set with MINIMUM_PLANNER_SPEED. Always recalculated.
|
// Last/newest block in buffer. Exit speed is set with MINIMUM_PLANNER_SPEED. Always recalculated.
|
||||||
if (next) {
|
if (next) {
|
||||||
calculate_trapezoid_for_block(next, next->entry_speed/next->nominal_speed,
|
float nom = next->nominal_speed;
|
||||||
MINIMUM_PLANNER_SPEED/next->nominal_speed);
|
calculate_trapezoid_for_block(next, next->entry_speed / nom, MINIMUM_PLANNER_SPEED / nom);
|
||||||
next->recalculate_flag = false;
|
next->recalculate_flag = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,11 +372,9 @@ void plan_init() {
|
||||||
uint8_t block_index = block_buffer_tail;
|
uint8_t block_index = block_buffer_tail;
|
||||||
|
|
||||||
while (block_index != block_buffer_head) {
|
while (block_index != block_buffer_head) {
|
||||||
if ((block_buffer[block_index].steps[X_AXIS] != 0) ||
|
block_t *block = &block_buffer[block_index];
|
||||||
(block_buffer[block_index].steps[Y_AXIS] != 0) ||
|
if (block->steps[X_AXIS] || block->steps[Y_AXIS] || block->steps[Z_AXIS]) {
|
||||||
(block_buffer[block_index].steps[Z_AXIS] != 0)) {
|
float se = (float)block->steps[E_AXIS] / block->step_event_count * block->nominal_speed; // mm/sec;
|
||||||
float se=(float(block_buffer[block_index].steps[E_AXIS])/float(block_buffer[block_index].step_event_count))*block_buffer[block_index].nominal_speed;
|
|
||||||
//se; mm/sec;
|
|
||||||
if (se > high) high = se;
|
if (se > high) high = se;
|
||||||
}
|
}
|
||||||
block_index = next_block_index(block_index);
|
block_index = next_block_index(block_index);
|
||||||
|
@ -399,14 +396,16 @@ void check_axes_activity() {
|
||||||
unsigned char tail_valve_pressure = ValvePressure,
|
unsigned char tail_valve_pressure = ValvePressure,
|
||||||
tail_e_to_p_pressure = EtoPPressure;
|
tail_e_to_p_pressure = EtoPPressure;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
block_t *block;
|
block_t *block;
|
||||||
|
|
||||||
if (blocks_queued()) {
|
if (blocks_queued()) {
|
||||||
uint8_t block_index = block_buffer_tail;
|
uint8_t block_index = block_buffer_tail;
|
||||||
tail_fan_speed = block_buffer[block_index].fan_speed;
|
tail_fan_speed = block_buffer[block_index].fan_speed;
|
||||||
#ifdef BARICUDA
|
#ifdef BARICUDA
|
||||||
tail_valve_pressure = block_buffer[block_index].valve_pressure;
|
block = &block_buffer[block_index];
|
||||||
tail_e_to_p_pressure = block_buffer[block_index].e_to_p_pressure;
|
tail_valve_pressure = block->valve_pressure;
|
||||||
|
tail_e_to_p_pressure = block->e_to_p_pressure;
|
||||||
#endif
|
#endif
|
||||||
while (block_index != block_buffer_head) {
|
while (block_index != block_buffer_head) {
|
||||||
block = &block_buffer[block_index];
|
block = &block_buffer[block_index];
|
||||||
|
|
Loading…
Reference in a new issue