diff options
author | Alexander Gee <bostwickenator@gmail.com> | 2020-05-20 02:48:52 +0300 |
---|---|---|
committer | Alexander Gee <bostwickenator@gmail.com> | 2020-05-23 01:45:32 +0300 |
commit | 91199c8501228929424d04e6ad9b7f0c83da2047 (patch) | |
tree | 00f2b2798c74481ebc6235b6957985fb7c44ca44 /plugins/PostProcessingPlugin/scripts/DisplayProgressOnLCD.py | |
parent | 17d6321eff083916e3edbc4dbe80f71f944798f4 (diff) |
Add line_set to avoid infinte loops
Diffstat (limited to 'plugins/PostProcessingPlugin/scripts/DisplayProgressOnLCD.py')
-rw-r--r-- | plugins/PostProcessingPlugin/scripts/DisplayProgressOnLCD.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/plugins/PostProcessingPlugin/scripts/DisplayProgressOnLCD.py b/plugins/PostProcessingPlugin/scripts/DisplayProgressOnLCD.py index 5ca42e4c84..01c0eb7d06 100644 --- a/plugins/PostProcessingPlugin/scripts/DisplayProgressOnLCD.py +++ b/plugins/PostProcessingPlugin/scripts/DisplayProgressOnLCD.py @@ -10,31 +10,29 @@ from ..Script import Script import re import datetime -class DisplayPercentCompleteOnLCD(Script): +class DisplayProgressOnLCD(Script): def __init__(self): super().__init__() def getSettingDataString(self): return """{ - "name":"Display Percent Complete on LCD", - "key":"DisplayPercentCompleteOnLCD", + "name":"Display Progress On LCD", + "key":"DisplayProgressOnLCD", "metadata": {}, "version": 2, "settings": { "TimeRemaining": { - "label": "Enable", + "label": "Time Remaining", "description": "When enabled, write Time Left: HHMMSS on the display using M117. This is updated every layer.", "type": "bool", "default_value": false - } - } - { + }, "Percentage": { - "label": "Enable", + "label": "Percentage", "description": "When enabled, set the completion bar percentage on the LCD using Marlin's M73 command.", "type": "bool", "default_value": false @@ -60,6 +58,7 @@ class DisplayPercentCompleteOnLCD(Script): def execute(self, data): output_time = self.getSettingValueByKey("TimeRemaining") output_percentage = self.getSettingValueByKey("Percentage") + line_set = {} if (output_percentage or output_time) == True: total_time = -1 previous_layer_end_percentage = 0 @@ -82,6 +81,13 @@ class DisplayPercentCompleteOnLCD(Script): elif line.startswith(";TIME_ELAPSED:"): # We've found one of the time elapsed values which are added at the end of layers + + # If we have seen this line before then skip processing it. We can see lines multiple times because we are adding + # intermediate percentages before the line being processed. This can cause the current line to shift back and be + # encountered more than once + if (line in line_set): + continue + line_set[line] = True # If total_time was not already found then noop if (total_time == -1): |