printrun-src/printrun/pronterface.py

changeset 34
654a41b13258
parent 33
eee51ca7cbe7
child 35
72c4cbf64211
--- a/printrun-src/printrun/pronterface.py	Sat Sep 23 08:51:58 2017 +0200
+++ b/printrun-src/printrun/pronterface.py	Sat Sep 23 10:27:49 2017 +0200
@@ -257,15 +257,28 @@
         if self.settings.monitor:
             self.update_monitor()
 
+        self.lc_printing = False
         self.pass_current = 1
 
     #  --------------------------------------------------------------
     #  Lasercutter methods
     #  --------------------------------------------------------------
 
+    def on_lc_printfile(self, event):
+        # lc print button
+        self.log("Priming Z axis to initial focus")
+        line = self.precmd("G1 Z%.2f" % (self.settings.lc_z_focus + self.lc_material_thickness.GetValue()))
+        self.onecmd(line)
+
+        self.printfile(event)
+        self.lc_printing = True
+
 
     def endcb_lasercut(self):
         # LASERCUT: Now check if we should do another print pass?
+        if not self.lc_printing:
+            return
+
         pass_count = self.lc_pass_count.GetValue()
         if pass_count > 1:
             time.sleep(0.5)
@@ -274,7 +287,8 @@
                 self.log("Starting lasercut pass # %i of %i" % (self.pass_current, pass_count))
                 if self.lc_pass_zdiff.GetValue() != 0:
                     # move Z focus
-                    new_z = self.settings.lc_z_focus + self.lc_material_thickness.GetValue() + (self.lc_pass_zdiff.GetValue() * self.pass_current)
+                    new_z = self.settings.lc_z_focus + self.lc_material_thickness.GetValue() + (
+                        self.lc_pass_zdiff.GetValue() * (self.pass_current - 1))
                     self.log("Re-Positioning laser focus by %.1f mm to %.1f" % (self.lc_pass_zdiff.GetValue(), new_z))
                     line = self.precmd("G1 Z%.2f" % (new_z))
                     self.onecmd(line)
@@ -285,10 +299,43 @@
                 self.printfile(None)
                 self.pass_current = tmp
             else:
+                self.lc_printing = False
+                wx.CallAfter(self.lc_printbtn.Enable)
+                wx.CallAfter(self.lc_printbtn.SetLabel, _("Start cutting"))
+
                 self.log("Resetting Z axis to initial focus")
                 line = self.precmd("G1 Z%.2f" % (self.settings.lc_z_focus + self.lc_material_thickness.GetValue()))
                 self.onecmd(line)
 
