♻️ Refactor Linear / Logical / Distinct Axes (#21953)
* More patches supporting EXTRUDERS 0 * Extend types in prep for more axes
This commit is contained in:
committed by
Scott Lahteine
parent
f5f999d7bf
commit
4194cdda5b
@ -48,7 +48,10 @@
|
||||
*/
|
||||
void GcodeSuite::G92() {
|
||||
|
||||
bool sync_E = false, sync_XYZE = false;
|
||||
#if HAS_EXTRUDERS
|
||||
bool sync_E = false;
|
||||
#endif
|
||||
bool sync_XYZE = false;
|
||||
|
||||
#if USE_GCODE_SUBCODES
|
||||
const uint8_t subcode_G92 = parser.subcode;
|
||||
@ -72,7 +75,11 @@ void GcodeSuite::G92() {
|
||||
case 9: // G92.9 - Set Current Position directly (like Marlin 1.0)
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
if (parser.seenval(axis_codes[i])) {
|
||||
if (i == E_AXIS) sync_E = true; else sync_XYZE = true;
|
||||
if (TERN1(HAS_EXTRUDERS, i != E_AXIS))
|
||||
sync_XYZE = true;
|
||||
else {
|
||||
TERN_(HAS_EXTRUDERS, sync_E = true);
|
||||
}
|
||||
current_position[i] = parser.value_axis_units((AxisEnum)i);
|
||||
}
|
||||
}
|
||||
@ -83,20 +90,26 @@ void GcodeSuite::G92() {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
if (parser.seenval(axis_codes[i])) {
|
||||
const float l = parser.value_axis_units((AxisEnum)i), // Given axis coordinate value, converted to millimeters
|
||||
v = i == E_AXIS ? l : LOGICAL_TO_NATIVE(l, i), // Axis position in NATIVE space (applying the existing offset)
|
||||
v = TERN0(HAS_EXTRUDERS, i == E_AXIS) ? l : LOGICAL_TO_NATIVE(l, i), // Axis position in NATIVE space (applying the existing offset)
|
||||
d = v - current_position[i]; // How much is the current axis position altered by?
|
||||
if (!NEAR_ZERO(d)) {
|
||||
#if HAS_POSITION_SHIFT && !IS_SCARA // When using workspaces...
|
||||
if (i == E_AXIS) {
|
||||
sync_E = true;
|
||||
current_position.e = v; // ...E is still set directly
|
||||
}
|
||||
else {
|
||||
position_shift[i] += d; // ...but other axes offset the workspace.
|
||||
if (TERN1(HAS_EXTRUDERS, i != E_AXIS)) {
|
||||
position_shift[i] += d; // ...most axes offset the workspace...
|
||||
update_workspace_offset((AxisEnum)i);
|
||||
}
|
||||
else {
|
||||
#if HAS_EXTRUDERS
|
||||
sync_E = true;
|
||||
current_position.e = v; // ...but E is set directly
|
||||
#endif
|
||||
}
|
||||
#else // Without workspaces...
|
||||
if (i == E_AXIS) sync_E = true; else sync_XYZE = true;
|
||||
if (TERN1(HAS_EXTRUDERS, i != E_AXIS))
|
||||
sync_XYZE = true;
|
||||
else {
|
||||
TERN_(HAS_EXTRUDERS, sync_E = true);
|
||||
}
|
||||
current_position[i] = v; // ...set Current Position directly (like Marlin 1.0)
|
||||
#endif
|
||||
}
|
||||
@ -111,8 +124,10 @@ void GcodeSuite::G92() {
|
||||
coordinate_system[active_coordinate_system] = position_shift;
|
||||
#endif
|
||||
|
||||
if (sync_XYZE) sync_plan_position();
|
||||
else if (sync_E) sync_plan_position_e();
|
||||
if (sync_XYZE) sync_plan_position();
|
||||
#if HAS_EXTRUDERS
|
||||
else if (sync_E) sync_plan_position_e();
|
||||
#endif
|
||||
|
||||
IF_DISABLED(DIRECT_STEPPING, report_current_position());
|
||||
}
|
||||
|
Reference in New Issue
Block a user