Adjust the move parameters to account for segmentation and/or part of the move having been done already
| 3094 | |
| 3095 | // Adjust the move parameters to account for segmentation and/or part of the move having been done already |
| 3096 | void GCodes::FinaliseMove(GCodeBuffer& gb, MovementState& ms) noexcept |
| 3097 | { |
| 3098 | ms.canPauseAfter = !ms.checkEndstops && !ms.doingArcMove; // pausing during an arc move isn't safe because the arc centre get recomputed incorrectly when we resume |
| 3099 | ms.filePos = gb.GetJobFilePosition(); |
| 3100 | gb.MotionCommanded(); |
| 3101 | |
| 3102 | if (ms.IsCurrentObjectCancelled()) |
| 3103 | { |
| 3104 | #if SUPPORT_LASER |
| 3105 | if (machineType == MachineType::laser) |
| 3106 | { |
| 3107 | platform.SetLaserPwm(0); |
| 3108 | } |
| 3109 | #endif |
| 3110 | } |
| 3111 | else |
| 3112 | { |
| 3113 | if (ms.totalSegments > 1) |
| 3114 | { |
| 3115 | ms.segMoveState = SegmentedMoveState::active; |
| 3116 | gb.SetState(GCodeState::waitingForSegmentedMoveToGo); |
| 3117 | |
| 3118 | for (size_t extruder = 0; extruder < numExtruders; ++extruder) |
| 3119 | { |
| 3120 | ms.coords[ExtruderToLogicalDrive(extruder)] /= ms.totalSegments; // change the extrusion to extrusion per segment |
| 3121 | } |
| 3122 | |
| 3123 | if (ms.moveFractionToSkip != 0.0) |
| 3124 | { |
| 3125 | const float fseg = floor(ms.totalSegments * ms.moveFractionToSkip); // round down to the start of a move |
| 3126 | ms.segmentsLeftToStartAt = ms.totalSegments - (unsigned int)fseg; |
| 3127 | ms.firstSegmentFractionToSkip = (ms.moveFractionToSkip * ms.totalSegments) - fseg; |
| 3128 | NewMoveAvailable(ms); |
| 3129 | return; |
| 3130 | } |
| 3131 | } |
| 3132 | else |
| 3133 | { |
| 3134 | ms.segMoveState = SegmentedMoveState::inactive; |
| 3135 | } |
| 3136 | |
| 3137 | ms.segmentsLeftToStartAt = ms.totalSegments; |
| 3138 | ms.firstSegmentFractionToSkip = ms.moveFractionToSkip; |
| 3139 | |
| 3140 | NewMoveAvailable(ms); |
| 3141 | } |
| 3142 | } |
| 3143 | |
| 3144 | // Set up a move to travel to the resume point. Return true if successful, false if needs to be called again. |
| 3145 | // This is only called if the first move commanded since changing from a cancelled object to a non-cancelled object or to no object involves extrusion. |
nothing calls this directly
no test coverage detected