diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-08-16 19:08:33 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-08-16 19:08:33 +0300 |
commit | 9973e73a060a3ee0395367d57e9a0c4ab3609b99 (patch) | |
tree | 423769247a5d9a68fee992bf11d826804c5736a3 /src/GCodes/GCodes2.cpp | |
parent | 89b36727435359069a884f3f8ca0893a1791393f (diff) |
Fixed issues caused by failed merge
Diffstat (limited to 'src/GCodes/GCodes2.cpp')
-rw-r--r-- | src/GCodes/GCodes2.cpp | 113 |
1 files changed, 36 insertions, 77 deletions
diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp index 4c54c1c1..5a2771db 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; } @@ -1472,9 +1470,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; } @@ -1680,14 +1676,16 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx reply.catf(" + %s", additionalExpansionName); } #endif +#ifdef DUET3_ATE + reply.lcatf("ATE firmware version %s date %s %s", Duet3Ate::GetFirmwareVersionString(), Duet3Ate::GetFirmwareDateString(), Duet3Ate::GetFirmwareTimeString()); +#else reply.catf(" FIRMWARE_DATE: %s%s", DATE, TIME_SUFFIX); +#endif } 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; } @@ -2029,9 +2027,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; } @@ -2117,7 +2113,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; } } @@ -2130,7 +2126,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])); } } @@ -2140,16 +2136,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 = ':'; } } @@ -2160,14 +2156,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) @@ -2175,7 +2170,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)); } } @@ -2187,7 +2182,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)); } } @@ -2197,20 +2192,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; @@ -2295,7 +2289,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++) { @@ -2464,7 +2458,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); } @@ -3328,13 +3322,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; } } @@ -3347,7 +3341,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)); } } @@ -3363,17 +3357,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) @@ -3421,19 +3414,8 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx break; case 568: // Tool Settings + if (simulationMode == 0) { - const unsigned int toolNumber = gb.GetLimitedUIValue('P', MaxTools); - if (reprap.GetTool(toolNumber).IsNull()) - { - reply.cat("Tool settings can only be set for existing tools"); - result = GCodeResult::error; - break; - } - - if (simulationMode != 0) - { - break; - } result = SetOrReportOffsets(gb, reply, 568); } break; @@ -3467,25 +3449,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 @@ -3743,11 +3707,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 @@ -4030,8 +3990,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; @@ -4668,7 +4627,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(); } @@ -4690,7 +4649,7 @@ bool GCodes::HandleTcode(GCodeBuffer& gb, const StringRef& reply) if (seen) { - if (!LockMovementAndWaitForStandstill(gb) || !IsCodeQueueIdle()) + if (!LockMovementAndWaitForStandstill(gb)) { return false; } |