|
@@ -1084,11 +1084,36 @@ void st_init() {
|
1084
|
1084
|
*/
|
1085
|
1085
|
void st_synchronize() { while (blocks_queued()) idle(); }
|
1086
|
1086
|
|
|
1087
|
+/**
|
|
1088
|
+ * Set the stepper positions directly in steps
|
|
1089
|
+ *
|
|
1090
|
+ * The input is based on the typical per-axis XYZ steps.
|
|
1091
|
+ * For CORE machines XYZ needs to be translated to ABC.
|
|
1092
|
+ *
|
|
1093
|
+ * This allows st_get_axis_position_mm to correctly
|
|
1094
|
+ * derive the current XYZ position later on.
|
|
1095
|
+ */
|
1087
|
1096
|
void st_set_position(const long& x, const long& y, const long& z, const long& e) {
|
1088
|
1097
|
CRITICAL_SECTION_START;
|
1089
|
|
- count_position[X_AXIS] = x;
|
1090
|
|
- count_position[Y_AXIS] = y;
|
1091
|
|
- count_position[Z_AXIS] = z;
|
|
1098
|
+
|
|
1099
|
+ #if ENABLED(COREXY)
|
|
1100
|
+ // corexy positioning
|
|
1101
|
+ // these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html
|
|
1102
|
+ count_position[A_AXIS] = x + y;
|
|
1103
|
+ count_position[B_AXIS] = x - y;
|
|
1104
|
+ count_position[Z_AXIS] = z;
|
|
1105
|
+ #elif ENABLED(COREXZ)
|
|
1106
|
+ // corexz planning
|
|
1107
|
+ count_position[A_AXIS] = x + z;
|
|
1108
|
+ count_position[Y_AXIS] = y;
|
|
1109
|
+ count_position[C_AXIS] = x - z;
|
|
1110
|
+ #else
|
|
1111
|
+ // default non-h-bot planning
|
|
1112
|
+ count_position[X_AXIS] = x;
|
|
1113
|
+ count_position[Y_AXIS] = y;
|
|
1114
|
+ count_position[Z_AXIS] = z;
|
|
1115
|
+ #endif
|
|
1116
|
+
|
1092
|
1117
|
count_position[E_AXIS] = e;
|
1093
|
1118
|
CRITICAL_SECTION_END;
|
1094
|
1119
|
}
|
|
@@ -1099,15 +1124,22 @@ void st_set_e_position(const long& e) {
|
1099
|
1124
|
CRITICAL_SECTION_END;
|
1100
|
1125
|
}
|
1101
|
1126
|
|
1102
|
|
-long st_get_position(uint8_t axis) {
|
|
1127
|
+/**
|
|
1128
|
+ * Get a stepper's position in steps.
|
|
1129
|
+ */
|
|
1130
|
+long st_get_position(AxisEnum axis) {
|
1103
|
1131
|
CRITICAL_SECTION_START;
|
1104
|
1132
|
long count_pos = count_position[axis];
|
1105
|
1133
|
CRITICAL_SECTION_END;
|
1106
|
1134
|
return count_pos;
|
1107
|
1135
|
}
|
1108
|
1136
|
|
|
1137
|
+/**
|
|
1138
|
+ * Get an axis position according to stepper position(s)
|
|
1139
|
+ * For CORE machines apply translation from ABC to XYZ.
|
|
1140
|
+ */
|
1109
|
1141
|
float st_get_axis_position_mm(AxisEnum axis) {
|
1110
|
|
- float axis_pos;
|
|
1142
|
+ float axis_steps;
|
1111
|
1143
|
#if ENABLED(COREXY) | ENABLED(COREXZ)
|
1112
|
1144
|
if (axis == X_AXIS || axis == CORE_AXIS_2) {
|
1113
|
1145
|
CRITICAL_SECTION_START;
|
|
@@ -1116,14 +1148,14 @@ float st_get_axis_position_mm(AxisEnum axis) {
|
1116
|
1148
|
CRITICAL_SECTION_END;
|
1117
|
1149
|
// ((a1+a2)+(a1-a2))/2 -> (a1+a2+a1-a2)/2 -> (a1+a1)/2 -> a1
|
1118
|
1150
|
// ((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;
|
|
1151
|
+ axis_steps = (pos1 + ((axis == X_AXIS) ? pos2 : -pos2)) / 2.0f;
|
1120
|
1152
|
}
|
1121
|
1153
|
else
|
1122
|
|
- axis_pos = st_get_position(axis);
|
|
1154
|
+ axis_steps = st_get_position(axis);
|
1123
|
1155
|
#else
|
1124
|
|
- axis_pos = st_get_position(axis);
|
|
1156
|
+ axis_steps = st_get_position(axis);
|
1125
|
1157
|
#endif
|
1126
|
|
- return axis_pos / axis_steps_per_unit[axis];
|
|
1158
|
+ return axis_steps / axis_steps_per_unit[axis];
|
1127
|
1159
|
}
|
1128
|
1160
|
|
1129
|
1161
|
void finishAndDisableSteppers() {
|