chiark / gitweb /
Add a retraction enable setting. Add extrusion/retraction buttons in printer interfac...
authordaid303 <daid303@gmail.com>
Wed, 3 Oct 2012 13:11:35 +0000 (15:11 +0200)
committerdaid303 <daid303@gmail.com>
Wed, 3 Oct 2012 13:11:35 +0000 (15:11 +0200)
Cura/cura_sf/fabmetheus_utilities/settings.py
Cura/gui/configWizard.py
Cura/gui/mainWindow.py
Cura/gui/printWindow.py
Cura/gui/simpleMode.py
Cura/util/machineCom.py
Cura/util/profile.py

index b504c159f12c1d54a70e8191ea0065ab1bf7ca13..c460b6f196fbcf4bfc21fe60210c098115ff7814 100644 (file)
@@ -384,7 +384,7 @@ def getProfileInformation():
                        'Maximum_E_Value_before_Reset_float': DEFSET,
                        'Minimum_Travel_for_Retraction_millimeters': storedSettingFloat("retraction_min_travel"),
                        'Retract_Within_Island': storedSettingInvertBoolean("retract_on_jumps_only"),
-                       'Retraction_Distance_millimeters': storedSettingFloat('retraction_amount'),
+                       'Retraction_Distance_millimeters': lambda setting: profile.getProfileSettingFloat('retraction_amount') if profile.getProfileSetting('retraction_enable') == 'True' else 0,
                        'Restart_Extra_Distance_millimeters': storedSettingFloat('retraction_extra'),
                },'alteration': {
                        'Activate_Alteration': storedSetting('add_start_end_gcode'),
index 105e77f8df64f1d147676f8538736d0c92b42e9c..b1e64747163840cdf6144b85b761d4a41c235982 100644 (file)
@@ -334,7 +334,7 @@ class UltimakerCheckupPage(InfoPage):
        def mcLog(self, message):\r
                pass\r
 \r
-       def mcTempUpdate(self, temp, bedTemp):\r
+       def mcTempUpdate(self, temp, bedTemp, targetTemp, bedTargetTemp):\r
                if self.checkupState == 0:\r
                        self.tempCheckTimeout = 20\r
                        if temp > 70:\r
index 39e733a326eb62cc324941c570e24877a39b7ca8..925cced9ecbc6d7fd4ca10fa50f8c506eb3f6115 100644 (file)
@@ -124,6 +124,7 @@ class mainWindow(configBase.configWindowBase):
                c = configBase.SettingRow(left, "Wall thickness (mm)", 'wall_thickness', '0.8', 'Thickness of the walls.\nThis is used in combination with the nozzle size to define the number\nof perimeter lines and the thickness of those perimeter lines.')
                validators.validFloat(c, 0.0001)
                validators.wallThicknessValidator(c)
+               c = configBase.SettingRow(left, "Enable retraction", 'retraction_enable', False, 'Retract the filament when the nozzle is moving over a none-printed area. Details about the retraction can be configured in the advanced tab.')
                
                configBase.TitleRow(left, "Fill")
                c = configBase.SettingRow(left, "Bottom/Top thickness (mm)", 'solid_layer_thickness', '0.6', 'This controls the thickness of the bottom and top layers, the amount of solid layers put down is calculated by the layer thickness and this value.\nHaving this value a multiply of the layer thickness makes sense. And keep it near your wall thickness to make an evenly strong part.')
index 4eb91444057d93b7398a07bd72aaebf7c028d93f..e2df8b2e1cd5d6b4edb5603eca3471c3573df5ce 100644 (file)
@@ -55,11 +55,11 @@ class printProcessMonitor():
                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
@@ -70,11 +70,8 @@ class PrintCommandButton(buttons.GenBitmapButton):
        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
@@ -163,33 +160,36 @@ class printWindow(wx.Frame):
                \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
@@ -248,11 +248,13 @@ class printWindow(wx.Frame):
                        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
@@ -330,6 +332,9 @@ class printWindow(wx.Frame):
                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
@@ -485,6 +490,7 @@ class printWindow(wx.Frame):
                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
@@ -507,8 +513,12 @@ class printWindow(wx.Frame):
                #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
index acabd652cc96d36b1faef80d0f4f1a2d32194344..8e5b4823b8eaf97510d8768969983ed644447f84 100644 (file)
@@ -39,7 +39,7 @@ class simpleModeWindow(configBase.configWindowBase):
                toolsMenu = wx.Menu()
                i = toolsMenu.Append(-1, 'Switch to Normal mode...')
                self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i)
-               menubar.Append(toolsMenu, 'Tools')
+               menubar.Append(toolsMenu, 'Normal mode')
                
                helpMenu = wx.Menu()
                i = helpMenu.Append(-1, 'Online documentation...')
@@ -180,10 +180,11 @@ class simpleModeWindow(configBase.configWindowBase):
                put('support', 'None')
                #put('machine_center_x', '100')
                #put('machine_center_y', '100')
-               #put('retraction_min_travel', '5.0')
-               #put('retraction_speed', '13.5')
-               #put('retraction_amount', '0.0')
-               #put('retraction_extra', '0.0')
+               put('retraction_enable', 'True')
+               put('retraction_min_travel', '5.0')
+               put('retraction_speed', '13.5')
+               put('retraction_amount', '4.5')
+               put('retraction_extra', '0.0')
                put('travel_speed', '150')
                put('max_z_speed', '3.0')
                put('bottom_layer_speed', '25')
index 3e3b1f7e873fce1b1a948d61c5ba2ce41a5dc4a4..6ea4ad0a4757b0135e68cd9e2b3e696cb0c798db 100644 (file)
@@ -62,12 +62,12 @@ class VirtualPrinter():
                #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:
@@ -103,7 +103,7 @@ class MachineComPrintCallback(object):
        def mcLog(self, message):
                pass
        
-       def mcTempUpdate(self, temp, bedTemp):
+       def mcTempUpdate(self, temp, bedTemp, targetTemp, bedTargetTemp):
                pass
        
        def mcStateChange(self, state):
@@ -151,6 +151,8 @@ class MachineCom(object):
                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()
@@ -287,20 +289,24 @@ class MachineCom(object):
                                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()
@@ -331,6 +337,7 @@ class MachineCom(object):
                                                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)
@@ -410,11 +417,27 @@ class MachineCom(object):
                        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()
index c0f6a745c006c3c98fb0c71d4d848135972eec7d..a528c1eb4d53886f3a7d3ec88eb03d3de7d3ea6f 100644 (file)
@@ -23,7 +23,7 @@ profileDefaultSettings = {
        'skirt_line_count': '1',\r
        'skirt_gap': '3.0',\r
        'print_speed': '50',\r
-       'print_temperature': '230',\r
+       'print_temperature': '220',\r
        'print_bed_temperature': '70',\r
        'support': 'None',\r
        'filament_diameter': '2.89',\r
@@ -31,8 +31,9 @@ profileDefaultSettings = {
        'machine_center_x': '100',\r
        'machine_center_y': '100',\r
        'retraction_min_travel': '5.0',\r
+       'retraction_enable': 'False',\r
        'retraction_speed': '40.0',\r
-       'retraction_amount': '0.0',\r
+       'retraction_amount': '4.5',\r
        'retraction_extra': '0.0',\r
        'retract_on_jumps_only': 'True',\r
        'travel_speed': '150',\r