mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 23:23:57 -06:00
Add line_set to avoid infinte loops
This commit is contained in:
parent
17d6321eff
commit
91199c8501
1 changed files with 14 additions and 8 deletions
|
@ -10,31 +10,29 @@ from ..Script import Script
|
||||||
import re
|
import re
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
class DisplayPercentCompleteOnLCD(Script):
|
class DisplayProgressOnLCD(Script):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def getSettingDataString(self):
|
def getSettingDataString(self):
|
||||||
return """{
|
return """{
|
||||||
"name":"Display Percent Complete on LCD",
|
"name":"Display Progress On LCD",
|
||||||
"key":"DisplayPercentCompleteOnLCD",
|
"key":"DisplayProgressOnLCD",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"settings":
|
"settings":
|
||||||
{
|
{
|
||||||
"TimeRemaining":
|
"TimeRemaining":
|
||||||
{
|
{
|
||||||
"label": "Enable",
|
"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": "Enable",
|
"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.",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"default_value": false
|
"default_value": false
|
||||||
|
@ -60,6 +58,7 @@ class DisplayPercentCompleteOnLCD(Script):
|
||||||
def execute(self, data):
|
def execute(self, data):
|
||||||
output_time = self.getSettingValueByKey("TimeRemaining")
|
output_time = self.getSettingValueByKey("TimeRemaining")
|
||||||
output_percentage = self.getSettingValueByKey("Percentage")
|
output_percentage = self.getSettingValueByKey("Percentage")
|
||||||
|
line_set = {}
|
||||||
if (output_percentage or output_time) == True:
|
if (output_percentage or output_time) == True:
|
||||||
total_time = -1
|
total_time = -1
|
||||||
previous_layer_end_percentage = 0
|
previous_layer_end_percentage = 0
|
||||||
|
@ -82,6 +81,13 @@ class DisplayPercentCompleteOnLCD(Script):
|
||||||
|
|
||||||
elif line.startswith(";TIME_ELAPSED:"):
|
elif line.startswith(";TIME_ELAPSED:"):
|
||||||
# We've found one of the time elapsed values which are added at the end of layers
|
# 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 was not already found then noop
|
||||||
if (total_time == -1):
|
if (total_time == -1):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue