def home_z(self, event): if self.connection_staticText.GetLabel() == "disconnected": self.statusBar.SetStatusText("No TinyG connection.") return pyTG.cmd("G28.2Z0") self.xread_textCtrl.SetValue("0.000") self.xset_textCtrl.SetValue("0.000")
def show_position(self): output = pyTG.cmd("$posx") self.xread_textCtrl.SetValue(str(float(output[18:26]))) output = pyTG.cmd("$posy") self.yread_textCtrl.SetValue(str(float(output[18:26]))) output = pyTG.cmd("$posz") self.zread_textCtrl.SetValue(str(float(output[18:26])))
def go_z(self, event): if float(self.zset_textCtrl.GetValue()) > 0: self.zset_textCtrl.SetValue("0.000") self.statusBar.SetStatusText("Value out of range!") return if float(self.zset_textCtrl.GetValue()) < -75: self.zset_textCtrl.SetValue("-75.000") self.statusBar.SetStatusText("Value out of range!") return if self.connection_staticText.GetLabel() == "disconnected": self.statusBar.SetStatusText("No TinyG connection.") return output = pyTG.cmd("G0Z" + str(self.zset_textCtrl.GetValue())) self.show_position()
def execute_console_code(self, event): if self.connection_staticText.GetLabel() == "disconnected": self.statusBar.SetStatusText("No TinyG connection.") return inp = self.console_textCtrl.GetValue() cmdlist = inp.split('\n') for l in cmdlist: self.statusBar.SetStatusText(l) if not l == "": if not l[0] == "#": self.console_output_textCtrl.AppendText(">>>" + l + "\n") output = pyTG.cmd(l) self.console_output_textCtrl.AppendText(output) self.m_panel3.Refresh() if 'pos' in output: try: self.set_position_control(output.split()[-1]) except: None self.show_position()
def run_gcode(self, event): # Check connectivity if self.connection_staticText.GetLabel() == "disconnected": self.statusBar.SetStatusText("No TinyG connection.") return # Remember user to select scriber as the first tool dlg = wx.MessageDialog(self, "Change tool to scriber (S)!", "Tool Change", wx.OK | wx.ICON_WARNING) dlg.ShowModal() dlg.Destroy() # If using glass spacers (default), then set the corresponding offset to the origin if self.offset_cb.GetValue(): self.home_all(None) pyTG.cmd("G92 X0 Y0 Z0") pyTG.cmd("G0 X" + str(self.cfg_scribeorigin_x) + " Y" + str(self.cfg_scribeorigin_y) + " Z0") pyTG.cmd("G92 X0 Y0 Z0") # Check if there are commands in the gcode text field inp = self.gcode_textCtrl.GetValue() if inp == "": self.statusBar.SetStatusText("No commands to execute.") return cmdlist = inp.split('\n') # Remember user again to select scriber as the first tool dlg2 = wx.MessageDialog(self, "Is the tool set to the right position (S)?", "Tool Change", wx.OK | wx.ICON_WARNING) dlg2.ShowModal() dlg2.Destroy() # Run the commands line by line for l in cmdlist: # Yield keeps the gui responsive wx.Yield() # Emergency stop (gui button) if self.stopall: self.stopall = False return if not l == "": # Custom gcode for vertical and horizontal lines (for wheel cutter) start with ">" if l[0] == ">": msg = "" # Commands for horizontal lines are initialised with "> CTH", for vertical lines with "> CTV" if l[4] == "H": msg = "Change tool to horizontal wheel (H)!" else: msg = "Change tool to vertical wheel (V)!" # Dialog to ask user to change the tool dlg = wx.MessageDialog(self, msg, "Tool Change", wx.OK | wx.ICON_WARNING) dlg.ShowModal() dlg.Destroy() # Dialog to make sure the user has changed the tool correctly dlg2 = wx.MessageDialog( self, "Is the tool set to the right position?", "Tool Change", wx.OK | wx.ICON_WARNING) dlg2.ShowModal() dlg2.Destroy() # The tool head sometimes moves during tool change, so home again for correct positioning self.home_all(None) # Go to a safe starting position (which is away from the datum bars) pyTG.cmd("G0 X50 Y50 Z0") # Ignore comment lines, starting with "#" if not l[0] == "#": # Run command output = pyTG.cmd(l) # try to update the position value display during the run (still buggy!) if 'pos' in output: try: self.set_position_control(output.split()[-1]) except: None # Bring tool head up (z=0), at the end of run pyTG.cmd("G0 Z0") self.show_position()
def zero_all(self, event): if self.connection_staticText.GetLabel() == "disconnected": self.statusBar.SetStatusText("No TinyG connection.") return pyTG.cmd("G28.3X0Y0Z0")