diff options
Diffstat (limited to 'src/GCodes/GCodes2.cpp')
-rw-r--r-- | src/GCodes/GCodes2.cpp | 96 |
1 files changed, 31 insertions, 65 deletions
diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp index d5dc4af4..ee50c201 100644 --- a/src/GCodes/GCodes2.cpp +++ b/src/GCodes/GCodes2.cpp @@ -267,12 +267,12 @@ bool GCodes::HandleGcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx break; case 20: // Inches (which century are we living in, here?) - gb.LatestMachineState().usingInches = true; + gb.UseInches(true); reprap.InputsUpdated(); break; case 21: // mm - gb.LatestMachineState().usingInches = false; + gb.UseInches(false); reprap.InputsUpdated(); break; @@ -515,9 +515,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx reply.copy("Pause the print before attempting to cancel it"); result = GCodeResult::error; } - else if ( !LockMovementAndWaitForStandstill(gb) // wait until everything has stopped - || !IsCodeQueueIdle() // must also wait until deferred command queue has caught up - ) + else if (!LockMovementAndWaitForStandstill(gb)) // wait until everything has stopped and deferred command queue has caught up { return false; } @@ -1464,9 +1462,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx case 109: // Deprecated in RRF, but widely generated by slicers { const bool movementWasLocked = gb.LatestMachineState().lockedResources.IsBitSet(MoveResource); - if ( !LockMovementAndWaitForStandstill(gb) // wait until movement has finished - || !IsCodeQueueIdle() // also wait until deferred command queue has caught up to avoid out-of-order execution - ) + if (!LockMovementAndWaitForStandstill(gb)) // wait until movement has finished and deferred command queue has caught up to avoid out-of-order execution { return false; } @@ -1677,9 +1673,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx break; case 116: // Wait for set temperatures - if ( !LockMovementAndWaitForStandstill(gb) // wait until movement has finished - || !IsCodeQueueIdle() // also wait until deferred command queue has caught up to avoid out-of-order execution - ) + if (!LockMovementAndWaitForStandstill(gb)) // wait until movement has finished and deferred command queue has caught up to avoid out-of-order execution { return false; } @@ -2021,9 +2015,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx case 190: // Set bed temperature and wait case 191: // Set chamber temperature and wait - if ( !LockMovementAndWaitForStandstill(gb) // wait until movement has finished - || !IsCodeQueueIdle() // also wait until deferred command queue has caught up to avoid out-of-order execution - ) + if (!LockMovementAndWaitForStandstill(gb)) // wait until movement has finished and deferred command queue has caught up to avoid out-of-order execution { return false; } @@ -2109,7 +2101,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx { if (gb.Seen(axisLetters[axis])) { - platform.SetAcceleration(axis, gb.GetDistance()); + platform.SetAcceleration(axis, gb.GetAcceleration()); seen = true; } } @@ -2122,7 +2114,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx gb.GetFloatArray(eVals, eCount, true); for (size_t e = 0; e < eCount; e++) { - platform.SetAcceleration(ExtruderToLogicalDrive(e), gb.ConvertDistance(eVals[e])); + platform.SetAcceleration(ExtruderToLogicalDrive(e), ConvertAcceleration(eVals[e])); } } @@ -2132,16 +2124,16 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx } else { - reply.printf("Accelerations (mm/sec^2): "); + reply.copy("Accelerations (mm/sec^2): "); for (size_t axis = 0; axis < numTotalAxes; ++axis) { - reply.catf("%c: %.1f, ", axisLetters[axis], (double)platform.Acceleration(axis)); + reply.catf("%c: %.1f, ", axisLetters[axis], (double)InverseConvertAcceleration(platform.Acceleration(axis))); } reply.cat("E:"); char sep = ' '; for (size_t extruder = 0; extruder < numExtruders; extruder++) { - reply.catf("%c%.1f", sep, (double)platform.Acceleration(ExtruderToLogicalDrive(extruder))); + reply.catf("%c%.1f", sep, (double)InverseConvertAcceleration(platform.Acceleration(ExtruderToLogicalDrive(extruder)))); sep = ':'; } } @@ -2152,14 +2144,13 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx { // Units are mm/sec if S1 is given, else mm/min const bool usingMmPerSec = (gb.Seen('S') && gb.GetIValue() == 1); - const float settingMultiplier = (usingMmPerSec) ? 1.0 : SecondsToMinutes; bool seen = false; // Do the minimum first, because we constrain the maximum rates to be no lower than it if (gb.Seen('I')) { seen = true; - platform.SetMinMovementSpeed(gb.GetDistance() * settingMultiplier); + platform.SetMinMovementSpeed(gb.GetSpeedFromMm(usingMmPerSec)); } for (size_t axis = 0; axis < numTotalAxes; ++axis) @@ -2167,7 +2158,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx if (gb.Seen(axisLetters[axis])) { seen = true; - platform.SetMaxFeedrate(axis, gb.GetDistance() * settingMultiplier); + platform.SetMaxFeedrate(axis, gb.GetSpeedFromMm(usingMmPerSec)); } } @@ -2179,7 +2170,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx gb.GetFloatArray(eVals, eCount, true); for (size_t e = 0; e < eCount; e++) { - platform.SetMaxFeedrate(ExtruderToLogicalDrive(e), gb.ConvertDistance(eVals[e]) * settingMultiplier); + platform.SetMaxFeedrate(ExtruderToLogicalDrive(e), ConvertSpeedFromMm(eVals[e], usingMmPerSec)); } } @@ -2189,20 +2180,19 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx } else { - const float reportingMultiplier = (usingMmPerSec) ? 1.0 : MinutesToSeconds; - reply.printf("Max speeds (mm/%s): ", (usingMmPerSec) ? "sec" : "min"); + reply.printf("Max speeds (%s)): ", (usingMmPerSec) ? "mm/sec" : "mm/min"); for (size_t axis = 0; axis < numTotalAxes; ++axis) { - reply.catf("%c: %.1f, ", axisLetters[axis], (double)(platform.MaxFeedrate(axis) * reportingMultiplier)); + reply.catf("%c: %.1f, ", axisLetters[axis], (double)InverseConvertSpeedToMm(platform.MaxFeedrate(axis), usingMmPerSec)); } reply.cat("E:"); char sep = ' '; for (size_t extruder = 0; extruder < numExtruders; extruder++) { - reply.catf("%c%.1f", sep, (double)(platform.MaxFeedrate(ExtruderToLogicalDrive(extruder)) * reportingMultiplier)); + reply.catf("%c%.1f", sep, (double)InverseConvertSpeedToMm(platform.MaxFeedrate(ExtruderToLogicalDrive(extruder)), usingMmPerSec)); sep = ':'; } - reply.catf(", min. speed %.2f", (double)(platform.MinMovementSpeed() * reportingMultiplier)); + reply.catf(", min. speed %.2f", (double)InverseConvertSpeedToMm(platform.MinMovementSpeed(), usingMmPerSec)); } } break; @@ -2287,7 +2277,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx if (!seen) { - reply.copy("Axis limit"); + reply.copy("Axis limits (mm)"); char sep = 's'; for (size_t axis = 0; axis < numTotalAxes; axis++) { @@ -2456,7 +2446,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx { // The pipeline is empty, so execute the babystepping move immediately SetMoveBufferDefaults(); - moveBuffer.feedRate = DefaultFeedRate; + moveBuffer.feedRate = ConvertSpeedFromMmPerMin(DefaultFeedRate); moveBuffer.tool = reprap.GetCurrentTool(); NewMoveAvailable(1); } @@ -3320,13 +3310,13 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx case 205: // Set/print maximum jerk speeds in mm/sec case 566: // Set/print maximum jerk speeds in mm/min { - const float multiplier1 = (code == 566) ? SecondsToMinutes : 1.0; + const bool useMmPerSec = (code == 205); bool seenAxis = false, seenExtruder = false; for (size_t axis = 0; axis < numTotalAxes; axis++) { if (gb.Seen(axisLetters[axis])) { - platform.SetInstantDv(axis, gb.GetDistance() * multiplier1); + platform.SetInstantDv(axis, gb.GetSpeedFromMm(useMmPerSec)); seenAxis = true; } } @@ -3339,7 +3329,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx gb.GetFloatArray(eVals, eCount, true); for (size_t e = 0; e < eCount; e++) { - platform.SetInstantDv(ExtruderToLogicalDrive(e), eVals[e] * multiplier1); + platform.SetInstantDv(ExtruderToLogicalDrive(e), ConvertSpeedFromMm(eVals[e], useMmPerSec)); } } @@ -3355,17 +3345,16 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx } else if (!seenExtruder) { - const float multiplier2 = (code == 566) ? MinutesToSeconds : 1.0; - reply.printf("Maximum jerk rates (mm/%s): ", (code == 566) ? "min" : "sec"); + reply.printf("Maximum jerk rates (%s): ", (useMmPerSec) ? "mm/sec" : "mm/min"); for (size_t axis = 0; axis < numTotalAxes; ++axis) { - reply.catf("%c: %.1f, ", axisLetters[axis], (double)(platform.GetInstantDv(axis) * multiplier2)); + reply.catf("%c: %.1f, ", axisLetters[axis], (double)InverseConvertSpeedToMm(platform.GetInstantDv(axis), useMmPerSec)); } reply.cat("E:"); char sep = ' '; for (size_t extruder = 0; extruder < numExtruders; extruder++) { - reply.catf("%c%.1f", sep, (double)(platform.GetInstantDv(ExtruderToLogicalDrive(extruder)) * multiplier2)); + reply.catf("%c%.1f", sep, (double)InverseConvertSpeedToMm(platform.GetInstantDv(ExtruderToLogicalDrive(extruder)), useMmPerSec)); sep = ':'; } if (code == 566) @@ -3459,25 +3448,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx break; case 572: // Set/report pressure advance - if (gb.Seen('S')) - { - const float advance = gb.GetFValue(); - if (!LockMovementAndWaitForStandstill(gb)) - { - return false; - } - result = platform.SetPressureAdvance(advance, gb, reply); - } - else - { - reply.copy("Extruder pressure advance"); - char c = ':'; - for (size_t i = 0; i < numExtruders; ++i) - { - reply.catf("%c %.3f", c, (double)platform.GetPressureAdvance(i)); - c = ','; - } - } + result = reprap.GetMove().ConfigurePressureAdvance(gb, reply); break; case 573: // Report heater average PWM @@ -3735,11 +3706,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx #endif case 593: // Configure dynamic ringing cancellation - if (!LockMovementAndWaitForStandstill(gb)) - { - return false; - } - result = reprap.GetMove().GetShaper().Configure(gb, reply); + result = reprap.GetMove().GetAxisShaper().Configure(gb, reply); break; #if SUPPORT_ASYNC_MOVES @@ -4022,8 +3989,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx // Get the feedrate (if any) and kick off a new move if (gb.Seen(feedrateLetter)) { - const float rate = gb.ConvertDistance(gb.GetFValue()); - gb.LatestMachineState().feedRate = rate * SecondsToMinutes; // don't apply the speed factor + gb.LatestMachineState().feedRate = gb.GetSpeed(); // don't apply the speed factor } moveBuffer.feedRate = gb.LatestMachineState().feedRate; moveBuffer.usingStandardFeedrate = true; @@ -4660,7 +4626,7 @@ bool GCodes::HandleTcode(GCodeBuffer& gb, const StringRef& reply) } else if (gb.Seen('T')) { - // We handle "T{expression}" as if it's "T "{expression}, also DSF may pass a T{expression} command in this way + // We handle "T T{expression}" as if it's "T "{expression}, also DSF may pass a T{expression} command in this way seen = true; toolNum = gb.GetIValue(); } @@ -4682,7 +4648,7 @@ bool GCodes::HandleTcode(GCodeBuffer& gb, const StringRef& reply) if (seen) { - if (!LockMovementAndWaitForStandstill(gb) || !IsCodeQueueIdle()) + if (!LockMovementAndWaitForStandstill(gb)) { return false; } |