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
path: root/src
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2017-01-07 15:37:46 +0300
committerDavid Crocker <dcrocker@eschertech.com>2017-01-07 15:37:46 +0300
commitf9bdece0778de72b6983abe90a3a22d449e33f17 (patch)
tree9e146fa53d68f4ae4a030ff655f976d1ac643fef /src
parent0ae1b2ecd8833d051e0774269e7d48d1701b79e3 (diff)
Implemented 'T' printer status code in M408 and web response
Diffstat (limited to 'src')
-rw-r--r--src/GCodes/GCodeMachineState.h6
-rw-r--r--src/GCodes/GCodes.cpp38
-rw-r--r--src/GCodes/GCodes.h4
-rw-r--r--src/GCodes/GCodes2.cpp4
-rw-r--r--src/Reprap.cpp1
5 files changed, 32 insertions, 21 deletions
diff --git a/src/GCodes/GCodeMachineState.h b/src/GCodes/GCodeMachineState.h
index 76943162..d1164493 100644
--- a/src/GCodes/GCodeMachineState.h
+++ b/src/GCodes/GCodeMachineState.h
@@ -19,11 +19,13 @@ enum class GCodeState : uint8_t
homing,
setBed,
- // These next 3 must be contiguous
+ // These next 4 must be contiguous
+ toolChange0,
toolChange1,
toolChange2,
toolChangeComplete,
- // These next 3 must be contiguous
+ // These next 4 must be contiguous
+ m109ToolChange0,
m109ToolChange1,
m109ToolChange2,
m109ToolChangeComplete,
diff --git a/src/GCodes/GCodes.cpp b/src/GCodes/GCodes.cpp
index f615f642..2b8b2dd7 100644
--- a/src/GCodes/GCodes.cpp
+++ b/src/GCodes/GCodes.cpp
@@ -93,6 +93,7 @@ void GCodes::Init()
eofStringLength = strlen(eofString);
offSetSet = false;
runningConfigFile = false;
+ doingToolChange = false;
active = true;
longWait = platform->Time();
dwellTime = longWait;
@@ -271,8 +272,22 @@ void GCodes::Spin()
}
break;
- case GCodeState::toolChange1: // Release the old tool (if any)
- case GCodeState::m109ToolChange1: // Release the old tool (if any)
+ case GCodeState::toolChange0: // Run tfree for the old tool (if any)
+ case GCodeState::m109ToolChange0: // Run tfree for the old tool (if any)
+ doingToolChange = true;
+ gb.AdvanceState();
+ {
+ const Tool * const oldTool = reprap.GetCurrentTool();
+ if (oldTool != nullptr && AllAxesAreHomed())
+ {
+ scratchString.printf("tfree%d.g", oldTool->Number());
+ DoFileMacro(gb, scratchString.Pointer(), false);
+ }
+ }
+ break;
+
+ case GCodeState::toolChange1: // Release the old tool (if any), then run tpre for the new tool
+ case GCodeState::m109ToolChange1: // Release the old tool (if any), then run tpre for the new tool
{
const Tool *oldTool = reprap.GetCurrentTool();
if (oldTool != NULL)
@@ -288,8 +303,8 @@ void GCodes::Spin()
}
break;
- case GCodeState::toolChange2: // Select the new tool (even if it doesn't exist - that just deselects all tools)
- case GCodeState::m109ToolChange2: // Select the new tool (even if it doesn't exist - that just deselects all tools)
+ case GCodeState::toolChange2: // Select the new tool (even if it doesn't exist - that just deselects all tools) and run tpost
+ case GCodeState::m109ToolChange2: // Select the new tool (even if it doesn't exist - that just deselects all tools) and run tpost
reprap.SelectTool(newToolNumber);
gb.AdvanceState();
if (reprap.GetTool(newToolNumber) != nullptr && AllAxesAreHomed())
@@ -300,10 +315,13 @@ void GCodes::Spin()
break;
case GCodeState::toolChangeComplete:
+ doingToolChange = false;
gb.SetState(GCodeState::normal);
break;
case GCodeState::m109ToolChangeComplete:
+ doingToolChange = false;
+ UnlockAll(gb); // allow movement again
if (cancelWait || ToolHeatersAtSetTemperatures(reprap.GetCurrentTool(), gb.MachineState().waitWhileCooling))
{
cancelWait = isWaiting = false;
@@ -3026,18 +3044,6 @@ void GCodes::SetToolHeaters(Tool *tool, float temperature)
tool->SetVariables(standby, active);
}
-// Begin the tool change sequence
-void GCodes::StartToolChange(GCodeBuffer& gb, bool inM109)
-{
- gb.SetState((inM109) ? GCodeState:: m109ToolChange1 : GCodeState::toolChange1);
- const Tool * const oldTool = reprap.GetCurrentTool();
- if (oldTool != nullptr && AllAxesAreHomed())
- {
- scratchString.printf("tfree%d.g", oldTool->Number());
- DoFileMacro(gb, scratchString.Pointer(), false);
- }
-}
-
// Retract or un-retract filament, returning true if movement has been queued, false if this needs to be called again
bool GCodes::RetractFilament(GCodeBuffer& gb, bool retract)
{
diff --git a/src/GCodes/GCodes.h b/src/GCodes/GCodes.h
index 77252d3f..58967284 100644
--- a/src/GCodes/GCodes.h
+++ b/src/GCodes/GCodes.h
@@ -113,6 +113,7 @@ public:
bool IsPausing() const;
bool IsResuming() const;
bool IsRunning() const;
+ bool IsDoingToolChange() const { return doingToolChange; }
bool AllAxesAreHomed() const; // Return true if all axes are homed
@@ -196,7 +197,6 @@ private:
void ManageTool(GCodeBuffer& gb, StringRef& reply); // Create a new tool definition
void SetToolHeaters(Tool *tool, float temperature); // Set all a tool's heaters to the temperature. For M104...
bool ToolHeatersAtSetTemperatures(const Tool *tool, bool waitWhenCooling) const; // Wait for the heaters associated with the specified tool to reach their set temperatures
- void StartToolChange(GCodeBuffer& gb, bool inM109); // Begin the tool change sequence
void SetAllAxesNotHomed(); // Flag all axes as not homed
void SetPositions(float positionNow[DRIVES]); // Set the current position to be this
@@ -242,6 +242,8 @@ private:
bool isPaused; // true if the print has been paused
bool dwellWaiting; // We are in a dwell
bool runningConfigFile; // We are running config.g during the startup process
+ bool doingToolChange; // We are running tool change macros
+
unsigned int segmentsLeft; // The number of segments left to do in the current move, or 0 if no move available
float dwellTime; // How long a pause for a dwell (seconds)?
RawMove moveBuffer; // Move details to pass to Move class
diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp
index efdf175c..51df0408 100644
--- a/src/GCodes/GCodes2.cpp
+++ b/src/GCodes/GCodes2.cpp
@@ -1133,7 +1133,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, StringRef& reply)
}
newToolNumber = tool->Number();
- StartToolChange(gb, true);
+ gb.SetState(GCodeState::m109ToolChange0);
}
else
{
@@ -3536,7 +3536,7 @@ bool GCodes::HandleTcode(GCodeBuffer& gb, StringRef& reply)
// If old and new are the same we no longer follow the sequence. User can deselect and then reselect the tool if he wants the macros run.
if (oldTool == nullptr || oldTool->Number() != newToolNumber)
{
- StartToolChange(gb, false);
+ gb.SetState(GCodeState::toolChange0);
return true; // proceeding with state machine, so don't unlock or send a reply
}
}
diff --git a/src/Reprap.cpp b/src/Reprap.cpp
index b758e9ab..5af3de3b 100644
--- a/src/Reprap.cpp
+++ b/src/Reprap.cpp
@@ -1475,6 +1475,7 @@ char RepRap::GetStatusCharacter() const
: (IsStopped()) ? 'H' // Halted
: (gCodes->IsPausing()) ? 'D' // Pausing / Decelerating
: (gCodes->IsResuming()) ? 'R' // Resuming
+ : (gCodes->IsDoingToolChange()) ? 'T' // Running tool change macros
: (gCodes->IsPaused()) ? 'S' // Paused / Stopped
: (printMonitor->IsPrinting()) ? 'P' // Printing
: (gCodes->DoingFileMacro() || !move->NoLiveMovement()) ? 'B' // Busy