diff --git a/MatterControl.Printing/GCode/GCodeMemoryFile.cs b/MatterControl.Printing/GCode/GCodeMemoryFile.cs index 4275f4573..8bebbd9a1 100644 --- a/MatterControl.Printing/GCode/GCodeMemoryFile.cs +++ b/MatterControl.Printing/GCode/GCodeMemoryFile.cs @@ -381,24 +381,27 @@ namespace MatterControl.Printing public (int toolIndex, double time) NextToolChange(int instructionIndex, int currentToolIndex = -1, int toolToLookFor = -1) { - int nextToolChange = -1; - // find the first tool change that we are less than - for (int i = 0; i < toolChanges.Count; i++) + if (GCodeCommandQueue.Count > 0) { - if (instructionIndex < toolChanges[i] - && GCodeCommandQueue[toolChanges[i]].ToolIndex != currentToolIndex - && (toolToLookFor == -1 || GCodeCommandQueue[toolChanges[i]].ToolIndex == toolToLookFor)) + int nextToolChange = -1; + // find the first tool change that we are less than + for (int i = 0; i < toolChanges.Count; i++) { - nextToolChange = i; - break; + if (instructionIndex < toolChanges[i] + && GCodeCommandQueue[toolChanges[i]].ToolIndex != currentToolIndex + && (toolToLookFor == -1 || GCodeCommandQueue[toolChanges[i]].ToolIndex == toolToLookFor)) + { + nextToolChange = i; + break; + } } - } - if (nextToolChange >= 0) - { - var toolIndex = GCodeCommandQueue[toolChanges[nextToolChange]].ToolIndex; - var time = GCodeCommandQueue[instructionIndex].SecondsToEndFromHere - GCodeCommandQueue[toolChanges[nextToolChange]].SecondsToEndFromHere; - return (toolIndex, time); + if (nextToolChange >= 0) + { + var toolIndex = GCodeCommandQueue[toolChanges[nextToolChange]].ToolIndex; + var time = GCodeCommandQueue[instructionIndex].SecondsToEndFromHere - GCodeCommandQueue[toolChanges[nextToolChange]].SecondsToEndFromHere; + return (toolIndex, time); + } } // there are no more tool changes diff --git a/MatterControlLib/PrinterCommunication/PrinterConnection.cs b/MatterControlLib/PrinterCommunication/PrinterConnection.cs index f33e7aa10..1eb89f223 100644 --- a/MatterControlLib/PrinterCommunication/PrinterConnection.cs +++ b/MatterControlLib/PrinterCommunication/PrinterConnection.cs @@ -2440,7 +2440,16 @@ You will then need to logout and log back in to the computer for the changes to // never leave the extruder and the bed hot ReleaseMotors(); - TurnOffBedAndExtruders(TurnOff.Now); + if (SecondsPrinted < 60 * 10) + { + // The user may still be sitting at the machine, leave it heated for a period of time + TurnOffBedAndExtruders(TurnOff.AfterDelay); + } + else + { + // Turn off the heaters on long prints as the user is less likely to be around and interacting + TurnOffBedAndExtruders(TurnOff.Now); + } } } }