diff -r 0abfa4642776 -r eee51ca7cbe7 printrun-src/printrun/pronterface.py --- a/printrun-src/printrun/pronterface.py Fri Sep 22 17:40:08 2017 +0200 +++ b/printrun-src/printrun/pronterface.py Sat Sep 23 08:51:58 2017 +0200 @@ -257,6 +257,39 @@ if self.settings.monitor: self.update_monitor() + self.pass_current = 1 + + # -------------------------------------------------------------- + # Lasercutter methods + # -------------------------------------------------------------- + + + def endcb_lasercut(self): + # LASERCUT: Now check if we should do another print pass? + pass_count = self.lc_pass_count.GetValue() + if pass_count > 1: + time.sleep(0.5) + if self.pass_current < pass_count: + self.pass_current += 1 + 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) + 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) + time.sleep(0.5) + + # "click" print button again + tmp = self.pass_current + self.printfile(None) + self.pass_current = tmp + else: + 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) + + # -------------------------------------------------------------- # Main interface handling # -------------------------------------------------------------- @@ -863,6 +896,7 @@ 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) @@ -1198,6 +1232,7 @@ self.sdprinting = False self.on_startprint() self.p.startprint(self.fgcode) + self.pass_current = 1 def sdprintfile(self, event): self.extra_print_time = 0 @@ -1600,6 +1635,8 @@ wx.CallAfter(self.printbtn.SetLabel, _("Print")) wx.CallAfter(self.toolbarsizer.Layout) + wx.CallAfter(self.endcb_lasercut) + def online(self): """Callback when printer goes online""" self.log(_("Printer is now online."))