From bd70a8e2dd5f1c0da4532bf3fedc16650b288353 Mon Sep 17 00:00:00 2001 From: daid303 Date: Mon, 29 Apr 2013 13:54:14 +0200 Subject: [PATCH] Update to the bed leveling wizard to allow insertion of filament, and fixing the integer bug. --- Cura/gui/configWizard.py | 84 +++++++++++++++++++++------------------- Cura/gui/sceneView.py | 17 ++++++++ Cura/util/machineCom.py | 1 + 3 files changed, 62 insertions(+), 40 deletions(-) diff --git a/Cura/gui/configWizard.py b/Cura/gui/configWizard.py index f1a2b2ea..f401d972 100644 --- a/Cura/gui/configWizard.py +++ b/Cura/gui/configWizard.py @@ -351,8 +351,8 @@ class FirmwareUpgradePage(InfoPage): self.AddText('Do not upgrade to this firmware if:') self.AddText('* You have an older machine based on ATMega1280') self.AddText('* Have other changes in the firmware') - button = self.AddButton('Goto this page for a custom firmware') - button.Bind(wx.EVT_BUTTON, self.OnUrlClick) +# button = self.AddButton('Goto this page for a custom firmware') +# button.Bind(wx.EVT_BUTTON, self.OnUrlClick) def AllowNext(self): return False @@ -802,7 +802,7 @@ class bedLevelWizardMain(InfoPage): return True def OnResume(self, e): - feedZ = profile.getProfileSettingFloat('max_z_speed') * 60 + feedZ = profile.getProfileSettingFloat('print_speed') * 60 feedTravel = profile.getProfileSettingFloat('travel_speed') * 60 if self._wizardState == 2: wx.CallAfter(self.infoBox.SetBusy, 'Moving head to back left corner...') @@ -814,14 +814,14 @@ class bedLevelWizardMain(InfoPage): elif self._wizardState == 4: wx.CallAfter(self.infoBox.SetBusy, 'Moving head to back right corner...') self.comm.sendCommand('G1 Z3 F%d' % (feedZ)) - self.comm.sendCommand('G1 X%d Y%d F%d' % (profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth') - 25, feedTravel)) + self.comm.sendCommand('G1 X%d Y%d F%d' % (profile.getPreferenceFloat('machine_width') - 5.0, profile.getPreferenceFloat('machine_depth') - 25, feedTravel)) self.comm.sendCommand('G1 Z0 F%d' % (feedZ)) self.comm.sendCommand('M400') self._wizardState = 5 elif self._wizardState == 6: wx.CallAfter(self.infoBox.SetBusy, 'Moving head to front right corner...') self.comm.sendCommand('G1 Z3 F%d' % (feedZ)) - self.comm.sendCommand('G1 X%d Y%d F%d' % (profile.getPreferenceFloat('machine_width'), 20, feedTravel)) + self.comm.sendCommand('G1 X%d Y%d F%d' % (profile.getPreferenceFloat('machine_width') - 5.0, 20, feedTravel)) self.comm.sendCommand('G1 Z0 F%d' % (feedZ)) self.comm.sendCommand('M400') self._wizardState = 7 @@ -831,6 +831,40 @@ class bedLevelWizardMain(InfoPage): self.comm.sendCommand('M104 S%d' % (profile.getProfileSettingFloat('print_temperature'))) self.comm.sendCommand('G1 X%d Y%d F%d' % (0, 0, feedTravel)) self._wizardState = 9 + elif self._wizardState == 10: + self._wizardState = 11 + wx.CallAfter(self.infoBox.SetInfo, 'Printing a square on the printer bed at 0.3mm height.') + feedZ = profile.getProfileSettingFloat('print_speed') * 60 + feedPrint = profile.getProfileSettingFloat('print_speed') * 60 + feedTravel = profile.getProfileSettingFloat('travel_speed') * 60 + w = profile.getPreferenceFloat('machine_width') + d = profile.getPreferenceFloat('machine_depth') + filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2 + filamentArea = math.pi * filamentRadius * filamentRadius + ePerMM = (profile.calculateEdgeWidth() * 0.3) / filamentArea + eValue = 0.0 + + gcodeList = [ + 'G1 Z2 F%d' % (feedZ), + 'G92 E0', + 'G1 X%d Y%d F%d' % (5, 5, feedTravel), + 'G1 Z0.3 F%d' % (feedZ)] + eValue += 5.0 + gcodeList.append('G1 E%f F%d' % (eValue, profile.getProfileSettingFloat('retraction_speed') * 60)) + + for i in xrange(0, 3): + dist = 5.0 + 0.4 * float(i) + eValue += (d - 2.0*dist) * ePerMM + gcodeList.append('G1 X%f Y%f E%f F%d' % (dist, d - dist, eValue, feedPrint)) + eValue += (w - 2.0*dist) * ePerMM + gcodeList.append('G1 X%f Y%f E%f F%d' % (w - dist, d - dist, eValue, feedPrint)) + eValue += (d - 2.0*dist) * ePerMM + gcodeList.append('G1 X%f Y%f E%f F%d' % (w - dist, dist, eValue, feedPrint)) + eValue += (w - 2.0*dist) * ePerMM + gcodeList.append('G1 X%f Y%f E%f F%d' % (dist, dist, eValue, feedPrint)) + + gcodeList.append('M400') + self.comm.printGCode(gcodeList) self.resumeButton.Enable(False) def mcLog(self, message): @@ -857,39 +891,9 @@ class bedLevelWizardMain(InfoPage): if temp < profile.getProfileSettingFloat('print_temperature') - 5: wx.CallAfter(self.infoBox.SetInfo, 'Heating up printer: %d/%d' % (temp, profile.getProfileSettingFloat('print_temperature'))) else: + wx.CallAfter(self.infoBox.SetAttention, 'The printer is hot now. Please insert some PLA filament into the printer.') + wx.CallAfter(self.resumeButton.Enable, True) self._wizardState = 10 - wx.CallAfter(self.infoBox.SetInfo, 'Printing a square on the printer bed at 0.3mm height.') - feedZ = profile.getProfileSettingFloat('max_z_speed') * 60 - feedPrint = profile.getProfileSettingFloat('print_speed') * 60 - feedTravel = profile.getProfileSettingFloat('travel_speed') * 60 - w = profile.getPreferenceFloat('machine_width') - d = profile.getPreferenceFloat('machine_depth') - filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2 - filamentArea = math.pi * filamentRadius * filamentRadius - ePerMM = (profile.calculateEdgeWidth() * 0.3) / filamentArea - eValue = 0.0 - - gcodeList = [ - 'G1 Z2 F%d' % (feedZ), - 'G92 E0', - 'G1 X%d Y%d F%d' % (5, 5, feedTravel), - 'G1 Z0.3 F%d' % (feedZ)] - eValue += 5; - gcodeList.append('G1 E%f F%d' % (eValue, profile.getProfileSettingFloat('retraction_speed') * 60)) - - for i in xrange(0, 3): - dist = 5.0 + 0.4 * i - eValue += (d - 2*dist) * ePerMM - gcodeList.append('G1 X%d Y%d E%f F%d' % (dist, d - dist, eValue, feedPrint)) - eValue += (w - 2*dist) * ePerMM - gcodeList.append('G1 X%d Y%d E%f F%d' % (w - dist, d - dist, eValue, feedPrint)) - eValue += (d - 2*dist) * ePerMM - gcodeList.append('G1 X%d Y%d E%f F%d' % (w - dist, dist, eValue, feedPrint)) - eValue += (w - 2*dist) * ePerMM - gcodeList.append('G1 X%d Y%d E%f F%d' % (dist, dist, eValue, feedPrint)) - - gcodeList.append('M400') - self.comm.printGCode(gcodeList) def mcStateChange(self, state): if self.comm is None: @@ -900,8 +904,8 @@ class bedLevelWizardMain(InfoPage): self.comm.sendCommand('M105') self.comm.sendCommand('G28') self._wizardState = 1 - elif self._wizardState == 10 and not self.comm.isPrinting(): - self.comm.sendCommand('G1 Z15 F%d' % (profile.getProfileSettingFloat('max_z_speed') * 60)) + elif self._wizardState == 11 and not self.comm.isPrinting(): + self.comm.sendCommand('G1 Z15 F%d' % (profile.getProfileSettingFloat('print_speed') * 60)) self.comm.sendCommand('G92 E0') self.comm.sendCommand('G1 E-10 F%d' % (profile.getProfileSettingFloat('retraction_speed') * 60)) self.comm.sendCommand('M104 S0') @@ -909,7 +913,7 @@ class bedLevelWizardMain(InfoPage): wx.CallAfter(self.infoBox.SetReadyIndicator) wx.CallAfter(self.GetParent().FindWindowById(wx.ID_FORWARD).Enable) wx.CallAfter(self.connectButton.Enable, True) - self._wizardState = 11 + self._wizardState = 12 elif self.comm.isError(): wx.CallAfter(self.infoBox.SetError, 'Failed to establish connection with the printer.', 'http://wiki.ultimaker.com/Cura:_Connection_problems') diff --git a/Cura/gui/sceneView.py b/Cura/gui/sceneView.py index ccbfd033..5dd682d2 100644 --- a/Cura/gui/sceneView.py +++ b/Cura/gui/sceneView.py @@ -436,6 +436,8 @@ class SceneView(openglGui.glGuiPanel): for m in obj._meshList: if m.vbo is not None and m.vbo.decRef(): self.glReleaseList.append(m.vbo) + import gc + gc.collect() if self._isSimpleMode: self._scene.arrangeAll() self.sceneUpdated() @@ -498,6 +500,21 @@ class SceneView(openglGui.glGuiPanel): if keyCode == wx.WXK_F3 and wx.GetKeyState(wx.WXK_SHIFT): shaderEditor(self, self.ShaderUpdate, self._objectLoadShader.getVertexShader(), self._objectLoadShader.getFragmentShader()) + if keyCode == wx.WXK_F4 and wx.GetKeyState(wx.WXK_SHIFT): + from collections import defaultdict + from gc import get_objects + self._beforeLeakTest = defaultdict(int) + for i in get_objects(): + self._beforeLeakTest[type(i)] += 1 + if keyCode == wx.WXK_F5 and wx.GetKeyState(wx.WXK_SHIFT): + from collections import defaultdict + from gc import get_objects + self._afterLeakTest = defaultdict(int) + for i in get_objects(): + self._afterLeakTest[type(i)] += 1 + for k in self._afterLeakTest: + if self._afterLeakTest[k]-self._beforeLeakTest[k]: + print k, self._afterLeakTest[k], self._beforeLeakTest[k], self._afterLeakTest[k] - self._beforeLeakTest[k] def ShaderUpdate(self, v, f): s = opengl.GLShader(v, f) diff --git a/Cura/util/machineCom.py b/Cura/util/machineCom.py index 8c1e7e9c..ebfaa88d 100644 --- a/Cura/util/machineCom.py +++ b/Cura/util/machineCom.py @@ -488,6 +488,7 @@ class MachineCom(object): except serial.SerialTimeoutException: self._log("Serial timeout while writing to serial port, trying again.") try: + time.sleep(0.5) self._serial.write(cmd + '\n') except: self._log("Unexpected error while writing serial port: %s" % (getExceptionString())) -- 2.30.2