Browse Source

Merge branch 'wporter82-master'

Diego Prado Gesto 6 years ago
parent
commit
757224c187

+ 49 - 0
plugins/PostProcessingPlugin/scripts/InsertAtLayerChange.py

@@ -0,0 +1,49 @@
+# Created by Wayne Porter
+
+from ..Script import Script
+
+class InsertAtLayerChange(Script):
+    def __init__(self):
+        super().__init__()
+
+    def getSettingDataString(self):
+        return """{
+            "name": "Insert at layer change",
+            "key": "InsertAtLayerChange",
+            "metadata": {},
+            "version": 2,
+            "settings":
+            {
+                "insert_location":
+                {
+                    "label": "When to insert",
+                    "description": "Whether to insert code before or after layer change.",
+                    "type": "enum",
+                    "options": {"before": "Before", "after": "After"},
+                    "default_value": "before"
+                },
+                "gcode_to_add":
+                {
+                    "label": "GCODE to insert.",
+                    "description": "GCODE to add before or after layer change.",
+                    "type": "str",
+                    "default_value": ""
+                }
+            }
+        }"""
+
+    def execute(self, data):
+        gcode_to_add = self.getSettingValueByKey("gcode_to_add") + "\n"
+        for layer in data:
+            # Check that a layer is being printed
+            lines = layer.split("\n")
+            if ";LAYER:" in lines[0]:
+                index = data.index(layer)
+                if self.getSettingValueByKey("insert_location") == "before":
+                    layer = gcode_to_add + layer
+                else:
+                    layer = layer + gcode_to_add
+
+                data[index] = layer
+
+        return data

+ 94 - 0
plugins/PostProcessingPlugin/scripts/TimeLapse.py

@@ -0,0 +1,94 @@
+# Created by Wayne Porter
+
+from ..Script import Script
+
+class TimeLapse(Script):
+    def __init__(self):
+        super().__init__()
+
+    def getSettingDataString(self):
+        return """{
+            "name": "Time Lapse",
+            "key": "TimeLapse",
+            "metadata": {},
+            "version": 2,
+            "settings":
+            {
+                "trigger_command":
+                {
+                    "label": "Trigger camera command",
+                    "description": "Gcode command used to trigger camera.",
+                    "type": "str",
+                    "default_value": "M240"
+                },
+                "pause_length":
+                {
+                    "label": "Pause length",
+                    "description": "How long to wait (in ms) after camera was triggered.",
+                    "type": "int",
+                    "default_value": 700,
+                    "minimum_value": 0,
+                    "unit": "ms"
+                },
+                "park_print_head":
+                {
+                    "label": "Park Print Head",
+                    "description": "Park the print head out of the way. Assumes absolute positioning.",
+                    "type": "bool",
+                    "default_value": true
+                },
+                "head_park_x":
+                {
+                    "label": "Park Print Head X",
+                    "description": "What X location does the head move to for photo.",
+                    "unit": "mm",
+                    "type": "float",
+                    "default_value": 0,
+                    "enabled": "park_print_head"
+                },
+                "head_park_y":
+                {
+                    "label": "Park Print Head Y",
+                    "description": "What Y location does the head move to for photo.",
+                    "unit": "mm",
+                    "type": "float",
+                    "default_value": 190,
+                    "enabled": "park_print_head"
+                },
+                "park_feed_rate":
+                {
+                    "label": "Park Feed Rate",
+                    "description": "How fast does the head move to the park coordinates.",
+                    "unit": "mm/s",
+                    "type": "float",
+                    "default_value": 9000,
+                    "enabled": "park_print_head"
+                }
+            }
+        }"""
+
+    def execute(self, data):
+        feed_rate = self.getSettingValueByKey("park_feed_rate")
+        park_print_head = self.getSettingValueByKey("park_print_head")
+        x_park = self.getSettingValueByKey("head_park_x")
+        y_park = self.getSettingValueByKey("head_park_y")
+        trigger_command = self.getSettingValueByKey("trigger_command")
+        pause_length = self.getSettingValueByKey("pause_length")
+        gcode_to_append = ";TimeLapse Begin\n"
+
+        if park_print_head:
+            gcode_to_append += self.putValue(G = 1, F = feed_rate, X = x_park, Y = y_park) + ";Park print head\n"
+        gcode_to_append += self.putValue(M = 400) + ";Wait for moves to finish\n"
+        gcode_to_append += trigger_command + ";Snap Photo\n"
+        gcode_to_append += self.putValue(G = 4, P = pause_length) + ";Wait for camera\n"
+        gcode_to_append += ";TimeLapse End\n"
+        for layer in data:
+            # Check that a layer is being printed
+            lines = layer.split("\n")
+            if ";LAYER:" in lines[0]:
+                index = data.index(layer)
+                layer += gcode_to_append
+
+                data[index] = layer
+
+        return data