printrun-src/printrun/pronterface.py

changeset 33
eee51ca7cbe7
parent 31
92035ebc4743
child 34
654a41b13258
equal deleted inserted replaced
32:0abfa4642776 33:eee51ca7cbe7
255 if self.filename is not None: 255 if self.filename is not None:
256 self.do_load(self.filename) 256 self.do_load(self.filename)
257 if self.settings.monitor: 257 if self.settings.monitor:
258 self.update_monitor() 258 self.update_monitor()
259 259
260 self.pass_current = 1
261
262 # --------------------------------------------------------------
263 # Lasercutter methods
264 # --------------------------------------------------------------
265
266
267 def endcb_lasercut(self):
268 # LASERCUT: Now check if we should do another print pass?
269 pass_count = self.lc_pass_count.GetValue()
270 if pass_count > 1:
271 time.sleep(0.5)
272 if self.pass_current < pass_count:
273 self.pass_current += 1
274 self.log("Starting lasercut pass # %i of %i" % (self.pass_current, pass_count))
275 if self.lc_pass_zdiff.GetValue() != 0:
276 # move Z focus
277 new_z = self.settings.lc_z_focus + self.lc_material_thickness.GetValue() + (self.lc_pass_zdiff.GetValue() * self.pass_current)
278 self.log("Re-Positioning laser focus by %.1f mm to %.1f" % (self.lc_pass_zdiff.GetValue(), new_z))
279 line = self.precmd("G1 Z%.2f" % (new_z))
280 self.onecmd(line)
281 time.sleep(0.5)
282
283 # "click" print button again
284 tmp = self.pass_current
285 self.printfile(None)
286 self.pass_current = tmp
287 else:
288 self.log("Resetting Z axis to initial focus")
289 line = self.precmd("G1 Z%.2f" % (self.settings.lc_z_focus + self.lc_material_thickness.GetValue()))
290 self.onecmd(line)
291
292
260 # -------------------------------------------------------------- 293 # --------------------------------------------------------------
261 # Main interface handling 294 # Main interface handling
262 # -------------------------------------------------------------- 295 # --------------------------------------------------------------
263 296
264 def reset_ui(self): 297 def reset_ui(self):
861 894
862 # first add the lasercutter options 895 # first add the lasercutter options
863 self.settings._add(StaticTextSetting("separator_lc_general", "General laser settings", "", group = "Laser")) 896 self.settings._add(StaticTextSetting("separator_lc_general", "General laser settings", "", group = "Laser"))
864 self.settings._add(SpinSetting("lc_travel_speed", 120, 1, 300, "Travel speed in mm/s", "", "Laser"), self.update_lc_settings) 897 self.settings._add(SpinSetting("lc_travel_speed", 120, 1, 300, "Travel speed in mm/s", "", "Laser"), self.update_lc_settings)
865 self.settings._add(SpinSetting("lc_engrave_speed", 10, 1, 300, "Engrave speed in mm/s", "", "Laser"), self.update_lc_settings) 898 self.settings._add(SpinSetting("lc_engrave_speed", 10, 1, 300, "Engrave speed in mm/s", "", "Laser"), self.update_lc_settings)
899 self.settings._add(SpinSetting("lc_z_focus", 16, -80, 80, "Laser Z focus position", "", "Laser"), self.update_lc_settings)
866 900
867 self.settings._add(StaticTextSetting("separator_lc_bitmap", "PNG Bitmap processing", "", group = "Laser")) 901 self.settings._add(StaticTextSetting("separator_lc_bitmap", "PNG Bitmap processing", "", group = "Laser"))
868 self.settings._add(FloatSpinSetting("lc_bitmap_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings) 902 self.settings._add(FloatSpinSetting("lc_bitmap_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings)
869 self.settings._add(SpinSetting("lc_dpi", 300, 25, 300, "Image DPI", "Image resolution for scaling", "Laser"), self.update_lc_settings) 903 self.settings._add(SpinSetting("lc_dpi", 300, 25, 300, "Image DPI", "Image resolution for scaling", "Laser"), self.update_lc_settings)
870 self.settings._add(SpinSetting("lc_grey_threshold", 0, 0, 255, "Grey threshold value for RGB", "", "Laser"), self.update_lc_settings) 904 self.settings._add(SpinSetting("lc_grey_threshold", 0, 0, 255, "Grey threshold value for RGB", "", "Laser"), self.update_lc_settings)
1196 wx.CallAfter(self.statusbar.SetStatusText, _("Not connected to printer.")) 1230 wx.CallAfter(self.statusbar.SetStatusText, _("Not connected to printer."))
1197 return 1231 return
1198 self.sdprinting = False 1232 self.sdprinting = False
1199 self.on_startprint() 1233 self.on_startprint()
1200 self.p.startprint(self.fgcode) 1234 self.p.startprint(self.fgcode)
1235 self.pass_current = 1
1201 1236
1202 def sdprintfile(self, event): 1237 def sdprintfile(self, event):
1203 self.extra_print_time = 0 1238 self.extra_print_time = 0
1204 self.on_startprint() 1239 self.on_startprint()
1205 threading.Thread(target = self.getfiles).start() 1240 threading.Thread(target = self.getfiles).start()
1597 if self.p.queueindex == 0: 1632 if self.p.queueindex == 0:
1598 self.p.runSmallScript(self.endScript) 1633 self.p.runSmallScript(self.endScript)
1599 wx.CallAfter(self.pausebtn.Disable) 1634 wx.CallAfter(self.pausebtn.Disable)
1600 wx.CallAfter(self.printbtn.SetLabel, _("Print")) 1635 wx.CallAfter(self.printbtn.SetLabel, _("Print"))
1601 wx.CallAfter(self.toolbarsizer.Layout) 1636 wx.CallAfter(self.toolbarsizer.Layout)
1637
1638 wx.CallAfter(self.endcb_lasercut)
1602 1639
1603 def online(self): 1640 def online(self):
1604 """Callback when printer goes online""" 1641 """Callback when printer goes online"""
1605 self.log(_("Printer is now online.")) 1642 self.log(_("Printer is now online."))
1606 wx.CallAfter(self.online_gui) 1643 wx.CallAfter(self.online_gui)

mercurial