+    def update_lc_settings(self, key, value):
+        return True
+
+    def _lc_add_settings(self, size):
+        # first add the lasercutter options
+        self.settings._add(StaticTextSetting("separator_lc_general", "General laser settings", "", group = "Laser"))
+        self.settings._add(SpinSetting("lc_travel_speed", 120, 1, 300, "Travel speed in mm/s", "", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_engrave_speed", 10, 1, 300, "Engrave speed in mm/s", "", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_z_focus", 16, -80, 80, "Laser Z focus position", "", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_pass_count", 1, 0, 20, "Default Number of cutting passes", "", "Laser"), self.reload_ui)
+        self.settings._add(FloatSpinSetting("lc_pass_zdiff", -0.25, -2.0, 2.0, "Default Z movement after each cut", "", "Laser"), self.reload_ui)
+        self.settings._add(FloatSpinSetting("lc_material_thickness", 4.0, 0.0, 80.0, "Default Material Thickness", "", "Laser"), self.reload_ui)
+
+        self.settings._add(StaticTextSetting("separator_lc_bitmap", "PNG Bitmap processing", "", group = "Laser"))
+        self.settings._add(FloatSpinSetting("lc_bitmap_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_dpi", 300, 25, 300, "Image DPI", "Image resolution for scaling", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_grey_threshold", 0, 0, 255, "Grey threshold value for RGB", "", "Laser"), self.update_lc_settings)
+        self.settings._add(BooleanSetting("lc_invert_cut", True, "PNG: Invert grey threshold", "Invert laser on/off logic", "Laser"), self.update_lc_settings)
+        self.settings._add(BooleanSetting("lc_change_dir", True, "PNG: Change direction", "Engrave in both directions on Y Axis", "Laser"), self.update_lc_settings)
+
+        self.settings._add(StaticTextSetting("separator_lc_hpgl", "HPGL processing", "", group = "Laser"))
+        self.settings._add(FloatSpinSetting("lc_hpgl_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings)
+
+        self.settings._add(StaticTextSetting("separator_lc_svg", "SVG processing", "", group = "Laser"))
+        self.settings._add(FloatSpinSetting("lc_svg_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings)
+        self.settings._add(FloatSpinSetting("lc_svg_smoothness", 0.2, 0.1, 10.0, "Smoothness", "Smoothness of curves (smaller value = smoother curve)", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_svg_width", 50, 1, 250, "Width (mm)", "Image width", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_svg_height", 50, 1, 250, "Height (mm)", "Image height", "Laser"), self.update_lc_settings)
+        self.settings._add(ComboSetting("lc_svg_scalemode", "scale", ["scale", "stretch"], "Scaling mode", "scale to dimensions / stretch to dimensions", "Laser"), self.update_lc_settings)
 
     #  --------------------------------------------------------------
     #  Main interface handling
@@ -886,35 +933,8 @@
     #  --------------------------------------------------------------
     #  Settings & command line handling (including update callbacks)
     #  --------------------------------------------------------------
-
-    def update_lc_settings(self, key, value):
-        return True
-
     def _add_settings(self, size):
-
-        # first add the lasercutter options
-        self.settings._add(StaticTextSetting("separator_lc_general", "General laser settings", "", group = "Laser"))
-        self.settings._add(SpinSetting("lc_travel_speed", 120, 1, 300, "Travel speed in mm/s", "", "Laser"), self.update_lc_settings)
-        self.settings._add(SpinSetting("lc_engrave_speed", 10, 1, 300, "Engrave speed in mm/s", "", "Laser"), self.update_lc_settings)
-        self.settings._add(SpinSetting("lc_z_focus", 16, -80, 80, "Laser Z focus position", "", "Laser"), self.update_lc_settings)
-
-        self.settings._add(StaticTextSetting("separator_lc_bitmap", "PNG Bitmap processing", "", group = "Laser"))
-        self.settings._add(FloatSpinSetting("lc_bitmap_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings)
-        self.settings._add(SpinSetting("lc_dpi", 300, 25, 300, "Image DPI", "Image resolution for scaling", "Laser"), self.update_lc_settings)
-        self.settings._add(SpinSetting("lc_grey_threshold", 0, 0, 255, "Grey threshold value for RGB", "", "Laser"), self.update_lc_settings)
-        self.settings._add(BooleanSetting("lc_invert_cut", True, "PNG: Invert grey threshold", "Invert laser on/off logic", "Laser"), self.update_lc_settings)
-        self.settings._add(BooleanSetting("lc_change_dir", True, "PNG: Change direction", "Engrave in both directions on Y Axis", "Laser"), self.update_lc_settings)
-
-        self.settings._add(StaticTextSetting("separator_lc_hpgl", "HPGL processing", "", group = "Laser"))
-        self.settings._add(FloatSpinSetting("lc_hpgl_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings)
-
-        self.settings._add(StaticTextSetting("separator_lc_svg", "SVG processing", "", group = "Laser"))
-        self.settings._add(FloatSpinSetting("lc_svg_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings)
-        self.settings._add(FloatSpinSetting("lc_svg_smoothness", 0.2, 0.1, 10.0, "Smoothness", "Smoothness of curves (smaller value = smoother curve)", "Laser"), self.update_lc_settings)
-        self.settings._add(SpinSetting("lc_svg_width", 50, 1, 250, "Width (mm)", "Image width", "Laser"), self.update_lc_settings)
-        self.settings._add(SpinSetting("lc_svg_height", 50, 1, 250, "Height (mm)", "Image height", "Laser"), self.update_lc_settings)
-        self.settings._add(ComboSetting("lc_svg_scalemode", "scale", ["scale", "stretch"], "Scaling mode", "scale to dimensions / stretch to dimensions", "Laser"), self.update_lc_settings)
-
+        self._lc_add_settings(size)
 
         self.settings._add(BooleanSetting("monitor", True, _("Monitor printer status"), _("Regularly monitor printer temperatures (required to have functional temperature graph or gauges)"), "Printer"), self.update_monitor)
         self.settings._add(StringSetting("simarrange_path", "", _("Simarrange command"), _("Path to the simarrange binary to use in the STL plater"), "External"))
@@ -1212,6 +1232,9 @@
         wx.CallAfter(self.printbtn.SetLabel, _("Restart"))
         wx.CallAfter(self.toolbarsizer.Layout)
 
+        wx.CallAfter(self.lc_printbtn.Disable)
+        wx.CallAfter(self.lc_printbtn.SetLabel, _("Cut in progress"))
+
     def printfile(self, event):
         self.extra_print_time = 0
         if self.paused:

mercurial