From 2cba5e4183c7713fd87616ba15e6331ad815d459 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Mar 2012 15:14:12 +0100 Subject: [PATCH] Fix problems with serial connection Added first version of steps per E Added more GCode path preview (lower layers) --- SkeinPyPy_NewUI/avr_isp/stk500v2.py | 5 +++- .../fabmetheus_utilities/settings.py | 12 ++++---- SkeinPyPy_NewUI/newui/configWizard.py | 29 +++++++++++++++---- SkeinPyPy_NewUI/newui/machineCom.py | 4 ++- SkeinPyPy_NewUI/newui/mainWindow.py | 6 ++-- SkeinPyPy_NewUI/newui/preview3d.py | 4 +-- SkeinPyPy_NewUI/skeinpypy.py | 1 + 7 files changed, 42 insertions(+), 19 deletions(-) diff --git a/SkeinPyPy_NewUI/avr_isp/stk500v2.py b/SkeinPyPy_NewUI/avr_isp/stk500v2.py index b384d651..97cf8a31 100644 --- a/SkeinPyPy_NewUI/avr_isp/stk500v2.py +++ b/SkeinPyPy_NewUI/avr_isp/stk500v2.py @@ -13,7 +13,10 @@ class Stk500v2(ispBase.IspBase): def connect(self, port = 'COM3', speed = 115200): if self.serial != None: self.close() - self.serial = Serial(port, speed, timeout=1) + try: + self.serial = Serial(port, speed, timeout=1) + except Serial.SerialException as e: + raise ispBase.IspError("Failed to open serial port") self.seq = 1 #Reset the controller diff --git a/SkeinPyPy_NewUI/fabmetheus_utilities/settings.py b/SkeinPyPy_NewUI/fabmetheus_utilities/settings.py index 6cf7c00c..fccb85b1 100644 --- a/SkeinPyPy_NewUI/fabmetheus_utilities/settings.py +++ b/SkeinPyPy_NewUI/fabmetheus_utilities/settings.py @@ -22,8 +22,8 @@ def storedSetting(name): def ifSettingAboveZero(name): return lambda setting: float(getProfileSetting(name, '0.0')) > 0 -def ifSettingIs(name, value): - return lambda setting: getProfileSetting(name) == value +def ifSettingIs(name, value, default): + return lambda setting: getProfileSetting(name, default) == value def storedPercentSetting(name): return lambda setting: float(getProfileSetting(name, setting.value)) / 100 @@ -134,10 +134,10 @@ def getSkeinPyPyProfileInformation(): 'Infill_Begin_Rotation_degrees': DEFSET, 'Infill_Begin_Rotation_Repeat_layers': DEFSET, 'Infill_Odd_Layer_Extra_Rotation_degrees': DEFSET, - 'Grid_Circular': ifSettingIs('infill_type', 'Grid Circular'), - 'Grid_Hexagonal': ifSettingIs('infill_type', 'Grid Hexagonal'), - 'Grid_Rectangular': ifSettingIs('infill_type', 'Grid Rectangular'), - 'Line': ifSettingIs('infill_type', 'Line'), + 'Grid_Circular': ifSettingIs('infill_type', 'Grid Circular', 'Line'), + 'Grid_Hexagonal': ifSettingIs('infill_type', 'Grid Hexagonal', 'Line'), + 'Grid_Rectangular': ifSettingIs('infill_type', 'Grid Rectangular', 'Line'), + 'Line': ifSettingIs('infill_type', 'Line', 'Line'), 'Infill_Perimeter_Overlap_ratio': DEFSET, 'Infill_Solidity_ratio': storedPercentSetting('fill_density'), 'Infill_Width': storedSetting("nozzle_size"), diff --git a/SkeinPyPy_NewUI/newui/configWizard.py b/SkeinPyPy_NewUI/newui/configWizard.py index 2dbeb904..1ca0ca06 100644 --- a/SkeinPyPy_NewUI/newui/configWizard.py +++ b/SkeinPyPy_NewUI/newui/configWizard.py @@ -176,7 +176,8 @@ class UltimakerCheckupPage(InfoPage): wx.CallAfter(self.AddProgressText, "Disabling step motors...") if self.DoCommCommandWithTimeout('M84') == False: - wx.CallAfter(self.AddProgressText, "Error: Missing reply to M84.") + wx.CallAfter(self.AddProgressText, "Error: Missing reply to Deactivate steppers (M84).") + wx.CallAfter(self.AddProgressText, "Possible cause: Temperature MIN/MAX.\nCheck temperature sensor connections.") return wx.MessageBox('Please move the printer head to the center of the machine\nalso move the platform so it is not at the highest or lowest position,\nand make sure the machine is powered on.', 'Machine check', wx.OK | wx.ICON_INFORMATION) @@ -184,18 +185,19 @@ class UltimakerCheckupPage(InfoPage): idleTemp = self.readTemp() wx.CallAfter(self.AddProgressText, "Checking heater and temperature sensor...") + wx.CallAfter(self.AddProgressText, "(This takes about 30 seconds)") if self.DoCommCommandWithTimeout("M104 S100") == False: wx.CallAfter(self.AddProgressText, "Failed to set temperature") return - time.sleep(20) + time.sleep(25) tempInc = self.readTemp() - idleTemp if self.DoCommCommandWithTimeout("M104 S0") == False: wx.CallAfter(self.AddProgressText, "Failed to set temperature") return - if tempInc < 20: + if tempInc < 15: wx.CallAfter(self.AddProgressText, "Your temperature sensor or heater is not working!") return wx.CallAfter(self.AddProgressText, "Heater and temperature sensor working\nWarning: head might still be hot!") @@ -288,24 +290,41 @@ class UltimakerCalibrationPage(InfoPage): def StoreData(self): settings.putProfileSetting('filament_diameter', self.filamentDiameter.GetValue()) +class UltimakerCalibrateStepsPerEPage(InfoPage): + def __init__(self, parent): + super(UltimakerCalibrateStepsPerEPage, self).__init__(parent, "Ultimaker Calibration") + + self.AddText("Calibrating the Steps Per E requires some manual actions.") + self.AddText("First remove any filament from your machine.") + self.AddText("Next put in your filament so the tip is aligned with the\ntop of the extruder drive.") + self.AddText("We'll push the filament 100mm") + self.AddText("[BUTTON:PUSH 100mm]") + self.AddText("Now measure the amount of extruded filament:\n(this can be more or less then 100mm)") + self.AddText("[INPUT:MEASUREMENT][BUTTON:SAVE]") + self.AddText("This results in the following steps per E:") + self.AddText("[INPUT:E_RESULT]") + self.AddText("You can repeat these steps to get better calibration.") + class configWizard(wx.wizard.Wizard): def __init__(self): super(configWizard, self).__init__(None, -1, "Configuration Wizard") self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGED, self.OnPageChanged) self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.OnPageChanging) - + self.firstInfoPage = FirstInfoPage(self) self.machineSelectPage = MachineSelectPage(self) self.ultimakerFirmwareUpgradePage = FirmwareUpgradePage(self) self.ultimakerCheckupPage = UltimakerCheckupPage(self) self.ultimakerCalibrationPage = UltimakerCalibrationPage(self) + self.ultimakerCalibrateStepsPerEPage = UltimakerCalibrateStepsPerEPage(self) self.repRapInfoPage = RepRapInfoPage(self) - + wx.wizard.WizardPageSimple.Chain(self.firstInfoPage, self.machineSelectPage) wx.wizard.WizardPageSimple.Chain(self.machineSelectPage, self.ultimakerFirmwareUpgradePage) wx.wizard.WizardPageSimple.Chain(self.ultimakerFirmwareUpgradePage, self.ultimakerCheckupPage) wx.wizard.WizardPageSimple.Chain(self.ultimakerCheckupPage, self.ultimakerCalibrationPage) + wx.wizard.WizardPageSimple.Chain(self.ultimakerCalibrationPage, self.ultimakerCalibrateStepsPerEPage) self.FitToPage(self.firstInfoPage) self.GetPageAreaSizer().Add(self.firstInfoPage) diff --git a/SkeinPyPy_NewUI/newui/machineCom.py b/SkeinPyPy_NewUI/newui/machineCom.py index c88699b0..47041ed9 100644 --- a/SkeinPyPy_NewUI/newui/machineCom.py +++ b/SkeinPyPy_NewUI/newui/machineCom.py @@ -25,7 +25,7 @@ def serialList(): i+=1 except: pass - return baselist+glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') +glob.glob("/dev/tty.*")+glob.glob("/dev/cu.*")+glob.glob("/dev/rfcomm*") + return baselist+glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') +glob.glob("/dev/tty.usb*")+glob.glob("/dev/cu.*")+glob.glob("/dev/rfcomm*") class InstallFirmware(wx.Dialog): def __init__(self, filename, port = 'AUTO'): @@ -61,6 +61,7 @@ class InstallFirmware(wx.Dialog): for self.port in serialList(): try: programmer.connect(self.port) + break except ispBase.IspError: pass else: @@ -107,6 +108,7 @@ class MachineCom(): programmer.connect(port) programmer.close() self.serial = Serial(port, baudrate, timeout=5) + break except ispBase.IspError: pass programmer.close() diff --git a/SkeinPyPy_NewUI/newui/mainWindow.py b/SkeinPyPy_NewUI/newui/mainWindow.py index 77ca4ca6..b6fb9a3f 100644 --- a/SkeinPyPy_NewUI/newui/mainWindow.py +++ b/SkeinPyPy_NewUI/newui/mainWindow.py @@ -17,6 +17,9 @@ from newui import machineCom def main(): app = wx.App(False) + if settings.getPreference('wizardDone', 'False') == 'False': + configWizard.configWizard() + settings.putPreference("wizardDone", "True") mainWindow() app.MainLoop() @@ -27,9 +30,6 @@ class mainWindow(configBase.configWindowBase): wx.EVT_CLOSE(self, self.OnClose) - if settings.getPreference('wizardDone', 'False') == 'False': - configWizard.configWizard() - menubar = wx.MenuBar() fileMenu = wx.Menu() i = fileMenu.Append(-1, 'Open Profile...') diff --git a/SkeinPyPy_NewUI/newui/preview3d.py b/SkeinPyPy_NewUI/newui/preview3d.py index 51201746..0ae626db 100644 --- a/SkeinPyPy_NewUI/newui/preview3d.py +++ b/SkeinPyPy_NewUI/newui/preview3d.py @@ -317,8 +317,6 @@ class PreviewGLCanvas(glcanvas.GLCanvas): if path['layerNr'] != self.parent.layerSpin.GetValue(): if path['layerNr'] < self.parent.layerSpin.GetValue(): c = 0.5 - (self.parent.layerSpin.GetValue() - path['layerNr']) * 0.1 - if c < -0.5: - continue if c < 0.1: c = 0.1 else: @@ -334,7 +332,7 @@ class PreviewGLCanvas(glcanvas.GLCanvas): glColor3f(c,0,0) if path['type'] == 'retract': glColor3f(0,c,c) - if path['type'] == 'extrude': + if c > 0.1 and path['type'] == 'extrude': if path['pathType'] == 'FILL': lineWidth = self.fillLineWidth / 2 else: diff --git a/SkeinPyPy_NewUI/skeinpypy.py b/SkeinPyPy_NewUI/skeinpypy.py index c701b9b9..5a706ac4 100644 --- a/SkeinPyPy_NewUI/skeinpypy.py +++ b/SkeinPyPy_NewUI/skeinpypy.py @@ -10,6 +10,7 @@ The slicing code is the same as Skeinforge. But the UI has been revamped to be.. """ from __future__ import absolute_import +import __init__ import sys import platform -- 2.30.2