X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=Cura%2Fgui%2FfirmwareInstall.py;h=722a293be798b78fd98f04d7eb1d443eba229d7c;hb=730e8f2c1c8dfc9498a1b416cc398606f60940c3;hp=088bb765e6e0a91e9d67242754f6930b62ae6eba;hpb=638290a2fb4208c216f7294f93d9aa0e7fc6c113;p=cura.git diff --git a/Cura/gui/firmwareInstall.py b/Cura/gui/firmwareInstall.py index 088bb765..722a293b 100644 --- a/Cura/gui/firmwareInstall.py +++ b/Cura/gui/firmwareInstall.py @@ -17,6 +17,31 @@ from Cura.util import profile from Cura.util import resources def getDefaultFirmware(machineIndex = None): + firmwareDict = { + 'ultimaker2go':"MarlinUltimaker2go.hex", + 'Witbox':"MarlinWitbox.hex", + 'lulzbot_mini': "Mini-Single-or-Flexystruder-LBHexagon-2015Q2.hex", + 'lulzbot_mini_flexystruder': "Mini-Single-or-Flexystruder-LBHexagon-2015Q2.hex", + 'lulzbot_TAZ_4_SingleV1': "Taz4-5-Single-or-Flexystruder-Budaschnozzle-2014Q3.hex", + 'lulzbot_TAZ_5_SingleV1': "Taz4-5-Single-or-Flexystruder-Budaschnozzle-2014Q3.hex", + 'lulzbot_TAZ_4_05nozzle': "Taz4-Single-Extruder-LBHexagon-2015Q3.hex", + 'lulzbot_TAZ_5_05nozzle': "Taz5-Single-Extruder-LBHexagon-2015Q3.hex", + 'lulzbot_TAZ_4_035nozzle': "Taz4-Single-Extruder-LBHexagon-2015Q3.hex", + 'lulzbot_TAZ_5_035nozzle': "Taz5-Single-Extruder-LBHexagon-2015Q3.hex", + 'lulzbot_TAZ_4_FlexystruderV1': "Taz4-5-Single-or-Flexystruder-Budaschnozzle-2014Q3.hex", + 'lulzbot_TAZ_5_FlexystruderV1': "Taz4-5-Single-or-Flexystruder-Budaschnozzle-2014Q3.hex", + 'lulzbot_TAZ_4_FlexystruderV2': "Taz4-5-Flexystruder-LBHexagon-2015Q3.hex", + 'lulzbot_TAZ_5_FlexystruderV2': "Taz4-5-Flexystruder-LBHexagon-2015Q3.hex", + 'lulzbot_TAZ_4_DualV1': "Taz4-5-Dual-or-FlexyDually-Budaschnozzle-2015Q1.hex", + 'lulzbot_TAZ_5_DualV1': "Taz4-5-Dual-or-FlexyDually-Budaschnozzle-2015Q1.hex", + 'lulzbot_TAZ_4_DualV2': "Taz4-5-Dual-LBHexagon-2015Q3.hex", + 'lulzbot_TAZ_5_DualV2': "Taz4-5-Dual-LBHexagon-2015Q3.hex", + 'lulzbot_TAZ_4_FlexyDuallyV1': "Taz4-5-Dual-or-FlexyDually-Budaschnozzle-2015Q1.hex", + 'lulzbot_TAZ_5_FlexyDuallyV1': "Taz4-5-Dual-or-FlexyDually-Budaschnozzle-2015Q1.hex", + 'lulzbot_TAZ_4_FlexyDuallyV2': "Taz4-5-FlexyDually-LBHexagon-2015Q3.hex", + 'lulzbot_TAZ_5_FlexyDuallyV2': "Taz4-5-FlexyDually-LBHexagon-2015Q3.hex", + 'lulzbot_TAZ_6_SingleTilapia': "Taz6-Single-Tilapia-2015-Q4.hex" + } machine_type = profile.getMachineSetting('machine_type', machineIndex) extruders = profile.getMachineSettingFloat('extruder_amount', machineIndex) heated_bed = profile.getMachineSetting('has_heated_bed', machineIndex) == 'True' @@ -41,44 +66,20 @@ def getDefaultFirmware(machineIndex = None): if extruders > 1: name += '-dual' return resources.getPathForFirmware(name + '.hex') - if machine_type == 'ultimaker2': if extruders > 2: return None if extruders > 1: return resources.getPathForFirmware("MarlinUltimaker2-dual.hex") return resources.getPathForFirmware("MarlinUltimaker2.hex") - if machine_type == 'lulzbot_mini': - return resources.getPathForFirmware("Mini_SingleV2_2014Q4.hex") - if machine_type == 'lulzbot_mini_flexy': - return resources.getPathForFirmware("Mini_FlexyV2_2014Q4.hex") - if machine_type == 'lulzbot_TAZ_4_SingleV1' or machine_type == 'lulzbot_TAZ_5_Single_V1': - return resources.getPathForFirmware("TAZ4-5_SingleV1_2014Q1.hex") - if machine_type == 'lulzbot_TAZ_4_05nozzle' or machine_type == 'lulzbot_TAZ_5_05nozzle' or \ - machine_type == 'lulzbot_TAZ_4_035nozzle' or machine_type == 'lulzbot_TAZ_5_035nozzle': - return resources.getPathForFirmware("TAZ4-5_SingleV2_2015Q1.hex") - if machine_type == 'lulzbot_TAZ_4_FlexystruderV1' or machine_type == 'lulzbot_TAZ_5_FlexystruderV1': - return resources.getPathForFirmware("TAZ4-5_FlexystrderV1_2015Q3.hex") - if machine_type == 'lulzbot_TAZ_4_FlexystruderV2' or machine_type == 'lulzbot_TAZ_5_FlexystruderV2': - return resources.getPathForFirmware("TAZ4-5_FlexystrderV2_2015Q3.hex") - if machine_type == 'lulzbot_TAZ_4_DuallyV1' or machine_type == 'lulzbot_TAZ_5_DuallyV1': - return resources.getPathForFirmware("TAZ4-5_Dual-Extruder_V1_2015Q3.hex") - if machine_type == 'lulzbot_TAZ_4_DuallyV2' or machine_type == 'lulzbot_TAZ_5_DuallyV2': - return resources.getPathForFirmware("TAZ4-5_Dual-Extruder_V2_2015Q3.hex") - if machine_type == 'lulzbot_TAZ_4_FlexyDuallyV1' or machine_type == 'lulzbot_TAZ_5_FlexyDuallyV1': - return resources.getPathForFirmware("TAZ4-5_FlexyDually-V1_2015Q3.hex") - if machine_type == 'lulzbot_TAZ_4_FlexyDuallyV2' or machine_type == 'lulzbot_TAZ_5_FlexyDuallyV2': - return resources.getPathForFirmware("TAZ4-5_FlexyDually-V2_2015Q3.hex") - if machine_type == 'ultimaker2go': - return resources.getPathForFirmware("MarlinUltimaker2go.hex") if machine_type == 'ultimaker2extended': if extruders > 2: return None if extruders > 1: return resources.getPathForFirmware("MarlinUltimaker2extended-dual.hex") return resources.getPathForFirmware("MarlinUltimaker2extended.hex") - if machine_type == 'Witbox': - return resources.getPathForFirmware("MarlinWitbox.hex") + if firmwareDict.has_key(machine_type): + return resources.getPathForFirmware(firmwareDict[machine_type]) return None def InstallFirmware(parent = None, filename = None, port = None, machineIndex = None): @@ -94,10 +95,6 @@ class InstallFirmwareDialog(wx.Dialog): port = profile.getMachineSetting('serial_port') if filename is None: filename = getDefaultFirmware(machineIndex) - if filename is None: - wx.MessageBox(_("I am sorry, but Cura does not ship with a default firmware for your machine configuration."), _("Firmware update"), wx.OK | wx.ICON_ERROR) - self.Destroy() - return self._machine_type = profile.getMachineSetting('machine_type', machineIndex) if self._machine_type == 'reprap': wx.MessageBox(_("Cura only supports firmware updates for ATMega2560 based hardware.\nSo updating your RepRap with Cura might or might not work."), _("Firmware update"), wx.OK | wx.ICON_INFORMATION) @@ -120,14 +117,23 @@ class InstallFirmwareDialog(wx.Dialog): self.Layout() self.Fit() self.success = False + self.show_connect_dialog = False def Run(self): + if self.filename is None: + wx.MessageBox(_("I am sorry, but Cura does not ship with a default firmware for your machine configuration."), _("Firmware update"), wx.OK | wx.ICON_ERROR) + return False self.success = False self.thread = threading.Thread(target=self.OnRun) self.thread.daemon = True self.thread.start() self.ShowModal() + # Creating a MessageBox in a separate thread while main thread is locked inside a ShowModal + # will cause Python to crash with X errors. So we need to show the dialog here instead + if self.show_connect_dialog: + wx.MessageBox(_("Failed to find machine for firmware upgrade\nIs your machine connected to the PC?"), + _("Firmware update"), wx.OK | wx.ICON_ERROR) return self.success def OnRun(self): @@ -137,7 +143,7 @@ class InstallFirmwareDialog(wx.Dialog): programmer = stk500v2.Stk500v2() programmer.progressCallback = self.OnProgress if self.port == 'AUTO': - wx.CallAfter(self.updateLabel, _("Please connect the printer to\nyour computer with the USB cable.")) + wx.CallAfter(self.updateLabel, _("Please connect the printer to your\ncomputer with a USB cable and power it on.")) while not programmer.isConnected(): for self.port in machineCom.serialList(True): try: @@ -154,10 +160,12 @@ class InstallFirmwareDialog(wx.Dialog): programmer.connect(self.port) except ispBase.IspError: programmer.close() + if not self: + #Window destroyed + return if not programmer.isConnected(): - wx.MessageBox(_("Failed to find machine for firmware upgrade\nIs your machine connected to the PC?"), - _("Firmware update"), wx.OK | wx.ICON_ERROR) + self.show_connect_dialog = True wx.CallAfter(self.Close) return @@ -187,7 +195,7 @@ class InstallFirmwareDialog(wx.Dialog): def updateLabel(self, text): self.progressLabel.SetLabel(text) - #self.Layout() + self.Layout() def OnProgress(self, value, max): if self: @@ -306,7 +314,7 @@ class AutoUpdateFirmware(wx.Dialog): programmer = stk500v2.Stk500v2() programmer.progressCallback = self.OnProgress if self.port == 'AUTO': - wx.CallAfter(self.updateLabel, _("Please connect the printer to\nyour computer with the USB cable.")) + wx.CallAfter(self.updateLabel, _("Please connect the printer to your\ncomputer with a USB cable and power it on.")) while not programmer.isConnected(): for self.port in machineCom.serialList(True): try: @@ -340,7 +348,7 @@ class AutoUpdateFirmware(wx.Dialog): def updateLabel(self, text): self.progressLabel.SetLabel(text) - #self.Layout() + self.Layout() def OnProgress(self, value, max): wx.CallAfter(self.progressGauge.SetRange, max)