if not self._printerConnection.hasActiveConnection() or \
self._printerConnection.isActiveConnectionOpen():
if self._printerConnection.isPrinting():
- button.SetLabel(_("Pause"))
+ if self.pauseTimer.IsRunning():
+ self.printButton.Enable(False)
+ self.printButton.SetLabel(_("Please wait..."))
+ else:
+ self.printButton.Enable(True)
+ button.SetLabel(_("Pause"))
else:
if self._printerConnection.isPaused():
- button.SetLabel(_("Resume"))
+ if self.pauseTimer.IsRunning():
+ self.printButton.Enable(False)
+ self.printButton.SetLabel(_("Please wait..."))
+ else:
+ self.printButton.Enable(True)
+ button.SetLabel(_("Resume"))
else:
button.SetLabel(_("Print"))
- button.Enable(True)
+ button.Enable(True)
+ self.pauseTimer.Stop()
else:
button.Enable(False)
elif button.command == self.script_cancelPrint:
self.errorLogButton = wx.Button(self.panel, -1, _("Error log"))
self.progress = wx.Gauge(self.panel, -1, range=1000)
+ self.pauseTimer = wx.Timer(self)
+ self.Bind(wx.EVT_TIMER, self.OnPauseTimer, self.pauseTimer)
+
self.sizer.Add(self.powerWarningText, pos=(0, 0), span=(1, 5), flag=wx.EXPAND|wx.BOTTOM, border=5)
self.sizer.Add(self.statsText, pos=(1, 0), span=(1, 5), flag=wx.LEFT, border=5)
self.sizer.Add(self.connectButton, pos=(2, 0))
self._printerConnection.removeCallback(self._doPrinterConnectionUpdate)
#TODO: When multiple printer windows are open, closing one will enable sleeping again.
preventComputerFromSleeping(self, False)
+ self.powerWarningTimer.Stop()
+ self.pauseTimer.Stop()
self.Destroy()
def OnConnect(self, e):
def OnPause(self, e):
self._printerConnection.pause(not self._printerConnection.isPaused())
+ self.pauseButton.Enable(False)
+ self.pauseTimer.Stop()
+ self.pauseTimer.Start(10000)
+
+ def OnPauseTimer(self, e):
+ self.pauseButton.Enable(True)
+ self.pauseTimer.Stop()
+ self._updateButtonStates()
def OnErrorLog(self, e):
LogWindow(self._printerConnection.getErrorLog())
self.OnPowerWarningChange(None)
self.powerWarningTimer.Start(10000)
+ self.pauseTimer = wx.Timer(self)
+ self.Bind(wx.EVT_TIMER, self.OnPauseTimer, self.pauseTimer)
+
self.connectButton = wx.Button(self.toppanel, -1, _("Connect"), size=(125, 30))
self.printButton = wx.Button(self.toppanel, -1, _("Print"), size=(125, 30))
self.cancelButton = wx.Button(self.toppanel, -1, _("Cancel"), size=(125, 30))
#TODO: When multiple printer windows are open, closing one will enable sleeping again.
preventComputerFromSleeping(self, False)
self._printerConnection.cancelPrint()
+ self.powerWarningTimer.Stop()
+ self.pauseTimer.Stop()
self.Destroy()
def OnPowerWarningChange(self, e):
def OnPrint(self, e):
if self._printerConnection.isPrinting() or self._printerConnection.isPaused():
self._printerConnection.pause(not self._printerConnection.isPaused())
+ self.pauseTimer.Stop()
+ self.printButton.Enable(False)
+ self.pauseTimer.Start(10000)
else:
self._printerConnection.startPrint()
+ def OnPauseTimer(self, e):
+ self.printButton.Enable(True)
+ self.pauseTimer.Stop()
+ self._updateButtonStates()
+
def OnCancel(self, e):
self._printerConnection.cancelPrint()
# Prevent Z movement when paused and all moves when printing
if (not self._printerConnection.hasActiveConnection() or \
self._printerConnection.isActiveConnectionOpen()) and \
- (not (self._printerConnection.isPaused() and motor == 'Z') and \
+ (not (self._printerConnection.isPaused() and motor != 'E') and \
not self._printerConnection.isPrinting()):
self._printerConnection.sendCommand("G91")
self._printerConnection.sendCommand("G1 %s%.1f F%d" % (motor, step, feedrate))
if not self._printerConnection.hasActiveConnection() or \
self._printerConnection.isActiveConnectionOpen():
if self._printerConnection.isPrinting():
- self.printButton.SetLabel(_("Pause"))
+ if self.pauseTimer.IsRunning():
+ self.printButton.Enable(False)
+ self.printButton.SetLabel(_("Please wait..."))
+ else:
+ self.printButton.Enable(True)
+ self.printButton.SetLabel(_("Pause"))
else:
if self._printerConnection.isPaused():
- self.printButton.SetLabel(_("Resume"))
+ if self.pauseTimer.IsRunning():
+ self.printButton.Enable(False)
+ self.printButton.SetLabel(_("Please wait..."))
+ else:
+ self.printButton.SetLabel(_("Resume"))
+ self.printButton.Enable(True)
else:
self.printButton.SetLabel(_("Print"))
- self.printButton.Enable(True)
+ self.printButton.Enable(True)
+ self.pauseTimer.Stop()
else:
self.printButton.Enable(False)
if not self._printerConnection.hasActiveConnection() or \
import sys
import subprocess
import json
+import re
from Cura.util import profile
from Cura.util import machineCom
self._gcodeData = []
self._printProgress = 0
self._ZPosition = 0
+ self._pausePosition = None
#Load the data into memory for printing, returns True on success
def loadGCodeData(self, dataStream):
self._process.stdin.write('START\n')
self._printProgress = 0
self._ZPosition = 0
+ self._pausePosition = None
def coolDown(self):
cooldown_toolhead = "M104 S0"
return
self._process.stdin.write('STOP\n')
self._printProgress = 0
+ self._ZPosition = 0
+ self._pausePosition = None
self.coolDown()
self.disableSteppers()
if not (self.isPrinting() or self.isPaused()) or self._process is None:
return
if value:
+ start_gcode = profile.getAlterationFileContents('start.gcode')
+ start_gcode_lines = len(start_gcode.split("\n"))
+ parkX = profile.getMachineSettingFloat('machine_width') - 10
+ parkY = profile.getMachineSettingFloat('machine_depth') - 10
+ maxZ = profile.getMachineSettingFloat('machine_height') - 10
+ #retract_amount = profile.getProfileSettingFloat('retraction_amount')
+ retract_amount = 5.0
+ moveZ = 10.0
+
+ if self._printProgress - 5 > start_gcode_lines: # Substract 5 because of the marlin queue
+ x = None
+ y = None
+ e = None
+ f = None
+ for i in xrange(self._printProgress - 1, start_gcode_lines, -1):
+ line = self._gcodeData[i]
+ if ('G0' in line or 'G1' in line) and 'X' in line and x is None:
+ x = float(re.search('X(-?[0-9\.]*)', line).group(1))
+ if ('G0' in line or 'G1' in line) and 'Y' in line and y is None:
+ y = float(re.search('Y(-?[0-9\.]*)', line).group(1))
+ if ('G0' in line or 'G1' in line) and 'E' in line and e is None:
+ e = float(re.search('E(-?[0-9\.]*)', line).group(1))
+ if ('G0' in line or 'G1' in line) and 'F' in line and f is None:
+ f = int(re.search('F(-?[0-9\.]*)', line).group(1))
+ if x is not None and y is not None and f is not None and e is not None:
+ break
+ if f is None:
+ f = 1200
+
+ if x is not None and y is not None:
+ # Set E relative positioning
+ self.sendCommand("M83")
+ # Retract 1mm
+ self.sendCommand("G1 E-%f F120" % retract_amount)
+
+ #Move the toolhead up
+ newZ = self._ZPosition + moveZ
+ if maxZ < newZ:
+ newZ = maxZ
+ if newZ > self._ZPosition:
+ self.sendCommand("G1 Z%f F200\n" % (newZ))
+
+ #Move the head away
+ self.sendCommand("G1 X%f Y%f F9000\n" % (parkX, parkY))
+
+ #Disable the E steppers
+ self.sendCommand("M84 E0\n")
+ # Set E absolute positioning
+ self.sendCommand("M82\n")
+
+ self._pausePosition = (x, y, self._ZPosition, f, e)
self._process.stdin.write("PAUSE\n")
else:
+ if self._pausePosition:
+ retract_amount = profile.getProfileSettingFloat('retraction_amount')
+ # Set E relative positioning
+ self.sendCommand("M83")
+ #Push the filament back, and retract again, the properly primes the nozzle when changing filament.
+ self.sendCommand("G1 E%f F120\n" % (retract_amount))
+ self.sendCommand("G1 E-%f F120\n" % (retract_amount))
+
+ # Position the toolhead to the correct position again
+ self.sendCommand("G1 X%f Y%f Z%f F%d\n" % self._pausePosition[0:4])
+
+ # Prime the nozzle again
+ self.sendCommand("G1 E%f F120\n" % (retract_amount))
+ # Set proper feedrate
+ self.sendCommand("G1 F%d\n" % (self._pausePosition[3]))
+ # Set E absolute position to cancel out any extrude/retract that occured
+ self.sendCommand("G92 E%f\n" % (self._pausePosition[4]))
+ # Set E absolute positioning
+ self.sendCommand("M82\n")
self._process.stdin.write("RESUME\n")
+ self._pausePosition = None
#Amount of progression of the current print file. 0.0 to 1.0
def getPrintProgress(self):