Modified "Display Filename And Layer On LCD"

This is a modified Display Filename And Layer On LCD script to offer a wider range of optional information.
Tried and tested on a Tevo Tornado (Running Marlin 2.x.x)
2 new options
- Scroll (If scrolling LCD is enabled)
- Max Layer (To display "Printing [name] - Layer # of ###")
This commit is contained in:
N95JPL 2018-11-16 00:10:30 +00:00 committed by GitHub
parent 846d608a03
commit 1ae0728c9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,10 +1,13 @@
# Cura PostProcessingPlugin # Cura PostProcessingPlugin
# Author: Amanda de Castilho # Author: Amanda de Castilho
# Date: August 28, 2018 # Date: August 28, 2018
# Modified: November 16, 2018 by Joshua Pope-Lewis
# Description: This plugin inserts a line at the start of each layer, # Description: This plugin shows custom messages about your print on the Status bar...
# M117 - displays the filename and layer height to the LCD # Please look at the 3 options
# Alternatively, user can override the filename to display alt text + layer height # - Scolling (SCROLL_LONG_FILENAMES) if enabled in Marlin and you arent printing a small item select this option.
# - Name: By default it will use the name generated by Cura (EG: TT_Test_Cube) - Type a custom name in here
# - Max Layer: Enabling this will show how many layers are in the entire print (EG: Layer 1 of 265!)
from ..Script import Script from ..Script import Script
from UM.Application import Application from UM.Application import Application
@ -15,18 +18,32 @@ class DisplayFilenameAndLayerOnLCD(Script):
def getSettingDataString(self): def getSettingDataString(self):
return """{ return """{
"name": "Display filename and layer on LCD", "name": "Display Filename And Layer On LCD",
"key": "DisplayFilenameAndLayerOnLCD", "key": "DisplayFilenameAndLayerOnLCD",
"metadata": {}, "metadata": {},
"version": 2, "version": 2,
"settings": "settings":
{ {
"scroll":
{
"label": "Scroll enabled/Small layers?",
"description": "If SCROLL_LONG_FILENAMES is enabled select this setting however, if the model is small disable this setting!",
"type": "bool",
"default_value": false
},
"name": "name":
{ {
"label": "text to display:", "label": "Text to display:",
"description": "By default the current filename will be displayed on the LCD. Enter text here to override the filename and display something else.", "description": "By default the current filename will be displayed on the LCD. Enter text here to override the filename and display something else.",
"type": "str", "type": "str",
"default_value": "" "default_value": ""
},
"maxlayer":
{
"label": "Display max layer?:",
"description": "Display how many layers are in the entire print on status bar?",
"type": "bool",
"default_value": true
} }
} }
}""" }"""
@ -35,15 +52,28 @@ class DisplayFilenameAndLayerOnLCD(Script):
if self.getSettingValueByKey("name") != "": if self.getSettingValueByKey("name") != "":
name = self.getSettingValueByKey("name") name = self.getSettingValueByKey("name")
else: else:
name = Application.getInstance().getPrintInformation().jobName name = Application.getInstance().getPrintInformation().jobName
lcd_text = "M117 " + name + " layer: " if not self.getSettingValueByKey("scroll"):
if self.getSettingValueByKey("maxlayer"):
lcd_text = "M117 Layer "
else:
lcd_text = "M117 Printing Layer "
else:
lcd_text = "M117 Printing " + name + " - Layer "
i = 0 i = 0
for layer in data: for layer in data:
display_text = lcd_text + str(i) display_text = lcd_text + str(i)
layer_index = data.index(layer) layer_index = data.index(layer)
lines = layer.split("\n") lines = layer.split("\n")
for line in lines: for line in lines:
if line.startswith(";LAYER_COUNT:"):
max_layer = line
max_layer = max_layer.split(":")[1]
if line.startswith(";LAYER:"): if line.startswith(";LAYER:"):
if self.getSettingValueByKey("maxlayer"):
display_text = display_text + " of " + max_layer + "!"
else:
display_text = display_text + "!"
line_index = lines.index(line) line_index = lines.index(line)
lines.insert(line_index + 1, display_text) lines.insert(line_index + 1, display_text)
i += 1 i += 1