Move hardcoded firmware-file table to definitions

This commit is contained in:
fieldOfView 2018-08-02 11:50:28 +02:00
parent 3ac5342dfc
commit 339987be9d
11 changed files with 30 additions and 44 deletions

View file

@ -93,57 +93,31 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin):
global_container_stack = self._application.getGlobalContainerStack() global_container_stack = self._application.getGlobalContainerStack()
if not global_container_stack: if not global_container_stack:
Logger.log("e", "There is no global container stack. Can not update firmware.") Logger.log("e", "There is no global container stack. Can not update firmware.")
self._firmware_view.close()
return "" return ""
# The bottom of the containerstack is the machine definition # The bottom of the containerstack is the machine definition
machine_id = global_container_stack.getBottom().id machine_id = global_container_stack.getBottom().id
machine_has_heated_bed = global_container_stack.getProperty("machine_heated_bed", "value") machine_has_heated_bed = global_container_stack.getProperty("machine_heated_bed", "value")
if platform.system() == "Linux":
baudrate = 115200
else:
baudrate = 250000 baudrate = 250000
if platform.system() == "Linux":
# Linux prefers a baudrate of 115200 here because older versions of
# pySerial did not support a baudrate of 250000
baudrate = 115200
# NOTE: The keyword used here is the id of the machine. You can find the id of your machine in the *.json file, eg. # If a firmware file is available, it should be specified in the definition for the printer
# https://github.com/Ultimaker/Cura/blob/master/resources/machines/ultimaker_original.json#L2 hex_file = global_container_stack.getMetaDataEntry("firmware_file", None)
# The *.hex files are stored at a seperate repository: if machine_has_heated_bed:
# https://github.com/Ultimaker/cura-binary-data/tree/master/cura/resources/firmware hex_file = global_container_stack.getMetaDataEntry("firmware_hbk_file", hex_file)
machine_without_extras = {"bq_witbox" : "MarlinWitbox.hex",
"bq_hephestos_2" : "MarlinHephestos2.hex",
"ultimaker_original" : "MarlinUltimaker-{baudrate}.hex",
"ultimaker_original_plus" : "MarlinUltimaker-UMOP-{baudrate}.hex",
"ultimaker_original_dual" : "MarlinUltimaker-{baudrate}-dual.hex",
"ultimaker2" : "MarlinUltimaker2.hex",
"ultimaker2_go" : "MarlinUltimaker2go.hex",
"ultimaker2_plus" : "MarlinUltimaker2plus.hex",
"ultimaker2_extended" : "MarlinUltimaker2extended.hex",
"ultimaker2_extended_plus" : "MarlinUltimaker2extended-plus.hex",
}
machine_with_heated_bed = {"ultimaker_original" : "MarlinUltimaker-HBK-{baudrate}.hex",
"ultimaker_original_dual" : "MarlinUltimaker-HBK-{baudrate}-dual.hex",
}
##TODO: Add check for multiple extruders
hex_file = None
if machine_id in machine_without_extras.keys(): # The machine needs to be defined here!
if machine_id in machine_with_heated_bed.keys() and machine_has_heated_bed:
Logger.log("d", "Choosing firmware with heated bed enabled for machine %s.", machine_id)
hex_file = machine_with_heated_bed[machine_id] # Return firmware with heated bed enabled
else:
Logger.log("d", "Choosing basic firmware for machine %s.", machine_id)
hex_file = machine_without_extras[machine_id] # Return "basic" firmware
else:
Logger.log("w", "There is no firmware for machine %s.", machine_id)
if hex_file: if hex_file:
try: try:
return Resources.getPath(CuraApplication.ResourceTypes.Firmware, hex_file.format(baudrate=baudrate)) return Resources.getPath(CuraApplication.ResourceTypes.Firmware, hex_file.format(baudrate=baudrate))
except FileNotFoundError: except FileNotFoundError:
Logger.log("w", "Could not find any firmware for machine %s.", machine_id) Logger.log("w", "Firmware file %s not found.", hex_file)
return "" return ""
else: else:
Logger.log("w", "Could not find any firmware for machine %s.", machine_id) Logger.log("w", "There is no firmware for machine %s.", machine_id)
return "" return ""
## Helper to identify serial ports (and scan for them) ## Helper to identify serial ports (and scan for them)

