mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
USBPrinting: Huge clean up in _getDefaultFirmwareName
* Moving TODO on top of if clauses * Moving all machine types and hex-file names into dictionaries * Adding error messages for unknown printers
This commit is contained in:
parent
97a7cee3e2
commit
29ea25d0b3
1 changed files with 31 additions and 24 deletions
|
@ -139,33 +139,40 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension):
|
||||||
baudrate = 115200
|
baudrate = 115200
|
||||||
else:
|
else:
|
||||||
baudrate = 250000
|
baudrate = 250000
|
||||||
if machine_type == "ultimaker_original":
|
|
||||||
firmware_name = "MarlinUltimaker"
|
machine_without_heated_bed = {"ultimaker_original" : "MarlinUltimaker-{baudrate}.hex",
|
||||||
if machine_instance.getMachineSettingValue("machine_heated_bed"): #Has heated bed upgrade kit?
|
"ultimaker_original_plus" : "MarlinUltimaker-UMOP-{baudrate}.hex",
|
||||||
firmware_name += "-HBK"
|
"bq_witbox" : "MarlinWitbox.hex",
|
||||||
firmware_name += "-%d" % (baudrate)
|
"ultimaker2_go" : "MarlinUltimaker2go.hex",
|
||||||
return firmware_name + ".hex"
|
"ultimaker2_extended" : "MarlinUltimaker2extended.hex",
|
||||||
elif machine_type == "ultimaker_original_plus":
|
"ultimaker2" : "MarlinUltimaker2.hex",
|
||||||
firmware_name = "MarlinUltimaker-UMOP-%d" % (baudrate)
|
"ultimaker2plus" : "MarlinUltimaker2plus.hex",
|
||||||
return firmware_name + ".hex"
|
"ultimaker2_extended_plus" : "MarlinUltimaker2extended-plus.hex",
|
||||||
elif machine_type == "bq_witbox":
|
}
|
||||||
return "MarlinWitbox.hex"
|
machine_with_heated_bed = {"ultimaker_original-HBK-{baudrate}.hex",
|
||||||
elif machine_type == "ultimaker2_go":
|
}
|
||||||
return "MarlinUltimaker2go.hex"
|
|
||||||
elif machine_type == "ultimaker2_extended":
|
|
||||||
return "MarlinUltimaker2extended.hex"
|
|
||||||
elif machine_type == "ultimaker2":
|
|
||||||
return "MarlinUltimaker2.hex"
|
|
||||||
elif machine_type == "ultimaker2plus":
|
|
||||||
return "MarlinUltimaker2plus.hex"
|
|
||||||
elif machine_type == "ultimaker2_extended_plus":
|
|
||||||
return "MarlinUltimaker2extended-plus.hex"
|
|
||||||
else:
|
|
||||||
Logger.log("e", "I don't know of any firmware for machine %s.", machine_type)
|
|
||||||
raise FileNotFoundError()
|
|
||||||
|
|
||||||
##TODO: Add check for multiple extruders
|
##TODO: Add check for multiple extruders
|
||||||
|
|
||||||
|
hex_file = None
|
||||||
|
if not machine_instance.getMachineSettingValue("machine_heated_bed"):
|
||||||
|
if machine_type in machine_without_heated_bed.keys():
|
||||||
|
hex_file = machine_without_heated_bed[machine_type]
|
||||||
|
else:
|
||||||
|
Logger.log("e", "There is no firmware for machine %s.", machine_type)
|
||||||
|
else:
|
||||||
|
if machine_type in machine_with_heated_bed.keys():
|
||||||
|
hex_file = machine_without_heated_bed[machine_type]
|
||||||
|
else:
|
||||||
|
Logger.log("e", "There is no firmware for machine %s with heated bed.", machine_type)
|
||||||
|
|
||||||
|
if hex_file:
|
||||||
|
return hex_file.format(baudrate=baudrate)
|
||||||
|
else:
|
||||||
|
Logger.log("e", "Could not find any firmware for machine %s.", machine_type)
|
||||||
|
raise FileNotFoundError()
|
||||||
|
|
||||||
|
|
||||||
def _addRemovePorts(self, serial_ports):
|
def _addRemovePorts(self, serial_ports):
|
||||||
# First, find and add all new or changed keys
|
# First, find and add all new or changed keys
|
||||||
for serial_port in list(serial_ports):
|
for serial_port in list(serial_ports):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue