diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-07-22 10:26:07 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-07-22 10:26:07 +0300 |
commit | ec52c2e766b31fbf44cf7ccfbd737cf1f702bf55 (patch) | |
tree | c2e694fc33d7f4ccfe51dced1ca53833b8e98f53 | |
parent | 3ea04e0def85a75f102841e33c720fda91ba2ee6 (diff) |
Skip cold extrusion code when in expansion mode
-rw-r--r-- | src/Movement/DDA.cpp | 111 |
1 files changed, 64 insertions, 47 deletions
diff --git a/src/Movement/DDA.cpp b/src/Movement/DDA.cpp index e91c4290..fa67e19a 100644 --- a/src/Movement/DDA.cpp +++ b/src/Movement/DDA.cpp @@ -18,6 +18,10 @@ # include <CAN/CanMotion.h> #endif +#if SUPPORT_REMOTE_COMMANDS +# include <Can/CanInterface.h> +#endif + #ifdef DUET_NG # define DDA_MOVE_DEBUG (0) #else @@ -1909,73 +1913,86 @@ pre(state == frozen) { p.EnableAllSteppingDrivers(); // make sure that all drivers are enabled } - const size_t numTotalAxes = reprap.GetGCodes().GetTotalAxes(); - unsigned int extrusions = 0, retractions = 0; // bitmaps of extruding and retracting drives - float extrusionFraction = 0.0; - for (const DriveMovement* pdm = activeDMs; pdm != nullptr; pdm = pdm->nextDM) + +#if SUPPORT_REMOTE_COMMANDS + if (CanInterface::InExpansionMode()) { - const size_t drive = pdm->drive; - p.SetDirection(drive, pdm->direction); - if (drive >= numTotalAxes && drive < MaxAxesPlusExtruders) // if it's an extruder + for (const DriveMovement* pdm = activeDMs; pdm != nullptr; pdm = pdm->nextDM) { - const size_t extruder = LogicalDriveToExtruder(drive); - if (pdm->direction == FORWARDS) - { - extrusions |= (1u << extruder); - extrusionFraction += directionVector[drive]; - } - else - { - retractions |= (1u << extruder); - } + p.SetDirection(pdm->drive, pdm->direction); } } - - bool extruding = false; - if ((extrusions | retractions) != 0) + else +#endif { - // Check for trying to extrude or retract when the hot end temperature is too low - const unsigned int prohibitedMovements = reprap.GetProhibitedExtruderMovements(extrusions, retractions); - for (DriveMovement **dmpp = &activeDMs; *dmpp != nullptr; ) + const size_t numTotalAxes = reprap.GetGCodes().GetTotalAxes(); + unsigned int extrusions = 0, retractions = 0; // bitmaps of extruding and retracting drives + float extrusionFraction = 0.0; + for (const DriveMovement* pdm = activeDMs; pdm != nullptr; pdm = pdm->nextDM) { - DriveMovement* const dm = *dmpp; - const size_t drive = dm->drive; - if (drive >= numTotalAxes && drive < MaxAxesPlusExtruders) + const size_t drive = pdm->drive; + p.SetDirection(drive, pdm->direction); + if (drive >= numTotalAxes && drive < MaxAxesPlusExtruders) // if it's an extruder { - if ((prohibitedMovements & (1u << LogicalDriveToExtruder(drive))) != 0) + const size_t extruder = LogicalDriveToExtruder(drive); + if (pdm->direction == FORWARDS) { - *dmpp = dm->nextDM; - dm->nextDM = completedDMs; - completedDMs = dm; + extrusions |= (1u << extruder); + extrusionFraction += directionVector[drive]; } else { - extruding = true; - dmpp = &(dm->nextDM); + retractions |= (1u << extruder); } } - else + } + + bool extruding = false; + if ((extrusions | retractions) != 0) + { + // Check for trying to extrude or retract when the hot end temperature is too low + const unsigned int prohibitedMovements = reprap.GetProhibitedExtruderMovements(extrusions, retractions); + for (DriveMovement **dmpp = &activeDMs; *dmpp != nullptr; ) { - dmpp = &(dm->nextDM); + DriveMovement* const dm = *dmpp; + const size_t drive = dm->drive; + if (drive >= numTotalAxes && drive < MaxAxesPlusExtruders) + { + if ((prohibitedMovements & (1u << LogicalDriveToExtruder(drive))) != 0) + { + *dmpp = dm->nextDM; + dm->nextDM = completedDMs; + completedDMs = dm; + } + else + { + extruding = true; + dmpp = &(dm->nextDM); + } + } + else + { + dmpp = &(dm->nextDM); + } } } - } - if (extruding) - { - p.ExtrudeOn(); - if (tool != nullptr) + if (extruding) { - // Pass the extrusion speed averaged over the whole move in mm/sec - tool->ApplyFeedForward((extrusionFraction * totalDistance * (float)StepClockRate)/(float)clocksNeeded); + p.ExtrudeOn(); + if (tool != nullptr) + { + // Pass the extrusion speed averaged over the whole move in mm/sec + tool->ApplyFeedForward((extrusionFraction * totalDistance * (float)StepClockRate)/(float)clocksNeeded); + } } - } - else - { - p.ExtrudeOff(); - if (tool != nullptr) + else { - tool->StopFeedForward(); + p.ExtrudeOff(); + if (tool != nullptr) + { + tool->StopFeedForward(); + } } } } |