|
@@ -1099,15 +1099,22 @@ void st_set_e_position(const long& e) {
|
1099
|
1099
|
CRITICAL_SECTION_END;
|
1100
|
1100
|
}
|
1101
|
1101
|
|
1102
|
|
-long st_get_position(uint8_t axis) {
|
|
1102
|
+/**
|
|
1103
|
+ * Get a stepper's position in steps.
|
|
1104
|
+ */
|
|
1105
|
+long st_get_position(AxisEnum axis) {
|
1103
|
1106
|
CRITICAL_SECTION_START;
|
1104
|
1107
|
long count_pos = count_position[axis];
|
1105
|
1108
|
CRITICAL_SECTION_END;
|
1106
|
1109
|
return count_pos;
|
1107
|
1110
|
}
|
1108
|
1111
|
|
|
1112
|
+/**
|
|
1113
|
+ * Get an axis position according to stepper position(s)
|
|
1114
|
+ * For CORE machines apply translation from ABC to XYZ.
|
|
1115
|
+ */
|
1109
|
1116
|
float st_get_axis_position_mm(AxisEnum axis) {
|
1110
|
|
- float axis_pos;
|
|
1117
|
+ float axis_steps;
|
1111
|
1118
|
#if ENABLED(COREXY) | ENABLED(COREXZ)
|
1112
|
1119
|
if (axis == X_AXIS || axis == CORE_AXIS_2) {
|
1113
|
1120
|
CRITICAL_SECTION_START;
|
|
@@ -1116,14 +1123,14 @@ float st_get_axis_position_mm(AxisEnum axis) {
|
1116
|
1123
|
CRITICAL_SECTION_END;
|
1117
|
1124
|
// ((a1+a2)+(a1-a2))/2 -> (a1+a2+a1-a2)/2 -> (a1+a1)/2 -> a1
|
1118
|
1125
|
// ((a1+a2)-(a1-a2))/2 -> (a1+a2-a1+a2)/2 -> (a2+a2)/2 -> a2
|
1119
|
|
- axis_pos = (pos1 + ((axis == X_AXIS) ? pos2 : -pos2)) / 2.0f;
|
|
1126
|
+ axis_steps = (pos1 + ((axis == X_AXIS) ? pos2 : -pos2)) / 2.0f;
|
1120
|
1127
|
}
|
1121
|
1128
|
else
|
1122
|
|
- axis_pos = st_get_position(axis);
|
|
1129
|
+ axis_steps = st_get_position(axis);
|
1123
|
1130
|
#else
|
1124
|
|
- axis_pos = st_get_position(axis);
|
|
1131
|
+ axis_steps = st_get_position(axis);
|
1125
|
1132
|
#endif
|
1126
|
|
- return axis_pos / axis_steps_per_unit[axis];
|
|
1133
|
+ return axis_steps / axis_steps_per_unit[axis];
|
1127
|
1134
|
}
|
1128
|
1135
|
|
1129
|
1136
|
void finishAndDisableSteppers() {
|