Implemented 'T' printer status code in M408 and web response
This commit is contained in:
parent
0ae1b2ecd8
commit
f9bdece077
5 changed files with 32 additions and 21 deletions
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue