Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/GCodes/GCodes3.cpp')
-rw-r--r--src/GCodes/GCodes3.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/GCodes/GCodes3.cpp b/src/GCodes/GCodes3.cpp
index 4fee02ae..9ab7291b 100644
--- a/src/GCodes/GCodes3.cpp
+++ b/src/GCodes/GCodes3.cpp
@@ -193,7 +193,7 @@ GCodeResult GCodes::OffsetAxes(GCodeBuffer& gb)
#if SUPPORT_WORKPLACE_COORDINATES
// Set workspace coordinates
-GCodeResult GCodes::GetSetWorkplaceCoordinates(GCodeBuffer& gb, const StringRef& reply)
+GCodeResult GCodes::GetSetWorkplaceCoordinates(GCodeBuffer& gb, const StringRef& reply, bool compute)
{
if (gb.Seen('P'))
{
@@ -205,11 +205,26 @@ GCodeResult GCodes::GetSetWorkplaceCoordinates(GCodeBuffer& gb, const StringRef&
{
if (gb.Seen(axisLetters[axis]))
{
- workplaceCoordinates[cs][axis] = gb.GetFValue() * distanceScale;
- seen = true;
+ const float coord = gb.GetFValue() * distanceScale;
+ if (!seen)
+ {
+ if (!LockMovementAndWaitForStandstill(gb)) // make sure the user coordinates are stable and up to date
+ {
+ return GCodeResult::notFinished;
+ }
+ seen = true;
+ }
+ workplaceCoordinates[cs][axis] = (compute)
+ ? coord - currentUserPosition[axis] + workplaceCoordinates[currentCoordinateSystem][axis]
+ : coord;
}
}
- if (!seen)
+
+ if (seen)
+ {
+ ToolOffsetInverseTransform(moveBuffer.coords, currentUserPosition); // update user coordinates in case we are using the workspace we just changed
+ }
+ else
{
reply.printf("Coordinates of workplace %" PRIu32 ":", cs);
for (size_t axis = 0; axis < numVisibleAxes; axis++)