\r
def UpdateButtonStates(self):\r
self.connectButton.Enable(self.machineCom == None or self.machineCom.isClosedOrError())\r
- #self.loadButton.Enable(self.printIdx == None)\r
- self.printButton.Enable(self.machineCom != None and self.machineCom.isOperational() and not (self.machineCom.isPrinting() or self.machineCome.isPaused()))\r
- self.pauseButton.Enable(self.machineCom != None and (self.machineCom.isPrinting() or self.machineCome.isPaused()))\r
- self.cancelButton.Enable(self.machineCom != None and (self.machineCom.isPrinting() or self.machineCome.isPaused()))\r
+ #self.loadButton.Enable(self.machineCom == None or not (self.machineCom.isPrinting() or self.machineCom.isPaused()))\r
+ self.printButton.Enable(self.machineCom != None and self.machineCom.isOperational() and not (self.machineCom.isPrinting() or self.machineCom.isPaused()))\r
+ self.pauseButton.Enable(self.machineCom != None and (self.machineCom.isPrinting() or self.machineCom.isPaused()))\r
+ if self.machineCom != None and self.machineCom.isPaused():\r
+ self.pauseButton.SetLabel('Resume')\r
+ else:\r
+ self.pauseButton.SetLabel('Pause')\r
+ self.cancelButton.Enable(self.machineCom != None and (self.machineCom.isPrinting() or self.machineCom.isPaused()))\r
self.temperatureSelect.Enable(self.machineCom != None and self.machineCom.isOperational())\r
self.bedTemperatureSelect.Enable(self.machineCom != None and self.machineCom.isOperational())\r
self.directControlPanel.Enable(self.machineCom != None and self.machineCom.isOperational())\r
def OnPause(self, e):\r
if self.machineCom.isPaused():\r
self.machineCom.setPause(False)\r
- self.pauseButton.SetLabel('Pause')\r
else:\r
self.machineCom.setPause(True)\r
- self.pauseButton.SetLabel('Resume')\r
\r
def OnClose(self, e):\r
global printWindowHandle\r
self.machineCom.sendCommand("M140 S%d" % (self.bedTemperatureSelect.GetValue()))\r
\r
def OnSpeedChange(self, e):\r
- self.feedrateRatioOuterWall = self.outerWallSpeedSelect.GetValue() / 100.0\r
- self.feedrateRatioInnerWall = self.innerWallSpeedSelect.GetValue() / 100.0\r
- self.feedrateRatioFill = self.fillSpeedSelect.GetValue() / 100.0\r
- self.feedrateRatioSupport = self.supportSpeedSelect.GetValue() / 100.0\r
+ if self.machineCom == None:\r
+ return\r
+ self.machineCom.setFeedrateModifier('WALL-OUTER', self.outerWallSpeedSelect.GetValue() / 100.0)\r
+ self.machineCom.setFeedrateModifier('WALL-INNER', self.innerWallSpeedSelect.GetValue() / 100.0)\r
+ self.machineCom.setFeedrateModifier('FILL', self.fillSpeedSelect.GetValue() / 100.0)\r
+ self.machineCom.setFeedrateModifier('SUPPORT', self.supportSpeedSelect.GetValue() / 100.0)\r
\r
def AddTermLog(self, line):\r
self.termLog.AppendText(unicode(line, 'utf-8', 'replace'))\r
if self.machineCom != None and self.machineCom.isPrinting():\r
return\r
#Send an initial M110 to reset the line counter to zero.\r
- lineType = 'CUSTOM'\r
+ prevLineType = lineType = 'CUSTOM'\r
gcodeList = ["M110"]\r
- typeList = [lineType]\r
for line in open(filename, 'r'):\r
if line.startswith(';TYPE:'):\r
lineType = line[6:].strip()\r
line = line[0:line.find(';')]\r
line = line.strip()\r
if len(line) > 0:\r
- gcodeList.append(line)\r
- typeList.append(lineType)\r
+ if prevLineType != lineType:\r
+ gcodeList.append((line, lineType, ))\r
+ else:\r
+ gcodeList.append(line)\r
+ prevLineType = lineType\r
gcode = gcodeInterpreter.gcode()\r
gcode.loadList(gcodeList)\r
print "Loaded: %s (%d)" % (filename, len(gcodeList))\r
self.filename = filename\r
self.gcode = gcode\r
self.gcodeList = gcodeList\r
- self.typeList = typeList\r
\r
wx.CallAfter(self.progress.SetRange, len(gcodeList))\r
wx.CallAfter(self.UpdateButtonStates)\r
self._gcodePos = 0
self._commandQueue = queue.Queue()
self._logQueue = queue.Queue(256)
+ self._feedRateModifier = {}
if port == 'AUTO':
programmer = stk500v2.Stk500v2()
if ret == '':
#self._log("Recv: TIMEOUT")
return ''
- self._log("Recv: %s" % (unicode(ret, 'ascii', 'replace').rstrip()))
+ self._log("Recv: %s" % (unicode(ret, 'ascii', 'replace').encode('ascii', 'replace').rstrip()))
return ret
def close(self, isError = False):
self._changeState(self.STATE_OPERATIONAL)
return
line = self._gcodeList[self._gcodePos]
+ if type(line) is tuple:
+ self._printSection = line[1]
+ line = line[0]
+ try:
+ if line == 'M0' or line == 'M1':
+ self.setPause(True)
+ line = 'M105' #Don't send the M0 or M1 to the machine, as M0 and M1 are handled as an LCD menu pause.
+ if self._printSection in self._feedRateModifier:
+ line = re.sub('F([0-9]*)', lambda m: 'F' + str(int(int(m.group(1)) * self._feedRateModifier[self._printSection])), line)
+ except:
+ self._log("Unexpected error: %s" % (getExceptionString()))
checksum = reduce(lambda x,y:x^y, map(ord, "N%d%s" % (self._gcodePos, line)))
self._sendCommand("N%d%s*%d" % (self._gcodePos, line, checksum))
self._gcodePos += 1
return
self._gcodeList = gcodeList
self._gcodePos = 0
+ self._printSection = 'CUSTOM'
self._changeState(self.STATE_PRINTING)
for i in xrange(0, 6):
self._sendNext()
self._sendNext()
if pause and self.isPrinting():
self._changeState(self.STATE_PAUSED)
+
+ def setFeedrateModifier(self, type, value):
+ self._feedRateModifier[type] = value
def getExceptionString():
locationInfo = traceback.extract_tb(sys.exc_info()[2])[0]