Move get_axis_position_mm to Planner (#10718)
This commit is contained in:
@ -1299,6 +1299,37 @@ void Planner::check_axes_activity() {
|
||||
|
||||
#endif // PLANNER_LEVELING
|
||||
|
||||
/**
|
||||
* Get an axis position according to stepper position(s)
|
||||
* For CORE machines apply translation from ABC to XYZ.
|
||||
*/
|
||||
float Planner::get_axis_position_mm(const AxisEnum axis) {
|
||||
float axis_steps;
|
||||
#if IS_CORE
|
||||
// Requesting one of the "core" axes?
|
||||
if (axis == CORE_AXIS_1 || axis == CORE_AXIS_2) {
|
||||
|
||||
// Protect the access to the position.
|
||||
const bool was_enabled = STEPPER_ISR_ENABLED();
|
||||
DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
|
||||
// ((a1+a2)+(a1-a2))/2 -> (a1+a2+a1-a2)/2 -> (a1+a1)/2 -> a1
|
||||
// ((a1+a2)-(a1-a2))/2 -> (a1+a2-a1+a2)/2 -> (a2+a2)/2 -> a2
|
||||
axis_steps = 0.5f * (
|
||||
axis == CORE_AXIS_2 ? CORESIGN(stepper.position(CORE_AXIS_1) - stepper.position(CORE_AXIS_2))
|
||||
: stepper.position(CORE_AXIS_1) + stepper.position(CORE_AXIS_2)
|
||||
);
|
||||
|
||||
if (was_enabled) ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
}
|
||||
else
|
||||
axis_steps = stepper.position(axis);
|
||||
#else
|
||||
axis_steps = stepper.position(axis);
|
||||
#endif
|
||||
return axis_steps * steps_to_mm[axis];
|
||||
}
|
||||
|
||||
/**
|
||||
* Block until all buffered steps are executed / cleaned
|
||||
*/
|
||||
|
Reference in New Issue
Block a user