Refactor setting names for consistancy, migration script

This commit is contained in:
Alexander Gee 2020-05-23 16:42:01 -05:00
parent 91199c8501
commit e807a086b4
2 changed files with 18 additions and 7 deletions

View file

@ -1,7 +1,7 @@
# Cura PostProcessingPlugin # Cura PostProcessingPlugin
# Author: Mathias Lyngklip Kjeldgaard, Alexander Gee # Author: Mathias Lyngklip Kjeldgaard, Alexander Gee
# Date: July 31, 2019 # Date: July 31, 2019
# Modified: May 13, 2020 # Modified: May 22, 2020
# Description: This plugin displays progress on the LCD. It can output the estimated time remaining and the completion percentage. # Description: This plugin displays progress on the LCD. It can output the estimated time remaining and the completion percentage.
@ -17,20 +17,20 @@ class DisplayProgressOnLCD(Script):
def getSettingDataString(self): def getSettingDataString(self):
return """{ return """{
"name":"Display Progress On LCD", "name": "Display Progress On LCD",
"key":"DisplayProgressOnLCD", "key": "DisplayProgressOnLCD",
"metadata": {}, "metadata": {},
"version": 2, "version": 2,
"settings": "settings":
{ {
"TimeRemaining": "time_remaining":
{ {
"label": "Time Remaining", "label": "Time Remaining",
"description": "When enabled, write Time Left: HHMMSS on the display using M117. This is updated every layer.", "description": "When enabled, write Time Left: HHMMSS on the display using M117. This is updated every layer.",
"type": "bool", "type": "bool",
"default_value": false "default_value": false
}, },
"Percentage": "percentage":
{ {
"label": "Percentage", "label": "Percentage",
"description": "When enabled, set the completion bar percentage on the LCD using Marlin's M73 command.", "description": "When enabled, set the completion bar percentage on the LCD using Marlin's M73 command.",
@ -56,8 +56,8 @@ class DisplayProgressOnLCD(Script):
lines.insert(line_index, "M117 Time Left {}".format(current_time_string)) lines.insert(line_index, "M117 Time Left {}".format(current_time_string))
def execute(self, data): def execute(self, data):
output_time = self.getSettingValueByKey("TimeRemaining") output_time = self.getSettingValueByKey("time_remaining")
output_percentage = self.getSettingValueByKey("Percentage") output_percentage = self.getSettingValueByKey("percentage")
line_set = {} line_set = {}
if (output_percentage or output_time) == True: if (output_percentage or output_time) == True:
total_time = -1 total_time = -1

View file

@ -120,6 +120,17 @@ class VersionUpgrade462to47(VersionUpgrade):
if "redo_layers" in script_parser["PauseAtHeight"]: if "redo_layers" in script_parser["PauseAtHeight"]:
script_parser["PauseAtHeight"]["redo_layer"] = str(int(script_parser["PauseAtHeight"]["redo_layers"]) > 0) script_parser["PauseAtHeight"]["redo_layer"] = str(int(script_parser["PauseAtHeight"]["redo_layers"]) > 0)
del script_parser["PauseAtHeight"]["redo_layers"] # Has been renamed to without the S. del script_parser["PauseAtHeight"]["redo_layers"] # Has been renamed to without the S.
# Migrate DisplayCompleteOnLCD to DisplayProgressOnLCD
if script_id == "DisplayPercentCompleteOnLCD":
script_settings = script_parser.items(script_id)
script_parser.remove_section(script_id)
script_id = "DisplayProgressOnLCD"
script_parser.add_section(script_id)
if (script_settings["TurnOn"] == "true"):
script_parser.set(script_id, "time_remaining", "true")
script_io = io.StringIO() script_io = io.StringIO()
script_parser.write(script_io) script_parser.write(script_io)
script_str = script_io.getvalue() script_str = script_io.getvalue()