Optimize `st_set_position()` for speed and size
flash: -186 SRAM: 0 time: x0.45
This commit is contained in:
parent
ef4efc22c3
commit
8149853fc9
|
|
@ -1330,7 +1330,7 @@ void plan_set_position(float x, float y, float z, const float &e)
|
|||
position_float[Z_AXIS] = z;
|
||||
position_float[E_AXIS] = e;
|
||||
#endif
|
||||
st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]);
|
||||
st_set_position(position);
|
||||
previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
|
||||
memset(previous_speed, 0, sizeof(previous_speed));
|
||||
}
|
||||
|
|
@ -1342,7 +1342,7 @@ void plan_set_z_position(const float &z)
|
|||
position_float[Z_AXIS] = z;
|
||||
#endif
|
||||
position[Z_AXIS] = lround(z*cs.axis_steps_per_unit[Z_AXIS]);
|
||||
st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]);
|
||||
st_set_position(position);
|
||||
}
|
||||
|
||||
void plan_set_e_position(const float &e)
|
||||
|
|
|
|||
|
|
@ -1313,18 +1313,15 @@ void st_synchronize()
|
|||
}
|
||||
}
|
||||
|
||||
void st_set_position(const long &x, const long &y, const long &z, const long &e)
|
||||
void st_set_position(const long *pos)
|
||||
{
|
||||
CRITICAL_SECTION_START;
|
||||
// Copy 4x4B.
|
||||
// This block locks the interrupts globally for 4.56 us,
|
||||
// which corresponds to a maximum repeat frequency of 219.18 kHz.
|
||||
// This block locks the interrupts globally for 2.06 us,
|
||||
// which corresponds to a maximum repeat frequency of ~484kHz.
|
||||
// This blocking is safe in the context of a 10kHz stepper driver interrupt
|
||||
// or a 115200 Bd serial line receive interrupt, which will not trigger faster than 12kHz.
|
||||
count_position[X_AXIS] = x;
|
||||
count_position[Y_AXIS] = y;
|
||||
count_position[Z_AXIS] = z;
|
||||
count_position[E_AXIS] = e;
|
||||
memcpy((uint8_t *)count_position, pos, sizeof(count_position));
|
||||
CRITICAL_SECTION_END;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ void isr();
|
|||
void st_synchronize();
|
||||
|
||||
// Set current position in steps
|
||||
void st_set_position(const long &x, const long &y, const long &z, const long &e);
|
||||
void st_set_position(const long *pos);
|
||||
void st_set_e_position(const long &e);
|
||||
|
||||
// Get current position in steps
|
||||
|
|
|
|||
Loading…
Reference in New Issue