View file

@ -12,7 +12,8 @@
"machine_extruder_trains": "machine_extruder_trains":
{ {
"0": "bq_hephestos_extruder_0" "0": "bq_hephestos_extruder_0"
} },
"firmware_file": "MarlinHephestos2.hex"
}, },
"overrides": { "overrides": {

View file

@ -12,7 +12,8 @@
"machine_extruder_trains": "machine_extruder_trains":
{ {
"0": "bq_witbox_extruder_0" "0": "bq_witbox_extruder_0"
} },
"firmware_file": "MarlinWitbox.hex"
}, },
"overrides": { "overrides": {

View file

@ -20,7 +20,8 @@
"machine_extruder_trains": "machine_extruder_trains":
{ {
"0": "ultimaker2_extruder_0" "0": "ultimaker2_extruder_0"
} },
"firmware_file": "MarlinUltimaker2.hex"
}, },
"overrides": { "overrides": {
"machine_name": { "default_value": "Ultimaker 2" }, "machine_name": { "default_value": "Ultimaker 2" },

View file

@ -14,7 +14,8 @@
"machine_extruder_trains": "machine_extruder_trains":
{ {
"0": "ultimaker2_extended_extruder_0" "0": "ultimaker2_extended_extruder_0"
} },
"firmware_file": "MarlinUltimaker2extended.hex"
}, },
"overrides": { "overrides": {

View file

@ -14,7 +14,8 @@
"machine_extruder_trains": "machine_extruder_trains":
{ {
"0": "ultimaker2_extended_plus_extruder_0" "0": "ultimaker2_extended_plus_extruder_0"
} },
"firmware_file": "MarlinUltimaker2extended-plus.hex"
}, },
"overrides": { "overrides": {

View file

@ -17,7 +17,8 @@
"machine_extruder_trains": "machine_extruder_trains":
{ {
"0": "ultimaker2_go_extruder_0" "0": "ultimaker2_go_extruder_0"
} },
"firmware_file": "MarlinUltimaker2go.hex"
}, },
"overrides": { "overrides": {

View file

@ -19,7 +19,8 @@
"machine_extruder_trains": "machine_extruder_trains":
{ {
"0": "ultimaker2_plus_extruder_0" "0": "ultimaker2_plus_extruder_0"
} },
"firmware_file": "MarlinUltimaker2plus.hex"
}, },
"overrides": { "overrides": {

View file

@ -18,7 +18,9 @@
"machine_extruder_trains": "machine_extruder_trains":
{ {
"0": "ultimaker_original_extruder_0" "0": "ultimaker_original_extruder_0"
} },
"firmware_file": "MarlinUltimaker-{baudrate}.hex",
"firmware_hbk_file": "MarlinUltimaker-HKB-{baudrate}.hex"
}, },
"overrides": { "overrides": {

View file

@ -19,6 +19,8 @@
"0": "ultimaker_original_dual_1st", "0": "ultimaker_original_dual_1st",
"1": "ultimaker_original_dual_2nd" "1": "ultimaker_original_dual_2nd"
}, },
"firmware_file": "MarlinUltimaker-{baudrate}-dual.hex",
"firmware_hbk_file": "MarlinUltimaker-HKB-{baudrate}-dual.hex",
"first_start_actions": ["UMOUpgradeSelection", "UMOCheckup", "BedLevel"], "first_start_actions": ["UMOUpgradeSelection", "UMOCheckup", "BedLevel"],
"supported_actions": ["UMOUpgradeSelection", "UMOCheckup", "BedLevel", "UpgradeFirmware"] "supported_actions": ["UMOUpgradeSelection", "UMOCheckup", "BedLevel", "UpgradeFirmware"]
}, },

View file

@ -16,7 +16,8 @@
"machine_extruder_trains": "machine_extruder_trains":
{ {
"0": "ultimaker_original_plus_extruder_0" "0": "ultimaker_original_plus_extruder_0"
} },
"firmware_file": "MarlinUltimaker-UMOP-{baudrate}.hex"
}, },
"overrides": { "overrides": {