From 4d960534465a6a55c22db707b5014c22ece6ec83 Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Wed, 3 Sep 2014 10:43:23 -0700 Subject: [PATCH] added support for @pause and M226 (user requested pause) --- .../PrinterConnectionAndCommunication.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/PrinterCommunication/PrinterConnectionAndCommunication.cs b/PrinterCommunication/PrinterConnectionAndCommunication.cs index 2f76635b2..9456549d3 100644 --- a/PrinterCommunication/PrinterConnectionAndCommunication.cs +++ b/PrinterCommunication/PrinterConnectionAndCommunication.cs @@ -1878,6 +1878,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication { pauseRequested = true; } + else if(lineToWrite == "M226" || lineToWrite == "@pause") + { + RequestPause(printerCommandQueueIndex+1); + } else { WriteChecksumLineToPrinter(lineToWrite); @@ -1924,8 +1928,13 @@ namespace MatterHackers.MatterControl.PrinterCommunication } } - public void RequestPause() + public void RequestPause(int injectionStartIndex = 0) { + if (injectionStartIndex == 0) + { + injectionStartIndex = printerCommandQueueIndex; + } + if (PrinterIsPrinting) { if (CommunicationState == CommunicationStates.PrintingFromSd) @@ -1945,8 +1954,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication { using (TimedLock.Lock(this, "RequestPause")) { - double currentFeedRate = loadedGCode.Instruction(printerCommandQueueIndex).FeedRate; - int lastIndexAdded = InjectGCode(pauseGCode, printerCommandQueueIndex); + double currentFeedRate = loadedGCode.Instruction(injectionStartIndex).FeedRate; + int lastIndexAdded = InjectGCode(pauseGCode, injectionStartIndex); // inject a marker to tell when we are done with the inserted pause code lastIndexAdded = InjectGCode("MH_PAUSE", lastIndexAdded);