self.thread = None\r
\r
class PrintCommandButton(buttons.GenBitmapButton):\r
- def __init__(self, parent, command, bitmapFilename, size=(20,20)):\r
+ def __init__(self, parent, commandList, bitmapFilename, size=(20,20)):\r
self.bitmap = toolbarUtil.getBitmapImage(bitmapFilename)\r
super(PrintCommandButton, self).__init__(parent.directControlPanel, -1, self.bitmap, size=size)\r
\r
- self.command = command\r
+ self.commandList = commandList\r
self.parent = parent\r
\r
self.SetBezelWidth(1)\r
def OnClick(self, e):\r
if self.parent.machineCom == None or self.parent.machineCom.isPrinting():\r
return;\r
- if self.command.startswith('G1'):\r
- self.parent.machineCom.sendCommand("G91")\r
- self.parent.machineCom.sendCommand(self.command)\r
- if self.command.startswith('G1'):\r
- self.parent.machineCom.sendCommand("G90")\r
+ for cmd in self.commandList:\r
+ self.parent.machineCom.sendCommand(cmd)\r
e.Skip()\r
\r
class printWindow(wx.Frame):\r
\r
sizer = wx.GridBagSizer(2, 2)\r
self.directControlPanel.SetSizer(sizer)\r
- sizer.Add(PrintCommandButton(self, 'G1 Y100 F6000', 'print-move-y100.png'), pos=(0,3))\r
- sizer.Add(PrintCommandButton(self, 'G1 Y10 F6000', 'print-move-y10.png'), pos=(1,3))\r
- sizer.Add(PrintCommandButton(self, 'G1 Y1 F6000', 'print-move-y1.png'), pos=(2,3))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 Y100 F6000', 'G90'], 'print-move-y100.png'), pos=(0,3))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 Y10 F6000', 'G90'], 'print-move-y10.png'), pos=(1,3))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 Y1 F6000', 'G90'], 'print-move-y1.png'), pos=(2,3))\r
\r
- sizer.Add(PrintCommandButton(self, 'G1 Y-1 F6000', 'print-move-y-1.png'), pos=(4,3))\r
- sizer.Add(PrintCommandButton(self, 'G1 Y-10 F6000', 'print-move-y-10.png'), pos=(5,3))\r
- sizer.Add(PrintCommandButton(self, 'G1 Y-100 F6000', 'print-move-y-100.png'), pos=(6,3))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 Y-1 F6000', 'G90'], 'print-move-y-1.png'), pos=(4,3))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 Y-10 F6000', 'G90'], 'print-move-y-10.png'), pos=(5,3))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 Y-100 F6000', 'G90'], 'print-move-y-100.png'), pos=(6,3))\r
\r
- sizer.Add(PrintCommandButton(self, 'G1 X-100 F6000', 'print-move-x-100.png'), pos=(3,0))\r
- sizer.Add(PrintCommandButton(self, 'G1 X-10 F6000', 'print-move-x-10.png'), pos=(3,1))\r
- sizer.Add(PrintCommandButton(self, 'G1 X-1 F6000', 'print-move-x-1.png'), pos=(3,2))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 X-100 F6000', 'G90'], 'print-move-x-100.png'), pos=(3,0))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 X-10 F6000', 'G90'], 'print-move-x-10.png'), pos=(3,1))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 X-1 F6000', 'G90'], 'print-move-x-1.png'), pos=(3,2))\r
\r
- sizer.Add(PrintCommandButton(self, 'G28 X0 Y0', 'print-move-home.png'), pos=(3,3))\r
+ sizer.Add(PrintCommandButton(self, ['G28 X0 Y0'], 'print-move-home.png'), pos=(3,3))\r
\r
- sizer.Add(PrintCommandButton(self, 'G1 X1 F6000', 'print-move-x1.png'), pos=(3,4))\r
- sizer.Add(PrintCommandButton(self, 'G1 X10 F6000', 'print-move-x10.png'), pos=(3,5))\r
- sizer.Add(PrintCommandButton(self, 'G1 X100 F6000', 'print-move-x100.png'), pos=(3,6))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 X1 F6000', 'G90'], 'print-move-x1.png'), pos=(3,4))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 X10 F6000', 'G90'], 'print-move-x10.png'), pos=(3,5))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 X100 F6000', 'G90'], 'print-move-x100.png'), pos=(3,6))\r
\r
- sizer.Add(PrintCommandButton(self, 'G1 Z10 F200', 'print-move-z10.png'), pos=(0,8))\r
- sizer.Add(PrintCommandButton(self, 'G1 Z1 F200', 'print-move-z1.png'), pos=(1,8))\r
- sizer.Add(PrintCommandButton(self, 'G1 Z0.1 F200', 'print-move-z0.1.png'), pos=(2,8))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 Z10 F200', 'G90'], 'print-move-z10.png'), pos=(0,8))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 Z1 F200', 'G90'], 'print-move-z1.png'), pos=(1,8))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 Z0.1 F200', 'G90'], 'print-move-z0.1.png'), pos=(2,8))\r
\r
- sizer.Add(PrintCommandButton(self, 'G28 Z0', 'print-move-home.png'), pos=(3,8))\r
+ sizer.Add(PrintCommandButton(self, ['G28 Z0'], 'print-move-home.png'), pos=(3,8))\r
\r
- sizer.Add(PrintCommandButton(self, 'G1 Z-0.1 F200', 'print-move-z-0.1.png'), pos=(4,8))\r
- sizer.Add(PrintCommandButton(self, 'G1 Z-1 F200', 'print-move-z-1.png'), pos=(5,8))\r
- sizer.Add(PrintCommandButton(self, 'G1 Z-10 F200', 'print-move-z-10.png'), pos=(6,8))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 Z-0.1 F200', 'G90'], 'print-move-z-0.1.png'), pos=(4,8))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 Z-1 F200', 'G90'], 'print-move-z-1.png'), pos=(5,8))\r
+ sizer.Add(PrintCommandButton(self, ['G91', 'G1 Z-10 F200', 'G90'], 'print-move-z-10.png'), pos=(6,8))\r
+\r
+ sizer.Add(PrintCommandButton(self, ['G92 E0', 'G1 E2 F120'], 'question.png'), pos=(8,1))\r
+ sizer.Add(PrintCommandButton(self, ['G92 E0', 'G1 E-2 F120'], 'question.png'), pos=(8,2))\r
\r
nb.AddPage(self.directControlPanel, 'Jog')\r
\r
sizer.Add(self.timelapsEnable, pos=(0,0), span=(1,2), flag=wx.EXPAND)\r
\r
pages = self.cam.propertyPages()\r
+ self.cam.buttons = [self.timelapsEnable]\r
for page in pages:\r
button = wx.Button(self.camPage, -1, page)\r
button.index = pages.index(page)\r
sizer.Add(button, pos=(1, pages.index(page)))\r
button.Bind(wx.EVT_BUTTON, self.OnPropertyPageButton)\r
+ self.cam.buttons.append(button)\r
\r
self.camPreview = wx.Panel(self.camPage)\r
sizer.Add(self.camPreview, pos=(2,0), span=(1,2), flag=wx.EXPAND)\r
self.bedTemperatureSelect.Enable(self.machineCom != None and self.machineCom.isOperational())\r
self.directControlPanel.Enable(self.machineCom != None and self.machineCom.isOperational() and not self.machineCom.isPrinting())\r
self.machineLogButton.Show(self.machineCom != None and self.machineCom.isError())\r
+ if self.cam:\r
+ for button in self.cam.buttons:\r
+ button.Enable(self.machineCom == None or not self.machineCom.isPrinting())\r
\r
def UpdateProgress(self):\r
status = ""\r
wx.CallAfter(self.progress.SetRange, len(gcodeList))\r
wx.CallAfter(self.UpdateButtonStates)\r
wx.CallAfter(self.UpdateProgress)\r
+ wx.CallAfter(self.SetTitle, 'Printing: %s' % (filename))\r
\r
def sendLine(self, lineNr):\r
if lineNr >= len(self.gcodeList):\r
#print message\r
pass\r
\r
- def mcTempUpdate(self, temp, bedTemp):\r
- self.temperatureGraph.addPoint(temp, self.temperatureSelect.GetValue(), bedTemp, self.bedTemperatureSelect.GetValue())\r
+ def mcTempUpdate(self, temp, bedTemp, targetTemp, bedTargetTemp):\r
+ self.temperatureGraph.addPoint(temp, targetTemp, bedTemp, bedTargetTemp)\r
+ if self.temperatureSelect.GetValue() != targetTemp:\r
+ wx.CallAfter(self.temperatureSelect.SetValue, targetTemp)\r
+ if self.bedTemperatureSelect.GetValue() != bedTargetTemp:\r
+ wx.CallAfter(self.bedTemperatureSelect.SetValue, bedTargetTemp)\r
\r
def mcStateChange(self, state):\r
if self.machineCom != None and state == self.machineCom.STATE_OPERATIONAL and self.cam != None:\r
#print "Send: %s" % (data.rstrip())
if 'M104' in data or 'M109' in data:
try:
- self.targetTemp = float(data[data.find('S')+1:])
+ self.targetTemp = float(re.search('S([0-9]+)', cmd).group(1))
except:
pass
if 'M140' in data or 'M190' in data:
try:
- self.bedTargetTemp = float(data[data.find('S')+1:])
+ self.bedTargetTemp = float(re.search('S([0-9]+)', cmd).group(1))
except:
pass
if 'M105' in data:
def mcLog(self, message):
pass
- def mcTempUpdate(self, temp, bedTemp):
+ def mcTempUpdate(self, temp, bedTemp, targetTemp, bedTargetTemp):
pass
def mcStateChange(self, state):
self._baudrateDetectRetry = 0
self._temp = 0
self._bedTemp = 0
+ self._targetTemp = 0
+ self._bedTargetTemp = 0
self._gcodeList = None
self._gcodePos = 0
self._commandQueue = queue.Queue()
break
#No matter the state, if we see an error, goto the error state and store the error for reference.
- if line.startswith('Error: '):
+ if line.startswith('Error:'):
#Oh YEAH, consistency.
- # Marlin reports an MIN/MAX temp error as "Error: x\n: Extruder switched off. MAXTEMP triggered !\n"
+ # Marlin reports an MIN/MAX temp error as "Error:x\n: Extruder switched off. MAXTEMP triggered !\n"
# But a bed temp error is reported as "Error: Temperature heated bed switched off. MAXTEMP triggered !!"
# So we can have an extra newline in the most common case. Awesome work people.
- if re.match('Error: [0-9]\n', line):
+ if re.match('Error:[0-9]\n', line):
line = line.rstrip() + self._readline()
- self._errorValue = line
- self._changeState(self.STATE_ERROR)
+ #Skip the communication errors, as those get corrected.
+ if 'checksum mismatch' in line or 'Line Number is not Last Line Number' in line or 'No Line Number with checksum' in line:
+ pass
+ else:
+ self._errorValue = line[6:]
+ self._changeState(self.STATE_ERROR)
if ' T:' in line or line.startswith('T:'):
self._temp = float(re.search("[0-9\.]*", line.split('T:')[1]).group(0))
if ' B:' in line:
self._bedTemp = float(re.search("[0-9\.]*", line.split(' B:')[1]).group(0))
- self._callback.mcTempUpdate(self._temp, self._bedTemp)
+ self._callback.mcTempUpdate(self._temp, self._bedTemp, self._targetTemp, self._bedTargetTemp)
#If we are waiting for an M109 or M190 then measure the time we lost during heatup, so we can remove that time from our printing time estimate.
if not 'ok' in line and self._heatupWaitStartTime != 0:
t = time.time()
except:
self._log("Unexpected error while setting baudrate: %d %s" % (baudrate, getExceptionString()))
elif 'ok' in line:
+ self._sendCommand("M999")
self._serial.timeout = 2
profile.putPreference('serial_baud_auto', self._serial.baudrate)
self._changeState(self.STATE_OPERATIONAL)
return
if 'M109' in cmd or 'M190' in cmd:
self._heatupWaitStartTime = time.time()
+ if 'M104' in cmd or 'M109' in cmd:
+ try:
+ self._targetTemp = float(re.search('S([0-9]+)', cmd).group(1))
+ except:
+ pass
+ if 'M140' in cmd or 'M190' in cmd:
+ try:
+ self._bedTargetTemp = float(re.search('S([0-9]+)').group(1))
+ except:
+ pass
self._log('Send: %s' % (cmd))
try:
- #TODO: This can throw a write timeout exception, but we do not want timeout on writes. Find a fix for this.
- # Oddly enough, the write timeout is not even set and thus we should not get a write timeout.
self._serial.write(cmd + '\n')
+ except SerialTimeoutException:
+ self._log("Serial timeout while writing to serial port, trying again.")
+ try:
+ self._serial.write(cmd + '\n')
+ except:
+ self._log("Unexpected error while writing serial port: %s" % (getExceptionString()))
+ self._errorValue = getExceptionString()
+ self.close(True)
except:
self._log("Unexpected error while writing serial port: %s" % (getExceptionString()))
self._errorValue = getExceptionString()